HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Whats wrong with my Evasion Aura

10-05-2007, 10:50 AM#1
Dg!Mortal
I made a spell based on thorn aura that gives nearby ally units Evasion bonus but sometime's it starts to heal the unit more than tha Damage taken can some one tell me whats the problem with this spell?
Thanks in advance.

Collapse JASS:
//==================================Evasion=Trigger======================================
function Evade_Evasion_Aura_Conditions takes nothing returns boolean
return (GetRandomInt(1,100)<10*GetUnitAbilityLevel(GetTriggerUnit(),'B000'))
endfunction
function Evade_Evasion_Aura takes nothing returns nothing
call SetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE,GetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE)+GetEventDamage())
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl",GetTriggerUnit(),"origin"))
call DestroyTrigger(GetTriggeringTrigger())
endfunction
//==============================End=of=Evasion=Trigger===================================
function Trig_Evasion_Aura_Conditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetTriggerUnit(), 'B000') > 0)
endfunction

function Trig_Evasion_Aura_Actions takes nothing returns nothing
local trigger tr=CreateTrigger()
call TriggerRegisterUnitEvent(tr,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
call TriggerAddCondition(tr,Condition(function Evade_Evasion_Aura_Conditions))
call TriggerAddAction(tr,function Evade_Evasion_Aura)
endfunction

//===========================================================================
function InitTrig_Evasion_Aura takes nothing returns nothing
    local trigger Evasion_Aura = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( Evasion_Aura, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( Evasion_Aura, Condition( function Trig_Evasion_Aura_Conditions ) )
    call TriggerAddAction( Evasion_Aura, function Trig_Evasion_Aura_Actions )
endfunction
10-05-2007, 12:46 PM#2
Vexorian
You should seriously just add the evasion ability to affected units, worried about the icon taking space? Just use the spellbook trick : (add spellbook that has the custom evasion, then disable spell book for that player)
10-05-2007, 01:02 PM#3
The Elite
and this should be in Triggers And Scripts

/sleep
10-05-2007, 03:55 PM#4
Dg!Mortal
Quote:
Originally Posted by Vexorian
You should seriously just add the evasion ability to affected units, worried about the icon taking space? Just use the spellbook trick : (add spellbook that has the custom evasion, then disable spell book for that player)

Thats a good Idea but I want my Pseudo evasion Stack with evasion ability Second i tryed adding evasion once but it was laggy, third: how I remove evasion when unit looses the aura without loss of multi instanceability? and what do you mean disabling spell book?
10-05-2007, 04:11 PM#5
Vexorian
Quote:
Thats a good Idea but I want my Pseudo evasion Stack with evasion ability and Second i tryed what you said once but it was laggy, third: how I remove evasion when unit looses the aura? without loss of multi instanceability?

I am not sure why removing the damage event and all that giberrish in MUI would be easier than removing an ability.

If it was laggy you possibly did something wrong.

If you want it to stack with evasion, you can do it by increasing the level of evasion.
10-05-2007, 04:21 PM#6
Dg!Mortal
So there is no way to make it without using evasion ability?(I know they did it in some maps)
what do you mean disabling spell book?
I didn't know that it is possible to remove Events :D
10-05-2007, 07:48 PM#7
Anopob
Disabling a spell book is like this: First you make a custom spell based off of Spellbook (it's under Items I believe), add your evasion spell in it, then go to triggers and whenever your event triggers, do "Player - Disable (SPELL = SPELLBOOK) for X Player".
10-06-2007, 01:14 AM#8
Vexorian
Quote:
Originally Posted by Dg!Mortal
So there is no way to make it without using evasion ability?(I know they did it in some maps)
what do you mean disabling spell book?
I didn't know that it is possible to remove Events :D
You can do it without evasion, but it is excessively harder.


An example:
Quote:
Collapse JASS:
call SetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE,GetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE)+GetEventDamage())
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl",GetTriggerUnit(),"origin"))
call DestroyTrigger(GetTriggeringTrigger())

What happens here is that EVENT_UNIT_DAMAGE triggers before the unit's life is subtracted.

So, you need a timer.

There are several topics regarding damage blocking out there, try a search, if this site's search doesn't work correctly use google and add site:wc3campaigns.net to the search query...
10-06-2007, 12:43 PM#9
Dg!Mortal
Quote:
Originally Posted by Vexorian
You can do it without evasion, but it is excessively harder.

What happens here is that EVENT_UNIT_DAMAGE triggers before the unit's life is subtracted.

So, you need a timer.

There are several topics regarding damage blocking out there, try a search, if this site's search doesn't work correctly use google and add site:wc3campaigns.net to the search query...
Realy? But sometimes it works just well and only sometimes start to heal for a value higher than damage taken I have so confusedanyway if it triggers before damage is subtracted how much takes till the hp get subtracted so i can use a timer or tiggersleepaction?
Btw I will do search
10-07-2007, 08:04 AM#10
Pyrogasm
The problem Vexorian is talking about is that if a unit takes enough damage to kill it (no matter how much you give it in that trigger), the unit will always die. Take the following example
  • Unit's life: 5
  • Damage done 25
  • Life given: 100
The unit will die upon taking damage. You can trick the game by re-adding the life in a 0.00 second callback for a timer that has the damaged unit and damage done attached to it (via structs or "handle variables").
10-07-2007, 01:33 PM#11
Vexorian
That's only one of the problems, but a more realistic one is the one his code is dealing with right now, that damage is done after the event, so if the unit had full hp, he wouldn't be able to block the damage without the timer.