[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:
[GUI] Simple Frictional Knockback System v1.11
Images
Highslide JS
Details
Uploaded:05:05, 21st Aug 2012
Last Updated:13:41, 27th Oct 2012
Keywords:simple, frictional, knockback, system, defskull, hashtable, force, physics, acceleration, deceleration, slowing, down, speed.
Type:System
Category:GUI / Triggers

INTRODUCTIONS
- This system allows you to apply knockback to units with a decreasing speed (deceleration).
- It would add "realistic" to the gameplay by using this simple system.
- It is in GUI !
- Will add more features, perhaps this system will change its name


HOW TO USE
External Instructions
- Open World Editor > File - Preferences... > General Tab > Tick the Automatically create unknown variables while pasting trigger data
- Copy the Simple Frictional Knockback System folder.

Internal Instructions
- There are 5 variables which you can manipulate;
* FK_KnockbackUnit - The unit that is going to be knockbacked
* FK_KnockbackAngle - The angle which the unit will be knockbacked
* FK_KnockbackFriction - The knockback friction per second
* FK_KnockbackSpeed - The knockback speed per second
* FK_KnockbackSFX - The Special Effect for the knockback (make sure that the SFX model does not has any animation duration such as; birth, stand, death, etc)

- Further instructions are inside Trigger Comments: HOW TO USE (PAGE 1 & 2)


TRIGGERS
FK Loop
Events
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(FK_Group is empty) Equal to True
Then - Actions
Trigger - Turn off (This trigger)
Else - Actions
Unit Group - Pick every unit in FK_Group and do (Actions)
Loop - Actions
Custom script: local real x
Custom script: local real y
Set FK_KnockbackUnit = (Picked unit)
Custom script: set udg_FK_Key = GetHandleId(udg_FK_KnockbackUnit)
Set FK_KnockbackSpeedPerInterval = (Load 0 of FK_Key from FK_Hashtable)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
FK_KnockbackSpeedPerInterval Greater than 0.00
Then - Actions
Set FK_KnockbackAngle = (Load 3 of FK_Key from FK_Hashtable)
Custom script: set x = GetUnitX(udg_FK_KnockbackUnit) + udg_FK_KnockbackSpeedPerInterval * Cos(udg_FK_KnockbackAngle * bj_DEGTORAD)
Custom script: set y = GetUnitY(udg_FK_KnockbackUnit) + udg_FK_KnockbackSpeedPerInterval * Sin(udg_FK_KnockbackAngle * bj_DEGTORAD)
Custom script: call SetUnitX(udg_FK_KnockbackUnit, x)
Custom script: call SetUnitY(udg_FK_KnockbackUnit, y)
Special Effect - Create a special effect attached to the origin of FK_KnockbackUnit using (Load 4 of FK_Key from FK_Hashtable)
Special Effect - Destroy (Last created special effect)
Unit - Order FK_KnockbackUnit to Stop
Hashtable - Save (FK_KnockbackSpeedPerInterval - (Load 1 of FK_Key from FK_Hashtable)) as 0 of FK_Key in FK_Hashtable
Else - Actions
Hashtable - Clear all child hashtables of child FK_Key in FK_Hashtable
Unit Group - Remove FK_KnockbackUnit from FK_Group

FK Setup
Events
Map initialization
Conditions
Actions
Custom script: set udg_FK_Hashtable = InitHashtable()
Set FK_IntervalPerMove = 0.03
Set TempLoc = (Center of (Playable map area))
Set TempLoc2 = TempLoc
Custom script: call RemoveLocation(udg_TempLoc)
Trigger - Add to FK Loop <gen> the event (Time - Every FK_IntervalPerMove seconds of game time)

FK Save
Events
Conditions
Actions
Set FK_KnockbackSpeedPerInterval = (FK_KnockbackSpeed x FK_IntervalPerMove)
Set FK_KB_FrictionPerInterval = ((FK_KnockbackFriction x FK_IntervalPerMove) x FK_IntervalPerMove)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(FK_TempGroup is empty) Equal to False
Then - Actions
Unit Group - Pick every unit in FK_TempGroup and do (Actions)
Loop - Actions
Set FK_KnockbackUnit = (Picked unit)
Custom script: set udg_FK_Key = GetHandleId(udg_FK_KnockbackUnit)
Hashtable - Save FK_KnockbackSpeedPerInterval as 0 of FK_Key in FK_Hashtable
Hashtable - Save FK_KB_FrictionPerInterval as 1 of FK_Key in FK_Hashtable
Hashtable - Save Handle OfFK_KnockbackUnit as 2 of FK_Key in FK_Hashtable
Hashtable - Save FK_KnockbackAngle as 3 of FK_Key in FK_Hashtable
Hashtable - Save FK_KnockbackSFX as 4 of FK_Key in FK_Hashtable
Unit Group - Add FK_KnockbackUnit to FK_Group
Custom script: call RemoveLocation(udg_TempLoc2)
Custom script: call RemoveLocation(udg_TempLoc)
Else - Actions
Custom script: set udg_FK_Key = GetHandleId(udg_FK_KnockbackUnit)
Hashtable - Save FK_KnockbackSpeedPerInterval as 0 of FK_Key in FK_Hashtable
Hashtable - Save FK_KB_FrictionPerInterval as 1 of FK_Key in FK_Hashtable
Hashtable - Save Handle OfFK_KnockbackUnit as 2 of FK_Key in FK_Hashtable
Hashtable - Save FK_KnockbackAngle as 3 of FK_Key in FK_Hashtable
Hashtable - Save FK_KnockbackSFX as 4 of FK_Key in FK_Hashtable
Unit Group - Add FK_KnockbackUnit to FK_Group
Custom script: call DestroyGroup(udg_FK_TempGroup)
Trigger - Turn on FK Loop <gen>
[/trigger]


CREDITS
- Leonardo Da Vinci ?
- Tank-Commander - Read v1.1 changelogs


CHANGELOGS
v1.0
- Initial release

v1.1
- Friction calculation has been shortened
- Dead units still gets knockbacked (realism)
- Optimized some variable into caching them

v1.11
- Fixed some importing method
Rating - 0.00 (0 votes)
(Hover and click)
Moderator Comments
Not Rated
22:31, 22nd Aug 2012
Magtheridon96:

Comments
  • Since you're creating 1 special effect 32x times a second, you may end up causing lag. In order to reduce the amount of lag, you can create special effects half the time, or maybe even a third of the time.
    Look:
    Example
    if randomInteger(0, 2) == 0 then
    // create special effect
    endif
  • You don't need to have the local reals x and y since you're only referencing them once. If you're referencing locals only once, then you don't need them.
  • You can cache the Cos/Sin values into the hashtable so you don't have to avoid retrieving the constant value in the loop during every single iteration. It's more efficient this way because Cos/Sin are heavy function calls despite their short name. (Optional)

This spell is awaiting update.


Download Simple Frictional Knockback System v1.11.w3x
(19.95 KB, 194 Downloads)

Old 08-21-2012, 05:10 AM   #2 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
Reserved.
defskull is offline   Reply With Quote
Old 08-21-2012, 08:56 AM   #3 (permalink)
Registered User Almia
Not even my final form.
 
Almia's Avatar
 
Join Date: Apr 2012
Posts: 3,045
Almia is a name known to all (679)Almia is a name known to all (679)Almia is a name known to all (679)
I dont get it
Why there are two triggers but only have one action?
Almia is offline   Reply With Quote
Old 08-21-2012, 09:22 AM   #4 (permalink)
Registered User .OmG.
Hive - my life
 
.OmG.'s Avatar
 
Join Date: May 2010
Posts: 197
.OmG. has little to show at this moment (8)
Screenshot is ugly... Convert to JPG format and not PNG
.OmG. is offline   Reply With Quote
Old 08-21-2012, 10:25 AM   #5 (permalink)
Registered User Tank-Commander
Most spells/systems
 
Tank-Commander's Avatar
 
Join Date: May 2009
Posts: 1,203
Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)
Notes

Set FK_KB_FrictionPerInterval = (FK_KnockbackFriction x FK_IntervalPerMove)
Set FK_KB_FrictionPerInterval = (FK_KB_FrictionPerInterval x FK_IntervalPerMove)

Put it into one line, no point doing it twice.

Unit - Order FK_KnockbackUnit to Stop

Why?

FK Key
Events
Conditions
Actions
Custom script: set udg_FK_Key = GetHandleId(udg_FK_KnockbackUnit)

Is this necessary? I mean you already do that here in FK Save:

Custom script: set udg_FK_Key = GetHandleId(udg_FK_KnockbackUnit)

Custom script: local real x

Wether these were locals or not wouldn't make any difference to the system and I get the feeling that for good practice they should be created outside of the group pick, since you're just making lots of locals when you only need one of each (x and y)

(FK_KnockbackUnit is alive) Equal to True

For realism, a dead unit wouldn't stop moving just because it died.

Custom script: call SetUnitX(udg_FK_KnockbackUnit, x + udg_FK_KnockbackSpeedPerInterval * Cos(LoadReal(udg_FK_Hashtable, udg_FK_Key, 3) * bj_DEGTORAD))
Custom script: call SetUnitY(udg_FK_KnockbackUnit, y + udg_FK_KnockbackSpeedPerInterval * Sin(LoadReal(udg_FK_Hashtable, udg_FK_Key, 3) * bj_DEGTORAD))

Load "LoadReal(udg_FK_Hashtable, udg_FK_Key, 3)" into another variable before doing anything with it. you call it twice so it's less efficient to load the same value from a hashtable twice.

All I've got for now
__________________
Tank-Commander is online now   Reply With Quote
Old 08-21-2012, 11:37 AM   #6 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
Radamantus
Quote:
I dont get it
Why there are two triggers but only have one action?
Which ?


.OmG.
Quote:
Screenshot is ugly... Convert to JPG format and not PNG
The screenshot is in JNGP.


Tank-Commander
Quote:
Set FK_KB_FrictionPerInterval = (FK_KnockbackFriction x FK_IntervalPerMove)
Set FK_KB_FrictionPerInterval = (FK_KB_FrictionPerInterval x FK_IntervalPerMove)

Put it into one line, no point doing it twice.
You mean like this;
Set FK_KB_FrictionPerInterval = ((FK_KnockbackFriction x FK_IntervalPerMove) x FK_IntervalPerMove)

Quote:
Unit - Order FK_KnockbackUnit to Stop

Why?
Using SetUnitX/Y does not interrupt orders, therefore units will still be able to move while being knockbacked.
If I order those units to Stop, they won't be able to be ordered around (Move, Attack, etc)
Also, when ordering unit to Stop + SetUnitX/Y, it is by default will stop the units from getting out of the map boundaries (saves check line code)

Quote:
FK Key
Events
Conditions
Actions
Custom script: set udg_FK_Key = GetHandleId(udg_FK_KnockbackUnit)

Is this necessary? I mean you already do that here in FK Save:
It is because applying this system to multiples units at once (Unit Group) has different approach.
It's a bit hard to understand, I'll try to change the instructions layout in the next version, making it more easier.

Quote:
Custom script: local real x

Wether these were locals or not wouldn't make any difference to the system and I get the feeling that for good practice they should be created outside of the group pick, since you're just making lots of locals when you only need one of each (x and y)
If you're dealing with IF/THEN/ELSE block + local variables + unit group, you would know where to put that function.

The settings of local variables can only be done inside Unit Group action, if you don't believe me, try it.

Quote:
(FK_KnockbackUnit is alive) Equal to True

