- Joined
- Jul 13, 2005
- Messages
- 21
I am trying to convert a corpse explosion ability I have written in GUI into JASS (only the functions are the same, otherwise the JASS was written from scratch). As usual 200 some compile errors. Since this is the first spell I have written I am completely lost as to what is causing them. (oh and yes i am using a custom model set in the mpq (feastaura)).
constant function Corpse_SpellId takes nothing returns integer
return 'A027' //Rawcode of Corpse Explosion Ability
endfunction
constant function Corpse_SFXMain takes nothing returns string
return "Spells\\Aura\\feastaura.mdx" //String name of warning SFX
endfunction
constant function Corpse_SFX takes nothing returns string
return "Objects\\Spawnmodels\\Demon\\DemonLargeDeathExplode\\DemonLargeDeathExplode.mdl"
//String name of explosion SFX
endfunction
constant function CorpseTarg_SFX takes nothing returns string
return "Objects\\Spawnmodels\\Demon\\DemonLargeDeathExplode\\DemonLargeDeathExplode.mdl"
//String name of target SFX
endfunction
constant function Corpse_DamCriteria takes player castown, unit f returns boolean
return (IsPlayerEnemy(GetOwningPlayer(f), castown)) and not(IsUnitType(f, UNIT_TYPE_MAGIC_IMMUNE)) and
not(IsUnitType(f, UNIT_TYPE_DEAD))
endfunction
constant function Corpse_Criteria takes unit p returns boolean
return (IsUnitType(p, UNIT_TYPE_DEAD)) and not(IsUnitType(p, UNIT_TYPE_HERO))
endfunction
constant function DamAmount takes unit f integer level returns integer
if not(IsUnitType(f, UNIT_TYPE_STRUCTURE)) then
return 45*level
else
return 45*level*0.30
endfunction
constant function CorpseSpell_Range takes integer level returns real
return 350+(level*0)//Level is not affecting range of effect
endfunction
constant function CorpseExpl_Range takes integer level returns real
return 200+(level*0)//Level is not affecting range of explosions
endfunction
constant function DamType takes nothing returns damagetype
return DAMAGE_TYPE_DISEASE
endfunction
constant function AttType takes nothing returns attacktype
return ATTACK_TYPE_CHAOS
endfunction
//=================================================================================
function CorpseExp_Conditions takes nothing returns boolean
return GetSpellAbilityId()==Corpse_SpellId()
endfunction
function groupunits takes location castloc, player castown, unit cast, integer level returns nothing
local group g=GetUnitsInRangeOfLocAll( CorpseSpell_Range(level), castloc)
local unit p=FirstOfGroup(g)
loop
exitwhen p==null
set p=FirstOfGroup(g)
call GroupRemoveUnit(g, p)
if (Corpse_Criteria(p)) then
call explodeunit(p, cast, castown, level)
endif
endloop
endfunction
//Gets all the corpses in the target area using the criteria in the header
function explodeunits takes unit p, unit cast, player castown, integer level returns nothing
local location loc=GetUnitLoc(p)
local group g=GetUnitsInRangeOfLocAll( CorpseExpl_Range(level), loc )
local unit f=FirstOfGroup(g)
local effect array sp
local integer n=0
local integer i=0
local effect sfx=AddSpecialEffectLoc(Corpse_SFX(), loc)
loop
exitwhen f==null
set f=FirstOfGroup(g)
call GroupRemoveUnit(g, f)
if (Corpse_DamCriteria(castown, f)) then
set loc=GetUnitLoc(f)
set sp[n]=AddSpecialEffectTarget(CorpseTarg_SFX(), f, "chest")
call damageunit(f, cast, level)
call RemoveUnit(p)
set n=n+1
endif
endloop
call TriggerSleepAction(.3) //Adjust time for special effect completion
loop
exitwhen i==n
call DestroyEffect(sp)
set i=i+1
endloop
call RemoveLocation(loc)
set n=0
set i=0
endfunction
//Creates the explosions at each corpse and damages units according to header criteria
function damageunit takes unit f, unit cast, integer level returns nothing
call UnitDamageTargetBJ(f, cast, DamAmount(f, level), AttType(), DamType())
endfunction
function CorpseExp_begin takes nothing returns nothing
local unit cast=GetSpellAbilityUnit()
local location castloc=GetSpellTargetLoc()
local player castown=GetOwningPlayer(cast)
local integer level=GetUnitAbilityLevel(cast, Corpse_SpellId())
local effect sp=AddSpecialEffectLoc(Corpse_SFXMain(), castloc)
call TriggerSleepAction(0.4)//Wait before explosions begin and removing warningeffect
call groupunits(castloc, castown, cast, level)
call DestroyEffect(sp)
endfunction
//====================================================================================
function InitTrig_Corpse_Explosion takes nothing returns nothing
set gg_trg_Corpse_Explosion = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Corpse_Explosion, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Corpse_Explosion, Condition( function CorpseExp_Conditions ) )
call TriggerAddAction( gg_trg_Corpse_Explosion, function CorpseExp_begin )
endfunction
constant function Corpse_SpellId takes nothing returns integer
return 'A027' //Rawcode of Corpse Explosion Ability
endfunction
constant function Corpse_SFXMain takes nothing returns string
return "Spells\\Aura\\feastaura.mdx" //String name of warning SFX
endfunction
constant function Corpse_SFX takes nothing returns string
return "Objects\\Spawnmodels\\Demon\\DemonLargeDeathExplode\\DemonLargeDeathExplode.mdl"
//String name of explosion SFX
endfunction
constant function CorpseTarg_SFX takes nothing returns string
return "Objects\\Spawnmodels\\Demon\\DemonLargeDeathExplode\\DemonLargeDeathExplode.mdl"
//String name of target SFX
endfunction
constant function Corpse_DamCriteria takes player castown, unit f returns boolean
return (IsPlayerEnemy(GetOwningPlayer(f), castown)) and not(IsUnitType(f, UNIT_TYPE_MAGIC_IMMUNE)) and
not(IsUnitType(f, UNIT_TYPE_DEAD))
endfunction
constant function Corpse_Criteria takes unit p returns boolean
return (IsUnitType(p, UNIT_TYPE_DEAD)) and not(IsUnitType(p, UNIT_TYPE_HERO))
endfunction
constant function DamAmount takes unit f integer level returns integer
if not(IsUnitType(f, UNIT_TYPE_STRUCTURE)) then
return 45*level
else
return 45*level*0.30
endfunction
constant function CorpseSpell_Range takes integer level returns real
return 350+(level*0)//Level is not affecting range of effect
endfunction
constant function CorpseExpl_Range takes integer level returns real
return 200+(level*0)//Level is not affecting range of explosions
endfunction
constant function DamType takes nothing returns damagetype
return DAMAGE_TYPE_DISEASE
endfunction
constant function AttType takes nothing returns attacktype
return ATTACK_TYPE_CHAOS
endfunction
//=================================================================================
function CorpseExp_Conditions takes nothing returns boolean
return GetSpellAbilityId()==Corpse_SpellId()
endfunction
function groupunits takes location castloc, player castown, unit cast, integer level returns nothing
local group g=GetUnitsInRangeOfLocAll( CorpseSpell_Range(level), castloc)
local unit p=FirstOfGroup(g)
loop
exitwhen p==null
set p=FirstOfGroup(g)
call GroupRemoveUnit(g, p)
if (Corpse_Criteria(p)) then
call explodeunit(p, cast, castown, level)
endif
endloop
endfunction
//Gets all the corpses in the target area using the criteria in the header
function explodeunits takes unit p, unit cast, player castown, integer level returns nothing
local location loc=GetUnitLoc(p)
local group g=GetUnitsInRangeOfLocAll( CorpseExpl_Range(level), loc )
local unit f=FirstOfGroup(g)
local effect array sp
local integer n=0
local integer i=0
local effect sfx=AddSpecialEffectLoc(Corpse_SFX(), loc)
loop
exitwhen f==null
set f=FirstOfGroup(g)
call GroupRemoveUnit(g, f)
if (Corpse_DamCriteria(castown, f)) then
set loc=GetUnitLoc(f)
set sp[n]=AddSpecialEffectTarget(CorpseTarg_SFX(), f, "chest")
call damageunit(f, cast, level)
call RemoveUnit(p)
set n=n+1
endif
endloop
call TriggerSleepAction(.3) //Adjust time for special effect completion
loop
exitwhen i==n
call DestroyEffect(sp)
set i=i+1
endloop
call RemoveLocation(loc)
set n=0
set i=0
endfunction
//Creates the explosions at each corpse and damages units according to header criteria
function damageunit takes unit f, unit cast, integer level returns nothing
call UnitDamageTargetBJ(f, cast, DamAmount(f, level), AttType(), DamType())
endfunction
function CorpseExp_begin takes nothing returns nothing
local unit cast=GetSpellAbilityUnit()
local location castloc=GetSpellTargetLoc()
local player castown=GetOwningPlayer(cast)
local integer level=GetUnitAbilityLevel(cast, Corpse_SpellId())
local effect sp=AddSpecialEffectLoc(Corpse_SFXMain(), castloc)
call TriggerSleepAction(0.4)//Wait before explosions begin and removing warningeffect
call groupunits(castloc, castown, cast, level)
call DestroyEffect(sp)
endfunction
//====================================================================================
function InitTrig_Corpse_Explosion takes nothing returns nothing
set gg_trg_Corpse_Explosion = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Corpse_Explosion, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Corpse_Explosion, Condition( function CorpseExp_Conditions ) )
call TriggerAddAction( gg_trg_Corpse_Explosion, function CorpseExp_begin )
endfunction