I am making a passive for a hero in a moba map, which removes Crowd Control (CC) from the hero x time later it was applied. On use, the passive knocks enemies back cause them damage and go into cooldown. For setting Crowd Control, I use [vJASS] - Buff System. The problem that I have is I do not know how to do a check on whether the applied/picked buff is of a type I want to remove. I thought about creating a boolean inside each buff struct. It will be set true if I want it to be removable by this spell, but I do not know to access it with the buff system API. Also, any feedback on my code will be great.
Here is my code and example of my CC:
Here is my code and example of my CC:
JASS:
scope CCcounter
private module SpellConfiguration
static constant integer SPELL_ABILITY_ID = '0000' //the rawcode of the spell
static constant integer SPELL_SFX_ID = '0000' //the rawcode of the spell
static constant integer KB_SFX_ID = '0000' //the rawcode of the spell
static constant real SPEED = 1000
static constant attacktype ATTACK_TYPE = ATTACK_TYPE_MAGIC
static constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_MAGIC
static constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
static constant method CCRemovalDelay takes integer unitLevel returns real
return 0.5 + 0.2 * unitLevel
endmethod
static constant method Cooldoown takes integer unitLevel returns real
return 40.0 - 0.2 * unitLevel
endmethod
static method Damage takes unit caster, integer unitLevel returns real
return (100. * unitLevel + 0.1 * GetHeroStr(caster, true)) * FPS
endmethod
static constant method KBRange takes integer unitLevel returns real
return 200.0 + 0.2 * unitLevel
endmethod
static method Targets takes unit target, unit caster returns boolean
return GetWidgetLife(target) > 0.405 and/*
*/ IsUnitEnemy(target, GetOwningPlayer(caster))
endmethod
endmodule
private struct CCcounter extends array
implement SpellConfiguration
timer t
unit target
integer cdCounter
private static method CooldoownTimer takes nothing returns nothing
local thistype this = GetTimerData(GetExpiredTimer())
if this.cdCounter == 0 then
set this.t = null
call ReleaseTimer(this.t)
else
set this.cdCounter = this.cdCounter - 1
endif
endmethod
private static method Action takes nothing returns nothing
local thistype this = GetTimerData(GetExpiredTimer())
local unit u
local real tX
local real tY
local integer unit_level
local real dmg
local real aoe
local group enemies
local boolean isUnitStunned = false
call Buff.pickBuffs(this.target)
implement BuffListStart
/*if Buff.picked.isBuffStun then
call Buff.picked.remove()
set isUnitStunned = true
endif*/
implement BuffListEnd
if isUnitStunned then
set enemies = CreateGroup()
set tX = GetUnitX(this.target)
set tY = GetUnitY(this.target)
set unit_level = GetUnitLevel(this.target)
set dmg = Damage(this.target, unit_level)
set aoe = KBRange(unit_level)
set u = null
set this.cdCounter = Cooldoown(unit_level)
call GroupEnumUnitsInRange(enemies, tX, tY, aoe, null)
loop
set u = FirstOfGroup(enemies)
exitwhen u == null
if Targets(u, target) then
set udg_KB3D_Unit = u
set udg_KB3D_Range = KBRange(unit_level)
set udg_KB3D_Speed = SPEED
set udg_KB3D_Angle = GetAngleBetweenPoints(tX, GetUnitX(u), tY, GetUnitY(u))
set udg_KB3D_LoopDamage = dmg
endif
call GroupRemoveUnit(enemies, u)
endloop
call ReleaseTimer(this.t)
set this.t = NewTimerEx(this)
call TimerStart(this.t, 1.0 , true, function thistype.CooldoownTimer)
call DestroyGroup(enemies)
set enemies = null
else
call ReleaseTimer(this.t)
endif
set target = null
endmethod
private static method AbilityCheck takes nothing returns nothing
local thistype this
if GetUnitAbilityLevel(BuffEvent.buff.target, SPELL_ABILITY_ID) > 0 and BuffEvent.buff.isBuffStun then
set this = GetUnitId(BuffEvent.buff.target)
if this.cdCounter == 0 then
set this.target = BuffEvent.buff.target
set this.t = NewTimerEx(this)
call TimerStart(this.t, CCRemovalDelay(GetUnitLevel(this.target)) , false, function thistype.Action)
endif
endif
endmethod
private static method onInit takes nothing returns nothing
call BuffEvent.create(function AbilityCheck)
endmethod
endstruct
endscope
JASS:
scope FrozenBuff
/* -------------------------------------------------------------------------- */
/* Frozen */
/* -------------------------------------------------------------------------- */
struct FrozenBuff extends Buff
private static constant integer RAWCODE = 'A00Z'
private static constant integer DISPEL_TYPE = BUFF_NEGATIVE
private static constant integer STACK_TYPE = BUFF_STACK_NONE
private static constant string SFX_ID = "Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl"
effect sfx
boolean isBuffStun
method onRemove takes nothing returns nothing
call Stun.stop(this.target)
call SetUnitTimeScale(this.target, 100 * 0.01)
call DestroyEffect(this.sfx)
endmethod
method onApply takes nothing returns nothing
set isBuffStun = true
call BJDebugMsg(R2S(this.duration))
call Stun.apply(this.target, 99, false)
call SetUnitTimeScale(this.target, 0 * 0.01)
set this.sfx = AddSpecialEffectTarget(SFX_ID, this.target, "origin")
endmethod
implement BuffApply
endstruct
endscope