[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Spells


Reply
 
Thread Tools
The Hive Workshop Spells:
Knockback 2D
by Bribe
Images
Highslide JS
Details
Uploaded:07:35, 5th Sep 2011
Last Updated:12:33, 9th Sep 2011
Keywords:Knockback, Berb, Berbanog, Unit Indexer
Type:System
Category:GUI / Triggers

Knockback 2D will knock a unit back, without interrupting orders, while
also considering pathing checks for different collision sizes. It destroys
trees and debris without destroying bridges (will be an environmentally-
friendly version hopefully coming soon).

You specify the speed of the knockback indirectly by giving it a distance
to travel and a time to travel it within. This is based on Berb's Knockback
Lite.

If the unit hits impassible terrain, it will "bounce" in a form of geometric
deflection angle. If you have any comments on how realistic this looks
or if you think I could do more with it, let me know.

The demo map features a template where you can add on-loop behavior,
I have already made an add-on which does special effects at random. &
another add-on that makes other units that come close to the knockback
unit to also get knocked back.

It is in GUI, meaning it is World Editor friendly. I hope that it is also easy
to understand how it works as the variables are pretty straightforward:
A unit to knock back, an angle (in degrees) to knock it back, a distance it
will travel and a length of time to complete the travel within.

How to install
  1. Copy the Unit Indexer and Knockback 2D triggers into your map.
  2. Copy the abilities from the map "Pathing Checker" and "Debris Checker"
  3. Set those abilities to the variables "K2DPathAbil" and "K2DDebrisAbil" in
    the Knockback 2D trigger.
  4. I have set the "Pathing Checker" ability to check the pathing of units with
    various collision sizes (16, 32, 48, 64), and have assigned different ability
    levels to built-in units in the game that have those collision sizes. If you've
    changed the collision size of those units please change the ability's units to
    ones that have those proper collision sizes.
  5. There are two dummy units created in the Knockback 2D trigger, set the
    unit types of each to whatever the dummy caster in your map is (or copy
    the dummy caster from the demo map).


System
Knockback 2D
Events
Map initialization
Conditions
Actions
-------- --------
-------- Set the timeout to be used throughout the system --------
-------- --------
Set K2DTimeout = 0.03
-------- --------
-------- Create dummy casters to check pathing throughout the game --------
-------- --------
Set CenterPoint = (Point(TempX, TempY))
Set UnitIndexerEnabled = False
Unit - Create 1 Dummy (Vexorian, Anitarf, Infrane) for Neutral Passive at CenterPoint facing 0.00 degrees
Set K2DCaster = (Last created unit)
Unit - Create 1 Dummy (Vexorian, Anitarf, Infrane) for Neutral Passive at CenterPoint facing 0.00 degrees
Set K2DClearer = (Last created unit)
Set UnitIndexerEnabled = True
Custom script: call RemoveLocation(udg_CenterPoint)
-------- --------
-------- Add a custom "Inferno" to it to check for pathing --------
-------- --------
Set K2DPathAbil = Pathing Checker
Unit - Add K2DPathAbil to K2DCaster
-------- --------
-------- Add a custom "flame strike" to destroy debris / trees in the area --------
-------- --------
Set K2DDebrisAbil = Debris Killer
Unit - Add K2DDebrisAbil to K2DClearer
-------- --------
Custom script: call ExecuteFunc("InitKnockback2D")
Custom script: endfunction
-------- --------
-------- This function destroys any knockback, you can call it yourself via ExecuteFunc("DestroyKnockback2D") --------
-------- --------
Custom script: function DestroyKnockback2D takes nothing returns nothing
Set IsUnitBeingKnockedBack[UDex] = False
Set K2DNext[K2DPrev[UDex]] = K2DNext[UDex]
Set K2DPrev[K2DNext[UDex]] = K2DPrev[UDex]
Set K2DPrev[UDex] = 0
Custom script: endfunction
-------- --------
-------- In case a unit is being knocked back while deindexed (very rare), destroy the knockback --------
-------- --------
Custom script: function DestroyKnockback2DProxy takes nothing returns boolean
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
IsUnitBeingKnockedBack[UDex] Equal to True
Then - Actions
Custom script: call DestroyKnockback2D()
Else - Actions
Custom script: return false
Custom script: endfunction
-------- --------
-------- Set the sine and cosine to a new angle --------
-------- --------
Custom script: function Knockback2DApplyAngle takes nothing returns nothing
Set K2DCos[UDex] = (Cos(K2DAngle[UDex]))
Set K2DSin[UDex] = (Sin(K2DAngle[UDex]))
Custom script: endfunction
-------- --------
-------- Check if a point is pathable --------
-------- --------
Custom script: function Knockback2DCheckXY takes real x, real y returns boolean
Custom script: set udg_TempX = x + udg_K2DVelocity[udg_UDex] * udg_K2DCos[udg_UDex]
Custom script: set udg_TempY = y + udg_K2DVelocity[udg_UDex] * udg_K2DSin[udg_UDex]
Custom script: return IssuePointOrderById(udg_K2DCaster, 0xD0100, udg_TempX, udg_TempY)
Custom script: endfunction
-------- --------
-------- This function is run each time you execute this trigger --------
-------- --------
Custom script: function Knockback2DSetup takes nothing returns nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Default movement speed of Knockback2DUnit) Not equal to 0.00
(Knockback2DUnit is A flying unit) Equal to False
Then - Actions
Set UDex = (Custom value of Knockback2DUnit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
IsUnitBeingKnockedBack[UDex] Not equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
K2DNext[0] Equal to 0
Then - Actions
Countdown Timer - Resume K2DTimer
Else - Actions
Set IsUnitBeingKnockedBack[UDex] = True
Set K2DPrev[K2DNext[0]] = UDex
Set K2DNext[UDex] = K2DNext[0]
Set K2DNext[0] = UDex
Else - Actions
Set K2DAngle[UDex] = Knockback2DAngle
Custom script: call Knockback2DApplyAngle()
Set K2DTimeLeft[UDex] = Knockback2DTime
Set K2DVelocity[UDex] = ((Knockback2DDistance / Knockback2DTime) x (K2DTimeout x 2.00))
Set K2DFriction[UDex] = ((K2DVelocity[UDex] / Knockback2DTime) x (K2DTimeout x K2DTimeout))
-------- --------
-------- Handle the pathing checker based on the unit's collision size --------
-------- --------
Custom script: set udg_TempX = GetUnitX(udg_Knockback2DUnit)
Custom script: set udg_TempY = GetUnitY(udg_Knockback2DUnit)
Custom script: if not IsUnitInRangeXY(udg_Knockback2DUnit, udg_TempX + 17, udg_TempY, 0) then
Set K2DRadius[UDex] = 1
Custom script: elseif not IsUnitInRangeXY(udg_Knockback2DUnit, udg_TempX + 33, udg_TempY, 0) then
Set K2DRadius[UDex] = 2
Custom script: elseif not IsUnitInRangeXY(udg_Knockback2DUnit, udg_TempX + 49, udg_TempY, 0) then
Set K2DRadius[UDex] = 3
Custom script: else
Set K2DRadius[UDex] = 4
Custom script: endif
Else - Actions
Custom script: endfunction
-------- --------
-------- This function is run periodically to update the movement of units --------
-------- --------
Custom script: function Knockback2DLooper takes nothing returns nothing
Custom script: local real x
Custom script: local real y
Unit - Unpause K2DCaster
Set UDex = K2DNext[0]
Custom script: loop
Custom script: exitwhen udg_UDex == 0
Set K2DTimeLeft[UDex] = (K2DTimeLeft[UDex] - K2DTimeout)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
K2DTimeLeft[UDex] Greater than 0.00
Then - Actions
Set TempUnit = UDexUnits[UDex]
Set K2DVelocity[UDex] = (K2DVelocity[UDex] - K2DFriction[UDex])
Custom script: set x = GetUnitX(udg_UDexUnits[udg_UDex])
Custom script: set y = GetUnitY(udg_UDexUnits[udg_UDex])
Unit - Set level of K2DPathAbil for K2DCaster to K2DRadius[UDex]
Custom script: if not Knockback2DCheckXY(x, y) then
Set K2DAngle[UDex] = (360.00 - K2DAngle[UDex])
Custom script: call Knockback2DApplyAngle()
Custom script: if not Knockback2DCheckXY(x, y) then
Set K2DAngle[UDex] = ((K2DAngle[UDex] + 180.00) mod 360.00)
Custom script: call Knockback2DApplyAngle()
Custom script: if not Knockback2DCheckXY(x, y) then
Set K2DAngle[UDex] = (360.00 - K2DAngle[UDex])
Custom script: call Knockback2DApplyAngle()
Custom script: set udg_TempX = x
Custom script: set udg_TempY = y
Custom script: endif
Custom script: endif
Custom script: endif
Custom script: call SetUnitX(udg_TempUnit, udg_TempX)
Custom script: call SetUnitY(udg_TempUnit, udg_TempY)
Else - Actions
-------- --------
-------- The knockback has finished --------
-------- --------
Custom script: call DestroyKnockback2D()
Set UDex = K2DNext[UDex]
Custom script: endloop
-------- --------
-------- Disable the dummy caster after the loop finishes so that it doesn't interfere with the map --------
-------- --------
Unit - Pause K2DCaster
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
K2DNext[0] Not equal to 0
Then - Actions
Set K2Dex = K2DNext[K2Dex]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
K2Dex Equal to 0
Then - Actions
Set K2Dex = K2DNext[0]
Else - Actions
Unit - Set level of K2DDebrisAbil for K2DClearer to K2DRadius[K2Dex]
Custom script: call IssuePointOrderById(udg_K2DClearer, 0xD0208, GetUnitX(udg_UDexUnits[udg_K2Dex]), GetUnitY(udg_UDexUnits[udg_K2Dex]))
Countdown Timer - Resume K2DTimer
Else - Actions
-------- --------
-------- If the list is empty, don't resume the timer --------
-------- --------
Custom script: endfunction
-------- --------
-------- Initialize it all --------
-------- --------
Custom script: function InitKnockback2D takes nothing returns nothing
Custom script: local trigger t = GetTriggeringTrigger()
Custom script: call TriggerClearActions(t)
Custom script: call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 2)
Custom script: call TriggerAddCondition(t, Filter(function DestroyKnockback2DProxy))
Custom script: call TriggerAddAction(t, function Knockback2DSetup)
Custom script: set t = null
Custom script: call UnitRemoveAbility(udg_K2DCaster, 'Amov')
Custom script: call UnitRemoveAbility(udg_K2DClearer, 'Amov')
Custom script: call TimerStart(udg_K2DTimer, udg_K2DTimeout, false, function Knockback2DLooper)
Countdown Timer - Pause K2DTimer


