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

[Trigger] Is this efficient?

Status
Not open for further replies.
Level 8
Joined
Apr 30, 2009
Messages
338
Finishing up all the abilities on my Berserker hero. Have a pretty simple spell here, but I am wondering if I could be making it more efficient, like somehow to not have a 0.03s periodic trigger for this.

It's based on an ability from Guild Wars that caps an enemy's max HP, preventing healing.

  • Mortal Wound 01
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to BRS-5 Mortal Wound
    • Actions
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing (0.25 x (Life of (Target unit of ability being cast))) damage of attack type Hero and damage type Normal
      • Special Effect - Create a special effect attached to the weapon, left of (Triggering unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect attached to the weapon, right of (Triggering unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect attached to the chest of (Target unit of ability being cast) using Objects\Spawnmodels\Orc\Orcblood\OrdBloodWyvernRider.mdl
      • Special Effect - Destroy (Last created special effect)
      • Set temp_point = (Position of (Target unit of ability being cast))
      • Unit - Create 1 D.BRS-5 Mortal Wound for (Owner of (Triggering unit)) at temp_point facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_temp_point)
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Undead Banshee - Curse (Target unit of ability being cast)
      • Hashtable - Save 10.00 as (Key duration) of (Key (Target unit of ability being cast)) in H_MortalWound
      • Hashtable - Save 75.00 as (Key hpmax) of (Key (Target unit of ability being cast)) in H_MortalWound
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is in G_MortalWound) Equal to False
        • Then - Actions
          • Unit Group - Add (Target unit of ability being cast) to G_MortalWound
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mortal Wound 02 <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Mortal Wound 02 <gen>
        • Else - Actions
  • Mortal Wound 02
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in G_MortalWound) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in G_MortalWound and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Key duration) of (Key (Picked unit)) from H_MortalWound) Greater than 0.00
                • Then - Actions
                  • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Critters\Albatross\CritterBloodAlbatross.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Hashtable - Save ((Load (Key duration) of (Key (Picked unit)) from H_MortalWound) - R_FRAME_PROJECTILES) as (Key duration) of (Key (Picked unit)) in H_MortalWound
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Percentage life of (Picked unit)) Greater than (Load (Key hpmax) of (Key (Picked unit)) from H_MortalWound)
                    • Then - Actions
                      • Unit - Set life of (Picked unit) to (Load (Key hpmax) of (Key (Picked unit)) from H_MortalWound)%
                    • Else - Actions
                • Else - Actions
                  • Unit - Remove ~BRS-5 Mortal Wound (Berserker) buff from (Picked unit)
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in H_MortalWound
                  • Unit Group - Remove (Picked unit) from G_MortalWound
        • Else - Actions
          • Trigger - Turn off (This trigger)
PS the effect of the blood effect every 0.03 is so cool though...

attachment.php
 

Attachments

  • mw.jpg
    mw.jpg
    1.4 MB · Views: 150
This is so hilarious. Your previous problem? Well, I have some ability that uses backfacing. Now, this problem is another ability of mine (kind of), hehe. Anyway, I used periodic trigger myself, I don't really think there is any way to do it differently. I used 1.00 seconds for the periodic health set, but it looked unnatural (regenerated and then back to the value it should be). Your best deal is this, or 0.05 seconds. It still performs visually great, with less calls.
 
Level 8
Joined
Apr 30, 2009
Messages
338
dont tell me you have a spell based off the taunt abilities from Warhammer online:

attachment.php
 

Attachments

  • taunt.jpg
    taunt.jpg
    53.9 KB · Views: 124
Level 8
Joined
Apr 30, 2009
Messages
338
I just always see abilities in MMOs and say "hey that would be a cool spell in DotA" where there are still a handful of boring heroes like skeleton king and sven
 
Level 11
Joined
Jan 25, 2009
Messages
572
This spell isn't MUI. Try to go throught an tutorial of either Hastables or Indexing System. The rules of THW says that a uploaded spell must be MUI and leakless and lagless on a standard computer.

EDIT: Oh shit nevermind! I didn't saw that u used hashtables. Just look throught the trigger for 3-4 secs xD
 
Why do you destroy the special effects instantly? (First Trigger). This causes the special effects not to appear unless you can see things that instantly disappear... Anyway, everything looks in order.

That happens to special effects that have no birth animation, not every single special effect. They properly appear and disappear as you want them to. Test it :)
 
Level 8
Joined
Apr 30, 2009
Messages
338
most of the blood effects can be destroyed instantly and will still play 1 iteration of their animation.

for the ones that don't appear when destroyed instantly, I just make a dummy unit with the effect model and give it an expiration timer of like 2 sec.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
To answer the main question, no it is not efficient as it is GUI which adds pointless complexity to the compiled code (slowing execution down).

Areas to improve efficency...
Instead of destroying last created effect relying on a variable set, you could destroy what the create effect native returns meaning only 1 call and no variable sets.
You could save loaded hashtable values to variables, this will up efficency as variable reads are a lot faster than hashtable lookups.
Counting the number of units in a group is very unefficent due to O(n) algerthim used. Rather keep track of the number in the group with an integer variable (add 1 or remove 1 when the group changes) which is always O(1) and very simple.
All other major optimizations would be unlocked via a serious JASS rewrite which I guess is out of the question here.
 
Status
Not open for further replies.
Top