Whats wrong here?

Homer

New Member
Reaction score
2
no does it need to be?

Edit: Found out i needed to give tempu a default value aka null

Heres my new code, however the code still seems to hang at the loop as it does not display the text that is in the loop.

JASS:
function UnitDies takes nothing returns nothing
local unit u = GetDyingUnit()
local unit tempu = null
local real x GetUnitX(u)
local real y = GetUnitY(u)
local real mag = 10
local group g = CreateGroup()
local unitData uD
local real distance = 0.00
call DisplayTextToPlayer(Player(0),0,0,"test")         
if (GetUnitTypeId(u)=='h000') then
call DisplayTextToPlayer(Player(0),0,0,"test2")
call GroupEnumUnitsInRange(g,x,y,400.,null) 
        loop
        set tempu = FirstOfGroup(g)
        call DisplayTextToPlayer(Player(0),0,0,"test3")
        exitwhen tempu==null
        set uD=GetUnitUserData(tempu) 
        call GroupRemoveUnit(g,tempu) //Do Stuff
        if (IsUnitAliveBJ(tempu)) then        
            if (GetUnitTypeId(tempu)=='h000') then
            call KillUnit(tempu)
            endif
            if (GetUnitTypeId(tempu)!='h000') then
            set distance = DistanceBetweenPoints(Location(x,y),Location(uD.x,uD.y))
            call uD.AddForce(AngleBetweenPoints(Location(x,y),Location(uD.x, uD.y)),mag)
            set uD.zforce=uD.zforce+17
            endif
        endif
        endloop
        
call Explode(x,y)
endif
call DestroyGroup(g) 
set g = null
endfunction

//===========================================================================
function InitTrig_unit_dies takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
call TriggerRegisterAnyUnitEventBJ( trig , EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( trig , function UnitDies)
endfunction
 

The Undaddy

Creating with the power of rage
Reaction score
55
no does it need to be?
No,it doesn't...

And if the trigger stops at the loop,which I believe means "test3" is not displayed,there are only two lines of code that could be the problem.
JASS:
call GroupEnumUnitsInRange(g,x,y,400.,null)


or

JASS:
set tempu = FirstOfGroup(g)


I believe there's something wrong with the enum function.
Edit: No,I don't know what :D I'm guessing atm.
 

Homer

New Member
Reaction score
2
Figured it out I think, It has to do with the x and y vars. I'm gonna try something real quick.

Edit: Yep, that was it. Notice in the var declaration I fail to put an = next to x? Not sure how I missed that ha. Thanks for the help though.

+rep
 

The Undaddy

Creating with the power of rage
Reaction score
55
Figured it out I think, It has to do with the x and y vars. I'm gonna try something real quick.

Edit: Yep, that was it. Notice in the var declaration I fail to put an = next to x? Not sure how I missed that ha. Thanks for the help though.

+rep

lol I wonder how it compiled :D
 

Homer

New Member
Reaction score
2
yeah haha I have no idea :)

Edit: New problem, figured I would not create a new topic.

JASS:
method UpdateLocation takes nothing returns nothing
        set this.xprev=this.x
        set this.yprev=this.y
        call BJDebugMsg(I2S(GetTerrainCliffLevel(this.x,this.y)))
        set this.x=GetUnitX(this.u)
        set this.y=GetUnitY(this.u)
        if GetTerrainCliffLevel(this.xprev,this.yprev)!=GetTerrainCliffLevel(this.x,this.y) then
            set this.x=this.xprev
            set this.y=this.yprev    
        endif
        if this.ForceExists() then
        
        
        set this.x=this.x+this.xforce
        set this.y=this.y+this.yforce
        
        call SetUnitPosition( this.u, this.x,this.y )
        endif
    endmethod


This is ran every .01 seconds. Or something to that extent. Anyways, the debug message returns two different heights if I'm not at cliff height 4. Otherwise it returns 4.

IE. Debug messages as seen in game below

//at normal ground level
4
2
4
2
4

//at ground level with cliff increased by 2
4
4
4
4
4

My guy currently spawns on the cliff, this might be the issue but I doubt that because that means the function itself is very buggy then(getterriancliffheight).

Thanks
2
 

The Undaddy

Creating with the power of rage
Reaction score
55
this.x and this.y should always be the same cliff level,but
JASS:
        set this.x=this.x+this.xforce
set this.y=this.y+this.yforce

may be the cause why it shows 2 sometimes.And because 2 != 4,it is returned to the location where the cliff height was 4,and shows 4 again.
 

Homer

New Member
Reaction score
2
Dunno, it seems its just a bug, because when I apply it it works fine. However the debug messages seem to report otherwise.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top