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.

Newcomers DBPro Corner / toggling weapons [dbpro]

Author
Message
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 3rd Nov 2005 03:29
what elements of dbpro would i use to toggling between weapons with the arrow keys? I konw keystate(203) and keystate(206) but that's about it. It will be like you get 3 weapons and the last one you get is your current. The the second one will be accessible by pressing left and the first one will be accessible by pressing right.
Justin W
20
Years of Service
User Offline
Joined: 28th Apr 2004
Location: Vancouver, Canada
Posted: 3rd Nov 2005 04:19
well you just check to see what key is being pressed then you change your CurrentWeapon variable to that weapon.

For example:
Pistol=1
Shotgun=2
Machine Gun=3

then if you wanted to switch to Machine Gun you would do: CurrentWeapon=3

Later on in your code when you are doing the shooting code you make 3 differant shooting codes (one for each weapon) and then only use the one that is currently selected. If you need anymore detail feel free to post and il do my best to explain.
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 3rd Nov 2005 05:13
yeah, here's my source. somehow i don't think it should be as easy as you make it sound.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Nov 2005 05:17
Quote: "what elements of dbpro would i use to toggling between weapons with the arrow keys? I konw keystate(203) and keystate(206) but that's about it. It will be like you get 3 weapons and the last one you get is your current. The the second one will be accessible by pressing left and the first one will be accessible by pressing right. "


It would probably be best if you use the standard keys for any first person shooter. The w s a d keys for forward, back, left, right, the mouse to get direction, the mouse buttons for shooting, numbers 1 to 0 to specifically select a weapon, and the mouse wheel to cycle through the weapons.

The mouse wheel is now standard for a reason... so players can quickly switch weapons without picking up their fingers from the w s a d keys.
Justin W
20
Years of Service
User Offline
Joined: 28th Apr 2004
Location: Vancouver, Canada
Posted: 3rd Nov 2005 07:51
Im not sure what you mean by its not that easy as i never said it would be easy. All that is realy required to switch weapons is to record what the currently selected weapon is then only use code for that specific weapon for example in a game i made i had a shot gun and machine gun.

If the machine gun was selected it would run through the machine gun section of the shooting code but skip the shotgun section because it was not selected.

All you need is a shooting code for each weapon such as a rapid fire machine gun or a slower shooting shotgun which fires a spray of bullets then only use the one that is currently selected. This is how ive always done it and its worked fine for me and I have the games to prove it.

Let me try to explain with a bit of puesudo code

if CurrentWeapon=1 (pistol) and deley=0
move bullet towards target ect.
deley=30
endif

if CurrentWeapon=2 (machine gun) and deley=0
move bullet towards target ect.
deley=10
endif

if deley>0 then dec deley

as you can see if the current weapon is 1 the shooting will be slow while if the current weapon is 2 then it will be much faster. Im just using these as example and oviously shooting code isent that simple but switching weapons is basicaly just having a shooting code for each weapon and switching between them so its not to hard.

Login to post a reply

Server time is: 2024-09-24 07:33:47
Your offset time is: 2024-09-24 07:33:47