- 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
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