Edit:
Problem solved, the unit was healed more than it should because I forgot to destroy the trigger when the shield goes down. It ran 2 times and 3 times etc for each spell cast on myself.
Ok so for the first time I'm making my own absorbing shield from scratch in vJass, but I bumped into a problem. When I use the spell on myself I receive the buff and everything, the trigger displays that the amount of shield power loss on every hit so far so good. But the "healing" part bugs, I need to "heal" the unit with the same amount of damage as he takes so it stays the same for as long as he has the absorbing shield.
Now for some reason he receives too much health, it looks more like he is being healed the actual amount of damage he takes, if you know what I mean...
(Btw, don't mind that I actually use a global here, the spell is supposed to be MPI not MUI.)
It should just be to set the units life the it's current life + the damage taken right? Or am I thinking wrong?
Problem solved, the unit was healed more than it should because I forgot to destroy the trigger when the shield goes down. It ran 2 times and 3 times etc for each spell cast on myself.
Ok so for the first time I'm making my own absorbing shield from scratch in vJass, but I bumped into a problem. When I use the spell on myself I receive the buff and everything, the trigger displays that the amount of shield power loss on every hit so far so good. But the "healing" part bugs, I need to "heal" the unit with the same amount of damage as he takes so it stays the same for as long as he has the absorbing shield.
Now for some reason he receives too much health, it looks more like he is being healed the actual amount of damage he takes, if you know what I mean...
(Btw, don't mind that I actually use a global here, the spell is supposed to be MPI not MUI.)
JASS:
scope AbsorbShield initializer Lightning
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "private")
globals
private constant integer raw = 039;A00B039;
private constant integer damage = 200
endglobals
globals
real array SP [13] //ShieldPower
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == raw
endfunction
private function Absorb takes nothing returns nothing
local trigger trg = GetTriggeringTrigger()
local unit Unit = GetTriggerUnit()
local integer I = GetConvertedPlayerId(GetOwningPlayer(Unit))
local real DT = GetEventDamage()
local real CH = GetUnitState(Unit,UNIT_STATE_LIFE)
call BJDebugMsg("c")
if UnitHasBuffBJ(Unit,039;B003039;) == true then
call SetUnitState(Unit,UNIT_STATE_LIFE,CH+DT)
set SP<i> = SP<i> - DT
call BJDebugMsg(R2S(SP<i>))
if SP<i> < 0 then
call UnitRemoveBuffBJ(039;B003039;,Unit)
set CH = GetUnitState(Unit,UNIT_STATE_LIFE)
call SetUnitState(Unit,UNIT_STATE_LIFE,CH-SP<i>)
endif
endif
set Unit = null
endfunction
private function Actions takes nothing returns nothing
local unit Unit = GetSpellTargetUnit()
local integer I = GetConvertedPlayerId(GetOwningPlayer(Unit))
local trigger trg = CreateTrigger()
local triggeraction ta
call TriggerRegisterUnitEvent( trg, Unit, EVENT_UNIT_DAMAGED )
set ta = TriggerAddAction( trg, function Absorb )
call BJDebugMsg("j")
set SP<i> = damage
endfunction
//===========================================================================
private function SafeFilt takes nothing returns boolean
return true
endfunction
private function Lightning takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(trig,GetLocalPlayer(),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
call TriggerAddCondition (trig, Condition (function Conditions ) )
call TriggerAddAction (trig, function Actions )
endfunction
endscope</i></i></i></i></i></i>
It should just be to set the units life the it's current life + the damage taken right? Or am I thinking wrong?