• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] TriggerSleepAction, not working?

Status
Not open for further replies.
Like the title says, without triggersleepaction this works:

JASS:
 function KillBombs takes unit Unit, integer Bombs, real Time, real rate, real damage, real radius returns nothing
      local location L
      local unit Bomb = Unit
      local real X = GetUnitX(Bomb) + 1000. * Cos(GetUnitFacing(Bomb) * bj_DEGTORAD)
      local real Y = GetUnitY(Bomb) + 1000. * Sin(GetUnitFacing(Bomb) * bj_DEGTORAD)
      local real height = GetUnitFlyHeight(Bomb)
      call UnitApplyTimedLife(Bomb, 'BTLF', (height / rate) )
      call SetUnitFlyHeight(Bomb, 0, rate)
      call IssuePointOrder(Bomb, "move", X, Y)
      call BJDebugMsg(R2S(height / rate))
      call TriggerSleepAction(height / rate)
      set L = GetUnitLoc(Bomb)
      call BombDamage(damage, radius, L, Bomb)
      call RemoveLocation(L)
      set L = null
      set Bomb = null
  endfunction

it basically cuts off at the " call BombDamage(damage, radius, L, Bomb)

any idea?

PS: i'm using call KillBombs.execute
PPS: i'll give you rep, unless your dr. super cool, because i've already given your rep in a while.
PPPS: stop reading these offtopic things and post a reply!
 
Level 14
Joined
Nov 18, 2007
Messages
816
I've hear that the parameters are some sort of globals (no need for nulling, so they can't be locals).
Wrong. Parameters are perfectly local. The reason you dont have to null parameters, according to some Blizzard employees is that WC3 can only distinguish between parameters and non-parameters. Globals and locals are treated equally regarding ref-counting.

In what context do you execute this function? Keep in mind that running it from certain functions, such as trigger conditions or timer callbacks can cause various problems in combination with TriggerSleepAction.
 
Level 8
Joined
Aug 6, 2008
Messages
451
Also TriggerSleepAction doesnt count gametime, and its not really supposed to be used for this kind of stuff.

If it plays OK for you, then its fine, but when it starts to annoy you much enough, I suggest you to learn how to use timers and get some system like TimerUtils for example.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Try putting
set L = GetUnitLoc(Bomb)
before the TSA. My second guess is that the Bomb unit may be removed causing the location to be incorrect or invalid as the bomb unit dies before you get its location. Check if this makes the bombdamage at the place the bomb came from.

If that works but incorrectly, simply change it so that you bombdamage the point at which you ordered the bomb to move to.
 
k, now i figured out tsa's working, this code isn't.

JASS:
  private function 1012921231 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) == false )
  endfunction
  
  private function damageunit takes nothing returns nothing
      call UnitDamageTarget(DamagedUnit, GetEnumUnit(), DamagingDamage, true, false, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_DEMOLITION, WEAPON_TYPE_WHOKNOWS)
      call BJDebugMsg("Testing")
  endfunction
  
  private function BombDamage takes real damage, real Rad, location loc, unit whichunit returns nothing
     local group ug = CreateGroup()
     call BJDebugMsg("Test")
     set DamagedUnit = whichunit
     set DamagingDamage = damage / 3
     call GroupEnumUnitsInRangeOfLoc(ug, loc, Rad - (Rad / 3), function 1012921231)
     call ForGroup(ug, function damageunit)
     call GroupEnumUnitsInRangeOfLoc(ug, loc, Rad - (Rad / 2), function 1012921231)
     call ForGroup(ug, function damageunit)
     call GroupEnumUnitsInRangeOfLoc(ug, loc, Rad - (Rad), function 1012921231)
     call ForGroup(ug, function damageunit)
     call DestroyGroup(ug)
  endfunction
it only shows the first testing, it never gets to damaging faze.
 
Status
Not open for further replies.
Top