//TESH.scrollpos=0
//TESH.alwaysfold=0
function RedRift_CastAbility takes nothing returns integer
return 'A00P' //Enter the raw code of the ability that triggers this
endfunction
function RedRift_OrbModel takes nothing returns string
return "Abilities\\Weapons\\VengeanceMissile\\VengeanceMissile.mdl" //Enter the model you want to use for the orb
endfunction
function RedRift_OrbHeight takes nothing returns real
return 150.55 //Enter the flying height of your orb, make sure your dummy model has at least hovering movement or flying
endfunction
function RedRift_BaseDmg takes nothing returns real
return 100.0 //Enter here the base damage of the spell
endfunction
function RedRift_IncDmg takes nothing returns real
return 60.0 //Enter here the damage increment per level
endfunction
function RedRift_Distance takes nothing returns real
return 2000.0 //Distance in units which the orb travells
endfunction
function RedRift_Speed takes nothing returns real
return 14.25 //The speed that the orb has when released (about 460 units per second)
endfunction
function RedRift_BaseGripRange takes nothing returns real
return 200.0 //The base range that enemy units are caught
endfunction
function RedRift_IncGripRange takes nothing returns real
return 30.0 //The increment value of the Grip range increases by this value per level
endfunction
function RedRift_DummyID takes nothing returns integer
return 'e002' //The ID of the dummy orb unit
endfunction
function RedRift_LightningType takes nothing returns string
//return"CLPB" //Chain Lightning Primary
//return"CLSB" //Chain Lightning Secondary
//return"DRAB" //Drain
//return "DRAL" //Drain Life
//return "DRAM" //Drain Mana
//return "AFOD" //Finger of Death
//return "FORK" //Forked Lightning
//return "HWPB" //Healing Wave Primary
//return "HWSB" //Healing Wave Secondary
//return "CHIM" //Lightning Attack
return "LEAS" //Magic Leash
//return "MBUR" //Mana Burn
//return "MFPB" //Mana Flare
//return "SPLK" //Spirit Link
// Remember, if you wanna use something different, comment out your primary and uncomment the one you're gonna use
endfunction
function RedRift_AdditionalEffects takes unit c, unit victim returns nothing
local integer DUMMY_SPELL = 'ACpu' //In my case this is the purge ability
local string ORDER_STRING = "Красный орб" //In my case i use purge... in case you wanna use something different, just change it
local unit dummy = CreateUnit(GetOwningPlayer©, RedRift_DummyID(), GetUnitX(victim), GetUnitY(victim), 0)
call UnitAddAbility(dummy, DUMMY_SPELL)
call UnitRemoveAbility(dummy, 'Aatk')
call IssueTargetOrder(dummy, ORDER_STRING, victim)
call UnitApplyTimedLife(dummy, 'BTLF', 1)
set dummy = null
/// Use any custom effects here if you wish, like stunning, slow... anything that is related from handle c to handle victim
endfunction
///////////////////////////////////////////////////////////
//No touching belllow if you don't know what you're doing//
//Don't bother reading, Jass is a mess but quite efficient if you know how to use it.//
///////////////////////////////////////////////////////////
function RedRift_Condition takes nothing returns boolean
return GetSpellAbilityId() == RedRift_CastAbility()
endfunction
//Irrelevant functions to the user...
//Very useful since we dont want our game to crash if the orb goes outside boundaries
//That's because we use SetUnitX/Y instead of SetUnitPosition
//Even with a collision enabled, SetUnitX/Y totally ignores it, thats why the orb can get outside the map boundaries. duh
function RedRift_SafeX takes real x returns real
local real rx=GetRectMinX(bj_mapInitialPlayableArea)+50
if(x<rx)then
return rx
endif
set rx=GetRectMaxX(bj_mapInitialPlayableArea)-50
if(x>rx)then
return rx
endif
return x
endfunction
function RedRift_SafeY takes real y returns real
local real ry=GetRectMinY(bj_mapInitialPlayableArea)+50
if(y<ry)then
return ry
endif
set ry=GetRectMaxY(bj_mapInitialPlayableArea)-50
if(y>ry)then
return ry
endif
return y
endfunction
function RedRift_SafeShift takes real a returns real
if a < .01 then
return .01
elseif a > .99 then
return .99
endif
return a
endfunction
function RedRift_Move takes nothing returns nothing
local integer table = GetHandleId(GetExpiredTimer())
local unit orb = LoadUnitHandle(udg_RedRiftHT, table, StringHash("Orb | Unit"))
local real dmg = LoadReal(udg_RedRiftHT, table, StringHash("Orb | Dmg"))
local real dist = LoadReal(udg_RedRiftHT, table, StringHash("Orb | Dist"))
local real X = LoadReal(udg_RedRiftHT, table, StringHash("Orb | X"))
local real Y = LoadReal(udg_RedRiftHT, table, StringHash("Orb | Y"))
local real Angle = LoadReal(udg_RedRiftHT, table, StringHash("Orb | Angle"))
local real speed = LoadReal(udg_RedRiftHT, table, StringHash("Orb | Speed"))
local group Gripped = LoadGroupHandle(udg_RedRiftHT, table, StringHash("Orb | Group"))
local real aoe = LoadReal(udg_RedRiftHT, table, StringHash("Orb | AOE"))
local real x = RedRift_SafeX(GetUnitX(orb) + speed * Cos(Angle * bj_DEGTORAD))
local real y = RedRift_SafeY(GetUnitY(orb) + speed * Sin(Angle * bj_DEGTORAD))
local group g = CreateGroup()
local real dur = LoadReal(udg_RedRiftHT, table, StringHash("Orb | Duration"))
local real x1
local real y1
local real scale
local unit u
local lightning l
local real array c
set dur = dur + .0315
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | Duration"), dur)
call SetUnitX(orb, x)
call SetUnitY(orb, y)
call GroupEnumUnitsInRange(g, GetUnitX(orb), GetUnitY(orb), aoe, null)
loop
set u = FirstOfGroup(g)
set l = null
exitwhen u == null
if ((not(IsUnitInGroup(u, Gripped))) and IsUnitEnemy(u, GetOwningPlayer(orb)) and (GetWidgetLife(u)>0.415) and (not(IsUnitType(u, UNIT_TYPE_STRUCTURE))) and (not(IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE)))) then
call GroupAddUnit(Gripped, u)
set scale = LoadReal(udg_RedRiftHT, table, StringHash("Orb | size"))
set scale = scale + .475
call SetUnitScale(orb, scale, scale, scale)
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | size"), scale)
call SaveLightningHandle(udg_RedRiftHT, table, GetHandleId(u), AddLightning(RedRift_LightningType(), true, GetUnitX(u), GetUnitY(u), GetUnitX(orb), GetUnitY(orb)))
endif
call GroupRemoveUnit(g, u)
endloop
call GroupAddGroup(Gripped, g)
loop
set u = FirstOfGroup(g)
set l = null
exitwhen u == null
set l = LoadLightningHandle(udg_RedRiftHT, table, GetHandleId(u))
call MoveLightningEx(l, true, GetUnitX(u), GetUnitY(u), GetUnitFlyHeight(u), x, y, GetUnitFlyHeight(orb))
set x1 = GetUnitX(u)
set y1 = GetUnitY(u)
if SquareRoot((x - x1) * (x - x1) + (y - y1) * (y - y1)) > 500 then
set c[0] = RedRift_SafeShift(GetLightningColorG(l) - .02)
set c[1] = RedRift_SafeShift(GetLightningColorB(l) - .03)
else
set c[0] = RedRift_SafeShift(GetLightningColorG(l) + .06)
set c[1] = RedRift_SafeShift(GetLightningColorB(l) + .09)
endif
call SetLightningColor(l, 1, c[0], c[1], .9)
if (GetWidgetLife(u)<.415) then
call DestroyLightning(l)
call GroupRemoveUnit(Gripped, u)
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
if (SquareRoot((X - x) * (X - x) + (Y - y) * (Y - y)) > dist) or (dur > 15) then
call PauseTimer(GetExpiredTimer())
loop
set u = FirstOfGroup(Gripped)
set l = null
exitwhen u == null
set l = LoadLightningHandle(udg_RedRiftHT, table, GetHandleId(u))
call DestroyLightning(l)
set x1 = GetUnitX(u)
set y1 = GetUnitY(u)
if SquareRoot((x - x1) * (x - x1) + (y - y1) * (y - y1)) > 500 then
call SetUnitPosition(u, GetUnitX(orb), GetUnitY(orb))
call RedRift_AdditionalEffects(orb, u)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Demon\\DemonBoltImpact\\DemonBoltImpact.mdl" , u, "chest"))
call UnitDamageTarget(orb, u, dmg, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(Gripped, u)
endloop
call DestroyGroup(Gripped)
call SetUnitVertexColor(orb, 255, 55, 100, 205)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Weapons\\Bolt\\BoltImpact.mdl", orb, "origin"))
call DestroyEffect(LoadEffectHandle(udg_RedRiftHT, table, StringHash("Orb | Art")))
call KillUnit(orb)
call FlushChildHashtable(udg_RedRiftHT, table)
call DestroyTimer(GetExpiredTimer())
endif
set orb = null
set g = null
set Gripped = null
endfunction
function RedRift_Actions takes nothing returns nothing
local timer t = CreateTimer()
local integer table = GetHandleId(t)
local real OrbX = GetUnitX(GetTriggerUnit())
local real OrbY = GetUnitY(GetTriggerUnit())
local real FINAL_DMG = RedRift_BaseDmg() + (RedRift_IncDmg() * (I2R(GetUnitAbilityLevel(GetTriggerUnit(), RedRift_CastAbility()))-1))
local real GRIP_RANGE = RedRift_BaseGripRange() + RedRift_IncGripRange() * I2R(GetUnitAbilityLevel(GetTriggerUnit(), RedRift_CastAbility()))
local real Angle = bj_RADTODEG * Atan2(GetSpellTargetY() - OrbY, GetSpellTargetX() - OrbX)
local unit Orb = CreateUnit(GetOwningPlayer(GetTriggerUnit()), RedRift_DummyID(), OrbX, OrbY, Angle)
call UnitRemoveAbility(Orb, 'Aatk')
call SetUnitFlyHeight(Orb, RedRift_OrbHeight(), 3000)
call SaveEffectHandle(udg_RedRiftHT, table, StringHash("Orb | Art"), AddSpecialEffectTarget(RedRift_OrbModel(), Orb, "origin"))
call SaveUnitHandle(udg_RedRiftHT, table, StringHash("Orb | Caster"), GetTriggerUnit())
call SaveUnitHandle(udg_RedRiftHT, table, StringHash("Orb | Unit"), Orb)
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | Dmg"), FINAL_DMG)
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | Dist"), RedRift_Distance())
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | X"), OrbX)
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | Y"), OrbY)
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | Angle"), Angle)
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | size"), 1)
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | Speed"), RedRift_Speed())
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | AOE"), GRIP_RANGE)
call SaveReal(udg_RedRiftHT, table, StringHash("Orb | Duration"), 0) // Just in case this gets stuck just outside map boundaries... The orb dies after 10 seconds
call SaveGroupHandle(udg_RedRiftHT, table, StringHash("Orb | Group"), CreateGroup())
call TimerStart(t, .0315, true, function RedRift_Move)
set t = null
set Orb = null
endfunction
//===========================================================================
function InitTrig_Red_Rift takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(t, Condition(function RedRift_Condition))
call TriggerAddAction( t, function RedRift_Actions )
set udg_RedRiftHT = InitHashtable()
set t = null
endfunction