Detecting Replaced Units via an Event

Sil3nt

SUP?
Reaction score
134
I don't think there's an event for detecting 'creates' or 'replaces', is there? Like my last thread, this is may be easier to understand if you've played Legion TD.

Basically, each round, a set of towers (buildable units) become units that automatically fight for the player, and reset to their positions each round as a building. The process repeats. I'm trying to replicate this same effect by having the units replaced each round using For and If's with unit-type array loops each round.

Anyway, the problem I'm having is upgrading the spells the buildings have (after being replaced) to level 2. I have triggers using the event 'finishes an upgrade' that level up the building spells, but once they're replaced they become level 1.

There are some solutions I could think to this but they all pretty much involve triggering each tower separately, and I'm trying to avoid it. Any suggestions?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
When you create a unit or replace it the "unit enters region (playable map area)" will be triggered.
However, as you might guess, you will need to filter out the right units by yourself since almost any unit in the game will trigger this event as well when it comes into play.
 

Sil3nt

SUP?
Reaction score
134
That sucks. But since I already have unit type arrays for towers and units already, I could make one for all of the 'Level 2' abilities and have my trigger pick every unit of type (on the map), check if they have any of the skills already in the ability array, and set those to level 2. This is possible right?

Not what you suggested but it just came to me, and seems like a feasible alternative.
 

Sil3nt

SUP?
Reaction score
134
When you create a unit or replace it the "unit enters region (playable map area)" will be triggered.
However, as you might guess, you will need to filter out the right units by yourself since almost any unit in the game will trigger this event as well when it comes into play.

Guess I'll find out soon enough, heh.

Thanks for the help again.
 

Sil3nt

SUP?
Reaction score
134
Ooook, I have another problem, didn't want to make another thread since it feels like one of those moments where I missed something very tiny so I'll bump this already bumped thread :)

Code:
Protector Invulnerability
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 5, do (Actions)
            Loop - Actions
                Set temp_loc[(Integer A)] = (Position of sent_towers[(Integer A)])
                Set sent_tower_temp_group[(Integer A)] = (Units within 800.00 of temp_loc[(Integer A)] matching ((((Matching unit) belongs to an ally of Player 1 (Red)) Equal to True) and ((Unit-type of (Matching unit)) Not equal to Ancient Protector)))
                Unit Group - Pick every unit in sent_tower_temp_group[(Integer A)] and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Number of units in sent_tower_temp_group[(Integer A)]) Greater than 0
                            Then - Actions
                                Unit - Add Invulnerable  to sent_towers[(Integer A)]
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Number of units in sent_tower_temp_group[(Integer A)]) Less than or equal to 0
                                    Then - Actions
                                        Unit - Remove Invulnerable  from sent_towers[(Integer A)]
                                        Game - Display to (All players) the text: (Tower  + ((String((Integer A))) +  - is vulnerable!))
                                    Else - Actions
        Custom script:   call RemoveLocation(udg_temp_loc[bj_forLoopAIndex])
        Custom script:   call DestroyGroup(udg_sent_tower_temp_group[bj_forLoopAIndex])

Basically, the trigger is supposed to make the towers invulnerable when there are allied units alive nearby (minus the protector's themselves), and vulnerable when they're alone.

So far it kind of half works, the towers become invulnerable when a unit enters its distance, but they do not become vulnerable when it leaves. I've added in a test command to check the units in 'sent_tower_temp_group[(Integer A)' and everything is what it's meant to be, so I've got no idea what it could be.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
cant you base this off voodoo (witch doctor ability with an invulnerable aura) and if you want the unit to be able to move, just make it a dummy unit and make the caster vulnerable after it is casted
 

Sil3nt

SUP?
Reaction score
134
I guess that would work if I started using classifications for units to determine what to make invulnerable and what not to.
I've already remade the trigger(s) and it works, though. This might be useful in the future if I decide or need to remake the 'system' I'm using. Great suggestion.
 
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