• 🏆 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!

[Trigger] selfdamage AI loop?

Status
Not open for further replies.

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
  • Damage per second
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • ((Casting unit) has buff Erupt (Caster) ) Equal to True
    • Actions
      • Unit - Cause (Casting unit) to damage (Casting unit), dealing 17.00 damage of attack type Magic and damage type Fire
      • Wait 1.00 game-time seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) has buff Erupt (Caster) ) Equal to True
        • Then - Actions
          • Unit - Cause (Casting unit) to damage (Casting unit), dealing 17.00 damage of attack type Magic and damage type Fire
          • Wait 1.00 game-time seconds
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) has buff Erupt (Caster) ) Equal to True
        • Then - Actions
          • Unit - Cause (Casting unit) to damage (Casting unit), dealing 17.00 damage of attack type Magic and damage type Fire
          • Wait 1.00 game-time seconds
        • Else - Actions
This is my messy trigger as it is now. I am trying to achieve an effect that damages the user as long as the buff "Erupt (Caster)" is active. The way I've tried to do it now seems messy, but there must be a sort of loop action I can find.

What I want is this:
  • Events
    • Unit - A unit Finishes casting an ability
      • If - Conditions
        • ((Casting unit) has buff Erupt (Caster) ) Equal to True
      • Then - Actions
        • Unit - Cause (Casting unit) to damage (Casting unit), dealing 17.00 damage of attack type Magic and damage type Fire
        • Wait 1.00 game-time seconds
[Here I want the loop, to make it do the entire trigger over and over, every second.]

I couldn't find it.
 
  • Tr
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Erupt
  • Actions
    • Unit Group - Add (Triggering unit) to EruptGroup
    • Trigger - Turn on Tri <gen>
  • Tri
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (EruptGroup is empty) Equal to True
      • Then - Actions
        • Trigger - Turn off (This trigger)
      • Else - Actions
        • Unit Group - Pick every unit in (EruptGroup) and do (Actions)
          • Loop - Actions
            • If (All conditions are true) then do (Actions) else do (Actions)
              • If - Conditions
                • ((Picked unit) has Erupt (buff)) Equal to True
              • Then - Actions
                • Unit - Cause (Picked unit) to damage (Picked unit) dealing 17.00 damage of attack type Magic and damage type Fire
              • Else - Actions
                • Unit Group - Remove (Picked unit) from EruptGroup
EruptGroup is a "Unit Group" variable.
 

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
Ah wonderful. Thanks, this really helped! :)

edit: will the unit successfully be removed from the unit group when he runs out of mana, and erupt fades?
edit2: yes of course it will, didn't proof-read your trigger;). thanks again.
edit3: I want this to deal more and more damage to the caster, depending on what level the spell is. Will I add that as an if/then/else line right before the damage, with a "if" level is 1, 2 and 3?
 
1) No, it won't, you didn't ask for that :p
  • Tri
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (EruptGroup is empty) Equal to True
      • Then - Actions
        • Trigger - Turn off (This trigger)
      • Else - Actions
        • Unit Group - Pick every unit in (EruptGroup) and do (Actions)
          • Loop - Actions
            • If (All conditions are true) then do (Actions) else do (Actions)
              • If - Conditions
                • ((Picked unit) has Erupt (buff)) Equal to True
                • (Mana of (Picked unit)) Greater than or Equal to X
              • Then - Actions
                • Unit - Cause (Picked unit) to damage (Picked unit) dealing 17.00 damage of attack type Magic and damage type Fire
              • Else - Actions
                • Unit Group - Remove (Picked unit) from EruptGroup
I added the Real comparison of "Mana of (Picked unit)) Greater than or Equal to X". Set X to the value of mana you want the trigger to stop from being further used, e.g. 20. mana.

By the way, you said the trigger did stop working, so I guess you use Immolation for this?

2) Damage must be saved via a hashtable. In order to learn extra stuff for the hashtable, redirect yourself here: http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/

Hashtable are big data savers, where you save values and objects and load them back. In order for your trigger to work with level dependency, you can also use indexing systems, but hashtables look more newbie-friendly.

  • Init
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Hashtable - Create a hashtable
    • Set Hash = (Last created hashtable)
Hash is a hashtable variable.

  • Tr
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Erupt
  • Actions
    • Set DamageDealt = (12 x (Real(Level of (Ability being cast) for (Triggering unit))))
    • Hashtable - Save DamageDealt as 1 of (Key(Triggering unit)) in Hash
    • Unit Group - Add (Triggering unit) to EruptGroup
    • Trigger - Turn on Tri <gen>
  • Tri
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (EruptGroup is empty) Equal to True
      • Then - Actions
        • Trigger - Turn off (This trigger)
      • Else - Actions
        • Unit Group - Pick every unit in (EruptGroup) and do (Actions)
          • Loop - Actions
            • If (All conditions are true) then do (Actions) else do (Actions)
              • If - Conditions
                • ((Picked unit) has Erupt (buff)) Equal to True
                • (Mana of (Picked unit)) Greater than or Equal to X
              • Then - Actions
                • Set DamageLoad = (Load 1 of (Key(Picked unit)) from Hash)
                • Unit - Cause (Picked unit) to damage (Picked unit) dealing DamageLoad damage of attack type Magic and damage type Fire
              • Else - Actions
                • Unit Group - Remove (Picked unit) from EruptGroup
                • Hashtable - Clear all child hashtables of (Key(Picked unit)) from Hash
The hashtable action is "Hashtable - Save Real" and when you are supposed to type the value, select the DamageDealt variable instead.
DamageLoad is again a real variable (just like DamageDealt) and uses the Hashtable - Load Real value.
 

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
Ah, okay. This line:

Set DamageDealt = (12 x (Real(Level of (Ability being cast) for (Triggering unit))))

Does that mean it deals 12 damage at level 1, 24 at level 2, and 36 at level 3 etc?
I was wondering how I could change that into something that does not follow a specific pattern.

btw thanks for that guide, it did help a bit. Will have to read it 15x times more till I get it completely, though :p
 

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
Okay, thanks. Regarding that damage dealt, will I have to clear it before I give it a new value? Now I am making a line for level 1 erupt, meaning it should do 12 damage. When I get to the second line, will I have to fill in some kind of "reset" of that variable before I give it a new value? Or will it simply overwrite 12?
 

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
Ah, brilliant. That should be all I need to know to get this spell to work! :)

Will post again if I get any issue.
Thanks.
 

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
The spell works nicely now, but the damage done isn't as high as what I wrote. Is this because heroes have a damage reduction? Maybe I should change it from "doing 17 damage", to "subtracting 17 life" if that is possible.
 
If you absorb life, it will ignore every possible defense the target unit has. Magic Reduction along with Armor are those defenses. So, even if a hero has 17 armor or 2 armor, it will deal the same damage (same goes to Chaos damage -> pierces through anything). The worst thing though is that you can't gain gold if the target unit is killed, simply because you don't deal damage, you just set life to a different value.

Since armors exist for this reason, increase damage from 17 to 50 or 100. A hero with high armor is logical to sustain greater damage than a hero with less armor, but if you really want to ignore defense, then use attack type: Chaos.

If your Attack type is "Spells", damage is reduced by Magic Resistance and cannot affect units with Magic Immunity. If the Attack type is "Normal", the damage is reduced by the unit's Armor. We usually use "Spells" to cause damage, since most skills are magic-oriented.
 
Status
Not open for further replies.
Top