waaaks!
Zinctified
- Reaction score
- 255
JASS:
scope Whirlwind initializer init
globals
private group n = CreateGroup()
private constant integer spell = 039;A00F039;
private constant real offset = 40
private constant string sfx1 = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
endglobals
private struct data
unit cast
real x
real y
real tick
real range
private method onDestroy takes nothing returns nothing
set .tick = 0
set .range = 0
endmethod
endstruct
private function callBack takes nothing returns nothing
local timer t = GetExpiredTimer()
local group attach = NewGroup()
local data d = GetTimerData(t)
local integer l = GetUnitAbilityLevel(d.cast,spell)
local real x = GetUnitX(d.cast)
local real y = GetUnitY(d.cast)
local real angle = 57.29582 * Atan2(d.y-y,d.x-x)
local real dx = d.x-x
local real dy = d.y-y
local real dis = SquareRoot(dx*dx + dy*dy)
local real px = x + offset * Cos(Atan2(d.y-y,d.x-x))
local real py = y + offset * Sin(Atan2(d.y-y,d.x-x))
local group g = NewGroup()
local unit u
local real r = d.range
local real attempts = d.range / offset
local real dur = attempts * 0.035
local xedamage xe = xedamage.create()
set xe.dtype = DTEARTH
set d.tick = d.tick + 0.035
call xe.factor(UNIT_TYPE_STRUCTURE,0.5)
call xe.useSpecialEffect(sfx1,"chest")
call SetUnitX(d.cast, px)
call SetUnitY(d.cast, py)
call GroupEnumUnitsInRange(g,x,y,250,null)
call SetUnitAnimationByIndex(d.cast, 11)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitEnemy(u, GetOwningPlayer(d.cast)) and GetWidgetLife(u) > 0.405 and not IsUnitInGroup(u,n) then
call xe.damageTarget(d.cast,u,100*l)
call GroupAddUnit(n,u)
if not IsUnitType(u,UNIT_TYPE_STRUCTURE) then
call GroupAddUnit(attach,u)
endif
endif
call GroupRemoveUnit(g,u)
endloop
set u = null
call ReleaseGroup(g)
loop
set u = FirstOfGroup(attach)
exitwhen u == null
call SetUnitX(u,GetUnitX(d.cast))
call SetUnitY(u,GetUnitY(d.cast))
call GroupRemoveUnit(attach,u)
endloop
call ReleaseGroup(attach)
if d.tick >= dur then
call SetUnitAnimation(d.cast, "stand")
call PauseUnit(d.cast, false)
call shake()
call GroupClear(n)
call GroupClear(attach)
call ReleaseTimer(t)
call d.destroy()
endif
set attach = null
set g = null
set u = null
set t = null
endfunction
private function act takes nothing returns nothing
local data d = data.create()
local timer t = NewTimer()
set d.cast = SpellEvent.CastingUnit
set d.x = SpellEvent.TargetX
set d.y = SpellEvent.TargetY
set d.range = SquareRoot((d.x - GetUnitX(d.cast)) * (d.x - GetUnitX(d.cast)) + (d.y - GetUnitY(d.cast)) * (d.y - GetUnitY(d.cast)))
call SetUnitAnimationByIndex(d.cast, 11)
call PauseUnit(d.cast,true)
call shake()
call TimerStart(t, 0.035, true, function callBack)
call SetTimerData(t,d)
set t = null
endfunction
private function init takes nothing returns nothing
call RegisterSpellEffectResponse(spell,act)
endfunction
endscope
I have this spell that moves a unit periodically to a point, picks enemy units nearby, dealing damage to them, removing them to a group, and adding them to another global group so that they won't get damaged again, then clearing the global group if a condition will return true.
I can't find a way to make this an MUI spell, lets say two units casts the same spell, in the same point, and unit1 picks enemy units nearby, dealing damage and add them to the global group, making units in the global group unaffected to damage from that spell, so that means, unit2 cannot deal damage to them, for there is only 1 global group for the whole game. Do I need to use some unit indexing stuffs for this, so that it creates 1 global group for 1 unit?