• 🏆 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] Does this leak?

Status
Not open for further replies.
Level 9
Joined
Apr 4, 2004
Messages
519
I tried to create a non-channeling Cloud ability for my Assassin to lower accuracy of enemies in an area around her. Basically it's like Rikimaru's Smokescreen in DotA. My question is, does this leak at any place that I can prevent? And it's only meant to be used by 1 hero so it doesn't actually matter if several units can cast it at the same time or not.

  • Smokescreen
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Smokescreen
    • Actions
      • Set HeroCaster = (Casting unit)
      • Unit - Create 1 Dummy for (Owner of HeroCaster) at (Position of HeroCaster) facing Default building facing degrees
      • Set DummyCaster = (Last created unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Smokescreen for HeroCaster) Equal to 1
        • Then - Actions
          • Unit - Set level of Smokescreen for DummyCaster to 1
          • Unit - Order DummyCaster to Human Dragonhawk Rider - Cloud (Position of HeroCaster)
          • Unit - Add a 8.00 second Generic expiration timer to DummyCaster
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Smokescreen for HeroCaster) Equal to 2
        • Then - Actions
          • Unit - Set level of Smokescreen for DummyCaster to 2
          • Unit - Order DummyCaster to Human Dragonhawk Rider - Cloud (Position of HeroCaster)
          • Unit - Add a 10.00 second Generic expiration timer to DummyCaster
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Smokescreen for HeroCaster) Equal to 3
        • Then - Actions
          • Unit - Set level of Smokescreen for DummyCaster to 3
          • Unit - Order DummyCaster to Human Dragonhawk Rider - Cloud (Position of HeroCaster)
          • Unit - Add a 12.00 second Generic expiration timer to DummyCaster
 
Level 8
Joined
Aug 4, 2006
Messages
357
Your trigger contains point leaks. You can read more about leaks here: http://www.hiveworkshop.com/forums/triggers-and-scripts-269/things-that-leak-35124/. I cleaned the leaks and made your code shorter using a little math. You need to make a point variable called HeroCasterPoint.
  • Smokescreen
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Smokescreen
    • Actions
      • Set HeroCaster = (Casting unit)
      • Set HeroCasterPoint = (Position of HeroCaster)
      • Unit - Create 1 Dummy for (Owner of HeroCaster) at HeroCasterPoint facing Default building facing degrees
      • Set DummyCaster = (Last created unit)
      • Unit - Set level of Smokescreen for DummyCaster to (Level of Smokescreen for HeroCaster)
      • Unit - Order DummyCaster to Human Dragonhawk Rider - Cloud HeroCasterPoint
      • Unit - Add a (6.00+2*(Level of Smokescreen for HeroCaster)) second Generic expiration timer to DummyCaster
      • Custom script: call RemoveLocation(HeroCasterPoint)
 
Level 8
Joined
Nov 9, 2008
Messages
502
It's instant so will be MUI anyway.

Understand that triggers run one after the other. If a trigger contains a wait, then other triggers will run during that wait period in which time a number of variables can be reset which could lead to functions refering to the wrong units and such.

'triggering unit' is the only reference that can be carried over a wait without it changing.
 
Level 9
Joined
Apr 4, 2004
Messages
519
@ maskedpoptart: Oh, I hadn't thought at all about trying to get the code shorter. xP And thanks alot for it! + rep

@ toofless: Thanks for the info. +rep :)
 
Level 9
Joined
Apr 4, 2004
Messages
519
While this thread is still somewhat active, I'd wanna take the opportunity to ask another question.

I'm trying to make a healing spell based on Acid Bomb, my problem is however; I can't make it heal friendly units. I've tried to put negative values in the Primary Damage section but that still damages them.

Another thing I tried to do was remove all values from the spell, and make a dummy cast Rejuvenation on the target unit. However, I don't really know how to make the dummy cast it when the missile art hits the target in question and not before that.

Any help is much appreciated and reputation will be added. :p
 
Level 8
Joined
Aug 4, 2006
Messages
357
EoW's method will only work if the targeted unit is not moving. For example, if the targeted unit is running away from the caster, the spell would trigger before the acid bomb actually hit. If the targeted unit is running toward the caster, the spell would trigger after the acid bomb hit.

I would suggest basing the ability off of channel and making it a non-homing AOE dummy spell. Then you can use EoW's method to accurately calculate when the missile will impact, and can order your dummy unit to cast the healing spell on units in range. If you need help with the trigger, let me know.
 
