HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Strange buff behaviour

03-03-2010, 01:31 PM#1
Saishy
I'm trying the Intuitive Buff System, but I'm getting strange behaviours.

I'm using a tornado slow aura to slow the unit's movement speed by 20%, it will also take 70% of the caster (STR) as damage every 3 seconds for 9s (3 times that damage).

First, it would not deal the last damage, so I added the function to the end call, but the buff only lasts 6 seconds on my archer, while lasting 9s on the knight.

Collapse JASS:
scope HijinKesso initializer Init_hijinkesso

globals
    private constant integer HIJIN = 'A01L'
    private constant real DIST = 30
    private constant real STR_POWER = 0.7
    private constant real DURATION = 9.
    private constant string EFFECT = "Abilities\\Spells\\Orc\\TrollBerserk\\HeadhunterWEAPONSLeft.mdl"
    private constant string MESSAGE = "Hijin Kesso!"
    private integer BUFF
endglobals

private struct HijinMissile extends xecollider
        unit caster
        real damage
        integer bleeding
        group dgroup
        boolean destroygroup
        dbuff d

        method onUnitHit takes unit target returns nothing
            if TargetCheck(this.caster, target) then
                if SpellHit(this.caster, target, HIJIN) and not(IsUnitInGroup(target, dgroup)) then
                    call UnitDamageTargetEx(this.caster, target, this.damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_SPELL, false, false)
                    set d = UnitAddBuff(this.caster, target, BUFF, DURATION, 1)
                    set d.data = this.bleeding
                endif
                call GroupAddUnit(dgroup, target)
                call this.terminate()
            endif
        endmethod
endstruct

function hijinkesso_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == HIJIN)
endfunction

function hijinkesso_Bleed takes nothing returns nothing
    local dbuff d = GetEventBuff()
    call UnitDamageTargetEx(d.source, d.target, d.data, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DOT, false, false)
    call BJDebugMsg(I2S(d.data))
endfunction

function hijinkesso_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    local real tx = GetSpellTargetX()
    local real ty = GetSpellTargetY()
    local real angletarget = Atan2(ty - y, tx - x)
    local real angle = angletarget + 1.57
    local integer level = GetUnitAbilityLevel(caster, HIJIN)
    local real damage = 10 + (40 * level)
    local integer bleeding = R2I(STR_POWER * GetHeroStr(caster, true))
    local integer i = 0
    local group dgroup = CreateGroup()
    local HijinMissile xc
    call DisplayText(caster, MESSAGE, 1)
    
    loop
        exitwhen (i == 2)
        set xc                  = HijinMissile.create(x + DIST * Cos(angle), y + DIST * Sin(angle), angletarget)
        set xc.fxpath           = EFFECT
        set xc.damage           = damage
        set xc.bleeding         = bleeding
        set xc.speed            = 1500.0   // The missile starts with a speed of 1500
        set xc.expirationTime   = 0.6     // it expires after 0.5 second.
        set xc.z                = 100.0     // some height, since missiles often fly...
        set xc.caster           = caster   // The owner of the spell
        //set xc.collisionSize  = 100       // The collision size
        set xc.angleSpeed       = 0.5
        call xc.setTargetPoint(tx, ty)
        set xc.dgroup           = dgroup
        set angle = angle + 3.14
        set i = i + 1
    endloop
    
    set caster = null
    call PolledWait2(5.)
    call DestroyGroup(dgroup)
    set dgroup = null
endfunction

//===========================================================================
function Init_hijinkesso takes nothing returns nothing
    local trigger trg_hijinkesso = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trg_hijinkesso, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(trg_hijinkesso, Condition(function hijinkesso_Conditions))
    call TriggerAddAction(trg_hijinkesso, function hijinkesso_Actions )
    set trg_hijinkesso = null
    set BUFF = DefineBuffType('A04O', 'B00A', 3., true, false, 0, hijinkesso_Bleed, hijinkesso_Bleed)
endfunction

endscope

What is wrong?