• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

A knockback system idea for GUI people

Status
Not open for further replies.
Level 15
Joined
Aug 14, 2007
Messages
936
I am opening this topic, to create a knock-back system for the map as a whole. Benefits from this is that it adds a realistic approach while prevent multiple stacking of other knock-backs to be bugged in appearance or flawed in anyway.
I will go ahead and give you my opinions and then show how it can possibly be done, people can add on details to enrich this system and hopefully give more knowledge to GUI experience users.

Ok, so because knock-backs can stack up in different ways and angle, you might want to put it together as a whole to code it instead of seperately doing it, in this way you can adjust the fly angle and have a better control on the mechanic.

Here is how it should be:
- You need a HASHTABLE
- You need a Unit Group
- You need a TRIGGER
: Set the trigger initially to OFF and with an event of Periodic Timer say every 0.05 seconds

Now let's dive deeper, let's say you have a spell cast that does aoe knock-back to all units around the caster for say 500 distance.

For that spell all you need usually is just 1 TRIGGER, so once you created that trigger it should contain, an event that tracks the caster casting the spell and a condition that checks which spell its cast. Then there is a series of actions. First, select enemies around, under unit group assign hash table codes, put in unit, distance of knock-back, angle, speed then add the picked unit into the Unit Group for knock-back, i will explain shortly.
After which you can turn on the trigger for knock-back, taking note that this trigger is for spell cast, the other is for the actual knock-back to occur.

For the knock-back trigger, the reason why there is a Unit Group requirement is because I like to do hash table in collaboration with Unit Group, it makes things easy to track. To close the trigger automatically, I usually check for the amount of units in the group, if it is 0 I will make it to turn off the trigger else do the knock-back. Now here in the knock-back codes you can do the normal move unit instantly to point thing we normally do with knock-backs, you just have to load the values from the picked unit in this Unit Group and adjust accordingly. I normally like to play with the speed, in this case I would lower the speed every time the units is moved, creating a more realistic approach, you can also add the rate in which the speed decrease along the way, adding another real value that tracks it (I know it is confusing may be read a couple more times) but that's all, opinions anyone?!

Here's another issue, when the same unit is affect by a different knock-back but still in the group, well, how the hell to detect that?
Here's the thing, for GUI people you all already know that you cannot stack Unit Group under Unit Group, it will cause some errors in the actions. Therefore I use Unit Group first, I pick the units and set them in a temporary array. Now I can do the knock-back first, assign them to an array, Use the Unit Group again, compare all picked units with the array, see if they are similar. Here's how you detect a different knock-back, you check the angle and speed, if it is the same unit but different angle and speed, you can kind of merge them in. How to merge? Say I detected 1 that has same unit but different speed and angle, I can set the Picked unit to null, set the boolean to False(you need this boolean set to true by default at the start of the search), check if the boolean is false, if it is do nothing, if it is true do the search. From here on it makes sure that it detects a different knock only once at a time to avoid trigger confusion. After you set the picked unit to null, you can immediately shift the values of the picked units to the arrayed unit. The values such as knock-back speed and knock-back angle can be changed according to the picked unit's values.

CHEERS
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Just check whether the unit to be knocked back has knockback speed saved or not. Boolean - hashtable value exists. If it exists, you combine the strengths and angles of the old and new knockback, to get the sum of the knockbacks. If one has done a bit of vector math, this concept should be easy to grasp and execute.
 
Level 15
Joined
Aug 14, 2007
Messages
936
Just check whether the unit to be knocked back has knockback speed saved or not. Boolean - hashtable value exists. If it exists, you combine the strengths and angles of the old and new knockback, to get the sum of the knockbacks. If one has done a bit of vector math, this concept should be easy to grasp and execute.

Thanks mate but it's more of an idea for knock-back, any suggestions for improvement such as yours is welcome.

Erm but I don't quite get what you mean by the boolean part o_O
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Erm but I don't quite get what you mean by the boolean part o_O

You store something, let's say it is the speed of knockback:
  • Hashtable - Save 5.00 as 0 of 0 in (Last created hashtable)
Then you can check whether the value exists or not:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (0 is stored as a Real of 0 in (Last created hashtable)) Equal to True
    • Then - Actions
    • Else - Actions
If the value exists, the unit is being controlled by the knockback system since otherwise there would be no value. The unit either has not ever been knocked back before or it has, but the knockback has ended and all data stored into hashtable for that instance has been flushed.
 
Status
Not open for further replies.
Top