Level 9
Joined
Apr 4, 2004
Messages
519
Another solution I came to is that, if I base the Hero's dummy spell of Drunken Haze or something similiar and add a 0.5 second duration on it and when the spell is used, it'll in turn activate a second trigger, checking if the targeted unit has the buff and then cast the healing spell on it.

I don't really know if that's efficient or not, though. Otherwise I'd probably go for your recommendation, masked. And I'd be happy to get some help with the triggering. :D

This is the current trigger I'm using for the solution I suggested:

  • Healing Mojo Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Healing Mojo
    • Actions
      • Set HeroCaster = (Casting unit)
      • Set HeroCastTarget = (Target unit of ability being cast)
      • Trigger - Turn on Healing Mojo Dummy Cast <gen>
      • Trigger - Run Healing Mojo Dummy Cast <gen> (checking conditions)
  • Healing Mojo Dummy Cast
    • Events
      • Time - Every 0.50 seconds of game time
      • Conditions
        • (HeroCastTarget has buff of Healing Mojo) Equal to True
      • Actions
        • Unit - Create 1 Dummy for (Owner of HeroCaster) at (Position of HeroCaster) facing Default building facing degrees
        • Set DummyCaster = (Last created unit)
        • Unit - Set level of Healing Mojo (Dummy) for DummyCaster to (Level of Healing Mojo for HeroCaster)
        • Unit - Order DummyCaster to Night Elf Druid of the Claw - Rejuvenation HeroCastTarget
        • Unit - Add a 1.00 second Generic expiration timer to DummyCaster
        • Trigger - Turn off (This trigger)
This, in fact works, I've noticed. But as I said I'm not sure how efficient it really is.
 
Level 2
Joined
Jul 17, 2009
Messages
27
Any suggestions as to how I could improve it? :p


Since I love the cat in Sinfest:

New integer variable: HealingMojo (starts at 0)
New integer variable: HealingMojoCounter (start is irrelevant)
New point variable: Locator (starts null)
HeroCaster is now an array [8190]
HeroCastTarget is now an array [8190]



  • Healing Mojo Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Healing Mojo
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HealingMojo Equal to 0
        • Then - Actions
          • Trigger - Turn on Healing Mojo Dummy Cast <gen>
          • Set HealingMojo = (HealingMojo + 1)
          • Set HeroCastTarget[HealingMojo] = (Target unit of ability being cast)
          • Set HeroCaster[HealingMojo] = (Casting unit)
        • Else - Actions
          • Set HealingMojo = (HealingMojo + 1)
          • Set HeroCastTarget[HealingMojo] = (Target unit of ability being cast)
          • Set HeroCaster[HealingMojo] = (Casting unit)
  • Healing Mojo Dummy Cast
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HealingMojo Greater than 0
        • Then - Actions
          • For each (Integer HealingMojoCounter) from 1 to HealingMojo, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (HeroCastTarget[(HealingMojoCounter)] has buff Healing Mojo) Equal to True
                • Then - Actions
                  • Set Locator = (Position of HeroCastTarget[HealingMojoCounter])
                  • Unit - Create 1 Dummy for (Owner of HeroCaster[HealingMojoCounter]) at Locator facing Default building facing degrees
                  • Set DummyCaster = (Last created unit)
                  • Unit - Set level of Healing Mojo (Dummy) for DummyCaster to (Level of Healing Mojo for HeroCaster[HealingMojoCounter])
                  • Unit - Order DummyCaster to Night Elf Druid Of The Claw - Rejuvenation HeroCastTarget[HealingMojoCounter]
                  • Unit - Add a 1.00 second Generic expiration timer to DummyCaster
                  • Set HeroCastTarget[HealingMojoCounter] = HeroCastTarget[HealingMojo]
                  • Set HeroCaster[HealingMojoCounter] = HeroCaster[HealingMojo]
                  • Set HeroCastTarget[HealingMojo] = No unit
                  • Set HeroCaster[HealingMojo] = No unit
                  • Set HealingMojo = (HealingMojo - 1)
                  • Set HealingMojoCounter = (HealingMojoCounter - 1)
                  • Custom script: call RemoveLocation(udg_Locator)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (HeroCastTarget[HealingMojoCounter] is dead) Equal to True
                    • Then - Actions
                      • Set HeroCastTarget[HealingMojoCounter] = HeroCastTarget[HealingMojo]
                      • Set HeroCaster[HealingMojoCounter] = HeroCaster[HealingMojo]
                      • Set HeroCastTarget[HealingMojo] = No unit
                      • Set HeroCaster[HealingMojo] = No unit
                      • Set HealingMojo = (HealingMojo - 1)
                      • Set HealingMojoCounter = (HealingMojoCounter - 1)
                    • Else - Actions
        • Else - Actions
          • Trigger - Turn off (This trigger)