Changelog
  • 1.0.0.0 - Release
  • 1.0.0.1 - Changed IssuePointOrder to IssuePointOrderById.
    Now uses 1 trigger instead of 2.
  • 1.1.0.0 - Added a "bounce" functionality to the knockback.
    Made an add-on to support knocking back adjecent units (collateral knockback)
Rating - 4.80 (5 votes)
(Hover and click)
Moderator Comments
Recommended
14:30, 9th Sep 2011
The_Reborn_Devil:

Everything looks nice and this system should be easy to use for GUI users.
This system deprecates Paladon's Knockback System.

This spell is approved and works properly.


Download Knockback.w3x
(48.8 KB, 1153 Downloads)

Old 09-05-2011, 08:18 AM   #2 (permalink)
Registered User Zaio
Aspiring JASS coder
 
Zaio's Avatar
 
Join Date: Jul 2011
Posts: 260
Zaio has little to show at this moment (40)Zaio has little to show at this moment (40)Zaio has little to show at this moment (40)Zaio has little to show at this moment (40)Zaio has little to show at this moment (40)
Wow, looks nice as always Bribe, gj.
Zaio is offline   Reply With Quote
Old 09-05-2011, 09:33 AM   #3 (permalink)
Registered User Foxhound03
Hive Abysswalker
 
