- Joined
- Sep 29, 2004
- Messages
- 52
Hey, finally starting to get used to using JASS instead of GUI. For a game I'm working on, I decided to try and turn one of my old spells into JASS, but I've ran into problem with the JASS Timer not initiating. If someone would kindly take a look at it, I would be greatful and plus rep to them:
JASS:
//############################################################
// Spell: Philosopher's Stone
//The Alchemist creates a Philosopher stone above his head,
//channeling it for up to 10 seconds. While channeling 20
//health is drained from every enemy, allowing the stone to
//grow bigger. Once the channeling is done the Stone explodes
//dealing damage based upon the total health absorbed/1.50.
//############################################################
function Philosopher_Stone_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A070'
endfunction
function Philosopher_Stone_Conditions_Sub2 takes nothing returns boolean
return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetTriggerPlayer()) == true )
endfunction
//This function makes everyone within a 1000 radius of the Stone
//loose health. With each health drawn, the stone grows bigger.
function PhilDamage takes nothing returns nothing
local unit cast2 = GetTriggerUnit()
local unit temp2
local group gx = CreateGroup()
local real x2 = GetUnitX(cast2)
local real y2 = GetUnitY(cast2)
local effect se2
set se2 = AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl",cast2,"chest")
call DestroyEffect( se2 )
set se2 = null
call GroupEnumUnitsInRange(gx,x2,y2, 1000.00,Condition(function Philosopher_Stone_Conditions_Sub2))
loop
set temp2 = FirstOfGroup(gx)
exitwhen temp2 == null
set udg_PhilosopherSize = (udg_PhilosopherSize + 20.00)
call UnitDamageTarget(cast2,temp2, 20.00,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DIVINE,null)
set se2 = AddSpecialEffectTarget("VampiricAuraTarget.mdx",temp2,"chest")
call DestroyEffect( se2 )
set se2 = null
call SetUnitScale(udg_PhilosopherStone,(udg_PhilosopherSize + 100.00),(udg_PhilosopherSize + 100.00),(udg_PhilosopherSize + 100.00))
call GroupRemoveUnit(gx,temp2)
endloop
call DestroyGroup(gx)
set temp2 = null
set cast2 = null
endfunction
//Philosopher Action allows the Stone to be channeled for up to 10 seconds.
//Once reaching 10 seconds the Stone explodes dealing massive damage,
//based upon the health drained during channel.
function Philosopher_Stone_Actions takes nothing returns nothing
//########################################################
local unit cast = GetTriggerUnit()
local unit temp
local timer dt = CreateTimer()
local real x = GetUnitX(cast)
local real y = GetUnitY(cast)
local location l = Location(x,y)
local real a = 0.00
local integer i = 0
local group g = CreateGroup()
local effect se
//########################################################
set udg_PhilosopherStone = CreateUnit(GetOwningPlayer(cast), 'h01Q',x,y,a)
//For some reason this timer fails to repeat, or event initialize
call TimerStart(dt,1.00,true,function PhilDamage)
loop
exitwhen i == 10
set i = i + 1
call TriggerSleepAction(1.00)
if not IsUnitInRangeLoc(cast,l,0.00) then
set i = 10
endif
endloop
call GroupEnumUnitsInRange(g,x,y, 1500.00,Condition(function Philosopher_Stone_Conditions_Sub2))
loop
set temp = FirstOfGroup(g)
exitwhen temp == null
call UnitDamageTarget(cast,temp,(udg_PhilosopherSize/1.50),true, false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DIVINE,null)
set se = AddSpecialEffectTarget("Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl",temp,"origin")
call DestroyEffect( se )
set se = null
call GroupRemoveUnit(g,temp)
endloop
call RemoveUnit(udg_PhilosopherStone)
set udg_PhilosopherStone = null
set udg_PhilosopherSize = 0.00
call DestroyTimer(dt)
call RemoveLocation(l)
endfunction
//===========================================================================
function InitTrig_Philosopher_Stone takes nothing returns nothing
local trigger P = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( P, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(P, Condition(function Philosopher_Stone_Conditions))
call TriggerAddAction( P, function Philosopher_Stone_Actions )
endfunction