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 / Problem with weapon

Author
Message
Doucan
21
Years of Service
User Offline
Joined: 26th Nov 2003
Location: Vermont USA
Posted: 9th Dec 2003 02:54
I recently hacked out a little game with the distance calculation code snippet from the db tutorials in which you're a jet being chased by a robot who if he gets close enough starts to kill you etc.. I decided to finish it and made some health bars, sounds and, this is where the problem starts, gave the player an auto-aim macine gun. I works, but not very well. Sometimes the bullets damage him and sometimes they don't. Since I'm not on the same computer that I wrote it on, I can't enclude a good code snippet but I'll do my best.

If spacekey()=1
show object whatever
position object whatever, x,y,z (It's not that important)
bulletlife=12
gosub shoot_bullet
endif

shoot_bullet:
if bulletlife>0
dec bulletlife
endif
`aim at enemy
point object whatever,enemyx,enemyy,enemyz
move object whatever,5
`check if bullet is dead
if bulletlife=0
hide object whatever
return

Then the program would continue on to check if the enemy was hit, and lower the health bar, and so on. Please tell me if there's any better way to do this, my code's probably gonna be hard to read because I can't directly copy it, but I'm new at this, so give me a little slack.

If you come to a fork in the road, take it!

-Yogi Berra
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Dec 2003 10:33
Hehehehehe

Sorry, just imagining what I think is happening to your bullets - I reckon they're running out of life too early - and if not, they're spinning round their target like crazy mosquitos!

Try incresing the bullet life, if you have a matrice, then use the ground height to check if the bullet can die early.

Very important though, only point the bullet object once, when aiming - then move the bullet object every loop. The way it is now, the bullet is sorta heat seeking, so there's a chance that it could miss the object then turn back until it ends up going nuts like a mosquito with an itchy stinger. If you point the bullet, then don't affect the angle in any way your bullets will fly straight and should work a lot better.

A quick tip though:
If your not sure where your object is positioned, text something at it's OBJECT SCREEN X() and Y() locations, it'll let you know if the object is disapearing underground or too small, just look for the text.



Van-B


I laugh in the face of fate!
Doucan
21
Years of Service
User Offline
Joined: 26th Nov 2003
Location: Vermont USA
Posted: 10th Dec 2003 01:45
My bullets aren't spinning around the target, they're just very picky about when to damage it and when not to, like sometimes they'll hurt him and sometimes they'll just go through him.

By the way I'm positioning the bullet rightwhere the player is, so the player appears to fire the bullet.

Also, what do you mean by using thematrix to check if the bullet dies?

Thanx for the help!

If you come to a fork in the road, take it!

-Yogi Berra
guru of boredom
21
Years of Service
User Offline
Joined: 12th Oct 2003
Location: middle of no where
Posted: 13th Dec 2003 01:03
your bullets could just be going through the object as well. because the move object command moves it 5 units and dosent not check for collisions inbetween the two positions. i sugest getting the nuclear glory dll for collisions if you are serious about this.

we are not outnumbered! we are just in a target rich enviroment!
P4 2.4 ghz 120 GB 256 mb GeForce4
Doucan
21
Years of Service
User Offline
Joined: 26th Nov 2003
Location: Vermont USA
Posted: 13th Dec 2003 23:40 Edited at: 13th Dec 2003 23:41
I'm not real serious, nor am I that good at programming. (yet ) This is the first successfull program. Although I did get it to sort of work. I put the point object command in the main loop and did some adjustments to the bullet's life nd got the damage results that I wanted.

Thanx guys

If you come to a fork in the road, take it!

-Yogi Berra

Login to post a reply

Server time is: 2025-05-22 00:37:29
Your offset time is: 2025-05-22 00:37:29