1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  5. Dismiss Notice
  6. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[GUI] Simple Frictional Knockback System v1.2

Submitted by defskull
This bundle is marked as substandard. It may contain bugs, not perform optimally or otherwise be in violation of the submission rules.
INTRODUCTIONS
- This system allows you to apply knockback to units with a decreasing speed (deceleration).


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 6 variables which you can manipulate;
* FK_UnitSet- The unit that is going to be knockbacked
* FK_AngleSet - The angle which the unit will be knockbacked
* FK_FrictionSet - The knockback friction per second
* FK_SpeedSet - The knockback speed per second
* FK_SFX_Set - The Special Effect for the knockback (make sure that the SFX model does not has any animation duration such as; birth, stand, death, etc)
* FK_IsStop - The option for the unit to be able to move during knockbacked


TRIGGERS
  • FK Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set FK_IntervalPerMove = 0.03
      • Trigger - Add to FK Loop <gen> the event (Time - Every FK_IntervalPerMove seconds of game time)


  • FK Event
    • Events
    • Conditions
    • Actions
      • Set FK_MaxIndex = (FK_MaxIndex + 1)
      • Set FK_Unit[FK_MaxIndex] = FK_UnitSet
      • Set FK_Speed[FK_MaxIndex] = (FK_SpeedSet x FK_IntervalPerMove)
      • Set FK_Friction[FK_MaxIndex] = ((FK_FrictionSet x FK_IntervalPerMove) x FK_IntervalPerMove)
      • Custom script: set udg_FK_AngleX[udg_FK_MaxIndex] = Cos(udg_FK_AngleSet * bj_DEGTORAD)
      • Custom script: set udg_FK_AngleY[udg_FK_MaxIndex] = Sin(udg_FK_AngleSet * bj_DEGTORAD)
      • Set FK_SFX[FK_MaxIndex] = FK_SFX_Set
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FK_IsStopSet Equal to True
        • Then - Actions
          • Custom script: call SetUnitPropWindow(udg_FK_Unit[udg_FK_MaxIndex], 0)
        • Else - Actions
      • Trigger - Turn on FK Loop <gen>


  • FK Loop
    • Events
    • Conditions
    • Actions
      • For each (Integer FK_CurrentIndex) from 1 to FK_MaxIndex, do (Actions)
        • Loop - Actions
          • Custom script: if (RectContainsUnit(GetPlayableMapRect(), udg_FK_Unit[udg_FK_CurrentIndex])) and (udg_FK_Speed[udg_FK_CurrentIndex] > 0) then
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 1
            • Then - Actions
              • Custom script: call DestroyEffect(AddSpecialEffect(udg_FK_SFX[udg_FK_CurrentIndex], GetUnitX(udg_FK_Unit[udg_FK_CurrentIndex]), GetUnitY(udg_FK_Unit[udg_FK_CurrentIndex])))
            • Else - Actions
          • Custom script: call SetUnitX(udg_FK_Unit[udg_FK_CurrentIndex], GetUnitX(udg_FK_Unit[udg_FK_CurrentIndex]) + udg_FK_Speed[udg_FK_CurrentIndex] * udg_FK_AngleX[udg_FK_CurrentIndex])
          • Custom script: call SetUnitY(udg_FK_Unit[udg_FK_CurrentIndex], GetUnitY(udg_FK_Unit[udg_FK_CurrentIndex]) + udg_FK_Speed[udg_FK_CurrentIndex] * udg_FK_AngleY[udg_FK_CurrentIndex])
          • Set FK_Speed[FK_CurrentIndex] = (FK_Speed[FK_CurrentIndex] - FK_Friction[FK_CurrentIndex])
          • Custom script: else
          • Set FK_Speed[FK_CurrentIndex] = 0.00
          • Custom script: call SetUnitPropWindow(udg_FK_Unit[udg_FK_CurrentIndex], GetUnitDefaultPropWindow(udg_FK_Unit[udg_FK_CurrentIndex]))
          • Set FK_AngleX[FK_CurrentIndex] = FK_AngleX[FK_MaxIndex]
          • Set FK_AngleY[FK_CurrentIndex] = FK_AngleY[FK_MaxIndex]
          • Set FK_Friction[FK_CurrentIndex] = FK_Friction[FK_MaxIndex]
          • Set FK_SFX[FK_CurrentIndex] = FK_SFX[FK_MaxIndex]
          • Set FK_Speed[FK_CurrentIndex] = FK_Speed[FK_MaxIndex]
          • Set FK_Unit[FK_CurrentIndex] = FK_Unit[FK_MaxIndex]
          • Set FK_MaxIndex = (FK_MaxIndex - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FK_MaxIndex Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
          • Custom script: endif


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


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

v1.2
- Change from using Hashtable to Dynamic Indexing
- Added 1 manipulative variable: FK_IsStop
- Movement should be slightly more efficient since uses JASS function rather than BJs (GUI)
- Cached some function so it will not keep recalling the same value
- Added chance for SFX to occur (so it won't occur for 32 times, causing potential frame drops)
- Removed unnecessary local variables
- Added comments on the script for better documentations
- Added OutOfWorldBound check


Keywords:
simple, frictional, knockback, system, defskull, hashtable, force, physics, acceleration, deceleration, slowing, down, speed, dynamic, indexing, stop,
Contents

Just another Warcraft III map (Map)

Reviews
Moderator
22:31, 22nd Aug 2012 Magtheridon96: 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....
  1. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,979
    Resources:
    17
    Spells:
    17
    Resources:
    17
    He maybe your padawan but he is Hive's Moderator and I will have to obey his standards lol.
     
  2. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    Nah if you convert it into JASS you'll see why you don't need the locals ^^
     
  3. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,979
    Resources:
    17
    Spells:
    17
    Resources:
    17
    So I should remove those 2 locals and just get the reals via GetUnitX/Y directly into the function ?
     
  4. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    yeah as I stated in one of my previous replies
     
  5. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,979
    Resources:
    17
    Spells:
    17
    Resources:
    17
    Since it uses SetUnitX/Y, if I don't order the unit to stop, what if the Player order Move to that unit ?
    You are 'knockbacked' but you can move, weird much ?

    Do you mean the SFX should spawn at random ?
    Not each interval ?
    But the random has a high chance to occur, is that it ?

    Noted.

    Alright sir.
     
  6. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Sometimes, you want the knockback to be something like a force interfering with a unit (the way it is in Warlock). So I just thought that a user may not want you to be ordering the unit to stop ;o

    Yeah, so, instead of having it spawn /every/ interval, you would have it spawn on some intervals.

    Pseudo code:
    FrequencyFactor = 5 // The greater this is, the less the effects will appear.
    if GetRandomInt(0, FrequencyFactor) == 0 then
    createEffect()
    endif

    edit

    Okay,

    When to Cache
    When to Cache a Value

    GUI

    Any time you repeat a call more than once, cache it. It's very simple.
    If you're only going to reference the variable once, caching it will only make your code a bit slower.

    JASS

    If you're repeating a call that returns:
    • A Scalar-type that doesn't need to be nulled:
      • Once, don't cache it.
      • Twice or more, cache it.
    • A Handle-type that needs to be nulled:
      • Once, don't cache it.
      • Twice, don't cache it.
      • Thrice or more, cache it.
     
  7. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,843
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Add the check pathability because it will cause crash if a unit exceeds the map bounds
     
  8. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    Stated before in this thread.
     
  9. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    I recommend this udg_FK_KnockbackAngle * bj_DEGTORAD in the save setup so that you dont need to do it everytime it in loops:
    • Custom script: call SaveReal(udg_FK_Hashtable, udg_FKey, 3, FK_KnockbackAngle*bj_DEGTORAD)
     
  10. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,843
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    So you don't have any plans on updating?
     
  11. makai

    makai

    Joined:
    Apr 30, 2010
    Messages:
    320
    Resources:
    2
    Models:
    2
    Resources:
    2
    waiting for this to get approved
     
  12. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,843
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    We have waited months.
     
  13. makai

    makai

    Joined:
    Apr 30, 2010
    Messages:
    320
    Resources:
    2
    Models:
    2
    Resources:
    2
    Defskull is currently busy with his university staff i guess.. Sad..
     
  14. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,843
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Still. Even he is active, he hadn't updated this.
     
  15. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,979
    Resources:
    17
    Spells:
    17
    Resources:
    17
    Updated v1.2.
     
  16. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,121
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Hey defskull, nice to see you updating this. My observations tell me that this needs work to be acceptable, and this system also needs a niche. I'll elaborate:

    1) Pathing is not considered except to keep the unit in the overall map. This is only good for knocking back units over completely flat and walkable terrain.
    2) If the goal is to have a completely bare knockback, the special effect doesn't serve a purpose and neither should the prop window be used.
    3) If you did enhance this to use pathing on non-flat maps, you basically end up with Knockback 2.5D.
     
  17. Wrda

    Wrda

    Joined:
    Nov 18, 2012
    Messages:
    1,230
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Agreed, but for realism, a unit that is already dead wouldn't be knockbacked too, wouldn't make any sense. So the condition should be there to prevent this.
     
  18. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,979
    Resources:
    17
    Spells:
    17
    Resources:
    17
    The dead-moving units are already fixed in the previous version(s) lol.
    Also, this one has decelerating knockback which Bribe's 2.5D doesn't support.

    Oh well, I guess my system is more simpler to be used for simple map I suppose.
     
  19. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,181
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    No collision with buildings, trees, cliffs. And you mess up the propulsion window values.