Moderator
M
Moderator
12:23, 17th Jun 2010
Hanky:
Nice idea and a nice spell. Approved!
Hanky:
Nice idea and a nice spell. Approved!
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXX XXXXXX
//XXXXX Copy this to the map header XXXXXX
//XXXXX (HellCircle.w3x) XXXXXX
//XXXXX on top of the trigger list XXXXXX
//XXXXX XXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function HideItem takes nothing returns nothing
call SetItemVisible(GetFilterItem(), false)
endfunction
function ShowItem takes nothing returns nothing
call SetItemVisible(GetFilterItem(), true)
endfunction
//this function checks if a point is pathable by moving 2 items to it and comparing their coordinates
function IsPathable takes real x, real y returns boolean
local boolean b = false
call MoveRectTo(udg_PathCheckRegion, x, y)
call EnumItemsInRect(udg_PathCheckRegion, null, function HideItem)
call SetItemPosition(udg_pathitem, x, y)
call SetItemPosition(udg_pathitem2, x, y)
if GetWidgetX(udg_pathitem)==x and GetWidgetY(udg_pathitem)==y and GetWidgetX(udg_pathitem2)!=x and GetWidgetY(udg_pathitem2)!=y then
set b = true
else
set b = false
endif
call EnumItemsInRect(udg_PathCheckRegion, null, function ShowItem)
call SetItemVisible(udg_pathitem, false)
call SetItemVisible(udg_pathitem2, false)
return b
endfunction
//destroys a tree and increases a counter
function KillTree takes nothing returns nothing
set udg_TreeKills = udg_TreeKills + 1
call KillDestructable(GetEnumDestructable())
endfunction
//checks if a destructable is a tree by ordering a dummy to harvest it
//dead destructables won't be effected either
function IsTree takes nothing returns boolean
return GetWidgetLife(GetFilterDestructable())>0.405 and IssueTargetOrder(udg_harvester, "harvest", GetFilterDestructable())
endfunction
//destroys all trees in the udg_PathCheckRegion (I felt like using this region since size is perfect)
function KillTrees takes real x, real y returns real
set udg_TreeKills = 0
call MoveRectTo(udg_PathCheckRegion, x, y)
call EnumDestructablesInRect(udg_PathCheckRegion, Condition(function IsTree), function KillTree)
call IssueImmediateOrder(udg_harvester, "stop")
return udg_TreeKills
endfunction
//moves the picked dummy to a certain position
function HellCircle_MoveDummys takes nothing returns nothing
set udg_a = udg_a + 360 / udg_HellCircle_Data[udg_i*11+7]
set udg_x2 = udg_x + Cos(udg_a*bj_DEGTORAD) * udg_r
set udg_y2 = udg_y + Sin(udg_a*bj_DEGTORAD) * udg_r
call SetUnitX(GetEnumUnit(), udg_x2)
call SetUnitY(GetEnumUnit(), udg_y2)
set udg_HellCircle_Data[udg_i*11+9] = udg_HellCircle_Data[udg_i*11+9] + KillTrees(udg_x2, udg_y2)
endfunction
Events

Time - Elapsed game time is 0.00 seconds
Conditions
Actions

-------- Initialize all values --------

-------- It's not recommended to change anything since it might cause bugs --------

Set zLoc = (Point(0.00, 0.00))

Set PathCheckRegion = (Region(-128.00, -128.00, 128.00, 128.00))

-------- But you will probably have to change this unit to any other unit with the harvest ability in case you removed it from the peasant --------

Unit - Create 1 Peasant for Neutral Passive at zLoc facing 0.00 degrees

Unit - Hide (Last created unit)

Unit - Make (Last created unit) Invulnerable

Set harvester = (Last created unit)

Item - Create Cheese at zLoc

Item - Hide (Last created item)

Set pathitem = (Last created item)

Item - Create Cheese at zLoc

Item - Hide (Last created item)

Set pathitem2 = (Last created item)

Custom script: call DestroyGroup(udg_HellCircle_Dummys[1])

Custom script: call DestroyGroup(udg_HellCircle_Hit[1])

Custom script: set udg_HellCircle_Dummys[1] = null

Custom script: set udg_HellCircle_Hit[1] = null
Events

Unit - A unit Starts the effect of an ability
Conditions

(Ability being cast) Equal to Hell Circle
Actions

Set HellCircle_Max = (HellCircle_Max + 1)

-------- Caster --------

Set HellCircle_Caster[HellCircle_Max] = (Triggering unit)

-------- Rotaton speed per 0.03 second --------

Set HellCircle_Data[(HellCircle_Max x 11)] = 5.00

-------- Current duration --------

Set HellCircle_Data[((HellCircle_Max x 11) + 2)] = 0.00

-------- Max duration --------

Set HellCircle_Data[((HellCircle_Max x 11) + 3)] = (((Real((Level of (Ability being cast) for HellCircle_Caster[HellCircle_Max]))) x 5.00) + 5.00)

-------- Inner AoE --------

Set HellCircle_Data[((HellCircle_Max x 11) + 4)] = 400.00

-------- Medium AoE --------

Set HellCircle_Data[((HellCircle_Max x 11) + 5)] = 500.00

-------- Outer AoE --------

Set HellCircle_Data[((HellCircle_Max x 11) + 6)] = 600.00

-------- Number of rotating dummys --------

Set HellCircle_Data[((HellCircle_Max x 11) + 7)] = 15.00

-------- Damage on hit --------

Set HellCircle_Data[((HellCircle_Max x 11) + 8)] = (((Real((Level of (Ability being cast) for HellCircle_Caster[HellCircle_Max]))) x 50.00) + 50.00)

-------- Trees hit --------

Set HellCircle_Data[((HellCircle_Max x 11) + 9)] = 0.00

-------- Damage per tree --------

Set HellCircle_Data[((HellCircle_Max x 11) + 10)] = (((Real((Level of (Ability being cast) for HellCircle_Caster[HellCircle_Max]))) x 0.50) + 1.00)

Trigger - Turn on Hell Circle Loop <gen>
Events

Time - Every 0.03 seconds of game time
Conditions

(Max Y of (Playable map area)) Greater than or equal to 10.00
Actions

For each (Integer i) from 1 to HellCircle_Max, do (Actions)


Loop - Actions



-------- Save the caster in a non-array variable so the unit will be loaded faster --------



Set u = HellCircle_Caster[i]



-------- Save the coordinates --------



Custom script: set udg_x = GetUnitX(udg_u)



Custom script: set udg_y = GetUnitY(udg_u)



-------- Move a location to the position of the caster so I can enumerate the units within range --------



Custom script: call MoveLocation(udg_zLoc, udg_x, udg_y)



-------- Increase duration by 0.03 --------



Set HellCircle_Data[((i x 11) + 2)] = (HellCircle_Data[((i x 11) + 2)] + 0.03)



If (All Conditions are True) then do (Then Actions) else do (Else Actions)




If - Conditions





(Life of u) Greater than 0.40





x Less than ((Max X of (Playable map area)) - HellCircle_Data[((i x 11) + 6)])





y Less than ((Max Y of (Playable map area)) - HellCircle_Data[((i x 11) + 6)])





x Greater than ((Min X of (Playable map area)) + HellCircle_Data[((i x 11) + 6)])





y Greater than ((Min Y of (Playable map area)) + HellCircle_Data[((i x 11) + 6)])





HellCircle_Data[((i x 11) + 2)] Less than HellCircle_Data[((i x 11) + 3)]




Then - Actions





-------- If it's the first run of the current spell instance a bunch of variables and dummys will be created as well as a floating text --------





Custom script: if udg_HellCircle_Dummys[udg_i] == null then





Custom script: set udg_HellCircle_Dummys[udg_i] = CreateGroup()