For realism, a dead unit wouldn't stop moving just because it died.
Yeah I was thinking hard whether this check should be implemented or not, but since you're thinking that "units just don't stop do they ?", I'll remove that check.

Quote:
Load "LoadReal(udg_FK_Hashtable, udg_FK_Key, 3)" into another variable before doing anything with it. you call it twice so it's less efficient to load the same value from a hashtable twice.
I've learn from Magtheridon, he said that if you only use the variable once per trigger run, it would be........
Ahhh, I see it now, I called it twice, for X and Y, ahhh thanks :)
defskull is offline   Reply With Quote
Old 08-21-2012, 12:19 PM   #7 (permalink)
Registered User Almia
Not even my final form.
 
Almia's Avatar
 
Join Date: Apr 2012
Posts: 3,045
Almia is a name known to all (679)Almia is a name known to all (679)Almia is a name known to all (679)
key and hashtable
Almia is offline   Reply With Quote
Old 08-21-2012, 12:56 PM   #8 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
Ah, you see, one is to acknowledge which unit should the data be saved to and hashtable is for saving angle per unit pick.

This "weird" settings only applies to units picked via Unit Group (FK_TempGroup).

As I mentioned earlier, I will change the layout to be more easier to understand in the next version.
defskull is offline   Reply With Quote
Old 08-21-2012, 01:51 PM   #9 (permalink)
Registered User baassee
MORE CONTESTS PLS
 
baassee's Avatar
 
Join Date: Nov 2008
Posts: 3,554
baassee is a splendid one to behold (845)baassee is a splendid one to behold (845)baassee is a splendid one to behold (845)baassee is a splendid one to behold (845)baassee is a splendid one to behold (845)
jsut declare the locals at the top of the actions, wont do any harm anyway
__________________
Nobody dies a virgin, life fucks us all. - Master Arena is alive! v4.0 in construction. - Dr Super Good for president! - Sorry derps but I do not do requests unless they prove themselves worthy of my time.
My Resources! - Help me out with my project! - How To Import vJASS spells tutorial! - Practice makes perf... improves you.
Quote:
Originally Posted by Marc Mamales View Post
Hey guys, please fix my spells, cz i dont know how to make it GUI.
baassee is offline   Reply With Quote
Old 08-21-2012, 01:56 PM   #10 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
Top of the actions where exactly baassee ?
Did you tried it yet ?
I tried, but it compiles error, I have talked with WaterKnight with this issues, locals must be declared inside the Unit Group action.

If you already tried it and succeed, please do share the code.
defskull is offline   Reply With Quote
Old 08-21-2012, 02:07 PM   #11 (permalink)
Registered User baassee
MORE CONTESTS PLS
 
baassee's Avatar
 
Join Date: Nov 2008
Posts: 3,554
baassee is a splendid one to behold (845)baassee is a splendid one to behold (845)baassee is a splendid one to behold (845)baassee is a splendid one to behold (845)baassee is a splendid one to behold (845)
Ah that's true, cause of engine I guess - cannot allocate the local within an if. ops forgot, enumeration creates a whole new function thus the locals have to be declared within that enum func ^^

anyway, these two parts should be stored into the hashtable as well as they are always the same

Cos(udg_FK_KnockbackAngle * bj_DEGTORAD)
Sin(udg_FK_KnockbackAngle * bj_DEGTORAD)

and you can actually get rid of the locals just put

GetUnitY(udg_FK_KnockbackUnit) + udg_FK_KnockbackSpeedPerInterval * Sin(udg_FK_KnockbackAngle * bj_DEGTORAD)

into

call SetUnitX(udg_FK_KnockbackUnit, x)
__________________
Nobody dies a virgin, life fucks us all. - Master Arena is alive! v4.0 in construction. - Dr Super Good for president! - Sorry derps but I do not do requests unless they prove themselves worthy of my time.
My Resources! - Help me out with my project! - How To Import vJASS spells tutorial! - Practice makes perf... improves you.
Quote:
Originally Posted by Marc Mamales View Post
Hey guys, please fix my spells, cz i dont know how to make it GUI.
baassee is offline   Reply With Quote
Old 08-21-2012, 02:46 PM   #12 (permalink)
Registered User Tank-Commander
Most spells/systems
 
Tank-Commander's Avatar
 
Join Date: May 2009
Posts: 1,203
Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)Tank-Commander is a glorious beacon of light (449)
Well, I would like to say on the grounds of using stop, other than stopping them from going out of bounds, I was mostly referring to the doctrine as to why you were disabling their functions, since interrupting orders isn't the most useful of things to do and stun/slow/etc. in the actual WC3 does not prevent orders, and knockback isn't really a "disable" thing. I'd suggest just putting the checking for map bounds in so that their orders aren't cancelled, guess it's preferential, but I'd still have a boolean in the "system" to allow you to enable/disable the stop being run and cancelling orders.
__________________
Tank-Commander is online now   Reply With Quote
Old 08-21-2012, 05:26 PM   #13 (permalink)
Registered User CoLd Bon3
The Hive's Breakdancer
 
CoLd Bon3's Avatar
 
Join Date: Aug 2010
Posts: 963
CoLd Bon3 will become famous soon enough (108)CoLd Bon3 will become famous soon enough (108)CoLd Bon3 will become famous soon enough (108)
Just one suggestion - create a configurable variable that sets where the special effect is spawned. Some people might want it to be on the head, no the origin which makes absolutely no sense but it will be good if you put this... just in case.

The system is great, nice job, defskull! :)
__________________
"You don't get what you wish for. You get what you work for!"
My resources : ||Spinning Blade 4.0v||Charge-Slash 2.0v||Damage Calculating System 1.3v [GUI]||Charge Spell-System 1.0v||
CoLd Bon3 is offline   Reply With Quote
Old 08-21-2012, 06:42 PM   #14 (permalink)
Registered User Matarael
Heavy drinker.
 
Join Date: Dec 2005
Posts: 524
Matarael has a spectacular aura about (133)Matarael has a spectacular aura about (133)Matarael has a spectacular aura about (133)Matarael has a spectacular aura about (133)
Tag.
Matarael is offline   Reply With Quote
Old 08-22-2012, 12:17 AM   #15 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
baassee
Quote:
anyway, these two parts should be stored into the hashtable as well as they are always the same

Cos(udg_FK_KnockbackAngle * bj_DEGTORAD)
Sin(udg_FK_KnockbackAngle * bj_DEGTORAD)
You mean to store those whole calculation or just FK_KnockbackAngle ?
If you're asking me to only save FK_KnockbackAngle, I already did that in v1.1.
But if you're asking me to save those whole calculation, I do not do it yet.
Ah yeah, they are constants right.

Quote:
and you can actually get rid of the locals just put

GetUnitY(udg_FK_KnockbackUnit) + udg_FK_KnockbackSpeedPerInterval * Sin(udg_FK_KnockbackAngle * bj_DEGTORAD)
I thought that repeating the same function without caching it reduces performance ?
That's why I used locals, x and y to cache the function, instead of repeating the GetUnitX/Y each time.


Tank-Commander
I was thinking this too, to add boolean whether the knockback should or should not "disable" the units.
Well I guess you have convinced me.
Because some people wants those knockbacked units to still be able to do anything, while at the same time, the knockback occurs to the unit.


CoLd Bon3
Quote:
Just one suggestion - create a configurable variable that sets where the special effect is spawned. Some people might want it to be on the head, no the origin which makes absolutely no sense but it will be good if you put this... just in case.

The system is great, nice job, defskull! :)
Hah, I thought this too, but the more I think about it, the more crazy it becomes because hey, knockbacked and friction is related to ground, that's why the SFX will be spawned at the feet of the unit, but I'll add this small configuration anyway, it's a small add btw, thanks for the convincing :)
defskull is offline   Reply With Quote
Reply

Bookmarks

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 05:32 PM.





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