Misreferencing a unit

Genkora

Frog blast the vent core!
Reaction score
92
This trigger of mine causes a tower to cast a spell when its mana reaches 100. It is passive, and for the most part it works rather well. However, it sometimes does not work, because the unit stored in my unit variable either does not exist or is out of range (Out of range of the 800 in the unit group "Random", the spell itself has a very very long range), but this is a rare occurrence. I know that is sometimes is referencing an incorrect unit because I have it set up to state the name of whatever unit is Runit.

Trigger:
  • Activate spells
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set Sgroup = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Charge Tower))
      • Unit Group - Pick every unit in Sgroup and do (Actions)
        • Loop - Actions
          • Set Cpoint = (Position of (Picked unit))
          • Set Random = (Units within 800.00 of Cpoint matching (((Unit-type of (Matching unit)) Not equal to Dummy) and (((Unit-type of (Matching unit)) Not equal to Missile Guy) and (((Unit-type of (Matching unit)) Not equal to Charge Tower) and (((Unit-type of (Matching unit)) No
          • Set Runit = (Random unit from Random)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Greater than or equal to 100.00
              • (Level of Frenzy Fire (passive) for (Picked unit)) Greater than 0
              • (Number of units in Random) Greater than 0
            • Then - Actions
              • Unit - Create 1 Dummy for Neutral Passive at Cpoint facing Default building facing degrees
              • Unit - Add a 6.00 second Generic expiration timer to (Last created unit)
              • Unit - Order (Last created unit) to Undead Banshee - Curse Runit
              • If ((Level of Frenzy Fire (real) for (Picked unit)) Equal to 1) then do (Unit Group - Add Runit to FFire1) else do (Do nothing)
              • If ((Level of Frenzy Fire (real) for (Picked unit)) Equal to 2) then do (Unit Group - Add Runit to FFire2) else do (Do nothing)
              • If ((Level of Frenzy Fire (real) for (Picked unit)) Equal to 3) then do (Unit Group - Add Runit to FFire3) else do (Do nothing)
              • Game - Display to (All players) the text: (Name of Runit)
              • If ((Level of Frenzy Fire (real) for (Picked unit)) Equal to 3) then do (Do nothing) else do (Unit - Increase level of Frenzy Fire (real) for (Picked unit))
              • Unit - Increase level of Frenzy Fire (passive) for (Picked unit)
              • Unit - Set mana of (Picked unit) to 0.00
              • Unit - Create 1 Missile Guy for Neutral Passive at Cpoint facing Default building facing degrees
              • Unit - Add a 6.00 second Generic expiration timer to (Last created unit)
              • Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb Runit
              • Custom script: call DestroyGroup (udg_Random)
              • Game - Display to (All players) the text: (String((Number of units in Random)))
            • Else - Actions
          • Custom script: call RemoveLocation (udg_Cpoint)
      • Custom script: call DestroyGroup (udg_Sgroup)
 

Curo

Why am I still playing this game...?
Reaction score
109
What do you mean by "incorrect unit"? Your set random = units matching.... line gets cut off, so I can't see what else you have there. If this is a TD, I think it would be more appropriate to use a charge tower attacks event, rather that your periodic. Then that way you could just make RUnit the attacked unit.
 

canons200

New Member
Reaction score
50
try alternative method? give the tower ability first, and use the event an unit is attacked or GDD. If all condition are matched, order unit to do action (acid bomb)?
 

Genkora

Frog blast the vent core!
Reaction score
92
Ok, I changed it to a unit is attacked, and used a random unit from group in case the tower happened to be attacking a magic immune (so it'll cast it on something else besides the immune thing it is attacking). Works great, thanks.
 
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