/*
===Fire Erruption v1.4
===By: Mckill2009
INSTALLATION:
- Copy the "Fire Erruption" (see left) folder to your map
- Copy the custom units and abilities to your map
- Make sure you inputed the correct raw ID's of the custom units and abilities
- You can view raw ID's by pressing CTRL+D in the object editor
- Examples of raw ID's are 'A001', 'A003' etc...
- See the Note below for more info
REQUIRES:
- RegisterPlayerUnitEvent by Magtheridon96
- SpellEffectEvent by Bribe
CREDITS:
- This spell was originally made by defskull in GUI (requested by me)
*/
scope FireErruption
/*
Note:
- SPELL_ID and CHANNEL_ID must match/synchronize to each other
- FE_DUMSPELLID and ORDER_ID must match/synchronize to each other.
- If you create your FE_DUMMY manually from the object editor make
sure that the "Animation - Cast Backswing/Point" is set to 0.
- The cooldown and mana of your Breath of Fire must be 0.
*/
globals
private constant integer SPELL_ID = 'A001' //Main spell raw ID, Blizzard
private constant integer FE_DUMSPELLID = 'A003' //Dummy spell raw ID, Breath of Fire
private constant integer FE_DUMMYID = 'h000' //Dummy raw ID
private constant integer FIREBALL_ID = 'h002' //Fireball Dummy raw ID
private constant integer CHANNEL_ID = 852089 //Blizzard orderID (for hero)
private constant integer ORDER_ID = 852580 //Breath of Fire orderID (for dummy)
//=============================================
private constant boolean PRELOAD = true
//Sets how many times the fireball will spit fire
private constant integer CAST_COUNT = 12
//This is the ground shaking SFX
private constant string FE_SFX = "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl"
//This is the angle between spitting fire
private constant real FE_BALL_GAP = 30.
//Sets how fast the fireball grows
private constant real SCALE_INTERVAL = 0.05
//Minimum 0.03, this is the speed of the rotating fire casted
private constant real CAST_SPEED = 0.03
//Maximum size of the fireball
private constant real MAX_SCALE = 10
endglobals
private struct FireErruption extends array
unit u
unit fireball
real x
real y
real scale
real angle
real castspeed
integer castcount
integer level
effect sfx
boolean isChanneling
static constant real delay = 0.03125
static unit dummy = null //used a global dummy for the fire casting
static timer t
static integer index = 0
static integer array indexAR
//=====allocator and destructor for this struct
static integer ins = 0
static integer array insAR
static method allocate takes nothing returns integer
local thistype this = insAR[0]
if this==0 then
set ins = ins + 1
set this = ins
else
set insAR[0] = insAR[this]
endif
return this
endmethod
method deallocate takes nothing returns nothing
set insAR[this] = insAR[0]
set insAR[0] = this
endmethod
//=====
static method periodic takes nothing returns nothing
local thistype this
local integer i = 0
local real x1
local real y1
loop
set i = i+1
set this = indexAR[i]
if not IsUnitType(.u, UNIT_TYPE_DEAD) and .isChanneling then
if GetUnitCurrentOrder(.u)==CHANNEL_ID then
if MAX_SCALE > .scale then
set .scale = .scale + SCALE_INTERVAL
call SetUnitScale(.fireball, .scale, 0, 0)
elseif .fireball != null then
call DestroyEffect(.sfx)
call RemoveUnit(.fireball)
set .fireball = null
elseif CAST_COUNT > .castcount then
set .castspeed = .castspeed + delay
if .castspeed > CAST_SPEED then
set .castspeed = 0
set .castcount = .castcount + 1
set .angle = .angle + FE_BALL_GAP
call SetUnitOwner(dummy, GetOwningPlayer(.u), false)
call SetUnitPosition(dummy, .x, .y)
set x1 = .x + 100 * Cos(.angle*bj_DEGTORAD)
set y1 = .y + 100 * Sin(.angle*bj_DEGTORAD)
call SetUnitAbilityLevel(dummy, FE_DUMSPELLID, .level)
call IssuePointOrderById(dummy, ORDER_ID, x1, y1)
endif
else
call IssueImmediateOrder(.u, "stop")
set .isChanneling = false
endif
else
set .isChanneling = false
endif
else
call DestroyEffect(.sfx)
call RemoveUnit(.fireball)
set .u = null
set .fireball = null
set .sfx = null
call .deallocate()
set indexAR[i] = indexAR[index]
set indexAR[index] = this
set index = index - 1
set i = i - 1
if index==0 then
call PauseTimer(t)
call DestroyTimer(t)
call RemoveUnit(dummy)
endif
endif
exitwhen i==index
endloop
endmethod
static method cast takes nothing returns nothing
local thistype this = allocate()
set .u = GetTriggerUnit()
set .x = GetSpellTargetX()
set .y = GetSpellTargetY()
set .fireball = CreateUnit(Player(15), FIREBALL_ID, .x, .y, 0)
set .level = GetUnitAbilityLevel(.u, SPELL_ID)
set .sfx = AddSpecialEffect(FE_SFX, .x, .y)
call SetUnitScale(.fireball, 0,0,0)
set .scale = 0
set .angle = 0
set .castcount = 0
set .castspeed = CAST_SPEED
set .isChanneling = true
call SetUnitFlyHeight(.fireball, 100, 0)
if index==0 then
set t = CreateTimer()
call TimerStart(t, delay, true, function thistype.periodic)
set dummy = CreateUnit(Player(15),FE_DUMMYID,0,0,0)
call UnitAddAbility(dummy, FE_DUMSPELLID)
call UnitRemoveAbility(dummy, 'Amov')
endif
set index = index + 1
set indexAR[index] = this
endmethod
static method onInit takes nothing returns nothing
//Setting up the spell effect
call RegisterSpellEffectEvent(SPELL_ID, function thistype.cast)
static if PRELOAD then
//Preloading dummies and abilities
set dummy = CreateUnit(Player(15),FE_DUMMYID,0,0,0)
call ShowUnit(dummy,false)
call RemoveUnit(dummy)
set dummy = CreateUnit(Player(15),FIREBALL_ID,0,0,0)
call ShowUnit(dummy,false)
call UnitAddAbility(dummy, FE_DUMSPELLID)
call RemoveUnit(dummy)
endif
endmethod
endstruct
endscope