• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Creep Revival System Not Work

Status
Not open for further replies.
Level 4
Joined
Oct 24, 2012
Messages
77
  • Creep Revival System Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in PlayRegion <gen> owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set Integer = (Integer + 1)
          • Unit - Set the custom value of (Picked unit) to Integer
          • Custom script: set udg_Creep_X[udg_Integer] = GetUnitX(GetEnumUnit())
          • Custom script: set udg_Creep_Y[udg_Integer] = GetUnitX(GetEnumUnit())
  • Revive Creep 1 by 1
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Not equal to True)
    • Actions
      • Wait 5.00 game-time seconds
      • Set tempPoint[1] = (Center of (Entire map))
      • Set tempPoint[2] = (tempPoint[1] offset by (Creep_X[(Custom value of (Triggering unit))], Creep_Y[(Custom value of (Triggering unit))]))
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at tempPoint[2] facing (Random angle) degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
      • Custom script: call RemoveLocation(udg_tempPoint[1])
      • Custom script: call RemoveLocation(udg_tempPoint[2])
Im cannot create unit. Please help
 
It should work in some cases. However, if the unit doesn't have a corpse, then it won't work. After the 5 second wait, "Unit-type of (Triggering unit)" will return 0 for units without corpses. I'm guessing this is where your problem is.

The fix is to declare the variables before the wait. However, that would make the trigger no longer MUI. You will have to use local variables. Make two global variables, one named "TempCustomValue" and the other named "TempId" of type "Integer". Then use the following trigger:
  • Revive Creep 1 by 1
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Not equal to True)
    • Actions
      • Custom script: local integer cv = GetUnitUserData(GetTriggerUnit())
      • Custom script: local integer typeId = GetUnitTypeId(GetTriggerUnit())
      • Wait 5.00 game-time seconds
      • Custom script: set udg_TempCustomValue = cv
      • Custom script: set udg_TempId = typeId
      • Set tempPoint[1] = (Center of (Entire map))
      • Set tempPoint[2] = (tempPoint[1] offset by (Creep_X[TempCustomValue], Creep_Y[TempCustomValue]))
      • Unit - Create 1 TempId for Neutral Hostile at tempPoint[2] facing (Random angle) degrees
      • Unit - Set the custom value of (Last created unit) to TempCustomValue
      • Custom script: call RemoveLocation(udg_tempPoint[1])
      • Custom script: call RemoveLocation(udg_tempPoint[2])
This will create locals, and then assign the globals to them after the wait (maintaining the MUI aspect). That way, you can use them in your GUI functions. You can also do local variable shadowing if you know how.
 
Status
Not open for further replies.
Top