Block damage spell sometimes heals the unit

waaaks!

Zinctified
Reaction score
255
ive created a spell that blocks any damage taken, from attacks, spells, etc.
the spell is a chance based 5%/10%/15%/20%, blocks damage and damages the damage source equal to the damage dealt, it blocks damage perfectly, but sometimes when a damage is blocked, it doesnt just block the damage but also gives an amount of hp to the unit, just like healing it

the trigger adds hp to the damaged unit equal to the damage taken, that makes the spell look like its blocking the damage dealt, but sometimes it just heals the unit, i suspected that sometimes the trigger doubles the amount damage dealt and add that to the unit's hp

lets say the unit takes 30 damage, that means it adds 30 hp to the unit, but the problem is, sometimes it gives 60 hp to the unit instead of 30, making it like a heal spell

if u still didnt get my point, play RotG Reborn v2.05, type "-ap" to choose from any tavern, use Chaos Emperor, type "-ml" if ur the only player playing, max out Chaos Immunity spell and go to the enemy's fountain, there u will observe that the fountain is damaging u rapidly, but sometimes it gives u hp

that healing thingy is the problem, i need to remove that and fix the spell by just blocking the damage taken, not healing the unit

heres the code
JASS:
scope ChaosImmunity

private function Conditions takes nothing returns boolean
    return GetLearnedSkill() == 'A036'
endfunction

private function Check takes nothing returns boolean
    return GetUnitAbilityLevel(GetTriggerUnit(), 'A036') > 0
endfunction

private function Start takes nothing returns nothing
    local trigger t = GetTriggeringTrigger()
    local unit cast = GetTriggerUnit()
    local unit targ = GetEventDamageSource()
    local real dmg  = GetEventDamage()
    local integer l = GetUnitAbilityLevel(cast, 'A036')
    if GetRandomInt(1, 100) <= 5*l and dmg < 10000 then
        call SetUnitState(cast, UNIT_STATE_LIFE, GetUnitState(cast, UNIT_STATE_LIFE) + dmg)
        call CreateInstantEffectTarget("Abilities\\Weapons\\DragonHawkMissile\\DragonHawkMissile.mdl", cast, "chest")
        if IsUnitType(targ, UNIT_TYPE_STRUCTURE) == false then
            call UnitDamageTarget(cast, targ, dmg, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
        endif
    endif
    call DisableTrigger(t)
    call EnableTrigger(t)
    set t = null
    set cast = null
    set targ = null
endfunction

private function Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local trigger t = CreateTrigger()
    call TriggerRegisterUnitEvent( t, cast, EVENT_UNIT_DAMAGED )
    call TriggerAddCondition( t, Condition( function Check ) )
    call TriggerAddAction( t, function Start )
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
    set t = null
endfunction

endscope

is there a way i can fix the healing thingy?
thanks
 

Trollvottel

never aging title
Reaction score
262
1. i think if your hero skills the skill 5 times, there are 5 triggers for him
2. think about attaching the trigger to the unit
3. the event_damage_blabla fires before the unit actually takes the damage, so start a non repeating timer with period 0.00 and block the damage (which you stored in a struct before) there.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Are you sure the unit is getting attacked? I'm not sure, but I think spells like "slow" or something or maybe even "Heal" count too... I'm not sure though.
 

waaaks!

Zinctified
Reaction score
255
@fireandpurge
not just attacked, but takes any damage

in that case, wouldnt it work to add an extra primary condition
GetUnitAbilityLevel (unit, ability) == 1
that means ill add that condition beside
GetLearnedSkill() == 'A036' right?
 

soulreaping

New Member
Reaction score
17
I'm not sure it'll work I think you need to check if the ability level is 0.

If you check if the ability level is 1, then it means the hero learns it the second time, not the first time.
 

Artificial

Without Intelligence
Reaction score
326
When you learn the skill for the first time, the level of it becomes 1. That code is run after the skill has already been learned (level 1), not before it (level 0).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top