- Joined
- Apr 18, 2010
- Messages
- 102
I dont know the reason, but it appears that the game crashes when this spell is used.
Code:
scope UnlimitedBladeWorks
globals
private constant integer ABILITY_ID = 'ubwe' //spell Id
private constant real FPS = 0.0312500
//Spell Constants
private constant real RADIUS = 800 //radius of the reality marble
private constant real CASTTIME = 0.5 //delay before the formation of RM
private constant real FORMTIME = 1.0 //formation time of reality marble
private constant real DURATION = 8 //duration of spell
//Spell Visuals
private constant string ANIMATION = "Spell Three" //caster animation when the spell is casted
private constant real ANIMATIONSPEED = 150 //animation speed of caster
private constant string CASTINGSOUND = "war3mapImported\\EMY_NP.mp3"
private constant string FIREFX = "Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl" //sfx of the RM border
private constant real FIREFXSIZE = 1.25 //size of Fireborder
private constant real FIREFXSPIN = 6 //degrees of spin of fire (rate depends of FPS)
private constant integer FIREFXCOUNT = 60 //number of firefx
private constant string SWORDFX = "war3mapImported\\EmiyaSword.mdl" //sfx of swords
private constant real SWORDFXSIZE = 1.25 //size of swords
private constant integer SWORDFXPITCH = 60 //pitch of swords
private constant real SWORDFXCOUNT = 1.75
private constant real SWORDFXINC = .25
private constant string GEAR1FX = "war3mapImported\\Gear2.mdl"
private constant string GEAR2FX = "war3mapImported\\Gear3.mdl"
private constant integer GEARCOUNT = 12
endglobals
//Function made by Blade.dk; Search for [url=http://www.wc3campaigns.com]wc3campaigns.com[/url] for more info
private function CopyGroup takes group g returns group
set bj_groupAddGroupDest = CreateGroup()
call ForGroup(g, function GroupAddGroupEnum)
return bj_groupAddGroupDest
endfunction
private struct MySpell
private unit caster
private real duration
private real formtime
private real casttime
private real firefxspeed
private real swordfxcount
private real radius
private real angle
private group realitymarblegroup
private group copygroup
private group firegroup
private real ubwX
private real ubwY
private real fireangleinc
private real gearangle
private integer stage
private static method onPeriodic takes nothing returns nothing
local timer tmr = GetExpiredTimer()
local integer g
local unit u
local real X1
local real Y1
local real X2
local real Y2
local real fireangle
local real gearsize
local real gearZ
local integer gearvar
local thistype this = GetTimerData(tmr)
// Your spell code. For example.
if this.stage == 1 then
if this.casttime > 0 then
if GetWidgetLife(this.caster) >= 0.405 then
set this.casttime = this.casttime - FPS
else
set this.stage = 0
endif
else
set this.stage = 2
set this.ubwX = GetUnitX(this.caster)
set this.ubwY = GetUnitY(this.caster)
set g = FIREFXCOUNT
loop
exitwhen g <= 0
set u = GetRecycledDummy(ubwX, ubwY, 0, this.angle)
call AddSpecialEffectTarget(FIREFX,u,"origin")
set this.angle = this.angle + fireangleinc
call GroupAddUnit(this.realitymarblegroup,u)
call GroupAddUnit(this.firegroup,u)
call SetUnitScale(u, FIREFXSIZE, 1, 1)
set g = g - 1
endloop
endif
endif
if this.stage == 2 then
if this.formtime > 0 then
set this.copygroup = CopyGroup(this.firegroup)
set this.radius = this.radius + this.firefxspeed
loop
set u = FirstOfGroup(this.copygroup)
exitwhen u == null
set X1 = GetUnitX(u)
set Y1 = GetUnitY(u)
set fireangle = GetUnitFacing(u)
set X2 = X1 + this.firefxspeed * Cos( Deg2Rad (fireangle))
set Y2 = Y1 + this.firefxspeed * Sin( Deg2Rad (fireangle))
call SetUnitX(u, X2)
call SetUnitY(u, Y2)
call SetUnitFacing(u, fireangle + FIREFXSPIN)
call GroupRemoveUnit(this.copygroup, u)
endloop
set g = R2I(this.swordfxcount)
loop
exitwhen g == 0
set X2 = this.ubwX + GetRandomReal( -1 * this.radius, this.radius ) * Cos(GetRandomReal(0,360))
set Y2 = this.ubwY + GetRandomReal( -1 * this.radius, this.radius ) * Sin(GetRandomReal(0,360))
set u = GetRecycledDummy(X2, Y2, 0, GetRandomReal(0,360))
call AddSpecialEffectTarget(SWORDFX,u,"origin")
call GroupAddUnit(this.realitymarblegroup,u)
call SetUnitScale(u, SWORDFXSIZE, 1, 1)
call SetUnitAnimationByIndex(u, SWORDFXPITCH)
set g = g - 1
endloop
set this.swordfxcount = this.swordfxcount + SWORDFXINC
set this.formtime = this.formtime - FPS
else
set this.stage = 3
set this.angle = GetRandomReal(0,360)
set g = GEARCOUNT
loop
exitwhen g == 0
set X2 = this.ubwX + (this.radius + 25)*Cos(this.angle)
set Y2 = this.ubwY + (this.radius + 25)*Sin(this.angle)
set this.angle = this.angle + this.gearangle
set gearsize = GetRandomReal(2.25,3.25)
set gearZ = GetRandomReal(125,225)
set u = GetRecycledDummy(X2, Y2, gearZ, this.angle)
set gearvar = GetRandomInt(1,2)
if gearvar == 1 then
call AddSpecialEffectTarget(GEAR1FX,u,"origin")
else
call AddSpecialEffectTarget(GEAR2FX,u,"origin")
endif
call GroupAddUnit(this.realitymarblegroup,u)
call SetUnitScale(u, gearsize, 1, 1)
set g = g - 1
endloop
endif
endif
if this.stage == 3 then
if this.duration > 0 then
set this.duration = this.duration - FPS
//apply border control
else
set this.stage = 0
endif
endif
//deallocation
if this.stage == 0 then
call this.destroy()
call ReleaseTimer(tmr)
call PauseUnit(this.caster, false)
loop
set u = FirstOfGroup(this.realitymarblegroup)
exitwhen u == null
call DummyAddRecycleTimer(u,0.5)
endloop
endif
set tmr = null
endmethod
private static method onEffect takes nothing returns nothing
local thistype this = thistype.create()// Creates a unique index "this".
//initializing spell variables
set this.caster = GetTriggerUnit()
set this.duration = DURATION
set this.casttime = CASTTIME
set this.formtime = FORMTIME
set this.firefxspeed = (RADIUS / (FORMTIME / (1/FPS)))
set this.radius = 0
set this.angle = GetRandomReal(0,360)
set this.swordfxcount = SWORDFXCOUNT
set this.fireangleinc = 360 / I2R(FIREFXCOUNT)
set this.gearangle = 360 / I2R(GEARCOUNT)
//start casting
//creating groups
set this.realitymarblegroup = CreateGroup()
set this.copygroup = CreateGroup()
set this.firegroup = CreateGroup()
//spell core
set this.stage = 1
call PauseUnit(this.caster, true)
call SetUnitAnimation(this.caster, ANIMATION)
call SetUnitTimeScale(this.caster, ANIMATIONSPEED)
call AttachSoundUnit(this.caster, CASTINGSOUND, 127, 9, 2000, false, true, 1500, 3000)
//add caster to Casting group here
//add caster to not moving group here
//add caster to not walking group here
call TimerStart(NewTimerEx(this), FPS, true, function thistype.onPeriodic)
endmethod
private static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(ABILITY_ID, function thistype.onEffect)
endmethod
endstruct
endscope
Last edited: