Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / very good equation, but not effecient!

Author
Message
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 14th Oct 2003 02:15
hello people,
take a good look at this code:

yup! its the equation for defining the distance between the bullet and the enemy, "if distance between them is less than 20 then kill the enemy."(x#,y#,z# are position of bullet)
The problem:
the size of the enemy! i have to hit the enemy in a very precise location of his body so he could die, which i find is very difficult for the user to deal with.
so do u have any suggestions? if my problem isnt clear, plz notify.
thankx for advance.

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 14th Oct 2003 02:24
Id throw an ABS in there or you may get some pretty funky results when that number becomes negative.

Just find the location where the bullet hits the enemy. Use intersect object, put the location in an arrary, then compare the array data to previously recorded data where certain spots are eg

X>500 and < 100 = Head

Hope that helps

RPGamer

Current Project: Eternal Destiny
We need a texture artist!
If your interested email me - [email protected]
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 14th Oct 2003 02:29
wow, that's alota code and finger stretching! but i think it could do the trick. if any other suggestions plz dont hazitate!
thankx

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 14th Oct 2003 05:27
[href]www.lunarpixel.com/temp/distance.DBA[/href]

is an example of a distance function in use.

=C=
22
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 14th Oct 2003 19:50
There is no way you will ever get negative values of something Squared... So no ABS is needed.

Also, Why don't you get your target object, add a cheap limb, (use a plain or cube), and test on the limb.

And it will make your code so much easier to read. It will be a case of testing like so (pseudocode follows):

Distance between Bullet and limb 1 of monster < 1 then Monster Dead!

all you will test is not the monster x but the monster limb x etc.

Does this make sense? Limb are good and coincidence, All you wanna do really is check on limbs aint it?

Sorry for the pseudocode, dont have my darkedit here with me to write a wee code sample for ya... but in principle is an easy little routine and you have written most of it already.

Cheers

-------------------------------
Pointy birds, Oh pointy pointy
Anoint my head, Anointy 'nointy
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 15th Oct 2003 00:59
that really helped so much! thanks guyz! i'll try it rite away!

‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 15th Oct 2003 22:55
Instead of sqrt(), I wonder if ^0.5 would be quicker.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 16th Oct 2003 11:45
Hmm, interesting Idea Phaelax...

Knowladge Belongs To The People...
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 17th Oct 2003 12:44 Edited at: 17th Oct 2003 12:45
Even quicker, square both sides of the equation. Instead of:
IF SQRT(dx^2 + dy^2 + dz^2) < 200 THEN ...
try:
IF dx^2 + dy^2 + dz^2 < 200^2 THEN ...

Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 17th Oct 2003 13:27
True...

Knowladge Belongs To The People...
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 17th Oct 2003 15:07
Oi I wasnt thinking, lol ABS a square root of a number LOL. Losing my basic math skills here

Current Project: Eternal Destiny
We need a texture artist!
If your interested email me - [email protected]

Login to post a reply

Server time is: 2025-05-21 15:06:36
Your offset time is: 2025-05-21 15:06:36