- Joined
- Aug 27, 2004
- Messages
- 471
Ok, i just tested my first jass spell, but it doesnt work!
It should: Damage enemies, heal allies, create some special effects.
Heres the code, its sorta long:
It compiles fine, but it does nothing... Even after i use it 10-20 times. Why doesnt this damn thing work?
It should: Damage enemies, heal allies, create some special effects.
Heres the code, its sorta long:
JASS:
function HE_Var_Setup takes nothing returns nothing // ~|
local real array Damage // ~|
local real array Healing // ~|
local real array Range // ~|
local integer alvl // ~|
local unit castingunit //
set Damage[1] = 100.00
set Damage[2] = 175.00
set Damage[3] = 250.00
set Healing[1] = 50.00
set Healing[2] = 90.00
set Healing[3] = 125.00
set Range[1] = 500.00
set Range[2] = 510.00
set Range[3] = 520.00
set alvl = GetHandleInt(GetTriggeringTrigger(), "alvl")
call SetHandleReal(GetTriggeringTrigger(), R2S(Damage[alvl]), Damage[alvl])
call SetHandleReal(GetTriggeringTrigger(), R2S(Healing[alvl]), Healing[alvl])
call SetHandleReal(GetTriggeringTrigger(), R2S(Range[alvl]), Range[alvl])
endfunction
function Holy_Explosion_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A000' ) ) then
return false
endif
return true
endfunction
//--------------------------Conditional functions---------------------------------
function HEA_BF takes nothing returns nothing
endfunction
function HEA_Cond1 takes nothing returns boolean
return IsUnitAliveBJ(GetFilterUnit()) == true
endfunction
function HEA_Cond2 takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true
endfunction
function HEA_CondSpec1 takes nothing returns boolean
return GetBooleanAnd(HEA_Cond1(), HEA_Cond2())
endfunction
function HEA_Cond3 takes nothing returns boolean
return IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true
endfunction
function HEA_CondSpec2 takes nothing returns boolean
return GetBooleanAnd(HEA_Cond1(), HEA_Cond3())
endfunction
//--------------------------------------------------------------------------------
//Damage function
function DealDamageL takes real Dam1, group Gro1 returns nothing
local unit FOG
if (CountUnitsInGroup(Gro1) > 0) then
loop
exitwhen(CountUnitsInGroup(Gro1) <= 0)
set FOG = FirstOfGroup(Gro1)
call SetUnitLifeBJ(FOG, (GetUnitStateSwap(UNIT_STATE_LIFE, FOG) - Dam1))
call GroupRemoveUnit(Gro1, FOG)
endloop
set FOG = null
set Gro1 = null
else
call DoNothing()
endif
endfunction
//Healing function
function DealHealingL takes real Hea1, group Gro1 returns nothing
local unit FOG
if (CountUnitsInGroup(Gro1) > 0) then
loop
exitwhen(CountUnitsInGroup(Gro1) <= 0)
set FOG = FirstOfGroup(Gro1)
call SetUnitLifeBJ(FOG, (GetUnitStateSwap(UNIT_STATE_LIFE, FOG) + Hea1))
call GroupRemoveUnit(Gro1, FOG)
endloop
set FOG = null
set Gro1 = null
else
call DoNothing()
endif
endfunction
//EyeCandy
function SpecialEffectsL takes real Radius, unit CSP returns nothing
local integer Counter = (R2I(Radius) / 50)
local real Momentum = 0
local real Facing = 0
if (Radius > 0) then
loop
exitwhen(Momentum > Counter)
set Momentum = (Momentum + 1)
loop
exitwhen(Facing > 360)
call AddSpecialEffectLocBJ(PolarProjectionBJ(GetUnitLoc(CSP), Momentum, Facing), "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl")
set Facing = (Facing + 1.00)
endloop
endloop
else
call DoNothing()
endif
endfunction
//-----------------------------End of conditional functions-----------------------
//-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=Main Body-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~=-~
function Holy_Explosion_Actions takes nothing returns nothing
local integer alvl
local unit caster = GetSpellAbilityUnit()
local location casterpos = GetUnitLoc(GetSpellAbilityUnit())
local real FinDamage
local real FinHealing
local real FinRange
local group EnemyTargs
local group AllyTargs
set alvl = GetUnitAbilityLevel(GetSpellAbilityUnit(), 'A000')
call SetHandleInt(GetTriggeringTrigger(), "alvl", alvl)
call SetHandleHandle(GetTriggeringTrigger(), "caster", caster)
call HE_Var_Setup()
set FinDamage = (GetHandleReal(GetTriggeringTrigger(), ("Damage["+I2S(alvl)+"]")))
set FinHealing = (GetHandleReal(GetTriggeringTrigger(), ("Healing["+I2S(alvl)+"]")))
set FinRange = (GetHandleReal(GetTriggeringTrigger(), ("Range["+I2S(alvl)+"]")))
set EnemyTargs = GetUnitsInRangeOfLocMatching(FinRange, casterpos, Condition(function HEA_CondSpec1))
set AllyTargs = GetUnitsInRangeOfLocMatching(FinRange, casterpos, Condition(function HEA_CondSpec2))
call DealDamageL(FinDamage, EnemyTargs)
call DealHealingL(FinHealing, AllyTargs)
call SpecialEffectsL(FinRange, caster)
endfunction
//===========================================================================
function InitTrig_Holy_Explosion takes nothing returns nothing
set gg_trg_Holy_Explosion = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Holy_Explosion, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Holy_Explosion, Condition( function Holy_Explosion_Conditions ) )
call TriggerAddAction( gg_trg_Holy_Explosion, function Holy_Explosion_Actions )
endfunction
It compiles fine, but it does nothing... Even after i use it 10-20 times. Why doesnt this damn thing work?