Foxhound03's Avatar
 
Join Date: Dec 2010
Posts: 335
Foxhound03 has little to show at this moment (27)Foxhound03 has little to show at this moment (27)Foxhound03 has little to show at this moment (27)
Nice
5/5 +REP
__________________

Sig By dragonson
Foxhound03 is offline   Reply With Quote
Old 09-05-2011, 11:30 AM   #4 (permalink)
Registered User Deuterium
-
 
Deuterium's Avatar
 
Join Date: Mar 2009
Posts: 1,981
Deuterium is a name known to all (667)Deuterium is a name known to all (667)Deuterium is a name known to all (667)
If there's someone who makes GUI awesome, it's Bribe :)
__________________
Deuterium is offline   Reply With Quote
Old 09-05-2011, 01:56 PM   #5 (permalink)
Forum Moderator Magtheridon96
JESUS MAN
 
Magtheridon96's Avatar
Resource Moderator
 
Join Date: Dec 2008
Posts: 5,700
Magtheridon96 has a brilliant future (1809)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. 
GUI? lol

Looks good :)
I like how you used the flamestrike ability to only kill trees but not bridges.

5/5 Bro :)
__________________
Magtheridon96 is offline   Reply With Quote
Old 09-05-2011, 02:08 PM   #6 (permalink)
Registered User maddeem
moo moo
 
maddeem's Avatar
 
Join Date: Jan 2011
Posts: 1,047
maddeem is a jewel in the rough (228)maddeem is a jewel in the rough (228)maddeem is a jewel in the rough (228)
^ just change the bridge to targeted as invul =p
Anyway, you have yet again made something useful for the guiers... Don't really feel like playing with it now, 4/5 until I do =p
__________________
maddeem is offline   Reply With Quote
Old 09-05-2011, 02:26 PM   #7 (permalink)
Registered User Jay the Editor
Practice makes better
 
Jay the Editor's Avatar
 