Custom script: set udg_HellCircle_Hit[udg_i] = CreateGroup()





Floating Text - Create floating text that reads 0 above u with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency





Set HellCircle_Text[i] = (Last created floating text)





Unit - Create (Integer(HellCircle_Data[((i x 11) + 7)])) HellCircle_Dummy for (Owner of HellCircle_Caster[i]) at zLoc facing 0.00 degrees





Unit Group - Add all units of (Last created unit group) to HellCircle_Dummys[i]





Custom script: endif





-------- Pick all valid units within the outer AoE and check if they should be knocked back in or out of the circle --------





Custom script: set bj_wantDestroyGroup = true





Unit Group - Pick every unit in (Units within HellCircle_Data[((i x 11) + 6)] of zLoc matching ((((Matching unit) belongs to an enemy of (Owner of u)) Equal to True) and ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is A flying unit) Equal to False) and (((Life o and do (Actions)






Loop - Actions







Custom script: set udg_x2 = GetUnitX(GetEnumUnit())







Custom script: set udg_y2 = GetUnitY(GetEnumUnit())







-------- Calculate distance --------







Set r = (Square root((((x - x2) x (x - x2)) + ((y - y2) x (y - y2)))))







If (All Conditions are True) then do (Then Actions) else do (Else Actions)








If - Conditions









r Greater than HellCircle_Data[((i x 11) + 5)]








Then - Actions









-------- Calculate angle between caster and picked unit --------









Custom script: set udg_a = Atan2(udg_y2 - udg_y, udg_x2 - udg_x)









-------- And set the new coordinates to the coordinates of the caster + the distance between them + 17 --------









-------- Units can't move faster then 522 without triggers which are 15-16 per 0.03 seconds so 17 should prevent any running unit from passing through the ring --------









Custom script: set udg_x2 = udg_x + Cos(udg_a) * (udg_r + 17)









Custom script: set udg_y2 = udg_y +Sin(udg_a) * (udg_r + 17)









-------- If the new position is pathable it will be applied --------









Custom script: if IsPathable(udg_x2, udg_y2) then









Custom script: call SetUnitX(GetEnumUnit(), udg_x2)









Custom script: call SetUnitY(GetEnumUnit(), udg_y2)









Custom script: endif









Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl









Special Effect - Destroy (Last created special effect)









-------- If they are hit the first time they will be damaged --------









If (All Conditions are True) then do (Then Actions) else do (Else Actions)










If - Conditions











((Picked unit) is in HellCircle_Hit[i]) Equal to False










Then - Actions











Unit - Cause u to damage (Picked unit), dealing HellCircle_Data[((i x 11) + 8)] damage of attack type Spells and damage type Normal











Unit Group - Add (Picked unit) to HellCircle_Hit[i]










Else - Actions








Else - Actions









If (All Conditions are True) then do (Then Actions) else do (Else Actions)










If - Conditions











r Greater than HellCircle_Data[((i x 11) + 4)]










Then - Actions











Custom script: set udg_a = Atan2(udg_y2 - udg_y, udg_x2 - udg_x)











Custom script: set udg_x2 = udg_x + Cos(udg_a) * (udg_r - 17)











Custom script: set udg_y2 = udg_y +Sin(udg_a) * (udg_r - 17)











Custom script: if IsPathable(udg_x2, udg_y2) then











Custom script: call SetUnitX(GetEnumUnit(), udg_x2)











Custom script: call SetUnitY(GetEnumUnit(), udg_y2)











Custom script: endif











Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl











Special Effect - Destroy (Last created special effect)











If (All Conditions are True) then do (Then Actions) else do (Else Actions)












If - Conditions













((Picked unit) is in HellCircle_Hit[i]) Equal to False












Then - Actions













Unit - Cause u to damage (Picked unit), dealing HellCircle_Data[((i x 11) + 8)] damage of attack type Spells and damage type Normal













Unit Group - Add (Picked unit) to HellCircle_Hit[i]












Else - Actions










Else - Actions





Set HellCircle_Data[((i x 11) + 1)] = (HellCircle_Data[((i x 11) + 1)] + HellCircle_Data[(i x 11)])





Set r = HellCircle_Data[((i x 11) + 5)]





Set a = HellCircle_Data[((i x 11) + 1)]





-------- Rotate dummys --------





Custom script: call ForGroup(udg_HellCircle_Dummys[udg_i], function HellCircle_MoveDummys)





-------- Change text to current number of destroyed trees and move it above the caster --------





Custom script: call SetTextTagPosUnit(udg_HellCircle_Text[udg_i], udg_u, 0)





Custom script: call SetTextTagText(udg_HellCircle_Text[udg_i], I2S(R2I(udg_HellCircle_Data[udg_i*11+9])), 0.023)





-------- Hide texttag for players unable to see the caster --------





Custom script: if IsUnitVisible(udg_u, GetLocalPlayer()) then





Custom script: call SetTextTagVisibility(udg_HellCircle_Text[udg_i], true)





Custom script: else





Custom script: call SetTextTagVisibility(udg_HellCircle_Text[udg_i], false)





Custom script: endif




Else - Actions





-------- The following is a little complicated cause I tried to prevent most leaks caused by Blizzard's "Pick every Unit within range" function --------





-------- However it's the same as any other indexing clearup --------





Set HellCircle_Caster[i] = HellCircle_Caster[HellCircle_Max]





Custom script: set bj_wantDestroyGroup = true





Unit Group - Pick every unit in (Units within HellCircle_Data[((i x 11) + 6)] of zLoc matching ((((Matching unit) belongs to an enemy of (Owner of u)) Equal to True) and ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is A flying unit) Equal to False) and (((Life o and do (Actions)






Loop - Actions







Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Weapons\DemolisherFireMissile\DemolisherFireMissile.mdl







Special Effect - Destroy (Last created special effect)







Unit - Cause u to damage (Picked unit), dealing (HellCircle_Data[((i x 11) + 9)] x HellCircle_Data[((i x 11) + 10)]) damage of attack type Spells and damage type Normal





For each (Integer i2) from 0 to 11, do (Actions)






Loop - Actions







Set HellCircle_Data[((i x 11) + i2)] = HellCircle_Data[((HellCircle_Max x 11) + i2)]





Floating Text - Destroy HellCircle_Text[i]





Set HellCircle_Text[i] = HellCircle_Text[HellCircle_Max]





Custom script: set bj_wantDestroyGroup = true





Unit Group - Pick every unit in HellCircle_Dummys[i] and do (Actions)






Loop - Actions







Unit - Kill (Picked unit)







Unit Group - Remove (Picked unit) from HellCircle_Dummys[i]





Custom script: set udg_HellCircle_Dummys[udg_i] = CreateGroup()





Unit Group - Add all units of HellCircle_Dummys[HellCircle_Max] to HellCircle_Dummys[i]





Unit Group - Remove all units from HellCircle_Hit[i]





Unit Group - Add all units of HellCircle_Hit[HellCircle_Max] to HellCircle_Hit[i]





Custom script: call DestroyGroup(udg_HellCircle_Dummys[udg_HellCircle_Max])





Custom script: call DestroyGroup(udg_HellCircle_Hit[udg_HellCircle_Max])





-------- I need to null the groups cause else I won't be able to detect easily if they were destroyed or not --------





Custom script: set udg_HellCircle_Dummys[udg_HellCircle_Max] = null





Custom script: set udg_HellCircle_Hit[udg_HellCircle_Max] = null





Set HellCircle_Max = (HellCircle_Max - 1)





Set i = (i - 1)

If (All Conditions are True) then do (Then Actions) else do (Else Actions)


If - Conditions



HellCircle_Max Less than 1


Then - Actions



Trigger - Turn off (This trigger)


Else - Actions