- Joined
- Mar 18, 2012
- Messages
- 1,716
Hello everybody!
I have a question about the correct use of Dummy (by Nestharus). The way I coded this Fireball spell works (pretty sure) perfectly, but i used i used Dummy as
private static Dummy array dummies instead of an non array version.
Two Questions:
1) Is a non array use superior to an array usage or is it just a matter of "style".
2)If seen a couple of time:
private static method run takes nothing returns boolean
why boolean?
Thanks in advance.
Here is the code:
I have a question about the correct use of Dummy (by Nestharus). The way I coded this Fireball spell works (pretty sure) perfectly, but i used i used Dummy as
private static Dummy array dummies instead of an non array version.
Two Questions:
1) Is a non array use superior to an array usage or is it just a matter of "style".
2)If seen a couple of time:
private static method run takes nothing returns boolean
why boolean?
Thanks in advance.
Here is the code:
JASS:
globals
private constant integer ABILITY_CODE = 'A03A'
private constant real BALL_SPEED = 15.
private constant real BALL_HEIGHT = 65.
private constant string FIREBALL_PATH = "Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl"
private constant string FIREBALL_EXPLODE = "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl"
private constant string EXPLOSION_PATH = ""
private constant real AOE = 200.
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
endglobals
private function GetDamage takes integer level returns real
return 100. + 50*level
endfunction
private function GetRange takes integer level returns integer
return 100//100 + 0*level
endfunction
private function TargetFilter takes unit caster, player owner, unit target returns boolean
return not IsUnitType(target, UNIT_TYPE_STRUCTURE) and not IsUnitType(target, UNIT_TYPE_DEAD) and IsUnitEnemy(target, owner) and GetUnitAbilityLevel(target, 'Aloc') == 0
endfunction
private struct Fireball extends array
private static player array owner
private static unit array caster
private static constant real TIMEOUT = 0.03125
private static group ENU = CreateGroup()
private static integer array ticks
private static real array facing
private static real array x
private static real array y
private static effect array model
private static real array damage
private static Dummy array dummies /*better use no array ????*/
implement CTTC
local unit u
implement CTTCExpire
if ticks[this] >= 1 then
set ticks[this] = ticks[this] - 1
set x[this] = x[this] + BALL_SPEED*Cos(facing[this])
set y[this] = y[this] + BALL_SPEED*Sin(facing[this])
if x[this] < WorldBounds.maxX and x[this] > WorldBounds.minX and y[this] < WorldBounds.maxY and y[this] > WorldBounds.minY then
if IsTerrainWalkable(x[this], y[this]) then
call SetUnitX(dummies[this].unit, x[this])
call SetUnitY(dummies[this].unit, y[this])
call GroupEnumUnitsInRange(ENU, x[this], y[this], AOE, null)
loop
set u = FirstOfGroup(ENU)
exitwhen u == null
call GroupRemoveUnit(ENU, u)
if TargetFilter(caster[this],owner[this], u) then
call UnitDamageTarget(caster[this], u, damage[this], false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
call ArcingTextTag.create( "|cffff0000" + I2S(R2I(damage[this])) + "|r", u)
call GroupClear(ENU)
call DestroyEffect(AddSpecialEffect(FIREBALL_EXPLODE,x[this], y[this]))
call DestroyEffect(model[this])
call dummies[this].destroy()
call this.destroy()
set owner[this] = null
set caster[this] = null
exitwhen true
endif
endloop
else
set ticks[this] = 0
endif
else
set ticks[this] = 0
endif
else
call DestroyEffect(AddSpecialEffect(FIREBALL_EXPLODE,x[this], y[this]))
call DestroyEffect(model[this])
call dummies[this].destroy()
call this.destroy()
set owner[this] = null
set caster[this] = null
endif
implement CTTCNull
implement CTTCEnd
private static method run takes nothing returns nothing/*returns boolean???*/
local thistype this = create()
local integer level = GetUnitAbilityLevel(caster[this], ABILITY_CODE)
set caster[this] = GetTriggerUnit()
set owner[this] = GetTriggerPlayer()
set damage[this] = GetDamage(level)
set ticks[this] = GetRange(level)
set facing[this] = Atan2(GetSpellTargetY() - GetUnitY(caster[this]), GetSpellTargetX() - GetUnitX(caster[this]))
set x[this] = GetUnitX(caster[this])
set y[this] = GetUnitY(caster[this])
set dummies[this] = Dummy.create(x[this], y[this], facing[this]*bj_RADTODEG)
set model[this] = AddSpecialEffectTarget(FIREBALL_PATH, dummies[this].unit, "origin")
call SetUnitFlyHeight(dummies[this].unit, BALL_HEIGHT, 0)
/*return false?????*/
endmethod
private static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(ABILITY_CODE, function thistype.run)
endmethod
endstruct