HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detecting a swing

05-06-2006, 11:55 AM#1
Mezzer
What the best way to detect when a unit swings? As in, if he's ranged, detect the moment he releases his projectile? I don't care when it hits, how it hits or anything similar, just when he makes an attack that will hit it's target (barring a miss)
05-06-2006, 01:43 PM#2
vile
Make a test map and add a unit is attacked event, and attacking unit is your ranger
Set the unit's attack type to melee

Start a timer in the actions of the attacked unit event, better use a global timer for tests.
Also register at the same time a damage event on the attacked unit, while damaging unit is equal to the ranger

in the damage actions, PAUSE the timer that you started and use a BJDebugMsg to show you how much time has been elapsed in the timer, I.E TimerGetElapsed(timer)

Use globals for this test of course to make it easy

That would be the exact time where he actually releases the projectile
Dont forget to make it melee range.

This duration differs on each unit since it all depends on the backswing fields in the unit on the object editor.
05-06-2006, 01:58 PM#3
Mezzer
K, not quite sure you understood me there. The only problem with the "unit gets attacked" event is that it fires at weird times otherwise it would be fine for me
05-06-2006, 04:14 PM#4
FatalError
Quote:
Originally Posted by Mezzer
K, not quite sure you understood me there. The only problem with the "unit gets attacked" event is that it fires at weird times otherwise it would be fine for me
There is no 100% foolproof way of detecting an attack. There are some attack detection systems out there, but you're probably better off without them.

What are you trying to do with this? Making your own evasion system?
05-06-2006, 04:16 PM#5
Mezzer
Yes and no, but it doesn't matter really. Can u think of a way of detecting when a unit should attack?
05-06-2006, 04:30 PM#6
vile
Huh, you asked me how to get the exact time of the swing of a unit since he starts swinging until the actual release. The way I showed you is the right way to detect it, and it IS accurate, i've made a whole damage detection system with it.
05-06-2006, 04:33 PM#7
Mezzer
Ok, but what if the unit was ranged? What if the target wasn't preplaced? All I'm saying is it's not what I was looking for. Thx though
05-06-2006, 05:14 PM#8
vile
You wanted the interval between the start of the swing and its end right?
That will do it for either ranged or melee, just set the attack type to melee and test it.
05-06-2006, 05:14 PM#9
TaintedReality
That IS what you're looking for.
Quote:
detect when a unit swings

That's exactly what it does.
05-06-2006, 05:19 PM#10
vile
Indeed, the START of the SWING is actually when a unit is attacking event, and its perfectly accurate.
05-06-2006, 05:34 PM#11
Mezzer
I get that, but I couldn't care less about the time interval. I wanted a way of detecting when a unit is about to release the projectile, not the time, rather the appropriate event and conditions that would make it as accurate as possible
05-06-2006, 06:02 PM#12
MysticGeneral
What everyone is telling you is correct. You're just misunderstanding them, Mezzer.

Event:
A unit attacks (Use this, even though he won't release the projectile yet, you activate the trigger)
Condition:
Unit attacking is equal to Archer
Action:
Wait .35 milliseconds (Because I'm guessing it takes .35 seconds for the archer to release her projectile)
ACTIONS HERE


I think that's what you want at least.
05-06-2006, 06:30 PM#13
Mezzer
Yes, thats the event, HOWEVER, that event fires a few times when it has apsolutely no logical reason to fire, hence my question in the first place. I would use that, but I wanted to know if anyone knew how to avoid those few 'defective' events. Hope it's now perfectly clear
05-06-2006, 07:27 PM#14
uberfoop
hes right. i think he wants the trigger to fire only if the projectile is acualy released, and the problem is that the 'a unit is attacked' fires sometimes just before the release, which would cause the trigger to fire whether or not the projectile was acualy fired. Its a problem that i heard that the phantom lancer in dota has. see, he has an ability that gives him a % chance on an attack to create a mirror image, but the problem with the ability is it still fires even if all you do is spam the 'stop' buttom. Thread Creater probably doesnt want this problem. I'm guessing you're out of luck...i know of no way to detect the exact moment a projectile is released and i doubt there is one.
05-06-2006, 07:55 PM#15
vile
I've created my own damage detection system for that to detect the damage just around .001 seconds before the actual damage.

When a unit starts attacking I add a timer that I already calculated the normal backswing duration, I added a distancebetweenpoints duration as well, and then the damage is registered just before the arrow is supposed to hit.

The only problem with it is that if the unit is coming towards you, the distancebetweenpoints can cause it not to fire, however, with melee units its working awesome.

Since I use this only on % chance, if a unit comes towards you it doesnt really bother me that much since its just a chance, and it doesnt happen that often.

If you want the system, tell me.