• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Gain Mana per Attack

Status
Not open for further replies.
Level 4
Joined
May 21, 2015
Messages
70
my trigger didnt work, my trigger will add mana to the attacking unit which is a the Warrior now my problem is the mana didnt add at all . what could be the wrong trigger/event?
  • Hero Gain Mana Init
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Trigger - Add to Hero Gain Mana <gen> the event (Unit - (Damage source) Takes damage)
  • Hero Gain Mana
    • Events
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Damage source)) Equal to (==) Warrior
        • Then - Actions
          • Countdown Timer - Start GainMana as a One-shot timer that will expire in 0.00 seconds
        • Else - Actions
          • Do nothing
  • Hero Gain Mana Trigger
    • Events
      • Time - GainMana expires
    • Conditions
      • (Unit-type of (Damage source)) Equal to (==) Warrior
    • Actions
      • Unit - Set mana of (Damage source) to ((Mana of (Damage source)) + 5.00)
 
Level 21
Joined
Nov 4, 2013
Messages
2,017
Nah that's totally messy. Why not simply this?:

  • Mana Gain
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Warrior
    • Actions
      • Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) + 5.00)
But this is not really effective. I suggest you use a DDS because if the Warrior stops the attack, he'd gain mana anyway.
 
As Shadow_Fury said, you're complicating it a bit. I posted a trigger using a DDS below, but in case you're curious as to why triggers aren't working:

(Damage source) only responds to "Unit takes damage" event. In your Init trigger, you are passing in a (Damage source) when one doesn't exist. As for the Hero Gain Mana trigger, it is only responding to the timer expire event, so again--a damage source doesn't exist. Most event responses don't carry over across triggers.

Damage detection systems are cumbersome to code yourself. I recommend that you use any of the popular ones on this site, such as Bribe's Damage Engine or looking_for_help's Damage Detection System. They'll make your life easier for spells such as this.

For example, here is how easy it is to do using Bribe's DDS:
  • Hero Mana Gain
    • Events
      • DamageEvent Equal to 1.00
    • Conditions
      • (Unit-type of DamageEventSource) Equal to Warrior
    • Actions
      • Unit - Set mana of (DamageEventSource) to ((Mana of (DamageEventSource)) + 5.00)
 
Level 13
Joined
Dec 21, 2010
Messages
541
The most efficient way to do that is to use the DDS system ..but I know that it's too difficult for beginners to understand some things... the reason why your trigger won't work is because of the first trigger you made.. It is still possible if you're going to use that event but you must pick every units that belongs to his enemies and add the event Trigger - Add to Hero Gain Mana <gen> the event (Unit - (Picked Unit) Takes damage), and also make a unit group then add those picked units in the group so the event for each unit won't be repeated.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
"but I know that it's too difficult for beginners to understand some things"
"So what I do suggest is that they make it themselves"

0.o

Just use a DDS :D
You could have done your trigger without Timer, so you need the custom event from the DDS, and as condition you use "attacker == warrior"
and as action, you increase mana.

You can even increase it relative to damage dealt.
 
Level 4
Joined
May 21, 2015
Messages
70
ok ok,,, im not a beginner im intermediate (i guess) but anyways.... +rep to all


EDIT:why i cannot +rep ''Wietlol'' is says you must spread some reputation to blah blaah blah...
but , thank you
 
Status
Not open for further replies.
Top