- Joined
- Mar 16, 2008
- Messages
- 941
[Solved] [vJass] Buff not found?
Oh, well... the problem isn't realy vJass related, but the code is written in vJass so I thought the prefix fits
I'm creating a spell at the moment that should do this:
Channeling manadrain that stuns the target. Damage brakes the stun/channeling. I decided to base it on shakle because the mana drain is better to do with triggers then the stun.
Okay, that is the main script. The DebugMessage showing the buff level always returns 0, and the remove function never works (called in a damage detection system used by the entire map).
Now you'd say: wrong id...
In addition, the buff with the id B003 is the only buff on the unit and creates a special effect that is unique for it.
I can't find the damn bug, help me pls^^
Justify
Oh, well... the problem isn't realy vJass related, but the code is written in vJass so I thought the prefix fits
I'm creating a spell at the moment that should do this:
Channeling manadrain that stuns the target. Damage brakes the stun/channeling. I decided to base it on shakle because the mana drain is better to do with triggers then the stun.
JASS:
//Damage detection in JustifySystems
scope Nethercage initializer InitCage
public keyword cage
globals
private constant integer SpellId = 'A000'
private constant integer BuffId = 'B003'
private constant real PERIOD = 0.1
private constant real DrainStart = 40.
private constant real DrainAdd = 30.
private timer Tim
private integer StructCount = 0
private cage array Caged
endglobals
public struct cage
unit caster
unit target
integer level
static method create takes nothing returns cage
local cage dat = cage.allocate()
set dat.caster = GetTriggerUnit()
set dat.target = GetSpellTargetUnit()
set dat.level = GetUnitAbilityLevel(dat.caster, SpellId)
if StructCount == 0 then
set Tim = AllocateTimer()
call TimerStart(Tim, PERIOD, true, function cage.drain)
endif
set StructCount = StructCount+1
return dat
endmethod
static method drain takes nothing returns nothing
local cage dat
local real burn
local real tr
local integer i = 0
loop
exitwhen i >= StructCount
set dat = Caged[i]
call BJDebugMsg(I2S(GetUnitAbilityLevel(dat.target, BuffId)))
if GetUnitAbilityLevel(dat.target, BuffId) > 0 then
set tr = GetUnitState(dat.target, UNIT_STATE_MANA)
set burn = PERIOD*(DrainStart+(dat.level-1)*DrainAdd)
if tr < burn then
set burn = tr
endif
call SetUnitState(dat.target, UNIT_STATE_MANA, tr-burn)
call SetUnitState(dat.caster, UNIT_STATE_MANA, GetUnitState(dat.caster, UNIT_STATE_MANA)+burn)
set i = i+1
else
//call dat.destroy()
//set StructCount = StructCount-1
//set Caged[i] = Caged[StructCount]
endif
//Avoids endless loop in this tests
set i = i+1
endloop
endmethod
static method remove takes unit target returns nothing
local cage dat
local integer i
if GetUnitAbilityLevel(target, BuffId) > 0 then
set i = 0
loop
exitwhen i >= StructCount
set dat = Caged[i]
call BJDebugMsg(GetUnitName(dat.target))
if target == dat.target then
call BJDebugMsg(GetUnitName(dat.caster))
call IssueImmediateOrder(dat.caster, "stop")
endif
set i = i+1
endloop
endif
endmethod
method onDestroy takes nothing returns nothing
set .caster = null
set .target = null
endmethod
endstruct
private function IsSpell takes nothing returns boolean
return GetSpellAbilityId() == SpellId
endfunction
private function InitCage takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i >= 16
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, ReturnTrue)
set i = i+1
endloop
call TriggerAddCondition(t, Condition(function IsSpell))
call TriggerAddAction(t, function cage.create)
set t = null
endfunction
endscope
Okay, that is the main script. The DebugMessage showing the buff level always returns 0, and the remove function never works (called in a damage detection system used by the entire map).
Now you'd say: wrong id...
In addition, the buff with the id B003 is the only buff on the unit and creates a special effect that is unique for it.
I can't find the damn bug, help me pls^^
Justify
Last edited: