- Joined
- Jul 15, 2007
- Messages
- 36
Hi, just working on a spell
At this stage, i am trying to filter in or out friendly units based on a constant function.
Ty Ty for help!
At this stage, i am trying to filter in or out friendly units based on a constant function.
JASS:
//Constant Functions: used to customise the spell
//*** Ability Definitions
//*** Set the ability that triggers Frostburn and the buff that enables it's alternate form
constant function Fb_Ability takes nothing returns integer
//This is the ability that triggers Frostburn
return 'A000'
endfunction
constant function Fb_Switch takes nothing returns integer
//This is the ability that determines whether or not the frost or fire variant is cast.
//that means, if this buff ability is active, then the non-default spell is cast (usually fire)
return 'B000'
endfunction
//*** Spell customisation
//*** Sets the way the spell interacts with the environment
constant function Fb_Default takes nothing returns boolean
//If set to true, frost is the default spell, and fire is cast when the buff is present
//If set to false, fire is the default, and frost is cast when the buff is present
return true
endfunction
constant function Fb_FriendorFoe takes nothing returns boolean
//If set to true, does not affect friendly units (own, allied)
//If set to false, damages friends and foe alike
return true
endfunction
constant function Fb_Attacktype takes nothing returns attacktype
return ATTACK_TYPE_MAGIC // Should ignore armour
//return ATTACK_TYPE_CHAOS // Does not ignore armour, but equal to all armour types
//return ATTACK_TYPE_NORMAL //etc....
endfunction
constant function Fb_Damagetype takes nothing returns damagetype
return DAMAGE_TYPE_MAGIC // Should ignore armour
//return DAMAGE_TYPE_NORMAL // Does not ignore armour, but equal to all armour types
//return //etc....
endfunction
//*** Spell Numbers
//*** Sets damage, AoE, etc.
constant function Fb_AOE takes nothing returns real
//This is the AoE of the spell in real units
//The spell effect is spread out over this area
return 300.
endfunction
constant function Fb_AOEincrement takes nothing returns real
//This is the increment added onto the AoE for each level above one of the cast spell
//The default is 0.
return 0.
endfunction
constant function Fb_DamageBase takes nothing returns real
//This is the base damage delt by the spell to each affected unit. It is multiplied by the spell level
return 70.
endfunction
constant function Fb_MaxLevel takes nothing returns integer
//This is the max level and defines how "powerful" the effect is.
//"Power" is divided into four
//If the value is one, then all levels show the maximum sprites
return 10
endfunction
// Sub-functions
function Fb_AffectedForce takes player trigplayer returns force
local force affected
if Fb_FriendorFoe() == true then
call ForceEnumEnemies(affected, trigplayer, null)
else
call ForceEnumPlayers(affected, null)
endif
return affected
endfunction
//Main function (called by trigger)
function Fb_Actions takes nothing returns nothing
local unit trigunit = GetTriggerUnit()
local unit u = null
local integer level = GetUnitAbilityLevel(trigunit, Fb_Ability())
local player trigplayer = GetOwningPlayer(trigunit)
local group g = null
call GroupEnumUnitsInRange(g, GetUnitX(trigunit), GetUnitY(trigunit), ( Fb_AOE() + (1 - level ) ) , null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if u == trigunit then
set u = null
endif
if IsUnitInForce(u, Fb_AffectedForce(trigplayer)) then
call UnitDamageTarget(trigunit, u, ( Fb_DamageBase() * level ), true, true, Fb_Attacktype(), Fb_Damagetype(), ConvertWeaponType(0))
endif
call GroupRemoveUnit(g, u)
endloop
set trigunit = null
set trigplayer=null
call DestroyGroup(g)
endfunction
- Am I leaking a force in Fb_AffectedForce() ? (as I know there is a ForceClear native
- Is there a simpler way so as to filter units weather they are in the affected force or not when they are added to the group of in-range units?
- Is it ATTACK_TYPE or DAMAGE_TYPE that determines if it is "spell/ability" damage or "weapon / attack (i.e. affected by armour)"? (I think it's DAMAGE_TYPE_MAGIC vs DAMAGE_TYPE_NORMAL)
Ty Ty for help!