HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Bit of help... mathy problem

07-28-2003, 11:26 AM#1
Dragoon-elf
Ok! Here goes..
I am trying to make a first person shooter (not a first, I'm sure) but I'm having trouble detecting when someone gets shot. Here's what I've got so far...

Unit Group - Pick every unit in (Units within TempReal of (Position of TempUnit)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Picked unit) Not equal to TempUnit
(Distance between (Position of (Picked unit)) and (Position of TempUnit)) Less than TempReal
((Tan(PlayerRealPitch[(Player number of (Owner of TempUnit))])) x (Distance between (Position of TempUnit) and (Position of (Picked unit)))) Less than ((Real((((Terrain cliff level at (Position of (Picked unit))) - (Terrain cliff level at (Position of TempUnit))) x 125))) + (100.00 + ((Current flying height of (Picked unit)) - (Current flying height of TempUnit))))
((Tan(PlayerRealPitch[(Player number of (Owner of TempUnit))])) x (Distance between (Position of TempUnit) and (Position of (Picked unit)))) Greater than ((Real((((Terrain cliff level at (Position of (Picked unit))) - (Terrain cliff level at (Position of TempUnit))) x 125))) + (-20.00 + ((Current flying height of (Picked unit)) - (Current flying height of TempUnit))))

Or - Any (Conditions) are true
Conditions
(Abs((RealAccuracy - (Angle from (Position of TempUnit) to (Position of (Picked unit)))))) Less than 2.00
And - All (Conditions) are true
Conditions
((Angle from ((Position of TempUnit) offset by 50.00 towards (RealAccuracy + 90.00) degrees) to (Position of (Picked unit))) - RealAccuracy) Less than 0.00
((Angle from ((Position of TempUnit) offset by 50.00 towards (RealAccuracy - 90.00) degrees) to (Position of (Picked unit))) - RealAccuracy) Greater than 0.00
Then - Actions
Set TempReal = (Distance between (Position of TempUnit) and (Position of (Picked unit)))
Set TempUnit2 = (Picked unit)
Else - Actions

I highlighted where I'm having trouble.

Bold (hit depending on height):
The pitch is the angle the unit is facing up/down, 0 being straight and 90 being straight up. TempUnit is the shooting unit, and the picked units are potential targets. Oh, and TempReal is the shooting unit's Range/Closest target found so far (why it's a condition 2x).

The height doesn't seem to work properly, I aim up/down, but only get hits "some times"..


Underlined (angle loop-de-loop)
That is a temporary solution to my problem. Since angles go from 180 to -180, sometimes the angles from the 2 points off of the unit's sides return 179 and -179. I need a condition to fix that apart as well... The current solution makes high-range units have easy shots when far away.
07-28-2003, 01:15 PM#2
Nemesis9x
Holy cow, that is alot of stuff. I dont think any of us can look at taht and help you cause we arent sure what each of the exact variables do and what they are. You would have to send ur map to some1.
07-28-2003, 01:51 PM#3
Dragoon-elf
well... it IS a 3d-straightline-collision, bound to be lots of trig.. heh

Anyways, I found out the flying height actually does work, it was just an "illusion" of not working.

BUT I still need help with the angles..

You see, when someone shots towards (let's say) 179 degrees. If their target is DIRECTLY in front of them, it will miss.
The 2 points will return angles like: -179 and 177.

...hmmm maybe if.. one is positive and the other negative.. ill just give it to them..