HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detect a buff

08-17-2004, 04:37 AM#1
Ez8
Hi.

I'm trying to make a spell that slows an enemy unit down if it has a buff.

Sort of like, every 5 seconds, check to see if any enemy unit around my hero has a certain buff, if it does, slow down it's speed. It keeps doing this, until either a speed cap is reached, or the unit is debuffed.

What kind of trigger would I be looking at?
08-17-2004, 06:05 AM#2
SpadeZ
First you need a trigger that sets the casting unit into a "unit" variable.

Then you need a trigger similar to this.

For the sake of this example, if the unit has the buff "Anti-magic shell" then its movement will be slowed.

Note: Let CAST_UNIT be the variable you set for the casting unit.

Code:
    Events
        Unit - A unit enters (Region centered at (Position of [b]CAST_UNIT[/b]) with size (300.00, 300.00))
    Conditions
        ((Triggering unit) has buff Anti-magic Shell) Equal to True
    Actions
        For each (Integer A) from 1 to 300, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Triggering unit) has buff Anti-magic Shell) Equal to True
                    Then - Actions
                        Unit - Set (Triggering unit) movement speed to ((Current movement speed of (Triggering unit)) - 30.00)
                    Else - Actions
                        Unit - Set (Triggering unit) movement speed to (Default movement speed of (Triggering unit))

Dunno if this works, but i hope it helps.
08-17-2004, 08:47 AM#3
volatile
The trigger above would work, but in gameplay constants you would want to set minimum speed = 0 so you can reduce an enemy units movement speed to 0. Then set up a trigger that turns on and detects in the area and every 1 second of gametime checks the units in the area for the specific buff you're looking for. Then just simply say something like "make picked units speed = picked units speed - 2. The reason I say 2, is cause this would happen every second of game time, it would be cool to see them slowly reduce to a crawl before they stop moving completely :P -30 would be a pretty sudden stop to all units in the area with your "slow" buff. You might also want to use a variable that records the movement speed of the unit before you start messing with it's speed, so that you can restore the original speed when the buff wears off, or you move out of the vicinity.
08-17-2004, 09:13 AM#4
SpadeZ
Sorry i forgot to put a wait action in the loop. -30 isn't alot. An average unit has the speed of 250 a hero has a movement speed of about 300. If you manage the wait action and adjust the minus factor then its pretty smooth. A 5 second wait action would accompany a -30 nicely, but a 2 second wait action would accompany a -8 better than a -30.

The movement speed zero in gameplay constants is a good idea.

The reason i didn't make a periodic trigger is because it compounds onto the lag. If you individually slow the units down rather than slowing all at once, the game wont experience greater hick-ups.

Depending on the wait action on the loop, you should adjust the number of times the loop should fire.

You see because in my trigger i used a loop, if you add a wait (which i forgot to put it) after the " Unit - Set (Triggering unit) movement speed to ((Current movement speed of (Triggering unit)) - 30.00)" then the units with the buff will eventually slow down to a crawl. Its really flexible how fast you want them to slow down.

e.g.
If you want them to very slowly reduce movement speed then just add a short wait trigger, about 2 seconds, and change the minus factor to about -8 or -10.

You see volatile suggested each second minus 2 off movement speed, that is really little. If you do the calculations it will take a unit 2 minuts to slow down to a halt, so it will take about 1 minute to see any real difference in speed, that is a long time. However every 2 seconds minus 10 is more reasonable, since it only takes 50 seconds for a unit to stop at a halt, you could feel the difference in speed in 25 seconds. That already is a slow reduction in speed. If you wanted a faster reduction in speed then go for every 2 seconds minus 15 off movement.

08-17-2004, 10:52 AM#5
Ez8
Three problems:

1)The trigger will only run when a unit enters the specified region around the caster. Thing is, the unit does not automatically gets the buff as soon as it comes near the hero, the skill is not an aura. Rather, the hero needs to target the unit individually to give the unit the buff. In other words, when the units enters the region, the trigger runs, detects no buff, and therefore does nothing. A few seconds later, the hero gives the buff to the unit, and the trigger doesn't run anymore, and therefore deson't detect the buff and nothing happens.

2)What about slowing the unit's attack speed?

3)The trigger doesn't actually revert the unit back to it's normal movement speed when it is debuffed. Because the trigger only runs when a unit enters a region, therefore it will not check whether the unit that is inside the region still has the buff.



All in all, I think the main problem with the suggested trigger is the event. I don't think that unit enters a region is suitable. Maybe a periodic event instead.
08-17-2004, 11:11 AM#6
iNfraNe
Or you could use if the hero casts a spell?
08-17-2004, 01:29 PM#7
SpadeZ
I cant clearly understand what exactly you want.
Like toot said you could use the hero finishes casting ability spell and pick all units around the hero and reduce the speed.

If you wanted the spell to be active after casting then u need another periodic trigger.

If it were to be a periodic event i would require 2 trigger minimum. One to identify when the hero casted the spell and one to do the periodic movement speed decreaser.

I have attempted to fix the trigger without using a periodic event.
You dont necessarily need the periodic trigger. You still can use hero finishes casting ability event and use a loop to pick all units within region around hero with specific buff using the if/then/else action, then minus speed and add a wait action. You will then need a another action under else to change the speed back to default.

Hows this:
Code:
Melee Initialization
    Events
        Unit - A unit Finishes casting an ability
    Conditions
        (Ability being cast) Equal to Animate Dead
    Actions
        For each (Integer A) from 1 to 300, do (Actions)
            Loop - Actions
                Unit Group - Pick every unit in (Units in (Region centered at (Position of (Triggering unit)) with size (300.00, 300.00))) and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Picked unit) has buff Anti-magic Shell) Equal to True
                            Then - Actions
                                Unit - Set (Picked unit) movement speed to ((Current movement speed of (Picked unit)) - 10.00)
                                Wait 2.00 seconds
                            Else - Actions
                                Unit - Set (Picked unit) movement speed to (Default movement speed of (Picked unit))

