Moderator
M
Moderator
11:38, 2nd Mar 2010
TriggerHappy:
Cool effect, good coding.
TriggerHappy:
Cool effect, good coding.
Events

Map initialization
Conditions
Actions

-------- Initialize the used hashtable and a dummy to check if a destructable is a tree --------

Hashtable - Create a hashtable

Set Hook_Hashtable = (Last created hashtable)

Set loc = (Point(0.00, 0.00))

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

Unit - Hide (Last created unit)

Unit - Make (Last created unit) Invulnerable

Set harvester = (Last created unit)

Custom script: call RemoveLocation(udg_loc)
Events

Unit - A unit Starts the effect of an ability
Conditions

(Ability being cast) Equal to Bane Web
Actions

-------- WARNING! --------

-------- This spell is extremely complex so you should not change anything besides the values marked with XXXXX/YYYYY unless you've got an advanced understanding of GUI --------

-------- This trigger picks 10 units within range and creates a hook for every one of them --------

Set i2 = 0

-------- XXXXXXXXXX --------

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

Set u = (Triggering unit)

-------- YYYYYYYYYY --------

Set loc = (Position of u)

Custom script: set bj_wantDestroyGroup = true

-------- XXXXXXXXXX --------

-------- 500 + 100 per Level = Distance --------

