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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top