Absorb shield spell gives wrong values

Kazuga

Let the game begin...
Reaction score
110
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.)
JASS:
scope AbsorbShield initializer Lightning
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "private")

globals
private constant integer raw           = 'A00B'  
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,'B003') == true then
        call SetUnitState(Unit,UNIT_STATE_LIFE,CH+DT)
        set SP<i> = SP<i> - DT
        call BJDebugMsg(R2S(SP<i>))
        if SP<i> &lt; 0 then
            call UnitRemoveBuffBJ(&#039;B003&#039;,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(&quot;j&quot;)
    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?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top