wraithseeker
Tired.
- Reaction score
- 122
The casting of dummy spell is instant so using one global dummy is instant too.
library SomeNamingConvention
globals
constant integer CONSTANT_GLOBAL = 0 // All Caps
integer OtherGlobal // Capital on first letter of each word
endglobals
struct StructName // Capital on first letter of each word
integer structmember // All small
method methodName takes nothing returns nothing // First word small, then capital on first letter of each word.
endmethod
endstruct
// Function Names: Capital on first letter of each word
// Arguments: either a single, small letter. Or same as struct methods.
function SomeOtherFunction takes integer i, unit whichUnit returns nothing
// Locals are all small. They're usually not longer than 3 letters though.
local integer somelocal
endfunction
endlibrary
Have you tried it?
private constant integer NUMBER_OF_BEAMS = 36// In v2.0, this constant is flexible, since linked list is introduced.
EDIT [2]: Thx, no problem anymore.@ Laiev:
What JassHelper do you have? There was a problem with module onInit methods conflicting with struct onInit methods a while ago. That is probably the cause of the error.
call UnitAddAbility(DUMMY,039;abil039;)
call SetUnitAbilityLevel(DUMMY,039;abil039;,level)
call IssueTargetOrderById(...)
call UnitRemoveAbility(DUMMY,039;abil039;) // important, else this can conflict with other abilities.
It costs more function calls. ><JASS:call UnitAddAbility(DUMMY,039;abil039;) call SetUnitAbilityLevel(DUMMY,039;abil039;,level) call IssueTargetOrderById(...) call UnitRemoveAbility(DUMMY,039;abil039;) // important, else this can conflict with other abilities.
It costs more function calls. ><
Maybe I will use xeCast.
.
set thistype.enumGroup = CreateGroup()
set thistype.cf = Condition(function thistype.Effects)
set thistype.radianOfCircle = (2 * bj_PI) / NUMBER_OF_BEAMS
set thistype.dummyOwner = Player(15)
set thistype.spellTicks = R2I(AOE / WAVE_SPEED)
set thistype.dummy = CreateUnit(thistype.dummyOwner,DUMMY_ID,0.,0.,0.)
call UnitAddAbility(thistype.dummy,DUMMY_SLOW_ID)
set thistype.loopz = NUMBER_OF_BEAMS
loop
exitwhen thistype.loopz == 0
set thistype.radianOfBeams[thistype.loopz] = thistype.radianOfCircle * thistype.loopz
set thistype.angleOfBeams[thistype.loopz] = thistype.radianOfBeams[thistype.loopz] * 57.2958
set thistype.cosine[thistype.loopz] = Cos(thistype.radianOfBeams[thistype.loopz])
set thistype.sine[thistype.loopz] = Sin(thistype.radianOfBeams[thistype.loopz])
set thistype.loopz = thistype.loopz - 1
endloop
private static method Filter takes unit whichUnit returns boolean
return GetWidgetLife(whichUnit) > .405 and IsUnitEnemy(whichUnit,thistype.this.p) and not IsUnitInGroup(whichUnit,thistype.this.damaged) and IsUnitType(whichUnit,UNIT_TYPE_STRUCTURE) == false
endmethod
set thistype.enumGroup = CreateGroup()
set thistype.cf = Condition(function thistype.Effects)
set thistype.radianOfCircle = (2 * bj_PI) / NUMBER_OF_BEAMS
set thistype.dummyOwner = Player(15)
set thistype.spellTicks = R2I(AOE / WAVE_SPEED)
set thistype.dummy = CreateUnit(thistype.dummyOwner,DUMMY_ID,0.,0.,0.)
call UnitAddAbility(thistype.dummy,DUMMY_SLOW_ID)
set thistype.loopz = NUMBER_OF_BEAMS
loop
exitwhen thistype.loopz == 0
set thistype.radianOfBeams[thistype.loopz] = thistype.radianOfCircle * thistype.loopz
set thistype.angleOfBeams[thistype.loopz] = thistype.radianOfBeams[thistype.loopz] * 57.2958
set thistype.cosine[thistype.loopz] = Cos(thistype.radianOfBeams[thistype.loopz])
set thistype.sine[thistype.loopz] = Sin(thistype.radianOfBeams[thistype.loopz])
set thistype.loopz = thistype.loopz - 1
endloop
scope ArticBlast
globals
private constant integer ABIL_ID = 039;A000039; // Hero ability.
private constant integer PROJ_ID = 039;h000039; // The projectile for the nova.
private constant integer SLOW_ID = 039;A001039; // The dummy slow ability.
private constant integer MAX_PROJS = 36 // Maximum number of projectiles allowed at any level.
private constant string ORDER_ID = "slow" // Order string for the dummy ability.
private constant string SLOW_EFFECT = "Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl"
private constant string SLOW_ATTACH = "origin"
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_MAGIC
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_MAGIC
private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
private constant boolean PRELOAD = true
endglobals
private constant function Damage takes integer level returns real
return 100.00 * level // Damage dealt per level.
endfunction
private constant function Speed takes integer level returns real
return 600.00 + (0.00 * level) // Speed the projectiles move in units per second.
endfunction
private constant function Radius takes integer level returns real
return 600.00 + (0.00 * level) // The radius of the nova.
endfunction
private constant function Projectiles takes integer level returns integer
return 20 + (4 * level) // How many projectiles there are per level. Cannot be over MAX_PROJS.
endfunction
private function FilterUnits takes unit filter, unit caster returns boolean
return GetWidgetLife(filter) > 0.405 and IsUnitEnemy(filter,GetOwningPlayer(caster)) and IsUnitType(filter,UNIT_TYPE_STRUCTURE) == false
endfunction
private struct Data
unit caster = null
player owner = null
group damaged = null
real castx = 0.00
real casty = 0.00
real damage = 0.00
real speed = 0.00
real total = 0.00
integer level = 0
integer projs = 0
integer ticks = 0
unit array proj[MAX_PROJS]
real array pcos[MAX_PROJS]
real array psin[MAX_PROJS]
static thistype tempData = 0
static group enumGroup = null
static boolexpr enumBool = null
method onDestroy takes nothing returns nothing
local integer i = 0
loop
exitwhen i == this.projs
call KillUnit(this.proj<i>)
set this.proj<i> = null
set i = i + 1
endloop
call Group.release(this.damaged)
set this.caster = null
set this.owner = null
set this.damaged = null
endmethod
static method filterUnits takes nothing returns boolean
local thistype this = thistype.tempData
local unit filt = GetFilterUnit()
if FilterUnits(filt,this.caster) == true and IsUnitInGroup(filt,this.damaged) == false then
call UnitDamageTarget(this.caster,filt,this.damage,false,false,ATTACK_TYPE,DAMAGE_TYPE,WEAPON_TYPE)
call DestroyEffect(AddSpecialEffectTarget(SLOW_EFFECT,filt,SLOW_ATTACH))
call UnitAddAbility(DUMMY,SLOW_ID)
call SetUnitAbilityLevel(DUMMY,SLOW_ID,this.level)
call IssueTargetOrder(DUMMY,ORDER_ID,filt)
call UnitRemoveAbility(DUMMY,SLOW_ID)
call GroupAddUnit(this.damaged,filt)
endif
set filt = null
return false
endmethod
method periodic takes nothing returns nothing
local integer i = 0
if T32_Tick == this.ticks then
call this.stopPeriodic()
call this.destroy()
else
set this.total = this.total + this.speed
set this.castx = GetUnitX(this.caster)
set this.casty = GetUnitY(this.caster)
loop
exitwhen i == this.projs
call SetUnitX(this.proj<i>,this.castx + this.total * this.pcos<i>)
call SetUnitY(this.proj<i>,this.casty + this.total * this.psin<i>)
set i = i + 1
endloop
set thistype.tempData = this
call GroupEnumUnitsInRange(thistype.enumGroup,this.castx,this.casty,this.total,thistype.enumBool)
endif
endmethod
implement T32x
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
local integer i = 0
local real r = 0.00
set this.caster = GetTriggerUnit()
set this.owner = GetOwningPlayer(this.caster)
set this.castx = GetUnitX(this.caster)
set this.casty = GetUnitY(this.caster)
set this.level = GetUnitAbilityLevel(this.caster,ABIL_ID)
set this.damage = Damage(this.level)
set this.speed = Speed(this.level) * T32_PERIOD
set this.projs = Projectiles(this.level)
set this.damaged = Group.get()
if this.projs > MAX_PROJS then
set this.projs = MAX_PROJS
endif
set this.ticks = T32_Tick + R2I(Radius(this.level) / this.speed)
set r = (2.00 * bj_PI) / this.projs
loop
exitwhen i == this.projs
set this.proj<i> = CreateUnit(this.owner,PROJ_ID,this.castx,this.casty,(r * i) * bj_RADTODEG)
set this.pcos<i> = Cos(r * i)
set this.psin<i> = Sin(r * i)
set i = i + 1
endloop
call this.startPeriodic()
return this
endmethod
static method conditions takes nothing returns boolean
if GetSpellAbilityId() == ABIL_ID then
call thistype.create()
endif
return false
endmethod
static method onInit takes nothing returns nothing
local trigger trig = CreateTrigger()
local unit dumm = null
set thistype.enumGroup = CreateGroup()
set thistype.enumBool = Filter(function thistype.filterUnits)
call GT_AddStartsEffectAction(function thistype.conditions,ABIL_ID)
if PRELOAD then
set dumm = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),PROJ_ID,0.00,0.00,0.00)
call DestroyEffect(AddSpecialEffect(SLOW_EFFECT,0.00,0.00))
call UnitAddAbility(dumm,SLOW_ID)
call RemoveUnit(dumm)
set dumm = null
endif
endmethod
endstruct
endscope
</i></i></i></i></i></i></i></i></i>