• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Adding an event with triggers

Status
Not open for further replies.
Level 9
Joined
Jun 1, 2008
Messages
180
I'm trying to make a unit deal double damage against a target with a specific buff. It should work like this: whenever the unit with the buff takes damage, it gets damaged by the damage source a second time.
There are two variables; one's the unit that cast the buff on the target earlier, the other one's the unit that has the buff.

I tried doing it the following way: there is a trigger for the ability itself (when the target receives the buff), both variables are set in this trigger. There is a different variable for the damage, where there is no event. The event is added to the trigger with a different trigger by using the trigger - add new event option.

It just doesn't want to work! :vw_unimpressed:
I've already had a working spell like this yesterday, and for some reason, that one doesn't work anymore either - even though I'm 10000% sure that I haven't even touched it! :vw_wtf:

What should I do?
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
  • Events
    • Unit - Unit gets Attacked
  • Conditions
    • Put unit condition here equal to true
  • Actions
    • Set attacker = (attacking unit)
    • Set Attacked = (triggering unit)
    • If (conditions) are true then do (then actions) else do (else actions)
      • If - Conditions
        • Boolean equal to true
      • Then - Actions
        • Trigger - Add event to (Attack Trigger <gen>) The event Event - Attacked takes damage
        • Set Boolean equal to False
      • Else - Actions
    • Trigger - Turn off (This trigger)
Ah... a few things u need to know, this trigger up here has to be initially off, and when the buff is cast turn it on and dont leave the boolean variable a default false or this wont work, make it default true
  • Events
  • Conditions
    • Attacked has buff equal to Your Buff
  • Actions
    • Unit - Create 1 Dummy Unit
    • Unit - Issue order to last created unit to attack attacked unit dealing damage taken
    • Unit - Remove last created unit from game
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
@InfinateAnswers
Your method is very bad since he wants double damage and changing dummy's damage all the time would be very inefficient,also dummy has no time to attack since it gets removed instantly. Also you made an infinite loop.

This should work though
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Damage Detection <gen> the event (Unit - (Picked unit) Takes damage)
  • Moar events
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Damage Detection <gen> the event (Unit - (Triggering unit) Takes damage)
  • Damage Detection
    • Events
    • Conditions
      • ((Triggering unit) has buff YourBuff) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Boolean Equal to False
        • Then - Actions
          • Unit - Cause (Damage source) to damage (Triggering unit), dealing (Damage taken) damage of attack type Spells and damage type Normal
          • Set Boolean = True
        • Else - Actions
          • Set Boolean = False
 
Level 9
Joined
Jun 1, 2008
Messages
180
Take a look at my triggers... Here's the first one (so we know how's the damage source)
  • Minotaur
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Minotaur
    • Actions
      • Set TrollSorcerer = (Triggering unit)
      • Trigger - Add to Seeing Red Damage <gen> the event (Unit - OrcHermit Takes damage)
      • Trigger - Turn on Voodoo Doll Damage <gen>
      • Trigger - Turn off (This trigger)
Second one (to set the target with the buff)
  • Seeing Red
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Seeing Red
    • Actions
      • Set SeeingRed_Target = (Target unit of ability being cast)
      • Animation - Change SeeingRed_Target's vertex coloring to (100.00%, 0.00%, 0.00%) with 0.00% transparency
And last but not least, the damage itself
  • Seeing Red Damage
    • Events
    • Conditions
      • (Damage source) Equal to Minotaur
    • Actions
      • Unit - Cause Minotaur to damage SeeingRed_Target, dealing 500.00 damage of attack type Spells and damage type Normal
 
Level 9
Joined
Jun 1, 2008
Messages
180
I really don't see the problem,my method works but you don't seem to use my triggers.

  • Seeing Red
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Seeing Red
    • Actions
      • Trigger - Add to Seeing Red Damage <gen> the event (Unit - (Target unit of ability being cast) Takes damage)
  • Seeing Red Damage
    • Events
    • Conditions
      • (Unit-type of (Damage source)) Equal to Minotaur
      • ((Triggering unit) has buff Seeing Red ) Equal to True
    • Actions
      • Unit - Cause Minotaur to damage (Triggering unit), dealing (Damage taken) damage of attack type Chaos and damage type Normal
Still not similar to yours?
By the way, I did the earlier spell my way, and it works. This one doesn't, for some reason.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
You made an infinite loop,also you're adding event multiple times for the same unit,if the Seeing red gets casted more than once.
Use my triggers with these conditions
  • (Unit-type of (Damage source)) Equal to Minotaur
  • ((Triggering unit) has buff Seeing Red ) Equal to True
In third trigger
 
Level 9
Joined
Jun 1, 2008
Messages
180
Damn it! Now I understand this infinite loop thing... Aww!!! I just have to turn off the trigger before the damaging action, then turn it on again. Now I know what to do, thanks a lot!

Edit: well it still doesn't deal damage, but at least it doesn't crash anymore. x'D
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
lol to prevent infinite loop,use this
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Boolean Equal to False
    • Then - Actions
      • Unit - Cause (Damage source) to damage (Triggering unit), dealing (Damage taken) damage of attack type Spells and damage type Normal
      • Set Boolean = True
    • Else - Actions
      • Set Boolean = False
You need Boolean variable of boolean type.
I did this in my trigger but you don't want to use it >_>
 
Level 9
Joined
Jun 1, 2008
Messages
180
lol to prevent infinite loop,use this
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Boolean Equal to False
    • Then - Actions
      • Unit - Cause (Damage source) to damage (Triggering unit), dealing (Damage taken) damage of attack type Spells and damage type Normal
      • Set Boolean = True
    • Else - Actions
      • Set Boolean = False
You need Boolean variable of boolean type.
I did this in my trigger but you don't want to use it >_>

Still nothing.
Here's what I'm actually doing: it's a hero called Minotaur. It can cast a spell called Seeing Red on a target enemy unit, turning it red. As long as the unit has that buff, the Minotaur (and only the Minotaur) deals double damage on it. Your triggers do work, so did mine on a totally different spell, but this just doesn't want to work out.
 
Level 9
Joined
Jun 1, 2008
Messages
180
Good luck with that. I've just tried your first trigger.
Adding all the units on the map, then damaging them if they get attacked by the Minotaur if they have the buff. Doesn't work either, although I traced your trigger.
I really don't know what's going on. This totally makes me appear like a damn newbie, but this is the first trigger that causes me such problems. Even though it's pretty much the same thing as the previous one! It makes me sick...

Edit: I've been able to make it work. It only works if I add the target unit of ability being cast to the new event... If I set a unit variable first, then add it as the variable, it doesn't do anything. Well, thanks for the help!
 
Last edited:
Status
Not open for further replies.
Top