- Joined
- Jun 25, 2008
- Messages
- 118
Ok this is a spell i am making for the spells and systems contest 16, so i cant take any fixes done by you guys, but im sure it will be ok if someone can just point out why this trigger doesnt work, it has no errors with JASS helper and no matter how many times i look at it i cant find any problems
Bee Swarm
Launches a swarm of angry killer bees that deal damage over time to the enemy. Damage over time increases when the target moves as the bees become more agitated. Damage over time decreases when the target stands still as the bees become less agitated. If damage per second reaches 0 they leave the target. Bees last up to 20 seconds.
Bee Swarm
Launches a swarm of angry killer bees that deal damage over time to the enemy. Damage over time increases when the target moves as the bees become more agitated. Damage over time decreases when the target stands still as the bees become less agitated. If damage per second reaches 0 they leave the target. Bees last up to 20 seconds.
JASS:
scope BeeSwarm initializer Init
//=========================Bee Swarm by BlackShogun==========================//
//=================================Setup=====================================//
//spell rawcode
private constant function BeeSwarmRawCode takes nothing returns integer
return 'A000'
endfunction
//dummy unit rawcode
private constant function BeeSwarmModel takes nothing returns integer
return 'h000'
endfunction
//dummy unit model
private constant function BeeSwarmSFX takes nothing returns string
return "Abilities\\Weapons\\CryptFiendMissile\\CryptFiendMissile.mdl"
endfunction
//base damage per second
private function BeeSwarmBaseDPS takes integer lvl returns real
return 5.0*lvl
endfunction
//increase in damage per second for every second the target is moving
private function BeeSwarmIncDPS takes integer lvl returns real
return 0.5*lvl
endfunction
//decrease in damage per second for every second the target is moving
private constant function BeeSwarmDecDPS takes nothing returns real
return 0.5
endfunction
//duration of spell
private constant function BeeSwarmDur takes nothing returns real
return 20.0
endfunction
//the movement and effects interval
private constant function BeeSwarmInterval takes nothing returns real
return 0.03
endfunction
//distance moved by projectile each interval
private constant function BeeSwarmDist takes nothing returns real
return 15.0
endfunction
//===============================EndSetup====================================//
//==================NOTE: DO NOT EDIT ANYTHING BEYOND HERE===================//
struct BeeSwarm_Data
unit cast
unit targ
unit u
real x
real y
real dmg
real time
effect sfx
endstruct
globals
private timer t = CreateTimer()
private BeeSwarm_Data array ar
private integer total = 0
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == BeeSwarmRawCode()
endfunction
private function Effects takes nothing returns nothing
local BeeSwarm_Data dat
local integer i=0
local real x1
local real y1
local real x2
local real y2
local real a
local real mx
local real my
local integer lvl
loop
exitwhen i>=total
set dat=ar[i]
set x1=GetUnitX(dat.u)
set y1=GetUnitY(dat.u)
set x2=GetUnitX(dat.targ)
set y2=GetUnitY(dat.targ)
set a=Atan2(y2-y1, x2-x1)
set mx=BeeSwarmDist()*Cos(a)
set my=BeeSwarmDist()*Sin(a)
set lvl=GetUnitAbilityLevel(dat.cast, BeeSwarmRawCode())
if not IsUnitInRange(dat.u, dat.targ, 50) then
call SetUnitX(dat.u, x1+mx)
call SetUnitY(dat.u, y1+my)
call SetUnitFacing(dat.u, 57.29583*a)
endif
if IsUnitInRange(dat.u, dat.targ, 50) and (not IsUnitType(dat.targ, UNIT_TYPE_DEAD)) then
call SetUnitX(dat.u, x2)
call SetUnitY(dat.u, y2)
call UnitDamageTarget(dat.cast, dat.targ, (BeeSwarmBaseDPS(lvl)*BeeSwarmInterval())+dat.dmg, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
if dat.x!=null then
if IsUnitInRangeXY(dat.targ, dat.x, dat.y, 5) then
set dat.dmg=dat.dmg-(BeeSwarmDecDPS()*BeeSwarmInterval())
else
set dat.dmg=dat.dmg+(BeeSwarmIncDPS(lvl)*BeeSwarmInterval())
endif
endif
set dat.x=x2
set dat.y=y2
endif
if (BeeSwarmBaseDPS(lvl)+dat.dmg<=0) or (dat.time>=BeeSwarmDur()) or (IsUnitInRange(dat.u, dat.targ, 50) and IsUnitType(dat.targ, UNIT_TYPE_DEAD)) then
call DestroyEffect(dat.sfx)
call RemoveUnit(dat.u)
set ar[i]=ar[total-1]
set total=total-1
call dat.destroy()
endif
set dat.time=dat.time+(1*BeeSwarmInterval())
set i=i+1
endloop
if total==0 then
call PauseTimer(t)
endif
endfunction
private function Actions takes nothing returns BeeSwarm_Data
local BeeSwarm_Data dat=BeeSwarm_Data.create()
local player p
set dat.cast=GetTriggerUnit()
set p = GetOwningPlayer(dat.cast)
set dat.targ=GetSpellTargetUnit()
set dat.u=CreateUnit(p, BeeSwarmModel(), GetUnitX(dat.cast), GetUnitY(dat.cast), 57.29583*Atan2(GetUnitY(dat.targ)-GetUnitY(dat.cast), GetUnitX(dat.targ)-GetUnitX(dat.cast)))
set dat.sfx=AddSpecialEffectTarget(BeeSwarmSFX(), dat.u, "chest")
set dat.dmg=0
set dat.time=0
set p=null
if total==0 then
call TimerStart(t, BeeSwarmInterval(), true, function Effects)
endif
set total=total+1
set ar[total-1]=dat
return dat
endfunction
private function Init takes nothing returns nothing
local trigger T = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(T, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(T, function Actions)
call TriggerAddCondition(T, Condition(function Conditions))
endfunction
endscope