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

[Trigger] Revive Trigger doesn't create Units

Status
Not open for further replies.
Level 18
Joined
Mar 13, 2009
Messages
1,411
I was helping someone else with a trigger that had to revive units when killed after 120 seconds on the spot they started at when the map started. I tested this trigger and it apparently stops working when it actually comes to creating the units.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set HashtableRevive = (Last created hashtable)
      • Set TempGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to GroupReviveLiving
              • Set TempLoc = (Position of (Picked unit))
              • Set TempTypeString = (String((Unit-type of (Picked unit))))
              • Hashtable - Save Handle OfTempLoc as 1 of (Key (Picked unit)) in HashtableRevive
              • Hashtable - Save TempTypeString as 3 of (Key (Picked unit)) in HashtableRevive
              • Custom script: call RemoveLocation( udg_TempLoc )
            • Else - Actions
      • Custom script: call DestroyGroup( udg_TempGroup )
  • Unit Killed
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in GroupReviveLiving) Equal to True
    • Actions
      • Unit Group - Add (Triggering unit) to GroupReviveDead
      • Hashtable - Save 120 as 2 of (Key (Triggering unit)) in HashtableRevive
  • Unit Revive
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in GroupReviveDead and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 2 of (Key (Picked unit)) from HashtableRevive) Equal to 0
            • Then - Actions
              • Set TempTypeString = (Load 3 of (Key (Picked unit)) from HashtableRevive)
              • Set TempLoc = (Load 1 of (Key (Picked unit)) in HashtableRevive)
              • Unit - Create 1 (Unit-type(TempTypeString)) for (Owner of (Picked unit)) at TempLoc facing Default building facing degrees
              • Hashtable - Save Handle Of(Load 1 of (Key (Picked unit)) in HashtableRevive) as 1 of (Key (Last created unit)) in HashtableRevive
              • Hashtable - Save (Load 3 of (Key (Picked unit)) from HashtableRevive) as 3 of (Key (Last created unit)) in HashtableRevive
              • Unit Group - Add (Last created unit) to GroupReviveLiving
              • Custom script: call RemoveLocation( udg_TempLoc )
              • Unit Group - Remove (Picked unit) from GroupReviveDead
            • Else - Actions
              • Set TempInteger = (Load 2 of (Key (Picked unit)) from HashtableRevive)
              • Hashtable - Save ((Load 2 of (Key (Picked unit)) from HashtableRevive) - 1) as 2 of (Key (Picked unit)) in HashtableRevive
Please help me help someone else and I'll +rep you ;)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
The trouble could be that after 120 seconds, the unit that has died has also decayed, and gets removed from the game. Try setting the time to a lower value and test if it works then.

By the way, why not use strings rather than integers as the save/load key.

I mean instead of

  • Hashtable - Save Handle OfTempLoc as 1 of ...
use

  • Hashtable - Save Handle OfTempLoc as location of ...
It more clear that way, at least to me. Just a suggestion :)
 
Level 18
Joined
Mar 13, 2009
Messages
1,411
I made a little trigger showing what unit type would be revived and that worked, locations seemed to bug though.

By the way, why not use strings rather than integers as the save/load key.

I mean instead of

  • Hashtable - Save Handle OfTempLoc as 1 of ...
use

  • Hashtable - Save Handle OfTempLoc as location of ...
It more clear that way, at least to me. Just a suggestion :)

I usually do, but I tried to do this trigger for someone else and tried not too make it look more complicated to explain :p
I failed by not being able to do this thing myself xD
 
Level 18
Joined
Mar 13, 2009
Messages
1,411
You're not really creating new locations, you're just pointing to already existing locations. So don't remove the locations, you can't point to them if you do.

Myeh I see, perhaps it goes wrong when I remove the leaks :<
The guy who needed the trigger had about 400 units preplaced that needed to be revived every time when killed on exactly the same spots.
 
Level 18
Joined
Mar 13, 2009
Messages
1,411
So do these:

1) Don't remove the locations
2) Set the revive time lower than what decaying time of bones + flesh is.

and it should work.

Well I did this trigger for someone else so I don't know if he can change the decay, but I'll ask :p

Well I could keep the location, but it uses a single variable for all the units so I'm afraid it will still give some problems :<
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Well I could keep the location, but it uses a single variable for all the units so I'm afraid it will still give some problems :<

Why would it?

You just make the variable point to the location of the location in your computer's memory. One unit/location at a time. No problems there, that's the way I see it.

You should also clear all child hashtables of the dying unit when you don't need it anymore.
 
Level 18
Joined
Mar 13, 2009
Messages
1,411
Why would it?

You just make the variable point to the location of the location in your computer's memory. One unit/location at a time. No problems there, that's the way I see it.

You should also clear all child hashtables of the dying unit when you don't need it anymore.

But it got a lot of units and I was hoping not to have to use giant arrays :\
Also when the unit died once it needs to revive again, but then when it dies again it needs to revive just like before on the location the unit was at when the map started.
 
Status
Not open for further replies.
Top