//***************************************************************************************************
//* ===================
//* Blast Orb
//* ===================
//* Made by Shdow89
//*
//*
//* How to implement:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* 1. Copy the spells Blast Orb, Orb Haste (dummy) to your map.
//*
//*
//* 2. Copy the dummy unit Blast Orb Dummy, Dummy Caster(BlastOrb) to your map. To Blast Orb Dummy
//* unit give the spell Orb Haste (dummy), and change the model path of the Dummy Caster(BlastOrb) unit
//* to any model you like. If you like it doesn't have to be any model, you can set it to none.mdl.
//*
//* 3. Make a global variable of type hashtable and name it Hash.
//*
//* 4. Copy Blast Orb buff to your map and make sure that spell Orb Hate (dummy) has that buff
//*
//*
//* 5. Copy this trigger to your map and the code in the custom script section of this map, and
//* change the dummy unit raw codes in it to those in your map.
//*
//*
//* Choosable/Effects:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* Go down through constant function and change to what you like. Units affected are:
//* Enemy Units, Non-Magic immune, Non-Structures and living. This can not be changed in the constants.
//* But if you know your way around JASS I'm sure you'll find it with ease (I hope so).
//*
//* Editor's Word:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* This is my first real JASS spell, and I am not sure if it follows JESP standards.
//* I'm open to all suggestions, and if I didn't remove some leaks point them to me, please.
//* I'm also finding for comments on how to improve my code, everything is welcome.
//* But please don't judge me, and start calling me noob if I did something wrong,
//* like I said, this is my first real JASS spell, and I'm very proud if it :).
//* Have fun, and I hope you'll enjoy :).
//*
//* Credits:
//* ¯¯¯¯¯¯¯¯
//* First and namely to Dr Super Good, for teaching me how to use hashtables.
//* BoneBraker for teaching me how to use constants.
//* emjlr3 whos spells forced me to learn JASS
//*
//*
//*************************************************************************************************
constant function Blast_Orb_SFX_Explosion takes nothing returns string
return "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl" // The effect for orb explosion
endfunction
constant function Blast_Orb_Unit_SFX takes nothing returns string
return "Abilities\\Weapons\\Bolt\\BoltImpact.mdl" // The effect for damaged enemies
endfunction
constant function Blast_Orb_Rawcode takes nothing returns integer
return 'A000' // Blast Orb Rawcode, change this to your rawcode
endfunction
constant function Orb_BuffID takes nothing returns integer
return 'BTLF' // The buff ID for the unit exp. timer (Generic), you don't have to change this.
endfunction
constant function Blast_DummyID takes nothing returns integer
return 'h000' // Blast Orb Dummy rawcode, CHANGE this to your code
endfunction
constant function Blast_DummyCasterID takes nothing returns integer
return 'h001'// Dummy Caster(BlastOrb) rawcode, CHANGE this to your code. And change the model in the object editor, if you want.
endfunction
constant function Orb_Haste_AbilityID takes nothing returns integer
return 'A001' // Orb Haste ability rawcode, CHANGE this to your code
endfunction
constant function Blast_Increment_Size takes nothing returns real
return 1.00 // The orb size that changes every second(x1). Keep this under 5.
endfunction
constant function Blast_Orb_Pull_Loop takes nothing returns real
return 0.03 // The speed of the timer, lower it is the faster it gets (can cause lagg if it's very low)
endfunction
constant function Blast_Orb_Time takes integer i returns integer
return 2+i // The timer orb exists 2 + level of the Blast Orb ability seconds.
endfunction
constant function Blast_Orb_AOEDamage takes integer i returns real
return 100.00*i // Damage and Area of Effect, that changes every secondU
endfunction
constant function Blast_Orb_Pull_Speed takes nothing returns real
return 3.00 // Pull speed of the orb, higher it is, faster the pull
endfunction
constant function DummyCaster_Red takes nothing returns integer
return 0.5 // Dummy Caster(BlastOrb) vertex coloring for color red
endfunction
constant function DummyCaster_Green takes nothing returns integer
return 0.5 // Dummy Caster(BlastOrb) vertex coloring for color green
endfunction
constant function DummyCaster_Blue takes nothing returns integer
return 0.5 // Dummy Caster(BlastOrb) vertex coloring for color blue
endfunction
constant function DummyCaster_Transparent takes nothing returns integer
return 60 // Dummy Caster(BlastOrb) transparency
endfunction
constant function Blast_CasterAnimation takes nothing returns string
return "channel" // Dummy Caster(BlatOrb) loop animation string
endfunction
//==========================================================================================
// If you know JASS, freely edit this. If not leave it as it is.
function Blast_Orb_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Blast_Orb_Rawcode()
endfunction
function Blast_Orb_Filter takes nothing returns boolean // Filter function for picking units in group
return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false and (GetWidgetLife(GetFilterUnit())>0.405)
endfunction
function Blast_Orb_Pull_Group takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit dummy = LoadUnitHandle(udg_Hash, GetHandleId(t), 1)
local unit w
local location p = GetUnitLoc(dummy)
local location p1
local location p3
local group g = GetUnitsInRangeOfLocAll(Blast_Orb_AOEDamage(GetUnitAbilityLevel(dummy, Orb_Haste_AbilityID())), p)
loop
set w = FirstOfGroup(g)
exitwhen w == null
call GroupRemoveUnit(g,w)
if IsUnitEnemy(w, GetOwningPlayer(dummy)) and IsUnitType(w, UNIT_TYPE_STRUCTURE) == false and IsUnitType(w, UNIT_TYPE_MAGIC_IMMUNE) == false and (GetWidgetLife(w)>0.405) then
set p1 = GetUnitLoc(w)
set p3 = PolarProjectionBJ(p,(DistanceBetweenPoints(p, p1) - Blast_Orb_Pull_Speed()), AngleBetweenPoints(p, p1))
call SetUnitPositionLoc( w, p3)
call RemoveLocation(p1)
call RemoveLocation(p3)
endif
endloop
set dummy = null
set w = null
call RemoveLocation(p)
call DestroyGroup(g)
endfunction
function Blast_Orb_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit c = GetTriggerUnit()
local unit dummy
local unit dummy1
local integer i = 0
local real size = Blast_Increment_Size()
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local real x1 = GetUnitX(c)
local real y1 = GetUnitY(c)
set dummy = CreateUnit(GetOwningPlayer(c), Blast_DummyID(), x, y, 0)
call UnitApplyTimedLife(dummy, Orb_BuffID(), Blast_Orb_Time(GetUnitAbilityLevel(c, Blast_Orb_Rawcode())))
set dummy1 = CreateUnit(GetOwningPlayer(c), Blast_DummyCasterID(), x1, y1, GetUnitFacing(c))
call SetUnitAnimation(dummy1, Blast_CasterAnimation())
call SetUnitVertexColor(dummy1, DummyCaster_Red(), DummyCaster_Green(), DummyCaster_Blue(), DummyCaster_Transparent())
call SaveUnitHandle(udg_Hash, GetHandleId(t), 1, dummy)
call TimerStart(t, Blast_Orb_Pull_Loop(), true, function Blast_Orb_Pull_Group)
loop
set i = i+1
exitwhen i > Blast_Orb_Time(GetUnitAbilityLevel(c, Blast_Orb_Rawcode()))
call SetUnitScale(dummy, size, size, size)
call SetUnitAbilityLevel(dummy, Orb_Haste_AbilityID(), i)
set size = size + Blast_Increment_Size()
call TriggerSleepAction(1)
endloop
call DestroyTimer(t)
call DamageEnemiesArea(c, Blast_Orb_AOEDamage(GetUnitAbilityLevel(dummy, Orb_Haste_AbilityID())), x, y, Blast_Orb_AOEDamage(GetUnitAbilityLevel(dummy, Orb_Haste_AbilityID())), true, false,ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS, Blast_Orb_Unit_SFX())
call PauseUnit(dummy1, true)
call ShowUnit(dummy1, false)
call DestroyEffect(AddSpecialEffect(Blast_Orb_SFX_Explosion(), x, y))
set c = null
set dummy1 = null
set i = 0
set x = 0.00
set y = 0.00
set x1 = 0.00
set y1 = 0.00
set size = 0.00
endfunction
function InitTrig_Blast_Orb takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Blast_Orb_Conditions))
call TriggerAddAction(t, function Blast_Orb_Actions)
set udg_Hash = InitHashtable()
call Preload(Blast_Orb_SFX_Explosion())
call Preload(Blast_Orb_Unit_SFX())
set t = null
endfunction