//**********************************************************************************
//* *
//* Spells By: emjlr3 *
//* *
//**********************************************************************************
//############################## Local Handle Vars By: Kattana
function H2I takes handle h returns integer
return h
return 0
endfunction
// ===========================
function LocalVars takes nothing returns gamecache
if udg_Cache == null then
call FlushGameCache(InitGameCache("somename"))
set udg_Cache = InitGameCache("somename")
endif
return udg_Cache
endfunction
function SetHandleHandle takes handle subject, string name, handle value returns nothing
if value==null then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
endif
endfunction
function SetHandleInt takes handle subject, string name, integer value returns nothing
if value==0 then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
if value==false then
call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
else
call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleReal takes handle subject, string name, real value returns nothing
if value==0 then
call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
else
call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleString takes handle subject, string name, string value returns nothing
if value==null then
call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
else
call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function GetHandleHandle takes handle subject, string name returns handle
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes handle subject, string name returns boolean
return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleUnit takes handle subject, string name returns unit
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleLocation takes handle subject, string name returns location
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleLightning takes handle subject, string name returns lightning
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleWidget takes handle subject, string name returns widget
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
//##############################
//***************************************************************************************************
//* ===================
//* Jump Template
//* ===================
//* Made by emjlr3.
//* Parabola function by Shadow1500.
//*
//*
//* How to implement:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* 1. Copy the abilities Jump and Fly Trick to your map.
//*
//* 2. Copy this trigger to your map and the code in the custom script section of this map.
//*
//*
//* Targets/Effects:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* This is set to all enemy ground units. The target effect can be changed.
//*
//*
//************************************************************************************************
//Variable Configuration:
constant function Jump_Template_SpellId takes nothing returns integer
return 'A013' //Rawcode of the ability being cast
endfunction
constant function Jump_Template_Fly_TrickId takes nothing returns integer
return 'A012' //Rawcode of the Fly Trick ability
endfunction
constant function Jump_Template_Target_Damage takes real Level returns real
return 0. + Level * 0. //Target Damage
endfunction
constant function Jump_Template_Target_Area takes real Level returns real
return 200. + Level * 0 //Target Area
endfunction
constant function Jump_Template_Arc takes nothing returns real
return 1.75 //Arc for the jump, a number between 1 and 2 reccomended
endfunction
constant function Jump_Template_Difference takes nothing returns real
return 100. //This is the distance back the unit will land from the target location, so it can look as if the unit is actually slamming their weapon on the target, instead of towards the front of it
endfunction
constant function Jump_Template_Animation1 takes nothing returns string
return "death" //Jump Animation
endfunction
constant function Jump_Template_Animation2 takes nothing returns string
return "dance" //End jump Animation
endfunction
constant function Jump_Template_Effect takes nothing returns string
return "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" //Target effect
endfunction
constant function Jump_Template_Timer_Speed takes nothing returns real
return .01 //Speed of the periodic timer
endfunction
//Spell:
function Jump_Template_Group takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(),bj_groupEnumOwningPlayer) and IsUnitType(GetFilterUnit(),UNIT_TYPE_GROUND)==true
endfunction
function Jump_Template_Damage takes unit u, real r, real x, real y, real r2, boolean attack, boolean ranged, attacktype at, damagetype dt, weapontype wt returns nothing
local group g = CreateGroup()
local boolexpr b = Condition(function Jump_Template_Group)
local unit v
set bj_groupEnumOwningPlayer = GetOwningPlayer(u)
call GroupEnumUnitsInRange(g, x, y, r, b)
call DestroyBoolExpr(b)
loop
set v = FirstOfGroup(g)
exitwhen v == null
call GroupRemoveUnit(g,v)
call UnitDamageTarget(u,v,r2,attack,ranged,at,dt,wt)
endloop
call DestroyGroup(g)
set g = null
set b = null
endfunction
function Jump_Template_Parabola takes real dist, real maxdist,real curve returns real
local real t = (dist*2)/maxdist-1
return (-t*t+1)*(maxdist/curve)
endfunction
function Jump_Template_Move takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit(t,"u")
local real maxdist = GetHandleReal(t,"maxdist")
local real ang = GetHandleReal(t,"ang")
local real movedist = GetHandleReal(t,"movedist")
local real x = GetHandleReal(t,"x")
local real y = GetHandleReal(t,"y")
local real dist = SquareRoot((GetUnitX(u)-x)*(GetUnitX(u)-x) + (GetUnitY(u)-y)*(GetUnitY(u)-y))
local real height = Jump_Template_Parabola(dist,maxdist,Jump_Template_Arc())
local integer i = GetHandleInt(t,"i")
local integer level = GetHandleInt(t,"level")
call SetUnitPosition(u, GetUnitX(u) + movedist * Cos(ang * bj_DEGTORAD) , GetUnitY(u) + movedist * Sin(ang * bj_DEGTORAD))
call SetUnitFlyHeight(u,height,null)
call SetHandleInt(t,"i",i + 1)
if i == 50 then
call SetUnitTimeScalePercent(u, 100)
elseif i == 100 then
call PauseTimer(t)
call FlushHandleLocals(t)
call DestroyTimer(t)
call PauseUnit( u,false )
call SetUnitPathing( u, true )
call SetUnitFlyHeight(u,GetUnitDefaultFlyHeight(u),9999)
set x = GetUnitX(u) + Jump_Template_Difference() * Cos(ang * bj_DEGTORAD)
set y = GetUnitY(u) + Jump_Template_Difference() * Sin(ang * bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect(Jump_Template_Effect(), x,y))
call Jump_Template_Damage(u, Jump_Template_Target_Area(level), x, y, Jump_Template_Target_Damage(level), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
call QueueUnitAnimation(u, Jump_Template_Animation2())
endif
set t = null
set u = null
endfunction
function Jump_Template_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit u = GetTriggerUnit()
local integer level = GetUnitAbilityLevel(u, Jump_Template_SpellId())
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local location l = GetSpellTargetLoc()
local real ang = bj_RADTODEG * Atan2((GetLocationY(l)-uy),(GetLocationX(l)-ux))
local real x = GetLocationX(l) - Jump_Template_Difference() * Cos(ang * bj_DEGTORAD)
local real y = GetLocationY(l) - Jump_Template_Difference() * Sin(ang * bj_DEGTORAD)
call SetHandleHandle(t,"u",u)
call SetHandleReal(t,"x",x)
call SetHandleReal(t,"y",y)
call SetHandleReal(t,"maxdist", SquareRoot((ux-x)*(ux-x) + (uy-y)*(uy-y)))
call SetHandleReal(t,"ang",ang)
call SetHandleReal(t,"movedist",SquareRoot((ux-x)*(ux-x) + (uy-y)*(uy-y))/100)
call SetHandleInt(t,"i",0)
call SetHandleInt(t,"level",level)
call PauseUnit( u,true )
call SetUnitPathing( u, false )
call UnitAddAbility( u,Jump_Template_Fly_TrickId() )
call UnitRemoveAbility( u,Jump_Template_Fly_TrickId() )
call SetUnitAnimation(u, Jump_Template_Animation1())
call SetUnitTimeScalePercent(u, 30)
call TimerStart(t,Jump_Template_Timer_Speed(),true,function Jump_Template_Move)
set t = null
set u = null
call RemoveLocation(l)
set l = null
endfunction
//===========================================================================
function Jump_Template_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Jump_Template_SpellId()
endfunction
function InitTrig_Jump_Template takes nothing returns nothing
set gg_trg_Jump_Template = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Jump_Template, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Jump_Template, Condition( function Jump_Template_Conditions ) )
call TriggerAddAction( gg_trg_Jump_Template, function Jump_Template_Actions )
endfunction