K
Knyves
Guest
When your tutorial uses more then one costom trigger code, I think it's kind of redundant to call it "Simple". just a thought...
local real ang = bj_RADTODEG * Atan2(ytarg – y, xtarg – x)
//*************************************************************
//* 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 real dist = GetHandleReal(dashtimer, "dist")
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 angle = AngleBetweenPoints(casterpos,targetpoint)
//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 SetUnitPositionLoc(caster, PolarProjectionBJ(casterpos, 75.00, angle))
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)
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
function Trig_Dash_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A001039;
endfunction
function Trig_Dash_Condition takes nothing returns boolean
local string String2 = GetAttachmentTable(GetTriggeringTrigger())
return IsUnitEnemy(Caster,GetFilterUnit(), GetOwningPlayer(GetTableUnit(String,"Caster"))) == true and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 0 and IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == false) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) == false)
endfunction
function Trig_Dash_Damage takes nothing returns nothing
local string String2 = GetAttachmentTable(GetTriggeringTrigger())
local unit Caster = GetTableUnit(String2,"Caster")
local unit Victim = GetTriggerUnit()
local real Damage = GetHeroAgi(Caster,true)
call UnitDamageTarget(Caster,Victim,Damage,true,true,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",Victim,chest)
set Caster = null
set Victim = null
endfunction
function Trig_Dash_Effects takes nothing returns nothing
local timer Timer = GetExpiredTimer()
local string String2 = GetAttachmentTable(Timer)
local trigger Trigger
local string String
local unit Caster = GetTableUnit(String2,"Caster",Caster)
local real Angle = GetTableReal(String2,"Angle",Angle)
local real Distance = GetTableReal(String2,"Distance",Distance)
local real Moved = GetTableReal(String2,"Moved",Moved)
call SetUnitPosition(Caster,GetUnitX(Caster) + 30 Cos(Angle * bj_DEGTORAD), GetUnitY(Caster) + 30 Sin(Angle * bj_DEGTORAD))
call SetUnitAnimationByIndex(Caster,10)
set Moved = Moved + 30
if Moved <= Distance or UNIT_STATE_LIFE <= 0 then
set Trigger = GetTableTrigger(String2,"Trigger",Trigger)
set String = GetAttTable(Trig)
call TriggerRemoveAction(Trigger,GetTableTriggerAction(String,"ta"))
call ClearTable(String)
call DestroyTrigger(Trigger)
set Trigger = null
call SetUnitTimeScalePercent(Caster,100)
call SetUnitPathing(Caster,true)
call SetUnitAnimationByIndex(Caster,0)
call ClearTable(String2)
call PauseTimer(Timer)
call DestroyTimer(Timer)
else
call SetTableReal(String2,"Moved",Moved)
endif
endfunction
function Trig_Dash_Actions takes nothing returns nothing
local unit Caster = GetTriggerUnit()
local location Target = GetSpellTargetLoc()
local real CasterX = GetUnitX(Caster)
local real CasterY = GetUnitY(Caster)
local real TargetX = GetLocationX(Target)
local real TargetY = GetLocationY(Target)
local real Angle = bj_RADTODEG * Atan2(TargetY - Y, TargetX - X)
local real DistanceX = TargetX - X
local real DistanceY = TargetY - Y
local real Distance = SquareRoot(DistanceX * DistanceX + DistanceY * DistanceY)
local trigger Trigger = CreateTrigger()
local string String = GetAttachmentTable(Trigger)
local timer Timer = CreateTimer()
local string String2 = GetAttachmentTable(Timer)
call TriggerRegisterUnitInRange(Trigger,Caster,150,null)
call TriggerAddCondition(Trigger,Condition(function Trig_Dash_Condition))
call SetTableObject(String,"TimerAction",TriggerAddAction(Trigger, function Trig_Dash_Damage))
call SetTableObject(String,"Caster",Caster)
call SetTableReal(String2,"Angle",Angle)
call SetTableReal(String2,"Distance",Distance)
call SetTableReal(String2,"Moved",Moved)
call SetTableObject(String2,"Caster",Caster)
call SetTableObject(String2,"Trigger",Trigger)
call TimerStart(Timer,0.03,true,function Trig_Dash_Effects)
call SetUnitTimeScalePercent(Caster,400)
call SetUnitPathing(Caster,false)
call SetUnitAnimationByIndex(Caster,10)
set Caster = null
call RemoveLocation(Target)
set Target = null
set Trigger = null
endfunction
//===========================================================================
function InitTrig_Dash takes nothing returns nothing
set gg_trg_Dash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Dash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Dash, Condition( function Trig_Dash_Conditions ) )
call TriggerAddAction( gg_trg_Dash, function Trig_Dash_Actions )
call Preload("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl")
endfunction