- Joined
- Sep 12, 2008
- Messages
- 657
Hey.. i was making a spell..
and for some reason sometimes it work.. sometimes it doesnt?
its suposed to drain a unit's mana. its not mui/mpi, just vjass..
1 unit has it all the game only.
it works 1 time, then it never works again.
thanks in advance.
and for some reason sometimes it work.. sometimes it doesnt?
its suposed to drain a unit's mana. its not mui/mpi, just vjass..
1 unit has it all the game only.
JASS:
library Byakugan initializer init
globals
//* =============================================================== *
//* ================== Spell made by dardas ================= *
//* ====================== Integers ========================= *
private integer ByakuganRawId = 'A002'
//* ====================== Strings ========================== *
private string ByakuganHitSFX = "Abilities\\Spells\\Human\\Feedback\\ArcaneTowerAttack.mdl"
private string ByakuganHitAttachmentPoint = "chest"
//* ======================= Reals =========================== *
private real ByakuganManaDrainPerHit = 20
private real ByakuganDuration = 15
//* ================ Dont Edit Below This =================== *
private unit ByakuganCaster = null
private unit ByakuganTarget = null
private effect ByakuganHitEffect = null
private real ByakuganTimer = 0
boolean ByakuganCasted = false
endglobals
private function ByakuganCond takes nothing returns boolean
if ( not ( GetSpellAbilityId() == ByakuganRawId ) ) then
return false
endif
return true
endfunction
private function ByakuganHit takes nothing returns nothing
if GetAttacker() == ByakuganCaster then
set ByakuganTarget = GetTriggerUnit()
call SetUnitState(ByakuganTarget, UNIT_STATE_MANA, (GetUnitState(ByakuganTarget, UNIT_STATE_MANA) - ByakuganManaDrainPerHit))
set ByakuganHitEffect = AddSpecialEffectTarget(ByakuganHitSFX, ByakuganTarget, ByakuganHitAttachmentPoint)
call DestroyEffect(ByakuganHitEffect)
set ByakuganHitEffect = null
set ByakuganTarget = null
endif
endfunction
private function ByakuganCast takes nothing returns nothing
set ByakuganCaster = GetTriggerUnit()
set ByakuganCasted = true
endfunction
private function ByakuganTimeLoop takes nothing returns nothing
if ByakuganTimer < ByakuganDuration then
set ByakuganTimer = ByakuganTimer + 0.032
else
set ByakuganCaster = null
set ByakuganTarget = null
set ByakuganCasted = false
endif
endfunction
private function init takes nothing returns nothing
local trigger DM = CreateTrigger()
local trigger DMM = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(DM, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(DM, Condition(function ByakuganCond))
call TriggerAddAction(DM, function ByakuganCast)
call TriggerRegisterAnyUnitEventBJ(DMM, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddAction(DMM, function ByakuganHit)
call TimerStart(CreateTimer(), 0.032, true, function ByakuganTimeLoop)
set DM = null
set DMM = null
endfunction
endlibrary
it works 1 time, then it never works again.
thanks in advance.