Moderator
M
Moderator
18:52, 3rd Jun 2009
hvo-busterkomo:
The spell was pretty good for a first attempt at vJASS. The effect was basic, but well executed. I've attached a script containing a small improvement. You should also be using a constant function with a take and return value instead of WAVE_NUMBER_PER_LEVEL and WAVE_BASE.
hvo-busterkomo:
The spell was pretty good for a first attempt at vJASS. The effect was basic, but well executed. I've attached a script containing a small improvement. You should also be using a constant function with a take and return value instead of WAVE_NUMBER_PER_LEVEL and WAVE_BASE.
JASS:
library MultiShock initializer Init
globals
private constant integer ACTIVATOR_RAWCODE = 'A003'
private constant integer DUMMY_RAWCODE = 'h000'
private constant string DUMMY_STRING = "carrionswarm"
private constant real TARGET_ARC = 300
private constant integer WAVE_NUMBER_PER_LEVEL = 3
private constant integer WAVE_NUMBER_BASE = 0
private constant real TARGET_ARC_CUTOFF = TARGET_ARC/6.28319
private constant real TARGET_OFFSET = 150
private constant real DUMMY_DURATION = 1
endglobals
private function MSCondition takes nothing returns boolean
return GetSpellAbilityId() == ACTIVATOR_RAWCODE
endfunction
private constant function DummyFilter takes nothing returns boolean
return true
endfunction
private function MultiShock takes nothing returns nothing
local unit tu = GetTriggerUnit()
local location tl = GetSpellTargetLoc()
local unit lu
local player p = GetOwningPlayer(tu)
local integer im = WAVE_NUMBER_BASE + GetUnitAbilityLevel(tu,ACTIVATOR_RAWCODE) * WAVE_NUMBER_PER_LEVEL
local integer i = 0
local real x = GetUnitX(tu)
local real y = GetUnitY(tu)
local real dx = x-GetLocationX(tl)
local real dy = y-GetLocationY(tl)
local real distance = SquareRoot(dx*dx+dy*dy)
local real circum
local real r
call RemoveLocation(tl)
set tl = null
if distance > TARGET_ARC_CUTOFF then
set circum = TARGET_ARC/distance
set r = Atan2(dy,dx) - circum/2
else
set circum = 6.28319
set r = GetUnitFacing(tu)*bj_DEGTORAD
endif
set circum = circum/im
loop
exitwhen i == im
set lu = CreateUnit(p,DUMMY_RAWCODE,x,y,r*bj_RADTODEG)
call UnitApplyTimedLife(lu,'BTLF',DUMMY_DURATION)
call IssuePointOrder(lu,DUMMY_STRING,x+TARGET_OFFSET*Cos(r),y+TARGET_OFFSET*Sin(r))
set r = r + circum
set i = i + 1
endloop
set tu = null
set lu = null
set p = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
local filterfunc ff = Filter(function DummyFilter)
loop
exitwhen (i >= bj_MAX_PLAYER_SLOTS)
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, ff)
set i = i + 1
endloop
call TriggerAddCondition(t,Condition(function MSCondition))
call TriggerAddAction(t,function MultiShock)
call DestroyFilter(ff)
set ff = null
endfunction
endlibrary