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
scope BeeSwarm initializer Init
//=========================Bee Swarm by BlackShogun==========================// //=================================Setup=====================================//
//dummy unit rawcode privateconstantfunction BeeSwarmModel takesnothingreturnsinteger return'h000' endfunction
//dummy unit model privateconstantfunction BeeSwarmSFX takesnothingreturnsstring return"Abilities\\Weapons\\CryptFiendMissile\\CryptFiendMissile.mdl" endfunction
//base damage per second privatefunction BeeSwarmBaseDPS takesinteger lvl returnsreal return 5.0*lvl endfunction
//increase in damage per second for every second the target is moving privatefunction BeeSwarmIncDPS takesinteger lvl returnsreal return 0.5*lvl endfunction
//decrease in damage per second for every second the target is moving privateconstantfunction BeeSwarmDecDPS takesnothingreturnsreal return 0.5 endfunction
//duration of spell privateconstantfunction BeeSwarmDur takesnothingreturnsreal return 20.0 endfunction
//the movement and effects interval privateconstantfunction BeeSwarmInterval takesnothingreturnsreal return 0.03 endfunction
//distance moved by projectile each interval privateconstantfunction BeeSwarmDist takesnothingreturnsreal 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 privatetimer t = CreateTimer() private BeeSwarm_Data array ar privateinteger total = 0 endglobals
privatefunction Effects takesnothingreturnsnothing local BeeSwarm_Data dat localinteger i=0 localreal x1 localreal y1 localreal x2 localreal y2 localreal a localreal mx localreal my localinteger 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 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!=nullthen 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
privatefunction Actions takesnothingreturns BeeSwarm_Data local BeeSwarm_Data dat=BeeSwarm_Data.create() localplayer 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
privatefunction Init takesnothingreturnsnothing localtrigger T = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(T, EVENT_PLAYER_UNIT_SPELL_EFFECT) call TriggerAddAction(T, function Actions) call TriggerAddCondition(T, Condition(function Conditions)) endfunction
It gives no errors, or syntax errors, it does not crash wc3.
The problem is it creates the dummy unit, and thats it, the dummy just sits there... as far as i can tell the function Effects isnt working properly, sry i shouldve included this information before, and since last i have made it so it sets the values of the locals AFTER refering to the struct (dat=ar[i]), so now it should be able to get the struct data properly. And i thought that was going to fix it but apparently not xD
although im no longer bothered about this spell, i do need to know what is wrong here etc so i dont make the same mistake again. I still have no idea whats wrong with this even after reading a few more vJASS tutorials, there must be someone who has the know-how that can help :D