I haven't checked these in-game, but this should fix any problems with multiple units using the ability or the unit dying before the projectile reaches it.
 
Level 9
Joined
Apr 4, 2004
Messages
519
Thanks Sophismata, and +rep to you.

I have another problem now, not sure if it should go into this thread but it'll have to do, I guess.

So, I've made a spell for a Skeleton Warrior hero. It's practically a Death and Decay without having to channel. My problem is, however, when I cast this spell, 2 dummies are created. One to cast the spell, and one to act as the special effect.

I have no problem with dummy #1, but the second one is screwing around with me. The special effect is, as you can see on the picture, a custom model. It's actually not supposed to float like that, and it doesn't as long as it has enough room. How do I prevent it from flying?

It's classified as a Flying unit so units won't have to run around it and so it's castable on cliffs etc. Doubt there triggers will do much good, but feel free to look at it.

  • Shadow Ball
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Shadow Ball (Forsaken Knight)
    • Actions
      • Set HeroCaster = (Casting Unit)
      • Set HeroCastPoint = (Target point of ability being cast)
      • Unit - Create 1 Dummy for (Owner of HeroCaster) at (Position of HeroCaster) facing Defauly building facing degrees
      • Set DummyCaster = (Last created unit)
      • Unit - Set level of Shadow Ball (Dummy) for DummyCaster to (Level of Shadow Ball (Forsaken Knight) for HeroCaster)
      • Unit - Order DummyCaster to Undead Lich - Death And Decay HeroCastPoint
      • Unit - Add a 10.00 second Generic expiration timer for DummyCaster
      • Unit - Create 1 Shadow Ball Dummy for (Owner of HeroCaster) at (Position of HeroCastPoint) facing Defauly building facing degrees
      • Set AbilityEffectDummy = (Last created unit)
      • Unit - Add a 10.00 second Generic expiration timer to AbilityEffectDummy
      • Custom script: call RemoveLocation( udg_HeroCastPoint)
Thanks in advance.
 

Attachments

  • wtf.JPG
    wtf.JPG
    232.9 KB · Views: 66
Level 8
Joined
Nov 9, 2008
Messages
502
You could make it a building with 0 collision and turn off all build requirements (pathable for example) although I don't see why putting the dummy as walk move type and turn it's collision off.

Alternatively have you tried to setting the fly height to 0 in the trigger?
 
Level 9
Joined
Apr 4, 2004
Messages
519
Oh yeah, I had totally forgot about setting it to foot & changing collision size to 0. That fixed it, thanks. xP
 
Level 9
Joined
Apr 4, 2004
Messages
519
Just thought I'd run this spell trigger through here too, just to check if it's done correctly or not. :p

  • Bad Voodoo
    • Events
      • Unit - A unit Learns a skill
    • Conditions
    • Actions
      • Set HeroCaster = (Learning Hero)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Learned Hero Skill) Equal to Bad Voodoo
              • (Level of Bad Voodoo for HeroCaster) Equal to 0
            • Then - Actions
              • Unit - Add Mana Regeneration to HeroCaster
            • Else - Actions
              • Unit - Set level of Mana Regeneration for HeroCaster to (Level of Bad Voodoo for HeroCaster)
Now, will this, as I intend it to do, add Mana Regeneration if the hero learns Bad Voodoo, and if the spell is leveled to level 2 and 3, it will set the level of Mana Regeneration to the appropiate level without adding an extra Mana Regeneration ability with each time the Bad Voodoo spell is learned?

Thanks in advance. :p
 
Level 8
Joined
Aug 4, 2006
Messages
357
Next time, you should just test it out. It's a lot faster than waiting for a response and having to bump... Anyway, here's the corrected trigger:
  • Bad Voodoo
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Bad Voodoo
    • Actions
      • Set HeroCaster = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Bad Voodoo for HeroCaster) Equal to 1
        • Then - Actions
          • Unit - Add Mana Regeneration to HeroCaster
        • Else - Actions
          • Unit - Set level of Mana Regeneration for HeroCaster to (Level of Bad Voodoo for HeroCaster)
 
Status
Not open for further replies.
Top