WarLuvr3393
Hmmm...too many things to play (WoW, COD4, WC3)
- Reaction score
- 54
Help me with my "Dash Spell"
Yep. This is the only way to learn...through trial and error. I was reading Daelin's guide on the knockback, but I tried my best to make it like a dash spell. Here's the code:
I can't get this right. It worked before and now it doesn't work. Please help me correct this problem.
Yep. This is the only way to learn...through trial and error. I was reading Daelin's guide on the knockback, but I tried my best to make it like a dash spell. Here's the code:
JASS:
//*************************************************************
//* Constant Functions (Only edit things under this section.) *
//*************************************************************
constant function FW_Raw_Code takes nothing returns integer
return 039;A003039;
endfunction
//**************
//* Conditions *
//**************
function FW_Spell_Check takes nothing returns boolean
return GetSpellAbilityId() == FW_Raw_Code()
endfunction
//*************
//* Functions *
//*************
function FW_Dash takes nothing returns nothing
//Local Varibles and Handles
local timer dashtimer = GetExpiredTimer()
local unit caster = GetHandleUnit(dashtimer, "caster")
local location casterpos = GetUnitLoc(caster)
local real xtarget = GetHandleReal(dashtimer, "xtarget")
local real ytarget = GetHandleReal(dashtimer, "ytarget")
local location targetpoint = Location(xtarget, ytarget)
local real dist = GetHandleReal(dashtimer, "dist")
local real angle = AngleBetweenPoints(casterpos,targetpoint)
local real X = GetUnitX(caster)
local real Y = GetUnitY(caster)
local real polarX = X + 75.00 * Cos(angle)
local real polarY = Y + 75.00 * Sin(angle)
//Functions
if GetHandleReal(dashtimer, "dist") >= 0.0 then //Cannot be exact. Must go into negatives to take effect so weird distances can be detected
call SetUnitPosition(caster,X,Y)
call SetHandleReal(dashtimer, "dist", dist-75.00) //This is my indicator which will keep decreasing until it's below 0
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", GetUnitX(caster), GetUnitY(caster)))
else
call PauseUnit(caster, false)
call ResetUnitAnimation(caster)
call SetUnitPathing(caster, false)
call FlushHandleLocals(dashtimer)
endif
//Null Variables
set caster = null
call RemoveLocation(casterpos)
call RemoveLocation(targetpoint)
set casterpos = null
set targetpoint = null
endfunction
function FW_Spell takes nothing returns nothing
//Local Variables
local unit caster = GetTriggerUnit()
local timer dashtimer = CreateTimer()
local location targetpoint = GetSpellTargetLoc()
local real xtarget = GetLocationX(targetpoint)
local real ytarget = GetLocationY(targetpoint)
local real dist = DistanceBetweenPoints(GetUnitLoc(caster), targetpoint)
//Handles
call SetHandleHandle(dashtimer, "caster", caster)
call SetHandleReal(dashtimer, "xtarget", xtarget)
call SetHandleReal(dashtimer, "ytarget", ytarget)
call SetHandleReal(dashtimer, "dist", dist)
//Functions
call PauseUnit(caster, true)
call SetUnitAnimation(caster, "attack")
call SetUnitPathing(caster, true)
call TimerStart(dashtimer, 0.035, true, function FW_Dash)
//Null Variables
call ResetUnitAnimation(caster)
call PauseTimer(dashtimer)
call DestroyTimer(dashtimer)
set dashtimer = null
call FlushHandleLocals(dashtimer)
set caster = null
call RemoveLocation(targetpoint)
set targetpoint = null
endfunction
//===========================================================================
function InitTrig_Flame_Walk takes nothing returns nothing
local integer i
set i = 0
set gg_trg_Flame_Walk = CreateTrigger( )
loop
exitwhen i>12
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Flame_Walk, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT)
set i = i + 1
endloop
call TriggerAddCondition( gg_trg_Flame_Walk, Condition(function FW_Spell_Check))
call TriggerAddAction( gg_trg_Flame_Walk, function FW_Spell )
call Preload("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl")
endfunction
I can't get this right. It worked before and now it doesn't work. Please help me correct this problem.