//==============================================================================//
//Death's Respite - JASS version //
// //
//Lifts the unit into the air and then throws it back, dealing damage. //
//==============================================================================//
//Constants //
//==============================================================================//
function Trig_DR_JASS_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A001' //Ability ID
endfunction
function DR_Max_Time_Lift takes nothing returns real
return 1.00 //Max time to lift unit into air
endfunction
function DR_Dmg_Multiplier takes nothing returns real
return 0.60 //Damage multiplier ( lvl x (str + int) x DmgConstant )
endfunction
function DR_Dmg_Init takes nothing returns real
return 30.00 //Initial Damage ( ( DmgInit x lvl ) + ( lvl x (str + int) x DmgConstant ) )
endfunction
function DR_Lift_per_Tick takes nothing returns real
return 2.00 //Height lifted per .02sec
endfunction
function DR_Throw_per_Tick takes nothing returns real
return 20.00 //Distance thrown per .02sec
endfunction
function DR_Porab_Length takes nothing returns real
return 1200.00 //Overall length of the porabolic shape multiplied by the time used to lift
endfunction
function DR_Porab_EndDist takes nothing returns real
return 600.00 //End distance from initial point for parabola multiplied by the time used to lift
endfunction
function DR_Height takes real MaxHeight, real MaxDist, real CurDist returns real
return (((4.00 * MaxHeight) / MaxDist) * (MaxDist - CurDist) * (CurDist / MaxDist))
endfunction
//==============================================================================//
//End Constants //
//==============================================================================//
function DR_JASS_Throw takes nothing returns nothing
local timer tt = GetExpiredTimer()
local real maxdist = LoadReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("MaxDist"))
local real curdist = LoadReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("CurDist"))
local real maxheight = LoadReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("MaxHeight"))
local real targetptx = LoadReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("TargetPtX"))
local real targetpty = LoadReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("TargetPtY"))
local real endptx = LoadReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("EndPtX"))
local real endpty = LoadReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("EndPtY"))
local unit target = LoadUnitHandle( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("Target") )
local location temp
call DisplayTextToForce( GetPlayersAll(), "test" )
if maxdist > curdist then
set temp = PolarProjectionBJ( Location( targetptx, targetpty ), DR_Throw_per_Tick(), AngleBetweenPoints(Location( targetptx, targetpty ), Location( endptx, endpty )) )
call SaveReal(udg_DR_JASS_Hash, GetHandleId(tt), StringHash("TargetPtX"), GetLocationX(temp) )
call SaveReal(udg_DR_JASS_Hash, GetHandleId(tt), StringHash("TargetPtY"), GetLocationY(temp) )
call SaveReal(udg_DR_JASS_Hash, GetHandleId(tt), StringHash("CurDist"), (curdist + DR_Throw_per_Tick()) )
set targetptx = LoadReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("TargetPtX"))
set targetpty = LoadReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("TargetPtY"))
call SetUnitPositionLoc(target, Location(targetptx, targetpty) )
call SetUnitFlyHeight( target, DR_Height( maxheight, maxdist, curdist ), 0.00 )
else
call PauseTimer(tt)
call DestroyTimer(tt)
set tt = null
set target = null
endif
call RemoveLocation(temp)
set tt = null
set target = null
endfunction
function DR_JASS_Lift takes nothing returns nothing
local timer t = GetExpiredTimer()
local timer tt = CreateTimer()
local unit caster = LoadUnitHandle( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Caster") )
local unit target = LoadUnitHandle( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Target") )
local real time = LoadReal( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Time") )
local integer lvl = LoadInteger( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Level") )
local integer str = LoadInteger( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Str") )
local integer int = LoadInteger( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Int") )
local location temp
if time <= DR_Max_Time_Lift() then
call SaveReal( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Time"), ( time + 0.02 ) )
call SetUnitFlyHeight( target, ( GetUnitFlyHeight(target) + DR_Lift_per_Tick() ), 0.00 )
call UnitDamageTarget( caster, target, (DR_Dmg_Init()*I2R(lvl)+((I2R(str)+I2R(int))*(I2R(lvl)*DR_Dmg_Multiplier()))*0.02), true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
call DestroyTimer(tt)
else
call TimerStart( tt, 0.02, true, function DR_JASS_Throw )
call SaveBoolean( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("Lifting"), false )
call SaveBoolean( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("Throw"), true )
call PauseUnit( target, false )
call SaveReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("MaxDist"), ( DR_Porab_Length() * time ) )
call SaveReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("CurDist"), ( (DR_Porab_Length() * time)/2.00 ) )
call SaveReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("MaxHeight"), ( time * 100.00 ) )
call SaveReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("TargetPtX"), GetLocationX(GetUnitLoc(target)))
call SaveReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("TargetPtY"), GetLocationY(GetUnitLoc(target)))
set temp = PolarProjectionBJ( Location(GetLocationX(GetUnitLoc(target)), GetLocationY(GetUnitLoc(target))), ((DR_Porab_Length() * time) / 2.00), AngleBetweenPoints(Location(GetLocationX(GetUnitLoc(caster)), GetLocationY(GetUnitLoc(caster))), Location(GetLocationX(GetUnitLoc(target)), GetLocationY(GetUnitLoc(target)))))
call SaveReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("EndPtX"), GetLocationX(temp))
call SaveReal( udg_DR_JASS_Hash, GetHandleId(tt), StringHash("EndPtY"), GetLocationY(temp))
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", target, "origin"))
call PauseTimer(t)
call DestroyTimer(t)
set t = null
set caster = null
set target = null
endif
call RemoveLocation(temp)
set t = null
set caster = null
set target = null
endfunction
function Trig_DR_JASS_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
local timer t = CreateTimer()
call PauseUnit( target, true )
call SaveUnitHandle( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Target"), target )
call SaveUnitHandle( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Caster"), caster )
call SaveReal( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Time"), 0.00 )
call SaveBoolean( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Throw"), false )
call SaveBoolean( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Lifting"), true )
call SaveInteger( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Str"), GetHeroStr( caster, true) )
call SaveInteger( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Int"), GetHeroInt( caster, true) )
call SaveInteger( udg_DR_JASS_Hash, GetHandleId(t), StringHash("Level"), GetUnitAbilityLevel(caster, GetSpellAbilityId()) )
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl", target, "origin"))
call UnitAddAbility(target, 'Arav')
call UnitRemoveAbility(target, 'Arav')
call TimerStart(t, 0.02, true, function DR_JASS_Lift)
set caster = null
set target = null
set t = null
endfunction
//===========================================================================
function InitTrig_DR_JASS takes nothing returns nothing
set gg_trg_DR_JASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_DR_JASS, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_DR_JASS, Condition( function Trig_DR_JASS_Conditions ) )
call TriggerAddAction( gg_trg_DR_JASS, function Trig_DR_JASS_Actions )
endfunction