Need vJASS help - Custom Polymorph

Rainther

I guess I should write something of value here...
Reaction score
61
Hi all. I've started working on a map and have hit a dead end. This JASS-based trigger is supposed to get triggered when a custom polymorph ability is being cast. It's supposed to remove the Polymorph-buff upon received damage on target at level 1 damage, and on level 2 and 3 when some damagin has occured. However the UnitRemoveBuffBJ(PolyBuff, target) doesn't work on removing the Sheep-buff, but it works on other buffs. The script however works from other triggers (removing Polymorph, that is) that I've tried, but not in this one.
Anybuddy who happends to posses a though in why this aint working?
Feel free to comment if I should do any ways to prevent leaks while at it.

This trigger is in vJASS and is using ABC -- STRUCT ATTACHMENT SYSTEM BY COHADAR -- v6.0 as help.

JASS:
scope Polymorph initializer Init

globals
    private constant integer SPELL_ID = 'Poly'
    private constant integer BUFF = 'B000'
endglobals

private struct Data
    unit cast
    unit taru
    integer abiLvL
    real dmg
endstruct

private function Act2 takes nothing returns nothing
    local trigger t = GetTriggeringTrigger()
    local Data d = GetTriggerStructA(t)
    local real dmg = GetEventDamage()
    
    if GetTriggerEventId()==EVENT_UNIT_DAMAGED then
        set d.dmg = d.dmg + dmg
        if d.abiLvL == 1 then
            call UnitRemoveBuffBJ( BUFF, d.taru )
            call ClearTriggerStructA(t)
            call d.destroy()
            call DisableTrigger(t)
            call DestroyTrigger(t)
        elseif d.abiLvL == 2 and d.dmg >= 200 then
            call UnitRemoveBuffBJ( BUFF, d.taru )
            call ClearTriggerStructA(t)
            call d.destroy()
            call DisableTrigger(t)
            call DestroyTrigger(t)
        elseif d.abiLvL == 3 and d.dmg >= 500 then
            call UnitRemoveBuffBJ( BUFF, d.taru )
            call ClearTriggerStructA(t)
            call d.destroy()
            call DisableTrigger(t)
            call DestroyTrigger(t)
        endif
    elseif GetSpellAbilityId() == SPELL_ID or UnitHasBuffBJ(d.taru, BUFF) != true then
        call ClearTriggerStructA(t)
        call d.destroy()
        call DisableTrigger(t)
        call DestroyTrigger(t)
    endif
    set t = null
endfunction
    
private function Act takes nothing returns nothing
    local trigger t = CreateTrigger()
    local unit cast = GetTriggerUnit()
    local unit taru = GetSpellTargetUnit()
    local integer abiLvL = GetUnitAbilityLevel(cast, SPELL_ID)
    local Data d = Data.create()
    
    set d.cast = cast
    set d.taru = taru
    set d.abiLvL = abiLvL
    set d.dmg = 0
    call SetTriggerStructA(t, d)
    call TriggerRegisterUnitEvent(t, taru, EVENT_UNIT_DAMAGED)
    call TriggerRegisterUnitEvent(t, cast, EVENT_UNIT_SPELL_CAST)
    call TriggerRegisterTimerEvent(t, 0.25, true)
    call TriggerAddAction(t, function Act2)
    set t = null
endfunction

private function Cons takes nothing returns boolean
    return GetSpellAbilityId() == SPELL_ID
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(t,Filter(function Cons) )
    call TriggerAddAction( t, function Act )
endfunction

endscope
 

Rainther

I guess I should write something of value here...
Reaction score
61
Is the polymorph-buff an ability which can't be spotted by the eye?

EDIT: Removing the ability instead of buff doesn't seem to do the trick either. I'm rather curious why I can remove the polymorph-buff through a seperate trigger with an event such as "Is attacked" but not in this trigger.
 

Rainther

I guess I should write something of value here...
Reaction score
61
Still haven't solved this problem... Does anybuddy have a clue why this trigger doesn't want to remove the buff of polymorph from the victim?
 

Silvenon

New Member
Reaction score
19
Maybe you can create a custom polymorph ability that doesn't display the buff at all (give it an empty buff).
 

Rainther

I guess I should write something of value here...
Reaction score
61
Have been thinking of doing such, however I'm not really sure how to change a units model through triggers. To disable a unit would be like to silence the units abilities, ranged and melee attack so that I get.
Anybuddy knows how to change model of a unit through triggers?
 

Silvenon

New Member
Reaction score
19
Copied from PitzerMike's tutorial:

Sca1 (Chaos): Adding a chaos ability to a unit transforms it into the unit type specified in the target unit id field of the ability. This can be used to change any aspect like the proper name or the model of a unit in the game or simply in combination with channel to implement morphing spells. Don't forget to remove the tech requirements from custom chaos abilities. One problem of Chaos is that it adds the morphed unit's current armor, damage, health and mana bonus received from items, auras and srength, agility, intelligence to the stats of the resulting unit. That means it's not a very good idea to morph heroes using chaos until Blizzard fixes those bugs. Ordinary units can't be affected by items and hero stats, so the only problem are buffs received from auras. Those buffs can easily be removed before the conversion and are automatically added again afterwards so that's not a real issue.

JASS:
call UnitRemoveAbility(u, 'BHab')
call UnitRemoveAbility(u, 'BUau')
call UnitRemoveAbility(u, 'BUav')
call UnitRemoveAbility(u, 'BEah')
call UnitRemoveAbility(u, 'BHad')
call UnitRemoveAbility(u, 'BEar')
call UnitRemoveAbility(u, 'BOae')
call UnitRemoveAbility(u, 'BOac')
call UnitRemoveAbility(u, 'Bapl')
call UnitRemoveAbility(u, 'Bplg')
call UnitRemoveAbility(u, 'Boar')
call UnitRemoveAbility(u, 'Babr')
call UnitRemoveAbility(u, 'Bakb')
call UnitAddAbility(u, <chaos ability id>)


This script will remove all aura buffs before applying the chaos upgrade. If you have custom buffs in your map, you'll have to remove them here too.

But that method is apparently a bit buggy with heroes. But that's the only way I could think of.
 
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