Tom_Kazansky
--- wraith it ! ---
- Reaction score
- 157
Knockback System
by Tom_Kazansky
by Tom_Kazansky
There are many Knockback Systems but most of them are written in Jass.
I make this system because GUI is easier to understand than Jass ("easier" not "easy")
Some informations about this system:
- easy to use (well, of course) (but Romek think It isn't )
- use 1 timer (how could I use many timers, GUI )
- changeable "arguments"
- it's MUI and a "stand alone" system
The triggers:
Trigger:
- Knocback Call
- Events
- Conditions
- Actions
- Set KnockbackSys_Index = (KnockbackSys_Index + 1)
- Set KnockbackSys_Unit[KnockbackSys_Index] = KnockbackCall_Unit
- Set KnockbackSys_Dist[KnockbackSys_Index] = KnockbackCall_Dist
- Set KnockbackSys_Angle[KnockbackSys_Index] = KnockbackCall_Angle
- Set KnockbackSys_SFXPath[KnockbackSys_Index] = KnockbackCall_SFX
- Set KnockbackSys_TickCount[KnockbackSys_Index] = (Integer((KnockbackCall_Dur / 0.04)))
- Set KnockbackSys_Tick[KnockbackSys_Index] = 0
- Set KnockbackSys_Sin[KnockbackSys_Index] = (90.00 / (Real(KnockbackSys_TickCount[KnockbackSys_Index])))
- Set KnockbackSys_DestroyTree[KnockbackSys_Index] = KnockbackCall_DestroyTree
Trigger:
- Knocback Execute
- Events
- Time - Every 0.04 seconds of game time
- Conditions
- Actions
- For each (Integer KnockbackSys_Looper) from 1 to KnockbackSys_Index, do (Actions)
- Loop - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- KnockbackSys_Tick[KnockbackSys_Looper] Greater than KnockbackSys_TickCount[KnockbackSys_Looper]
- Then - Actions
- Set KnockbackSys_Index = (KnockbackSys_Index - 1)
- For each (Integer A) from KnockbackSys_Looper to KnockbackSys_Index, do (Actions)
- Loop - Actions
- Set TempInt = (Integer A)
- Set KnockbackSys_Unit[TempInt] = KnockbackSys_Unit[(TempInt + 1)]
- Set KnockbackSys_Dist[TempInt] = KnockbackSys_Dist[(TempInt + 1)]
- Set KnockbackSys_Angle[TempInt] = KnockbackSys_Angle[(TempInt + 1)]
- Set KnockbackSys_SFXPath[TempInt] = KnockbackSys_SFXPath[(TempInt + 1)]
- Set KnockbackSys_TickCount[TempInt] = KnockbackSys_TickCount[(TempInt + 1)]
- Set KnockbackSys_Tick[TempInt] = KnockbackSys_Tick[(TempInt + 1)]
- Set KnockbackSys_Sin[TempInt] = KnockbackSys_Sin[(TempInt + 1)]
- Set KnockbackSys_DestroyTree[TempInt] = KnockbackSys_DestroyTree[(TempInt + 1)]
- Loop - Actions
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- KnockbackSys_Tick[KnockbackSys_Looper] Less than or equal to KnockbackSys_TickCount[KnockbackSys_Looper]
- Then - Actions
- Set KnockbackSys_Tick[KnockbackSys_Looper] = (KnockbackSys_Tick[KnockbackSys_Looper] + 1)
- Set TempReal = (KnockbackSys_Dist[KnockbackSys_Looper] x (Sin((KnockbackSys_Sin[KnockbackSys_Looper] x (Real((KnockbackSys_Tick[KnockbackSys_Looper] - 1)))))))
- Set TempReal2 = (KnockbackSys_Dist[KnockbackSys_Looper] x (Sin((KnockbackSys_Sin[KnockbackSys_Looper] x (Real(KnockbackSys_Tick[KnockbackSys_Looper]))))))
- Set TempLoc = (Position of KnockbackSys_Unit[KnockbackSys_Looper])
- Set TempLoc2 = (TempLoc offset by (TempReal2 - TempReal) towards KnockbackSys_Angle[KnockbackSys_Looper] degrees)
- Unit - Move KnockbackSys_Unit[KnockbackSys_Looper] instantly to TempLoc2
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- KnockbackSys_DestroyTree[KnockbackSys_Looper] Equal to True
- Then - Actions
- Destructible - Pick every destructible within 200.00 of TempLoc2 and do (Actions)
- Loop - Actions
- Destructible - Kill (Picked destructible)
- Loop - Actions
- Destructible - Pick every destructible within 200.00 of TempLoc2 and do (Actions)
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- KnockbackSys_SFXPath[KnockbackSys_Looper] Not equal to <Empty String>
- Then - Actions
- Special Effect - Create a special effect at TempLoc2 using KnockbackSys_SFXPath[KnockbackSys_Looper]
- Special Effect - Destroy (Last created special effect)
- Else - Actions
- If - Conditions
- Custom script: call RemoveLocation( udg_TempLoc )
- Custom script: call RemoveLocation( udg_TempLoc2 )
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - Actions
- For each (Integer KnockbackSys_Looper) from 1 to KnockbackSys_Index, do (Actions)
- Events
Readme
Requirements:
¯¯¯¯¯¯¯¯¯¯¯¯¯
World Editor
Implementation Instructions:
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Copy and Paste the category "Knockback System"
Remember to check: File \ Preferences \ General \ Automatically create unknown variables while pasting trigger data.
How to use:
¯¯¯¯¯¯¯¯¯¯¯¯¯
To use this system, you need the following lines:
Set KnockbackCall_Unit = <unit that you want it to be knocked>
Set KnockbackCall_Dur = <total duration of knockback>
Set KnockbackCall_Dist = <distance of knockback>
Set KnockbackCall_Angle = <angle of knockback>
Set KnockbackCall_SFX = <knockback effect, put an <Empty String> if you don't want any effects to show>
Set KnockbackCall_DestroyTree = True <If you don't want to destroy trees, use "False" )
Trigger - Run Knocback Call <gen> (ignoring conditions) <- do not change this line
'KnockbackCall_Unit' will be knocked back 'KnockbackCall_Dist' over 'KnockbackCall_Dur' seconds towards 'KnockbackCall_Angle' degrees.
¯¯¯¯¯¯¯¯¯¯¯¯¯
World Editor
Implementation Instructions:
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Copy and Paste the category "Knockback System"
Remember to check: File \ Preferences \ General \ Automatically create unknown variables while pasting trigger data.
How to use:
¯¯¯¯¯¯¯¯¯¯¯¯¯
To use this system, you need the following lines:
Set KnockbackCall_Unit = <unit that you want it to be knocked>
Set KnockbackCall_Dur = <total duration of knockback>
Set KnockbackCall_Dist = <distance of knockback>
Set KnockbackCall_Angle = <angle of knockback>
Set KnockbackCall_SFX = <knockback effect, put an <Empty String> if you don't want any effects to show>
Set KnockbackCall_DestroyTree = True <If you don't want to destroy trees, use "False" )
Trigger - Run Knocback Call <gen> (ignoring conditions) <- do not change this line
'KnockbackCall_Unit' will be knocked back 'KnockbackCall_Dist' over 'KnockbackCall_Dur' seconds towards 'KnockbackCall_Angle' degrees.
Some sample spells:
Force Push:
Storm Hammer
Trigger:
- Force Push
- Events
- Unit - A unit Starts the effect of an ability
- Conditions
- (Ability being cast) Equal to Force Push
- Actions
- Set TempUnit = (Triggering unit)
- Set TempLoc = (Position of TempUnit)
- Set TempGroup = (Units within 300.00 of TempLoc matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of TempUnit)) Equal to True))))
- Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
- Special Effect - Destroy (Last created special effect)
- Unit Group - Pick every unit in TempGroup and do (Actions)
- Loop - Actions
- Set TempLoc2 = (Position of (Picked unit))
- Unit - Cause TempUnit to damage (Picked unit), dealing 100.00 damage of attack type Chaos and damage type Force
- -------- call knockback --------
- Set KnockbackCall_Unit = (Picked unit)
- Set KnockbackCall_Dur = 0.80
- Set KnockbackCall_Dist = (500.00 - (Distance between TempLoc and TempLoc2))
- Set KnockbackCall_Angle = (Angle from TempLoc to TempLoc2)
- Set KnockbackCall_SFX = Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
- Set KnockbackCall_DestroyTree = True
- Trigger - Run Knocback Call <gen> (ignoring conditions)
- -------- --- done --- --------
- Custom script: call RemoveLocation( udg_TempLoc2 )
- Loop - Actions
- Custom script: call DestroyGroup( udg_TempGroup )
- Custom script: call RemoveLocation( udg_TempLoc )
- Events
Storm Hammer
Trigger:
- Storm Hammer
- Events
- Unit - A unit Is attacked
- Conditions
- (Level of Storm Hammers for (Attacking unit)) Greater than 0
- (Random integer number between 1 and 100) Less than or equal to 20
- Actions
- Set TempUnit = (Attacking unit)
- Set TempUnit2 = (Attacked unit)
- Set TempLoc = (Position of TempUnit)
- Set TempLoc2 = (Position of TempUnit2)
- Animation - Play TempUnit's Attack Slam animation
- Unit - Cause TempUnit to damage TempUnit2, dealing 50.00 damage of attack type Chaos and damage type Force
- -------- call knockback --------
- Set KnockbackCall_Unit = TempUnit2
- Set KnockbackCall_Dur = 1.00
- Set KnockbackCall_Dist = 300.00
- Set KnockbackCall_Angle = (Angle from TempLoc to TempLoc2)
- Set KnockbackCall_SFX = Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
- Set KnockbackCall_DestroyTree = True
- Trigger - Run Knocback Call <gen> (ignoring conditions)
- -------- --- done --- --------
- Custom script: call RemoveLocation( udg_TempLoc )
- Custom script: call RemoveLocation( udg_TempLoc2 )
- Events
Credits are not needed, but appreciated.
---
(+rep are also appreciated )
--------------
Enjoy ! :thup: