• 🏆 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] Unit Storage Help

Status
Not open for further replies.
Level 19
Joined
Apr 10, 2010
Messages
2,789
Well basically, ive made a unit storage system for my map. It works but the problem is, when I revive 1 stored unit, it needs to kill one unit in the storage area but it doesnt. Triggers are below.

  • Revive Set
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Dying unit)) slot status) Equal to Is playing
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Footman
        • Then - Actions
          • Set tempunit01 = (Dying unit)
          • Set tempplayer01 = (Owner of tempunit01)
          • Set footmanboolean = True
          • Set footmancount = (footmancount + 1)
          • Unit - Create 1 (Unit-type of tempunit01) for tempplayer01 at (Random point in tempregion <gen>) facing Default building facing degrees
          • Special Effect - Create a special effect attached to the overhead of (Last created unit) using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Game - Display to (Player group(tempplayer01)) the text: You have stored 1 f...
          • Trigger - Turn on Footman Revive <gen>
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Dying unit)) Equal to Rifleman
            • Then - Actions
              • Set tempunit02 = (Dying unit)
              • Set tempplayer02 = (Owner of tempunit02)
              • Set riflemanboolean = True
              • Set riflemancount = (riflemancount + 1)
              • Unit - Create 1 (Unit-type of tempunit02) for tempplayer02 at (Random point in tempregion <gen>) facing Default building facing degrees
              • Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Game - Display to (Player group(tempplayer01)) the text: You have stored 1 r...
              • Trigger - Turn on Rifleman Revive <gen>
            • Else - Actions
  • Footman Revive
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Revive Footman
      • footmanboolean Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • footmancount Greater than or equal to 1
        • Then - Actions
          • Unit - Create 1 (Unit-type of tempunit01) for tempplayer01 at (Center of Footman Revive <gen>) facing Default building facing degrees
          • Special Effect - Create a special effect at (Center of Footman Revive <gen>) using Abilities\Spells\Items\AIim\AIimTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Camera - Pan camera for tempplayer01 to (Center of Footman Revive <gen>) over 0.00 seconds
          • Unit - Kill tempunit01
        • Else - Actions
          • Game - Display to (Player group(tempplayer01)) the text: You need atleast 1 ...
  • Rifleman Revive
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Revive Rifleman
      • riflemanboolean Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • riflemancount Greater than or equal to 1
        • Then - Actions
          • Unit - Create 1 (Unit-type of tempunit02) for tempplayer02 at (Center of Rifleman Revive <gen>) facing Default building facing degrees
          • Special Effect - Create a special effect at (Center of Rifleman Revive <gen>) using Abilities\Spells\Items\AIim\AIimTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Camera - Pan camera for tempplayer02 to (Center of Rifleman Revive <gen>) over 0.00 seconds
          • Unit - Kill tempunit02
        • Else - Actions
          • Game - Display to (Player group(tempplayer02)) the text: You need atleast 1 ...
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Last edited:
Level 19
Joined
Apr 10, 2010
Messages
2,789
You set Set tempunit01 = (Dying unit) ?
Where you are supposed to set it as
Set tempunit01 = (Last Created Unit)
After this line:
Unit - Create 1 (Unit-type of tempunit01) for tempplayer01 at (Random point in tempregion <gen>) facing Default building facing degrees

It checks what unit dies. So if a unit dies it knows what unit is it.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
I think the best storage is Hastables...

example:

  • Storage
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
        • Then - Actions
          • Hashtable - Save Handle Of(Triggering unit) as (Key footman) of (Key (Killing unit)) in H
          • Set Footman = (Footman + 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to Rifleman
            • Then - Actions
              • Hashtable - Save Handle Of(Triggering unit) as (Key rifleman) of (Key (Killing unit)) in H
              • Set Rifleman = (Rifleman + 1)
            • Else - Actions
  • Revive
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunder Clap
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Footman Greater than 0
        • Then - Actions
          • Game - Display to (All players) the text: UNIT CREATED
          • Set Caster = (Triggering unit)
          • Set CasterPnt = (Position of Caster)
          • Unit - Create 1 (Unit-type of (Load (Key footman) of (Key (Triggering unit)) in H)) for (Owner of Caster) at CasterPnt facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_CasterPnt)
          • Set Footman = (Footman - 1)
        • Else - Actions
          • Game - Display to (All players) the text: NO FOOTMAN CREATED
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Rifleman Greater than 0
        • Then - Actions
          • Game - Display to (All players) the text: UNIT CREATED
          • Set Caster = (Triggering unit)
          • Set CasterPnt = (Position of Caster)
          • Unit - Create 1 (Unit-type of (Load (Key rifleman) of (Key (Triggering unit)) in H)) for (Owner of Caster) at CasterPnt facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_CasterPnt)
          • Set Rifleman = (Rifleman - 1)
        • Else - Actions
          • Game - Display to (All players) the text: NO RIFLEMAN CREATED
 
Status
Not open for further replies.
Top