• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Dummy and Phoenix Fire

Status
Not open for further replies.
Level 2
Joined
Jun 8, 2014
Messages
15
Hey! I've got a problem here. I'm creating a map, where a unit enters a structure, it will create a dummy at the position of the structure, which will fire off a modified phoenix fire attack.

So, how do I remove the dummy if a player chooses to unload the unit out of the structure? I would prefer GUI though.

This is my trigger when the unit enters:

  • Auto firing
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
      • ((Loading unit) is A ground unit) Equal to True
      • (Unit-type of (Loading unit)) Equal to Rocketeer
    • Actions
      • Unit - Create 1 Dummy 1 for (Triggering player) at (Position of (Transporting unit)) facing 0.00 degrees
      • Unit - Add Bunker (Rocket) to (Last created unit)
      • Unit - Add Rocket to (Last created unit)
Thank you!

EDIT: I'm not sure if I could use "Last Created Unit" as there might be other players who create other dummies with other abilities. I think it might cause other triggers to malfunction.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Create a variable of type "unit"
Create dummy unit and as next line use the "Set variable" action (found under general tab in the list of action for trigger) and make the variable you created point to last created unit.

Then use the variable as reference for everything you do with the dummy.

So your trigger should look like this:
  • Auto firing
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
      • ((Loading unit) is A ground unit) Equal to True
      • (Unit-type of (Loading unit)) Equal to Rocketeer
    • Actions
      • Unit - Create 1 Dummy 1 for (Triggering player) at (Position of (Transporting unit)) facing 0.00 degrees
      • Set unit_var = (Last created unit)
      • Unit - Add Bunker (Rocket) to unit_var
      • Unit - Add Rocket to unit_var
unit_var is just some name I came up with for the variable of type unit. You can choose different name of course.

and then, later when you want to for example remove the dummy, just use this action:
  • Unit - Remove unit_var from the game
do note: if you're not accustomed to variables, then let's just say that each variable can only hold 1 "data" inside - so if your unit_var already has the dummy unit with phoenix fire in it, do not save any other unit into this variable - because then you won't be able to work with the dummy with phoenix fire through this variable :)
 
Level 2
Joined
Jun 8, 2014
Messages
15
Thanks for the reply! But what if it the player chooses to put in like 4 rocketeers into the structure simultaneously, and another player chooses to put another 4 rocketeers into his own structure? Is there any way I can go about making this trigger work?

EDIT: Do I have to use arrays?
 
Level 2
Joined
Jun 8, 2014
Messages
15
-Okay, I've tried to use the variable method and this is what I got.


  • Rocketeer
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
      • ((Loading unit) is A ground unit) Equal to True
      • (Unit-type of (Loading unit)) Equal to Rocketeer
    • Actions
      • Set RocketeerIndex = (RocketeerIndex + 1)
      • Set RocketeerBunkerCount[RocketeerIndex] = (Real(RocketeerIndex))
      • Unit - Create 1 Dummy for (Triggering player) at (Position of (Transporting unit)) facing 0.00 degrees
      • Set RocketeerDummy[RocketeerIndex] = (Last created unit)
      • Unit - Add Bunker (Rocket) to RocketeerDummy[RocketeerIndex]
      • Unit - Add Rocket to RocketeerDummy[RocketeerIndex]



  • Rocketeer Unloaded
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer(RocketeerBunkerCount[RocketeerIndex])) Equal to 0
        • Then - Actions
          • Unit - Remove RocketeerDummy[RocketeerIndex] from the game
        • Else - Actions
          • Do nothing


However, the trigger doesn't seem to work. The dummy still stays there and fire. I will be using dynamic indexing too (or unit indexer is better?). Is there any way to solve the problem?

EDIT: The trigger should work like Starcraft Terran's bunker, where a unit (say a marine) loads into the bunker, it will gain the "machine gun" ability while if it is a firebat, it will gain the "flamethrower" ability. And then when you unload a unit out, the ability is lost, according to the type of unit.

Thank you!
 
Level 2
Joined
Jun 8, 2014
Messages
15
I found the solution. I used unit indexer to make the thing work. Thanks guys!

Here are the triggers.


  • Rocketeer
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
      • ((Loading unit) is A ground unit) Equal to True
      • (Unit-type of (Loading unit)) Equal to Rocketeer
    • Actions
      • Set RocketeerID = (Custom value of (Triggering unit))
      • Set RocketeerTemp[RocketeerID] = (Loading unit)
      • Unit - Create 1 Dummy for (Triggering player) at (Position of (Transporting unit)) facing 0.00 degrees
      • Set RocketeerTempDummy[RocketeerID] = (Last created unit)
      • Unit - Add Bunker (Rocket) to RocketeerTempDummy[RocketeerID]
      • Unit - Add Rocket to RocketeerTempDummy[RocketeerID]
      • Trigger - Turn on RocketeerCheck <gen>



  • RocketeerCheck
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Bunker) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (RocketeerTemp[RocketeerID] is loaded into (Picked unit)) Equal to False
            • Then - Actions
              • Unit - Remove RocketeerTempDummy[RocketeerID] from the game
            • Else - Actions
              • Do nothing
 
Status
Not open for further replies.
Top