If you wanted to limit the duration, then just change the number of times the loop fires.

Wasn't too hard to fix. Fingers crossed that it works, .
08-17-2004, 02:33 PM#8
Ez8
The ability is a passive, so unit cast an ability won't work.

Any other ideas?
08-17-2004, 02:34 PM#9
Ez8
And there's still the question about unit's attack speed.

Oh, and the slowing effect is accumulative, but let's not get into that for now.
08-17-2004, 02:36 PM#10
Anitarf
What's the level of multi instanceability you need? One hero per game, one hero per player, as many heroes as you wish?
08-17-2004, 07:20 PM#11
Ez8
Quote:
Originally Posted by Anitarf
What's the level of multi instanceability you need? One hero per game, one hero per player, as many heroes as you wish?


Ok, I'm not yet advanced enough to understand 100% the implications of what you said, but I think I'm looking at one hero per player.
08-18-2004, 01:09 AM#12
iNfraNe
Quote:
Originally Posted by Ez8
1)The trigger will only run when a unit enters the specified region around the caster. Thing is, the unit does not automatically gets the buff as soon as it comes near the hero, the skill is not an aura. Rather, the hero needs to target the unit individually to give the unit the buff. In other words, when the units enters the region, the trigger runs, detects no buff, and therefore does nothing. A few seconds later, the hero gives the buff to the unit, and the trigger doesn't run anymore, and therefore deson't detect the buff and nothing happens.
Quote:
Originally Posted by Ez8
The ability is a passive, so unit cast an ability won't work.
it is just me or ... is something wrong here :** :(
if you would tell us what ability u have in mind... that would help...
08-18-2004, 07:42 AM#13
SpadeZ
Yea i'm not really sure what you want your spell to do. The trigger i posted is accumulative because of the loop, i never really noticed that you wanted the speed reduced, but thats no problem. If the spell is passive then the triggers would look something like this:

Note: These triggers work efficient only if there is one hero that is able to learn the spell. But if its a MP map and all players can choose this hero then plz say so and i will fix up these triggers.

Let LEARN_UNIT be a unit variable with initial value none.

Code:
[color=green][size=4][u][b][center]Trigger 1[/center][/b][/u][/size][/color][size=4][u][b][center][/center][/b][/u][/size][u][b][center][/center][/b][/u][b][center][/center][/b][center][/center]

    Events
        Unit - A unit Learns a skill
    Conditions
        (Learned Hero Skill) Equal to [u][b]SPELL[/b][/u]
    Actions
        Set LEARN_UNIT = (Learning Hero)
        Trigger - Turn on Trigger 2 <gen>

Code:
[color=green][size=4][u][b][center]Trigger 1[/center][/b][/u][/size][/color][size=4][u][b][center][/center][/b][/u][/size][u][b][center][/center][/b][/u][b][center][/center][/b][center][/center]

    Events
        Time - Every 2.00 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Region centered at (Position of LEARN_UNIT) with size (300.00, 300.00))) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked unit) has buff Anti-magic Shell) Equal to True
                    Then - Actions
                        Unit - Set (Picked unit) movement speed to ((Current movement speed of (Picked unit)) - 10.00)
                    Else - Actions
                        Unit - Set (Picked unit) movement speed to (Default movement speed of (Picked unit))

Getting warmer? If its still not what you want, then feel free to point out.
08-18-2004, 10:29 AM#14
Anitarf
What SpadeZ posted is almost quite there. Only, you did say multiple of these heroes may be in the game at once, so here's an updated version (fixed some other stuff as well.)

Code:
Events
        Time - Every 2.00 seconds of game time
    Conditions
    Actions
        Set TempUnitGroup = (Units in (playable map area) matching condition: (and - (matching unit has buff (TheBuffOfTheSlowingSpell) equal to false) and (((Current movement speed of (Matching unit)) less than (Default movement speed of (Matching unit)))
        Unit group - Pick all units in TempUnitGroup and do actions:
            Loop - Actions
                Unit - Set (Picked unit) movement speed to (Default movement speed of (Picked unit))        
        Custom script:  call DestroyGroup( udg_TempUnitGroup )

        For each Integer A from 1 to 12 do actions
            loop - actions:
                Set TempUnitGroup = (Units owned by (Player (Integer A)) matching condition:(unit type of (matching unit) equal to WhateverYourHeroIsCalled))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of unts in (TempUnitGroup)) greater than 0
                    Then - Actions
                        Set TempPoint = (position of (random unit from(TempUnitGroup)))
                        Custom script:  call DestroyGroup( udg_TempUnitGroup )
                        Set TempUnitGroup = (Units in range (whatever range you want) of(TempPoint) matching condition: (and - (matching unit has buff (TheBuffOfTheSlowingSpell) equal to true) and (owner of(matching unit)) is an enemy of (player (Integer A)) equal to true))
                         Unit group - Pick all units in TempUnitGroup and do actions:
                            Loop - Actions
                                Unit - Set (Picked unit) movement speed to ((Current movement speed of (Picked unit)) - 10.00)
                        Custom script:  call DestroyGroup( udg_TempUnitGroup )
                        Custom script:  call RemoveLocation( udg_TempPoint )
                    Else - Actions
                        Custom script:  call DestroyGroup( udg_TempUnitGroup )

08-18-2004, 10:58 AM#15
SpadeZ
Good fix.