- Joined
- Jul 28, 2008
- Messages
- 211
I made a spell but it isn't working. I would look at it and find what's wrong, but I'm kinda lazy and I have other stuff to do.
Can anybody help me?
The spell should damage a unit over 10 seconds, but slow it at the same time. The slow effect becomes stronger every second.
Thanks in advance.
EDIT : Forgot to create Timer....still not working
Can anybody help me?
JASS:
scope Fatal initializer Init
globals
constant integer DURATION = 10
//Spell Duration
constant integer SPELL_ID = 'A000'
//Spell Id
constant string EFFECT = "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodFootman.mdl"
//Damage Effect
constant string ATTACHMENT = "chest"
//Effect Attachment Point
constant integer BUFF_ID = 'B000'
//Damage Buff Id
constant integer SLOW_ID = 'A001'
//Passive Slow Ability Id
constant attacktype ATTACK_TYPE = ATTACK_TYPE_CHAOS
//Attack Type
constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
//Damage Type
constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
//Weapon Type
endglobals
private function DAMAGE takes integer level returns real
return 5.00 * I2R(level)
endfunction
//Damage
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////DO NOT TOUCH ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING///////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
globals
timer Timer
endglobals
private struct Fatal
unit target
unit caster
integer lvl
integer dur = DURATION
static integer Total
static Fatal array Fat
static method LoopDamage takes nothing returns nothing
local Fatal f
local integer i = 0
loop
exitwhen i > f.Total
set f = f.Fat[i]
if GetUnitAbilityLevel(f.target, BUFF_ID) > 0 and f.dur > 0 then
call DestroyEffect(AddSpecialEffectTarget(EFFECT, f.target, ATTACHMENT))
call UnitDamageTarget(f.caster, f.target, DAMAGE(f.lvl), false, true, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
call SetUnitAbilityLevel(f.target, SLOW_ID, GetUnitAbilityLevel(f.target, SLOW_ID) + 1)
set f.dur = f.dur - 1
else
call UnitRemoveAbility(f.target, SLOW_ID)
call f.destroy()
set f.Total = f.Total - 1
set f.Fat[i] = f.Fat[f.Total]
set i = i - 1
endif
set i = i + 1
endloop
if f.Total == 0 then
call PauseTimer(Timer)
endif
endmethod
static method start takes unit target, unit caster returns nothing
local Fatal f = Fatal.allocate()
if f.Total == 0 then
call TimerStart(Timer, 1, true, function Fatal.LoopDamage)
endif
set f.caster = caster
set f.target = target
set f.lvl = GetUnitAbilityLevel(caster, SPELL_ID)
set f.Fat[f.Total] = f
set f.Total = f.Total + 1
call UnitAddAbility(target, SLOW_ID)
call SetUnitAbilityLevel(target, SLOW_ID, 1)
endmethod
endstruct
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Actions takes nothing returns nothing
call Fatal.start(GetSpellTargetUnit(), GetTriggerUnit())
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer index
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function Cond))
call TriggerAddAction(t, function Actions)
set Timer = CreateTimer()
endfunction
endscope
The spell should damage a unit over 10 seconds, but slow it at the same time. The slow effect becomes stronger every second.
Thanks in advance.
EDIT : Forgot to create Timer....still not working
Last edited: