HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Units Attacking

10-20-2011, 04:18 AM#1
Tastingo
I'm kind of curious how Unit Attacking works. What I mean is if both units have the same model and same exact stats, how does it decide who attacks first. I know they do not attack at the same time because of the game Freeze Tag. One unit will attack, while the other gets paused.

People in the Freeze Tag community discovered that if you order your unit to attack at a certain range, which they call "timing" you will win the battle. So the game involves people moving back and forth to get that distance. However it only works about 95% of the time.

I'm wondering if there is a way to see the script that determines who attacks first, or if anyone knows. I'm kind of curious if its random, or if it actually is determined by when you order your unit to attack.
10-20-2011, 07:20 AM#2
PurgeandFire111
I am pretty sure it is random. I tested it using archers, and then setting their vertex colors in accordance to whoever was ordered first. The one ordered first would be green, and then the one ordered second would be teal. (they were both ordered by script, however. They were ordered at the same time) Then, upon damage, the first to cause damage would be turned red and the second would be turned blue.

When I did that test, it would always vary. Even if I used the same order when issuing, the colors would always end up switching without a distinct pattern.

When I tried having one ordered first, early, and then ordering the other a little later (before they were in equal range), I got the same varying results.

Therefore, I think it is more of a random and matter-of-chance kind of thing. I didn't see any visible patterns in the results.
10-20-2011, 10:09 PM#3
Tastingo
I actually tested it too. I tried with the same player numbers and different player numbers. Players were also all allied, so auto attack wouldn't mess anything up. I actually got results that weren't random.

I had 2 commands that ordered them to attack at the same time. attack 1 and attack 2. These different commands would just change the order of which was ordered first. It seemed pretty random.

Then I repeated it with different player numbers. I thought maybe the higher or lower player number might have priority. Still the same results.

Next I tried what we do in Freeze Tag which is where you order to attack at different times. In fact it made it 100% guarantee to attack first.

So in my test I had the left unit attacking the right unit. I then found different ranges where if I ordered the right unit to attack it would attack first.

Here is a picture:
Red is the timing/order range to attack first. Blue is just where I had units respawn before I would order them to attack again.



So in a nutshell the time when you order your unit to attack does matter. Would be very nice if someone knew where I could view the attack code.