Weapon Switch

Blitz3D Forums/Blitz3D Programming/Weapon Switch

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm creating an FPS and the entire point of it is for it to be dynamic - so I can create levels on the fly just by editing a simple XML file. It was all going fine until I got to the weapon part. I needed a way to dynamically pick up weapons, and toggle weapons depending on how many you had.

Here is my code so far. "WEAPON_Update()" is called in the main loop.

Function WEAPON_Update()
	
	t_weapon = 0
	
	For uw.weapon = Each weapon
		
		If uw\inhand = False
			If EntityDistance(camera, uw\entity) < 3
				weaponpick = CameraPick(camera, 800,600)
				If weaponpick = uw\entity
					Color 0,255,0
					Text "Pick Up" + uw\name$
					If MouseHit(2)
						uw\inhand = True
						uw\active = True
						c_weapon = uw\id
					EndIf
				EndIf
			EndIf
		ElseIf uw\inhand = True
			t_weapon = t_weapon + 1
			If c_weapon = uw\id
				uw\active = True
			Else
				uw\active = False
			EndIf
			If KeyHit(15) Then c_weapon = c_weapon + 1
			If c_weapon > t_weapon Then c_weapon = 0
		EndIf
		
		If uw\active = True
			ShowEntity uw\entity
		Else
			HideEntity uw\entity
		EndIf 
	Next	

End Function

This code doesn't work, but otherwise, I have no other way to approach the situation.

Any ideas?

Thanks in advance,
No Enemies