Join Date: Aug 2008
Posts: 430
Jay the Editor is on a distinguished road (70)Jay the Editor is on a distinguished road (70)
Best of the best! :DD
Jay the Editor is offline   Reply With Quote
Old 09-05-2011, 02:36 PM   #8 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
You can still "kill" an invulnerable destructable using that kill destructable
command, but not only that the user would have to manually change the
status of all bridges in the map, rather than letting this system just auto-
matically filter them.

If you look at Paladon's Knockback, currently the most widely used knock-
back for GUI, it is horribly coded and if you set "destroy trees" to true it
will kill bridges. I am thinking of rejecting that resource as this does the
same thing but is much much more efficient at it and doesn't have nearly
the same number of bugs.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline   Reply With Quote
Old 09-05-2011, 02:46 PM   #9 (permalink)
Registered User Deuterium
-
 
Deuterium's Avatar
 
Join Date: Mar 2009
Posts: 1,981
Deuterium is a name known to all (667)Deuterium is a name known to all (667)Deuterium is a name known to all (667)
Agree with you Bribe according to Paladon's system... it used to be the best available systems at it's time but now we've got this one I'm guessing people shouldn't be using his anymore :/
__________________
Deuterium is offline   Reply With Quote
Old 09-05-2011, 03:23 PM   #10 (permalink)
Registered User zv27
The real me RnR forever
 
zv27's Avatar
 
Join Date: Aug 2010
Posts: 236
zv27 has disabled reputation
Not bad, but for my own part jass version is much more efficient and, most importantly, a much simpler.
Anyway,this was done perfectly.5/5
And remember,BEAUTY IS IN SIMPLICITY!!!
zv27 is offline   Reply With Quote
Old 09-05-2011, 03:26 PM   #11 (permalink)
Registered User Spinnaker
Till I Collapse
 
Spinnaker's Avatar
 
Join Date: Mar 2008
Posts: 2,180
Spinnaker is a name known to all (612)
PayPal Donor: This user has donated to The Hive. Hero Contest #4: Narght the Night Stalker 
Personaly I wasn't using Paladon's knockback since it's ugly ;/ I have created my own which works much similar (not as effecient as Bribe's tho) to this one with SetUnitX/Y usage too.

@Bribe it would be nice if you add Parabola Knockback option - meaning knockback in the air. I know that such thing should be map related-only but it's always nice stuff to have.

I'm always using 'flying-knockback' to be honest, classic one tends to be boring :S
__________________
Quote:
Orginally Posted by leviathan221
Where is gui?

Orginally Posted by tobi3234
i dont use vJass, GUI or anything else.. so a need a trigger without using of them.
Spinnaker is offline   Reply With Quote
Old 09-05-2011, 03:30 PM   #12 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
That's why I named this Knockback 2D, because I plan to release
a Knockback 3D at some point :P

@ zv27, what knockback are you referring to? This code does better
than any knockback I've seen in regards to handling collision sizes.
For example, Berb's Knockback Lite, where I got the formulas from,
uses an item to check for pathing which is limited to size 16 collision
and will therefore throw units into impassible terrain much of the
time. This system needs to be more complex than his in order to
avert the bugginess.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline   Reply With Quote
Old 09-05-2011, 03:32 PM   #13 (permalink)
Registered User Spinnaker
Till I Collapse
 
Spinnaker's Avatar
 
Join Date: Mar 2008
Posts: 2,180
Spinnaker is a name known to all (612)
PayPal Donor: This user has donated to The Hive. Hero Contest #4: Narght the Night Stalker 
I was looking for the irony in 2D. Sad that you didn't give me enought time to catch up the idea behind it :S

I'm pretty sure that you know about D4RK_Gandalf's movement tutorial. GUI parabola template there, since jass one you know on heart ;P
__________________
Quote:
Orginally Posted by leviathan221
Where is gui?

Orginally Posted by tobi3234
i dont use vJass, GUI or anything else.. so a need a trigger without using of them.
Spinnaker is offline   Reply With Quote
Old 09-05-2011, 03:53 PM   #14 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
I'm curious how you have designed your flying knockback in the
past, because currently we'd be looking at a lot of instances where
units could get stuck in a hard-to-reach spot.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline   Reply With Quote
Old 09-05-2011, 04:01 PM   #15 (permalink)
Registered User Spinnaker
Till I Collapse
 
Spinnaker's Avatar
 
Join Date: Mar 2008
Posts: 2,180
Spinnaker is a name known to all (612)
PayPal Donor: This user has donated to The Hive. Hero Contest #4: Narght the Night Stalker 
What do you exactly mean? The pathability-checking? Items should help you with such issue.
__________________
Quote:
Orginally Posted by leviathan221
Where is gui?

Orginally Posted by tobi3234
i dont use vJass, GUI or anything else.. so a need a trigger without using of them.
Spinnaker is offline   Reply With Quote
Reply

Bookmarks

Tags
berb, berbanog, bounce, collision, knockback, spinnaker

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 04:46 AM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle