T.s.e
Wish I was old and a little sentimental
- Reaction score
- 133
So, I have this spell which is instant cast, and upon casting, it will cause another unit to cast a spell, which damages enemy units in a line and creates some fancy effects.
All that is fine, but the created effects are not placed in a line unless the caster is facing up, left, right or downwards.
A picture is worth more than a thousand words, and two pictures are worth more than two thousand words:
This is all good.
And here it becomes all wrong...
All that is fine, but the created effects are not placed in a line unless the caster is facing up, left, right or downwards.
A picture is worth more than a thousand words, and two pictures are worth more than two thousand words:
This is all good.
And here it becomes all wrong...
JASS:
library Abolish initializer i uses TimerUtils, UsefulFuncs, Dra, Damage
globals
private constant integer SPELLID = 039;abol039;
private constant string FX1 = "Abilities\\Spells\\Orc\\Disenchant\\DisenchantSpecialArt.mdl"
private constant string FX2 = "Abilities\\Weapons\\RedDragonBreath\\RedDragonMissile.mdl"
private constant string FX3 = "Abilities\\Weapons\\DemonHunterMissile\\DemonHunterMissile.mdl"
private constant real WIDTH = 128.
private group G
endglobals
private constant function DAMAGE takes integer lvl returns real
return 50. + 10.*lvl
endfunction
private constant function RANGE takes integer lvl returns real
return 800. + lvl*400.
endfunction
private struct Abolish
unit u
real x
real y
player p
real z
endstruct
private function CB takes nothing returns nothing
local Abolish a = GetTimerData(GetExpiredTimer())
local integer i = GetPlayerId(GetOwningPlayer(a.u))
local integer j = 0
local integer lvl = GetUnitAbilityLevel(a.u, SPELLID)
if GetUnitCurrentOrder(i:Familiarz) == OrderId("cyclone") then
call GroupEnumUnitsInLine(G, a.x, a.y, a.x + RANGE(lvl) * Cos(a.z), a.y + RANGE(lvl) * Sin(a.z), WIDTH)
loop
exitwhen j == R2I(RANGE(lvl)/333)
call DestroyEffect(AddSpecialEffect(FX2, a.x + GetRandomReal(0, RANGE(lvl)) * Cos(a.z), a.y + GetRandomReal(0, RANGE(lvl)) * Sin(a.z)))
call DestroyEffect(AddSpecialEffect(FX3, a.x + GetRandomReal(0, RANGE(lvl)) * Cos(a.z), a.y + GetRandomReal(0, RANGE(lvl)) * Sin(a.z)))
set j = j + 1
endloop
loop
exitwhen FirstOfGroup(G) == null
if IsUnitEnemy(FirstOfGroup(G), a.p) then
if GetWidgetLife(FirstOfGroup(G)) > 0.405 then
if IsUnitType(FirstOfGroup(G), UNIT_TYPE_MAGIC_IMMUNE) == false then
call UnitDamageTargetEx(a.u, FirstOfGroup(G), DAMAGE(GetUnitAbilityLevel(a.u, SPELLID)), false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
endif
endif
endif
call GroupRemoveUnit(G, FirstOfGroup(G))
endloop
else
call a.destroy()
call ReleaseTimer(GetExpiredTimer())
endif
endfunction
private function F takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer i = GetPlayerId(GetOwningPlayer(u))
local real x = GetUnitX(i:Familiarz) + 20 * Cos(GetUnitFacing(i:Familiarz)*bj_DEGTORAD)
local real y = GetUnitY(i:Familiarz) + 20 * Sin(GetUnitFacing(i:Familiarz)*bj_DEGTORAD)
local integer lvl = GetUnitAbilityLevel(u, SPELLID)
local timer t = NewTimer()
local Abolish a = Abolish.create()
if GetSpellAbilityId() == SPELLID then
set a.u = u
set a.x = x
set a.y = y
set a.p = Player(i)
set a.z = GetUnitFacing(i:Familiarz)*bj_DEGTORAD
call IssueImmediateOrder(i:Familiarz, "cyclone")
call SetTimerData(t, a)
call TimerStart(t, 0.09, true, function CB)
else
call a.destroy()
call ReleaseTimer(t)
endif
set u = null
return false
endfunction
private function i takes nothing returns nothing
local trigger t = CreateTrigger()
set G = CreateGroup()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Filter(function F))
endfunction
endlibrary