Start a trigger via damaged unit

Xebarsis

New Member
Reaction score
7
In my game sometimes a unit called the "Runaway Gold Mine Cart" spawns. I want to make it so that every time you attack this unit, the attacking player gets 3 gold.

Unfortunately, I only know how to make it give the user gold when the gold mine cart is under attack. What I mean by this is that it's exploitable; you could pretend to attack the gold mine cart and then hit the stop button before the attack is finished and the trigger will still play.

Code:
Goldmine Cart Damage
    Events
        Unit - A unit Is attacked
    Conditions
        (Unit-type of (Attacked unit)) Equal to Gold Mine Cart
    Actions
        Player - Add 3 to (Owner of (Attacking unit)) Current gold
        Sound - Play Coin <gen> at 100.00% volume, attached to (Attacked unit)

Is there a way I can adjust this trigger to only give 3 gold and play the sound effect when the gold mine cart is actually damaged instead of simply attacked?
 

nome

New Member
Reaction score
0
Events
Unit - A unit is Attacked
Conditions
(Unit-type of (Attacked unit)) Equal to Gold Mine Cart
Actions
Wait until ((Percentage life of (Attacked unit)) Less than 100.00), checking every 1.00 seconds
Player - Add 3 to (Owner of (Attacking unit)) Current gold
Sound - Play Coin <gen> at 100.00% volume, attached to (Attacked unit)

try that?
 

PooBucket

New Member
Reaction score
12
If yours is a TD, then on that specific round pick every unit and give it pillage.
You can also put a Sound Effect on it I think, so when you attack you give the sound effect. The ability Pillage works when you actually attack it, no bugs.
 

Malkier

New Member
Reaction score
2
Code:
Goldmine Cart damage
    Events
        Unit - A unit Is attacked
    Conditions
        (Unit-type of (Triggering unit)) Equal to Footman
    Actions
        Set goldcarthp = (Integer((Life of (Triggering unit))))
        Set attacker = (Owner of (Attacking unit))
        Set goldcart = (Triggering unit)
        Wait until ((Integer((Life of goldcart))) Less than goldcarthp), checking every 1.00 seconds
        Player - Add 3 to attacker Current gold
        Sound - Play Coin <gen> at 100.00% volume, attached to (Attacked unit)

that trigger should work..will be bugged up if multiple ppl attack it at once though..maybe using variable arrays for each player would be better for multiple player games
 

Xebarsis

New Member
Reaction score
7
Code:
Goldmine Cart damage
    Events
        Unit - A unit Is attacked
    Conditions
        (Unit-type of (Triggering unit)) Equal to Footman
    Actions
        Set goldcarthp = (Integer((Life of (Triggering unit))))
        Set attacker = (Owner of (Attacking unit))
        Set goldcart = (Triggering unit)
        Wait until ((Integer((Life of goldcart))) Less than goldcarthp), checking every 1.00 seconds
        Player - Add 3 to attacker Current gold
        Sound - Play Coin <gen> at 100.00% volume, attached to (Attacked unit)

that trigger should work..will be bugged up if multiple ppl attack it at once though..maybe using variable arrays for each player would be better for multiple player games

Thank you for the trigger Malkier, but the thing about my map is that there's likely to be a lot of different players attacking it at the same time, so if you say that it will be bugged if multiple people are attacking it then it would become bugged for sure. How do I use variable arrays within this trigger to allow it to work with multiple players?
 

Strilanc

Veteran Scripter
Reaction score
42
The attacked event doesn't work for this type of thing. If you constantly re-order the attack (just right-click on the cart a lot) you get one event per click instead of one per attack.
 
Reaction score
341
Make it an array...

set tempinteger = tempinteger+1
set goldcarthp[tempinteger] = LIFE

then do it for the rest.
 

Genyuumaru

New Member
Reaction score
15
Ummm... Why not add an event to the trigger to make it run when the Cart is damaged.

Like Create 1 Gold Mine Cart for Someone in center of region <gen>

Then "Trigger - Add the event Last Created Unit takes damage to (trigger where the event unit is attacked is) "

Remove the unit is attacked event and replace attacked unit to triggering unit (use damage source to check what player attacked the cart).

Works 200% Hope I helped.
 

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
A unit enters entire map

Triggering unit equal to Gold Cart

Add Triggering unit to Group
Pick every units in Group
Add event to Trigger2 (Picked unit) takes damage

Trigger2
Event
Condition
Action
Add 3 gold to Owner of (Damage Source unit or something) current gold
 

Xebarsis

New Member
Reaction score
7
A unit enters entire map

Triggering unit equal to Gold Cart

Add Triggering unit to Group
Pick every units in Group
Add event to Trigger2 (Picked unit) takes damage

Trigger2
Event
Condition
Action
Add 3 gold to Owner of (Damage Source unit or something) current gold

That worked perfectly! Thank you! Does this trigger also work if there are multiple runaway mine carts that are under attack? (Rare occurance, but it could happen.)
 

vypur85

Hibernate
Reaction score
803
> if there are multiple runaway

Yeah it works in multiple instances. It's MUI. But it doesn't differentiate between physical attack and spell damage. So casting damaging spell onto the cart will result in gold gain (this also includes AOE damage like Immolation).
 

Xebarsis

New Member
Reaction score
7
> if there are multiple runaway

Yeah it works in multiple instances. It's MUI. But it doesn't differentiate between physical attack and spell damage. So casting damaging spell onto the cart will result in gold gain (this also includes AOE damage like Immolation).

Haha, I like that. Immolation could turn into a tactic to milk a runaway gold mine cart for all it has.
 

Xebarsis

New Member
Reaction score
7
Hey, I was testing out the trigger and it turns out that illusions and mirror images that are attacking the runaway gold mine cart for 0 damage still initiate the trigger and give the player 3 gold. The cart isn't actually getting damaged though, so this is a huge exploit. Does anyone know how to make this not apply to units with a mirror image or illusion?
 
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