• 🏆 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!

[Solved] Long wait causes revival to fail?

Status
Not open for further replies.
Level 2
Joined
Jan 1, 2018
Messages
9
My creep revival system works perfectly with a 30 second wait but not a 300 second wait?

Here are the triggers:

  • Revival System
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set Creep_ID = (Creep_ID + 1)
          • Unit - Set the custom value of (Picked unit) to Creep_ID
          • Custom script: set udg_Creep_X[udg_Creep_ID] = GetUnitX(GetEnumUnit())
          • Custom script: set udg_Creep_Y[udg_Creep_ID] = GetUnitY(GetEnumUnit())
  • Revive Creeps
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Equal to False)
    • Actions
      • Wait 300.00 seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at ((Center of (Entire map)) offset by (Creep_X[(Custom value of (Triggering unit))], Creep_Y[(Custom value of (Triggering unit))])) facing (Random angle) degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
      • Unit - Make (Last created unit) Remain awake when unprovoked at night
Does anyone know why it might not be working with a 300 second wait?

Thanks
 
Level 15
Joined
Mar 25, 2016
Messages
1,327
the triggering unit decays and after that is removed, so triggering unit will be null or no unit. The unti type of no unit is no unit type, so it cannot be created.
to fix this you can use a local variable to save the unit type / custom value before the wait.

decay time is around 90 seconds if I remember correctly, death time is like 2-5 seconds for most units
 
Level 2
Joined
Jan 1, 2018
Messages
9
I see what you mean.

Look, the triggers I posted above were copied and pasted from a tutorial. I don't understand the JASS parts. I'll research local variables and post back tomorrow.
 
So we want to use variables for it. When using normal variables in GUI, they might be overwritten during the long wait duration. So what we want is to declare some local variables, which we can still use properly ater the wait. Local variables are always created at top of the trigger actions, and what we need:
  • unitId -> Custom value of dying unit (integer)
  • unitType -> Unit type of dying unit (integer)
In gui triggers (like you're coding now) "UnitType" is actually not an integer, but behind the scenes in JASS they're actually both just integers. You will understand in a moment why we need to know. So let's declare variables for custom value and unit type in local variables:

  • Custom script: local integer unitId = GetUnitUserData(GetTriggerUnit())
  • Custom script: local integer unitType = GetUnitTypeId(GetTriggerUnit())
^This must be at very top. What it does is declaring two local variables "unitId" and "unitType" of type "integer" , and it gives them value of custom value and unit type of dying unit. What comes after the "=" is just some JASS functions which are used to get the values.

To use those values now in GUI you need to create GUI variables in the variable editor, so you will need:
  • UnitId -> Custom value of dying unit (integer)
  • UnitType -> Unit type of dying unit (unit type)
So what we wanna do now is to give the value of our local variables to our normal GUI variables. We do it simply like this:

  • Custom script: set udg_UnitId = unitId
  • Custom script: set_udg_UnitType = unitType
On the left side of the "=" sign there's the GUI variable, and on the right side the local variable from which we wanna use the value. When using "Custom script", which is just like using JASS, we need a _udg prefix when we use GUI variables as you can see. Else it would not know the GUI variable.

After setting the GUI variables to the local ones, they hold the same value, and can be used, like:
  • Unit - Set the custom value of (Last created unit) to UnitId
 
Level 2
Joined
Jan 1, 2018
Messages
9
Working.

  • Revival System
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set Creep_ID = (Creep_ID + 1)
          • Unit - Set the custom value of (Picked unit) to Creep_ID
          • Custom script: set udg_Creep_X[udg_Creep_ID] = GetUnitX(GetEnumUnit())
          • Custom script: set udg_Creep_Y[udg_Creep_ID] = GetUnitY(GetEnumUnit())
  • Revive Creeps
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Equal to False)
    • Actions
      • Custom script: local integer creepcustom = GetUnitUserData(GetTriggerUnit())
      • Custom script: local integer creeptype = GetUnitTypeId(GetTriggerUnit())
      • Wait 300.00 seconds
      • Custom script: set udg_Creep_ID = creepcustom
      • Custom script: set udg_Creep_Type = creeptype
      • Unit - Create 1 Creep_Type for Neutral Hostile at ((Center of (Entire map)) offset by (Creep_X[Creep_ID], Creep_Y[Creep_ID])) facing (Random angle) degrees
      • Unit - Set the custom value of (Last created unit) to Creep_ID
      • Unit - Make (Last created unit) Remain awake when unprovoked at night
 
Status
Not open for further replies.
Top