Replace dead unit with multiple units (with dead units orders)

Nano

New Member
Reaction score
0
Hey guys,

I'm making a TD and one of the creep types is a 'multiplier' type. You kill one of them and out pop two half size copies of it.

However I've run into some issues in that my approach seems to be producing no positive results.

Here's what I have currently:
Trigger:
  • Events
    • Unit - Any Unit dies
    • Conditions
      • (Owner of (Triggering unit)) == 0
      • multiplier_round == 1
    • Actions
      • Unit - Create 1 multiplier_type for player (0) at (Position of (Triggering unit)) facing (Facing of (Triggering unit)) degrees (Ignore Placement)

Note: multiplier_type is a Unit Type variable that is set at the start of the round/wave

This seemingly does nothing. Am I working off incorrect assumptions? Can I not get the position and facing of the triggering unit since it's dead?

Secondly, assuming there is a way to do the above correctly, I have this:

Trigger:
  • General - For each integer order_counter from 1 to 10 with increment 1, do (Actions)
    • Actions
      • Unit - Order (Last created unit) to ((Triggering unit) order(order_counter)) (After Existing Orders)


From this I'm trying to grab all the orders that the dead creep had (creeps are assigned all their movement orders when they're spawned) and I want the 'multiplied' creeps to move exactly as their dead parent was going to.

I couldn't find any action that seemed to match this so I went for the loop through each order (up to an arbitrary number), but is there a better way to do this?

Thanks :)
 

Terrabull

Veteran Member (Done that)
Reaction score
38
When is the owner of the dying unit ever player 0? I thought you always had to create one for a player. If this is something new that I havent' seen about Galaxy yet, just ignore me.
 

Nano

New Member
Reaction score
0
All the creeps I spawn are for the neutral player (0).

This definitely works as I use it in other triggers.
 

xarell

New Member
Reaction score
1
Trigger:
  • Events
    • Unit - Any Unit dies
    • Conditions
      • (Owner of (Triggering unit)) == 0
      • multiplier_round == 1
    • Actions
      • Unit - Create 1 multiplier_type for player (0) at (Position of (Triggering unit)) facing (Facing of (Triggering unit)) degrees (Ignore Placement)


This works fine for me, so you should check if the condition multiplier_round == 1 actually becomes true. I tested this with a siege tank being replaced after death by a thor.
 

Nano

New Member
Reaction score
0
Thanks Xarell, I'll definitely make sure I check that when I get home.
 

Nano

New Member
Reaction score
0
You were right, the trigger did work, my end of round trigger was getting run prematurely and switching the multiplier_round variable back to 0.

The units not spawn correctly at the place the triggering unit died, but they do not seem to have any orders (they just sit still).

Does anyone know what I'm doing wrong with copying the orders from the triggering unit?
 

xarell

New Member
Reaction score
1
I think the problem is, since the unit is dead, that it doesn't have an orders anymore. You can check this with the function Unit Order Count, which returns an Integer.

I'll try to find a solution for you.
 

xarell

New Member
Reaction score
1
With the little trigger knowledge I posses, I have managed to develop a work-around for you. It is probably not the best solution and inefficient, it works though.

I use these global variables in my triggers:

multiplier_round = 1 <Integer>
point_array = No Point <Point[3]>
points_on_path = 4 <Integer (Constant)>

So make sure you declare them. :)

Trigger:
  • Melee Initialization
    • Events
      • Game - Map initialization
    • Local Variables
      • loop_counter = 0 &lt;Integer&gt;
    • Conditions
    • Actions
      • Variable - Set point_array[0] = Point 001
      • Variable - Set point_array[1] = Point 002
      • Variable - Set point_array[2] = Point 003
      • Variable - Set point_array[3] = Point 004
      • Unit - Create 1 Hellion for player 0 at (Center of (Entire map)) facing 270.0 degrees (No Options)
      • General - For each integer loop_counter from 0 to 3 with increment 1, do (Actions)
        • Actions
          • Unit - Order (Last created unit) to ( Move targeting point_array[loop_counter]) (After Existing Orders)
      • Unit - Set (Last created unit) custom value 0 to (Real(points_on_path))


As you can see, I use points to determine the path the unit is supposed to follow, which is I think the best way to do it. I use the Unit's custom value (0) to store the amount of remaining points it has to go to, this is a Real.

Trigger:
  • Update Position
    • Events
      • Unit - Any Unit Enters within 2.0 of Point 001
      • Unit - Any Unit Enters within 2.0 of Point 002
      • Unit - Any Unit Enters within 2.0 of Point 003
      • Unit - Any Unit Enters within 2.0 of Point 004
    • Local Variables
    • Conditions
    • Actions
      • Unit - Set (Triggering unit) custom value 0 to ((Custom value 0 of (Triggering unit)) - 1.0)


As the Unit approches any one of the points, it has less points to go to in total, so here the custom value (0) of the Unit has to decrease.

Trigger:
  • Multiplier
    • Events
      • Unit - Any Unit dies
    • Local Variables
      • loop_counter = 0 &lt;Integer&gt;
      • next_point = 0 &lt;Integer&gt;
    • Conditions
      • (Owner of (Triggering unit)) == 0
      • multiplier_round == 1
    • Actions
      • Unit - Create 1 Viking (Assault Mode) for player 0 at (Position of (Triggering unit)) facing (Facing of (Triggering unit)) degrees (Ignore Placement)
      • Unit - Set (Last created unit) custom value 0 to (Custom value 0 of (Triggering unit))
      • General - For each integer loop_counter from 0 to ((Integer((Custom value 0 of (Triggering unit)))) - 1) with increment 1, do (Actions)
        • Actions
          • Variable - Set next_point = (points_on_path - ((Integer((Custom value 0 of (Triggering unit)))) - loop_counter))
          • Unit - Order (Last created unit) to ( Move targeting point_array[next_point]) (After Existing Orders)


The first part of the trigger you already know, note that the custom value of the newly created Viking has to be set to the one the triggering unit had.
The next_point variable stores the index of the next point the unit hast to got to. The rest is pretty self explainatory.

EDIT: removed unnessary line which caused bugs

This trigger can cause some problems with massive amounts of units(1 out of 30 units does not inherit orders), I think that's because it's not multi instanceable(some term I picked up here). If someone would make it so, I believe those problems would be gone(I cannot).
 

Nano

New Member
Reaction score
0
You're a champion Xarell. I didn't know about unit custom values and I ended up implementing a solution very similar to what you have here.

Greatly appreciated.

It's a shame I cant just directly clone the dead unit's orders as this method seems far more computationally expensive in involving extra loops and event listeners. It works though and that's what matters right now :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top