• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Help with Manaverage

Status
Not open for further replies.
Level 6
Joined
Aug 5, 2017
Messages
251
This should be easy. Every time a hero attack an enemy unit, he has a chance to receive mana. Code below:
  • Manaverage
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Demon Warlock
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Manaverage for DemonWarlock) Equal to 1
        • Then - Actions
          • Set Manaverage = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Manaverage Less than or equal to 15
            • Then - Actions
              • Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) + 20.00)
              • Special Effect - Create a special effect attached to the origin of (Attacking unit) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Manaverage for DemonWarlock) Equal to 2
        • Then - Actions
          • Set Manaverage = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Manaverage Less than or equal to 30
            • Then - Actions
              • Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) + 40.00)
              • Special Effect - Create a special effect attached to the origin of (Attacking unit) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Manaverage for DemonWarlock) Equal to 3
        • Then - Actions
          • Set Manaverage = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Manaverage Less than or equal to 45
            • Then - Actions
              • Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) + 60.00)
              • Special Effect - Create a special effect attached to the origin of (Attacking unit) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
        • Else - Actions
I used 2 variables here:
  • Set DemonWarlock = (Attacking unit)
The variable above as specified at the Melee initialization trigger.
And
  • Set Manaverage = (Random integer number between 1 and 100)
The code still wouldn't work. I think it has something to do with the beginning, but I'm not sure. Can someone help me with this?
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
Where is Set DemonWarlock = (Attacking unit) in the trigger? I cannot find it. If DemonWarlock is not defined when the trigger runs, it won't work. You probably should just put it at the beginning of the trigger.



A unit Is attacked is not a good event. It triggers everytime a unit starts attacking (attack animation starts). By rapidly using the stop command, a unit will start attacking very often without actually attacking.

It is better to use the damage event combined with a buff placing attack ability such as orb of corruption or poison.



Instead of copying the actions for every 3 levels, you can simply use another variable:
if (Level of Manaverage for DemonWarlock) Equal to 1
ManaverageChance = 15​
else
if (Level of Manaverage for DemonWarlock) Equal to 1
ManaverageChance = 30​
else
ManaverageChance = 45​

And then after that you can use the condition
if Manaverage Less than or equal to ManaverageChance
so you only have to write that once.
 
Level 6
Joined
Aug 5, 2017
Messages
251
That's a little bit complicated. I'll think of something else. Still, thanks Jampion.
Edit: I just thought there was a way to activate the code without the damage indicator, as it did seem possible.
I know that ManaaverageChance is another integer variable. I'll see if I can come up with a way to make the code work.
 
Last edited:
Status
Not open for further replies.
Top