I`m wondering why this isn`t working :/

Infiriel

New Member
Reaction score
0
Hello guyz
I`ve gotta little problem with changing damage type of physical attacks from default physical to pure.
Below you can see my version of trigger:


JASS:
function Trig_PurifDamager_Kopiuj_Conditions takes nothing returns boolean
    if ( not ( GetAttacker() == gg_unit_E000_0000 ) ) then
        return false
    endif
    if ( not ( UnitHasBuffBJ(gg_unit_E000_0000, 'B001') == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_PurifDamager_Kopiuj_Actions takes nothing returns nothing
    call DisableTrigger( GetTriggeringTrigger() )
    // Setting Variables
    set udg_PurifUnitHolder = GetAttackedUnitBJ()
    set udg_PurifHpHolder = GetUnitStateSwap(UNIT_STATE_LIFE, GetAttackedUnitBJ())
    // Checking target`s armor reduction
    call SetUnitLifeBJ( udg_PurifUnitHolder, 100.00 )
    call UnitDamageTargetBJ( gg_unit_E000_0000, udg_PurifUnitHolder, 100.00, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
    set udg_PurifArmorDecrem = ( ( 100.00 - GetUnitStateSwap(UNIT_STATE_LIFE, udg_PurifUnitHolder) ) / 100.00 )
    call SetUnitLifeBJ( udg_PurifUnitHolder, udg_PurifHpHolder )
    // Wait until projectile hits the target (even too much time)
    call TriggerSleepAction( ( DistanceBetweenPoints(GetUnitLoc(udg_PurifUnitHolder), GetUnitLoc(gg_unit_E000_0000)) / 1600.00 ) )
    // Setting Variable to HP after being attacked
    set udg_PurifHpHolder2 = GetUnitStateSwap(UNIT_STATE_LIFE, GetAttackedUnitBJ())
    // Why this isn`t working then???
    call UnitDamageTargetBJ( gg_unit_E000_0000, udg_PurifUnitHolder, ( ( ( udg_PurifHpHolder - udg_PurifHpHolder2 ) / ( 1 - udg_PurifArmorDecrem ) ) - ( udg_PurifHpHolder - udg_PurifHpHolder2 ) ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_ENHANCED )
    call EnableTrigger( GetTriggeringTrigger() )
endfunction

//===========================================================================
function InitTrig_PurifDamager_Kopiuj takes nothing returns nothing
    set gg_trg_PurifDamager_Kopiuj = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_PurifDamager_Kopiuj, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_PurifDamager_Kopiuj, Condition( function Trig_PurifDamager_Kopiuj_Conditions ) )
    call TriggerAddAction( gg_trg_PurifDamager_Kopiuj, function Trig_PurifDamager_Kopiuj_Actions )
endfunction


FIrst it saves Hp, and Unit ID to variables, then check, and return damage reduction of target, and save it to another variable.
Next action is "Wait" until missile hit (It`s designed for ranged hero with 1.8k missile speed)
To this point everything is working - last function: GUI "Damage target" seems to have problems with executing a formula to get a final damage output.

Could anyone tell me what do i do wrong, or even create a working piece of code for me? (please)
 

dudeim

New Member
Reaction score
22
try this removed all bj's except for two and used local variables

JASS:
function Trig_PurifDamager_Kopiuj_Conditions takes nothing returns boolean
    return GetAttacker() == gg_unit_E000_0000 and GetUnitAbilityLevel(gg_unit_E000_0000, 'B001') > 0
endfunction

function Trig_PurifDamager_Kopiuj_Actions takes nothing returns nothing
local unit u =  GetTriggerUnit()
local real r = GetUnitState(u,UNIT_STATE_LIFE)
local real s = ( ( 100.00 - GetUnitState(u,UNIT_STATE_LIFE) ) / 100.00 )
local real w
//local variables much better specialy for muiness
    call DisableTrigger( GetTriggeringTrigger() )

 ( ( ( r - w ) / ( 1 - s ) ) - ( r - w ) ) 

    call SetUnitState(u,UNIT_STATE_LIFE,100)
    call UnitDamageTarget(
    call UnitDamageTarget( gg_unit_E000_0000, u, 100.00, true, false ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
    call SetUnitState(u,UNIT_STATE_LIFE,s)
    // too lazy to remove bj below
    call TriggerSleepAction( ( DistanceBetweenPoints(GetUnitLoc(udg_PurifUnitHolder), GetUnitLoc(gg_unit_E000_0000)) / 1600.00 ) )
    set w = GetUnitState(u,UNIT_STATE_LIFE)
    call UnitDamageTarget( gg_unit_E000_0000, u,  ( ( ( r - w ) / ( 1 - s ) ) - ( r - w ) ), true, false ATTACK_TYPE_CHAOS, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS )
    call EnableTrigger( GetTriggeringTrigger() )
endfunction

//===========================================================================
function InitTrig_PurifDamager_Kopiuj takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( t, Condition( function Trig_PurifDamager_Kopiuj_Conditions ) )
    call TriggerAddAction( t, function Trig_PurifDamager_Kopiuj_Actions )
endfunction


and know that this can be abused (dunno if it's usefull but still) try getting a damage detection system to detect when the damage is really taken and not when the target is just attacked.
 

Infiriel

New Member
Reaction score
0
Your code is causing instant kills. Mine wasn`t enough effective, but your is way too effective :D
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Because the trigger fires again when you use

JASS:
call UnitDamageTarget( gg_unit_E000_0000, u, 100.00, true, false ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )


Add this to the beggining of your actions:


And this to the end of your actions:


[EDIT]

Ouh, it's already been done, lol

JASS:
call SetUnitState(u,UNIT_STATE_LIFE,100)
    call UnitDamageTarget( gg_unit_E000_0000, u, 100.00, true, false ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )


Seriously?
Insta-kill found
 

Infiriel

New Member
Reaction score
0
@up nope this isn`t the important thing - i`ve changed it, so it left 200hp while giving 100dmg, and it still gave an insta-kill.
The second thing is that it killed even is tests with very high armor amount (so it shouldn`t give lethal damage due to armor reduction)


This is the insta-kill reason: after giving that 100 damage it is changing hp to "armor reduction" variable, which value is less than 1 - but sadly after fixing that this script does nothing.
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top