• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Why Doesn't this Work?

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
Why doesn't this work? I thought "Triggering unit", "Triggering Player", etc was MUI. Sometimes the Aliens are not respawning...

  • Respawn Aliens
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) is in AliensPlayerGroup) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from AlienUnitGroup
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Objects\Spawnmodels\Naga\NagaBlood\NagaBloodWindserpent.mdl
      • Special Effect - Destroy (Last created special effect)
      • Wait (Real((Point-value of (Triggering unit)))) seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at AlienLair facing AlienLair
 
There are two likely issues. Either:
(1) The unit may have faded after the wait, and its memory might've been cleared. For example, if a unit dies and decays, blizzard will throw away some of the memory or recycle it after some time (I assume). If the wait lasts longer than that, then retrieving the unit-type will just return 0.

(2) Perhaps you meant to add the unit back to AlienUnitGroup after you created it.

If you really want to use a wait, then there are some options:
  • Respawn Aliens
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) is in AliensPlayerGroup) Equal to True
    • Actions
      • Custom script: local integer utype = GetUnitTypeId(GetTriggerUnit())
      • Custom script: local player owner = GetTriggerPlayer()
      • Unit Group - Remove (Triggering unit) from AlienUnitGroup
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Objects\Spawnmodels\Naga\NagaBlood\NagaBloodWindserpent.mdl
      • Special Effect - Destroy (Last created special effect)
      • Wait (Real((Point-value of (Triggering unit)))) seconds
      • Custom script: set bj_lastCreatedUnit = CreateUnitAtLoc(owner, utype, udg_AlienLair, 0)
  • Respawn Aliens
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) is in AliensPlayerGroup) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from AlienUnitGroup
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Objects\Spawnmodels\Naga\NagaBlood\NagaBloodWindserpent.mdl
      • Special Effect - Destroy (Last created special effect)
      • Set RA_WriteIndex = (RA_WriteIndex + 1)
      • Set RA_UnitType[RA_WriteIndex] = (Unit-type of (Triggering unit))
      • Set RA_Owner[RA_WriteIndex] = (Owner of (Triggering unit))
      • Wait (Real((Point-value of (Triggering unit)))) seconds
      • Set RA_ReadIndex = (RA_ReadIndex + 1)
      • Unit - Create 1 RA_UnitType[RA_ReadIndex] for RA_Owner[RA_ReadIndex] at AlienLair facing AlienLair
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RA_ReadIndex Equal to RA_WriteIndex
        • Then - Actions
          • Set RA_ReadIndex = 0
          • Set RA_WriteIndex = 0
        • Else - Actions
This technique is explained here.


There is a plethora of other methods as well. Personally, using locals/custom script is the easiest.

As for issue (2), you would just add the unit to the unit group after you create it.

Essentially: (Triggering unit) and (Triggering player) is MUI, but the handle might become invalid after a certain amount of time since it just died. As such, you have to cache the data while it is still available to you.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Thanks, your custom script solution seems to have worked. Units seem to be respawning as they should.

(1) The unit may have faded after the wait, and its memory might've been cleared. For example, if a unit dies and decays, blizzard will throw away some of the memory or recycle it after some time (I assume). If the wait lasts longer than that, then retrieving the unit-type will just return 0.

I think this must have been happening because I'm certain I was setting the new unit into the unit group within another trigger.
 
Status
Not open for further replies.
Top