Unit Group - Pick every unit in (Units within (500.00 + (100.00 x (Real((Level of (Ability being cast) for u))))) of loc matching ((((((Matching unit) is Magic Immune) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of u)) Equal to True)) and (((Matching unit) is A flyin and do (Actions)


Loop - Actions



-------- 10 = maximum of targeted units --------



-------- This is very useful if your pc sucks and you want to save performance --------



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




If - Conditions





i2 Equal to 10




Then - Actions





-------- YYYYYYYYYY --------





Skip remaining actions




Else - Actions



-------- Create the first hook segment facing its target and adding it to a group --------



Set loc2 = (Position of (Picked unit))



Set a = (Angle from loc to loc2)



Custom script: call RemoveLocation( udg_loc2)



Unit - Create 1 Hook_Dummy for (Owner of u) at loc facing a degrees



Animation - Change (Last created unit) flying height to 75.00 at 0.00



Unit Group - Add (Last created unit) to Hook_Heads



-------- An expiration timer to remove dummys if the caster got removed from the game somehow --------



Unit - Add a 20.00 second Generic expiration timer to (Last created unit)



Set i = (Key (Last created unit))



-------- XXXXXXXXXX --------



-------- Save target --------



Hashtable - Save Handle Of(Picked unit) as i of 0 in Hook_Hashtable



-------- Save caster --------



Hashtable - Save Handle Ofu as i of 1 in Hook_Hashtable



-------- Shoot speed --------



Hashtable - Save 15.00 as 2 of i in Hook_Hashtable



-------- Distance between each segment --------



-------- Increasing this is also a very useful way to increase performance --------



-------- If it looks ugly just increase the units scaling size --------



Hashtable - Save 50.00 as 3 of i in Hook_Hashtable



-------- Return Speed --------



Hashtable - Save 17.00 as 4 of i in Hook_Hashtable



-------- Pull Damage --------



Hashtable - Save ((30.00 + (15.00 x (Real((Level of (Ability being cast) for u))))) / 33.00) as 5 of i in Hook_Hashtable



-------- Impact Damage --------



Hashtable - Save (50.00 + (25.00 x (Real((Level of (Ability being cast) for u))))) as 6 of i in Hook_Hashtable



-------- YYYYYYYYYY --------



Set i2 = (i2 + 1)

Custom script: call RemoveLocation( udg_loc )

-------- run --------

Trigger - Turn on HookLoop <gen>
Events

Time - Every 0.03 seconds of game time
Conditions
Actions

-------- WARNING! --------

-------- You should not modify anything of this trigger unless you know what you are doing --------

-------- Real values --------

-------- 0 of i: max number of segments --------

-------- 1 of i: 0 = hook is moving twords target; 1 = hook is returning --------

-------- 2 of i: shoot speed --------

-------- 3 of i: distance between segments --------

-------- 4 of i: return speed --------

-------- 5 of i: pull dmg --------

-------- 6 of i: impact dmg --------

-------- Integers --------

-------- i: id of the Picked Unit --------

-------- i2: array slot for hook segments --------

-------- Units --------

-------- i of 0: target --------

-------- i of 1: caster --------

-------- Picked Unit (same as GetEnumUnit()): first hook segment --------

-------- i2 of i: array containing all hook segments --------

-------- Description --------

-------- The first half of the trigger moves the first segment towards the target until it reaches it and creates new segments to fill the gap between the caster and the last segment --------

-------- The second half moves them back to the caster and kills them if they come too close and moves the target with them --------

Unit Group - Pick every unit in Hook_Heads and do (Actions)


Loop - Actions



Set i = (Key (Picked unit))



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




If - Conditions





(Load 1 of i from Hook_Hashtable) Equal to 0




Then - Actions





-------- This basicly is the same as "Move unit to (position of this unit) offset by (distance) towards (angle between this unit and the target)" --------





-------- Except this is enhanced with JASS --------





Set r = (Load 2 of i from Hook_Hashtable)





Set u = (Load i of 0 in Hook_Hashtable)





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





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





Custom script: set udg_x2 = GetUnitX(udg_u)





Custom script: set udg_y2 = GetUnitY(udg_u)





Set a = (Atan2((y2 - y), (x2 - x)))





Set x = (x + ((Cos(a)) x r))





Set y = (y + ((Sin(a)) x r))





Custom script: call SetUnitFacing(GetEnumUnit(), udg_a)





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






If - Conditions







4096.00 Less than (((x - x2) x (x - x2)) + ((y - y2) x (y - y2)))






Then - Actions







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







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







Set r = (Load 3 of i from Hook_Hashtable)







For each (Integer i2) from 1 to (Load 0 of i from Hook_Hashtable), do (Actions)








Loop - Actions









Set u = (Load i2 of i in Hook_Hashtable)









Custom script: set udg_x2 = GetUnitX(udg_u)









Custom script: set udg_y2 = GetUnitY(udg_u)









Set a = (Atan2((y - y2), (x - x2)))









Set x = (x - ((Cos(a)) x r))









Set y = (y - ((Sin(a)) x r))









Custom script: call SetUnitX(udg_u, udg_x)









Custom script: call SetUnitY(udg_u, udg_y)









Custom script: call SetUnitFacing(udg_u, udg_a)







Set u = (Load i of 1 in Hook_Hashtable)







Custom script: set udg_x2 = GetUnitX(udg_u)







Custom script: set udg_y2 = GetUnitY(udg_u)







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








If - Conditions









4096.00 Less than (((x - x2) x (x - x2)) + ((y - y2) x (y - y2)))








Then - Actions









-------- Create new segment --------









Custom script: set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(GetEnumUnit()), GetUnitTypeId(GetEnumUnit()), udg_x2, udg_y2, udg_a)









Animation - Change (Last created unit) flying height to (Current flying height of (Picked unit)) at 0.00









-------- I don't have to increase i2 by 1 for proper indexing cause the loop does that by itself --------









Hashtable - Save i2 as 0 of i in Hook_Hashtable









Set i2 = (Key (Last created unit))









-------- Save new segment --------









Hashtable - Save Handle Of(Last created unit) as (Load 0 of i from Hook_Hashtable) of i in Hook_Hashtable








Else - Actions






Else - Actions







-------- Set state to "return target to caster" --------







Hashtable - Save 1 as 1 of i in Hook_Hashtable







-------- And save the target --------







Hashtable - Save Handle Of(Picked unit) as 0 of i in Hook_Hashtable




Else - Actions





Set r = (Load 4 of i from Hook_Hashtable)





Set u = (Load i of 1 in Hook_Hashtable)





Custom script: set udg_x = GetUnitX(udg_u)





Custom script: set udg_y = GetUnitY(udg_u)





-------- Load Number of segments --------





Set i2 = (Load 0 of i from Hook_Hashtable)





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






If - Conditions







i2 Greater than -1






Then - Actions







Set u = (Load i2 of i in Hook_Hashtable)







Custom script: set udg_x2 = GetUnitX(udg_u)







Custom script: set udg_y2 = GetUnitY(udg_u)







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








If - Conditions









4096.00 Greater than (((x - x2) x (x - x2)) + ((y - y2) x (y - y2)))








Then - Actions









-------- Reduce number of segments --------









Unit - Kill u









-------- and let the trigger know it --------









Hashtable - Save (i2 - 1) as 0 of i in Hook_Hashtable








Else - Actions







-------- Start a loop --------







Custom script: loop







-------- Loop conditions --------







Custom script: exitwhen udg_i2 == -1







-------- Beginning of loop actions --------







Set u = (Load i2 of i in Hook_Hashtable)







Custom script: set udg_x2 = GetUnitX(udg_u)







Custom script: set udg_y2 = GetUnitY(udg_u)







Set a = (Atan2((y - y2), (x - x2)))







Set x = (x2 + ((Cos(a)) x r))







Set y = (y2 + ((Sin(a)) x r))







Custom script: call SetUnitX(udg_u, udg_x)







Custom script: call SetUnitY(udg_u, udg_y)







Custom script: call SetUnitFacing(udg_u, 180+udg_a)







Set i2 = (i2 - 1)







-------- End of loop actions --------







Custom script: endloop







Set u = (Load i of 0 in Hook_Hashtable)







Unit - Cause (Load i of 1 in Hook_Hashtable) to damage u, dealing (Load 5 of i from Hook_Hashtable) damage of attack type Spells and damage type Normal







Custom script: call SetUnitX(udg_u, udg_x)







Custom script: call SetUnitY(udg_u, udg_y)







-------- Desroy trees within range --------







Set loc = (Point(x2, y2))







Destructible - Pick every destructible within 150.00 of loc and do (Actions)








Loop - Actions









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










If - Conditions











(Current life of (Picked destructible)) Greater than 0.00










Then - Actions











Unit - Order harvester to Harvest (Picked destructible)











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












If - Conditions













(Current order of harvester) Equal to (Order(harvest))












Then - Actions













Destructible - Kill (Picked destructible)












Else - Actions











Unit - Order harvester to Stop










Else - Actions






Else - Actions







-------- Damage the target --------







Unit - Cause (Load i of 1 in Hook_Hashtable) to damage (Load i of 0 in Hook_Hashtable), dealing (Load 6 of i from Hook_Hashtable) damage of attack type Spells and damage type Normal







-------- Unstuck it --------







Set u = (Load i of 0 in Hook_Hashtable)







Unit - Order u to Stop







-------- Remove any leaks --------







Unit Group - Remove (Picked unit) from Hook_Heads







Hashtable - Clear all child hashtables of child i in Hook_Hashtable

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


If - Conditions



(Hook_Heads is empty) Equal to True


Then - Actions



Trigger - Turn off (This trigger)


Else - Actions
Events

Unit - A unit Dies
Conditions

(Unit-type of (Triggering unit)) Equal to Hook_Dummy
Actions

-------- We don't want the unit but we want the death effect so we wait until the effect is over and remove the unit after that --------

Wait 2.00 game-time seconds

Unit - Remove (Triggering unit) from the game