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 / how do i change guns in an fps

Author
Message
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 14th Feb 2004 22:57
can anyone tell me how to change my gun in an fps

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 14th Feb 2004 23:32
Move the mouse cursor to the change weapon icon and click until the desired weapon shows up.

Peace, the anti-Bush.
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 14th Feb 2004 23:45
ime not sure if that was a joke or not so ill take it as a joke that was acctually quite funny

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 15th Feb 2004 00:22
but anyway can someone help pls and if anyone knows how to make one of those ammo metres you know 10,9 like 10 bullets and 9 catriges and make it go down as you shoot that would be helpfull pls

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 15th Feb 2004 01:36
to keep it simple and no fancy gun changing.

load up 10 models of guns(for the sake of argument)
eg: load object "gun1.3ds",1
load object "gun2.3ds",1 etc etc

untill you have all 10 guns loaded,

then position them all at the cameras position,

and have if inkey$()="1" then gun=1
if inkey$()="2" then gun=2
etc etc,

then in your code have

for i=1 to 10
hide object i
next i

this will hide all 10 guns

then
show object gun

the number "gun" will be the selected gun, if it is 0 then you havent got a gun selected and if you select gun 9 then gun 9 will load up

and an ammo count is easy,

providing you have your bullet shooting code eg:

if mouseclick()=1
shoot bullet blah blah...
endif

change that to

if mouseclick()=1
if ammo>0
shoot bullet blah blah...
ammo=ammo-1
endif
endif

and make sure you put

ammo=100

at the top of your code,
then you can fire 100 bullets then the bullets will stop as you have ran out of ammo,

if you want different ammo counts you will have to use an array of bullet counts, if you want me to explaing that just ask

steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 15th Feb 2004 16:28
thanks for your help i tried the gun changing code i havent tried the ammo one yet because ime figuring out whats wrong whith the gun one first could you help ive posted my code if you can tell me what ive done wrong that would be appreciated i really dont know whats wrong

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 15th Feb 2004 18:24
well your problem is easy,

i said to put

for i=1 to 10
hide object i
next i

as in my exaple gun 1 was object 1 2 is 2 etc etc, but in your code gun 1 is, 2, 20 & 21

so have

hide object 2
hide object 20
hide object 21

if gun=1 then show object 2
if gun=2 then show object 20
if gun=3 then show object 21

it would be much easier if your gun object numbers were one after another, but if you add that code instead of the old code it should work,

i plan to make a in depth fps tutorial covering most areas of the engine, but i need to make a good website 1st.

steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 16th Feb 2004 23:13
so somthing like this or have i got it wrong again because it comes up runtime error at line 235 object number range is 1 to 65535

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 17th Feb 2004 00:17
i am really sorry it was all my fault i figured it out
and thanks for your help you have to be the best coder ive ever met
thanks (now on to the bullet code mooohahahaha moooooohahahaha but wait) theres one problem it still shoots even if i dont have a gun up :' which is just smelly i know its a lot to ask but do you think
that you could tell me how to make different guns shoot differently because i have a colt shooting like an ak-47 and make no gun not shoot at all

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 17th Feb 2004 00:56
It would require a lot of physics coding, if your talking about recoil and such. Not shooting without a gun is simple

First have a variable, such as GunInHand and set that to 1 when you have a gun. Then wrap your shooting code in

If GunInHand > 0


We need help! Email us! [email protected]
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 17th Feb 2004 14:59 Edited at: 17th Feb 2004 15:09
lol i like making fps games,

ok to do recoil

position them at the end of the loop
eg

this should work but ive never used lock object on for guns,

if rot#>15 then rot#=15
if rot<0 then rot#=0
xrotate object 2,rot#
rot#=rot#-3

put that after your shooting code and after your gun positioning code

in your shooting bit
ie:
if mouseclick=1
blah blah
endif

add in the blah blah area:

if gun=1 then rot#=rot#+7+rnd(3)
if gun=2 then rot#=rot#+10+rnd(4)
if gun=3 then rot#=rot#+8+rnd(7)

and for how many other guns you have

[EDIT]


say you have 3 guns, gun 1, 2 and 3

then have

if gun<1 then shoot=0
if gun>0 then shoot=1
if gun>3 then shoot=0

then at your shooting code put

if shoot=1
put that right before the if mouseclick statement

then put endif after the code or next to the other endif`s, after the shooting code

that should stop gun 4,5,6 etc shooting as it dont exist

i released the source code to my alienware entry, since its a fps it should help you out, it has all the recoil, gun goes off the screen when changing guns, ammo, magazine counts, reloading, etc etc

heres the code again.
hmm i cant edit and add source code

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 17th Feb 2004 15:09
ok there it is

steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 18th Feb 2004 15:26 Edited at: 18th Feb 2004 20:49
thnks but what i meant was how to make a colt shoot like bang........bang...... and an ak-47 shoot like bang bang bang you know somthing like that but thanks for the recoil code if you could tell me that i would be gratfull

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 18th Feb 2004 23:24
ok, nice n simple,

in the shooting code ie:
if mousclick=1

<-----in here

endif

put
if gun=1 then shootwait=20+rnd(6)
if gun=2 then shootwait=5+rnd(2)
if gun=3 then shootwait=7+rnd(4)

then just inside the shooting code ie:

if mousclick=1
<-------here

blah blah

<------- and here
endif

add in is shootwait<0 at here
and add endif at, and here

then after the shooting code put dec shootwait,

and add your gun sounds or whatever in the shooting code then you have what you asked

steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 19th Feb 2004 13:54
thanks ime sure it will work DARK CODER i cant try it cause ime in school but i will as soon as i get home thanks

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 19th Feb 2004 23:57
thanks again dark coder could you tell me about that bullet array thing to make different bullet counts for different guns pls and if ime gettin annoyin just say and ill post a new thread and ask somone else but if you could tell me i will be gratefull.

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 23rd Feb 2004 00:56
please tell me pls pls pls

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
Dark Serpent
21
Years of Service
User Offline
Joined: 24th Feb 2004
Location: U.S.A.
Posted: 27th Feb 2004 04:55
Hold up for a sec!n your draining him of everything he knows! although this is useful because I'm making a first person shooter myself.

$$$Serpant$$$
dragon tail
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location: United Kingdom
Posted: 27th Feb 2004 22:18
nice work dark coder! i played your game, and i have to say its the best FPS game i've played in darkbasic . keep up the good work!

Erm, where was I? Ah, just wondering, where did you get your gun models from? Did you create them in 3DS or something ?

Current Rig:
P4 2.4GHz | 512MB RAM | 80GB | Geforce4 Ti4600 | XP pro SP1
please help the newb
Dark Serpent
21
Years of Service
User Offline
Joined: 24th Feb 2004
Location: U.S.A.
Posted: 16th Mar 2004 01:20 Edited at: 16th Mar 2004 01:25
I just cant get the ammo code to work.
I just can't find out whats wrong. PS. If your looking for the enemy look down(this is the code without the ammo variable or whatever.)

I'm exited in boresville....what does that tell you?

Login to post a reply

Server time is: 2025-05-31 21:22:54
Your offset time is: 2025-05-31 21:22:54