FAQ  •  Register  •  Login

detecting the players current weapons and removing them?

Moderator: Inside3D Admins

<<

ceriux

User avatar

Posts: 1852

Joined: Sat Sep 06, 2008 3:30 pm

Location: Florida, USA

Post Thu Mar 22, 2012 9:14 pm

detecting the players current weapons and removing them?

how can i detect what weapons the player has ? that way i can remove them. basically iv built a buy menu and i need to check which weapon the player has and when he purchases the new weapon remove it.

would i do something like make a .float and store owep? and if owep = it_wep self.items = self.items && self.items - owep? or something?
QuakeDB - if you have any cool quake video's please feel free to upload them on my moddb group!
<<

andrewj

Posts: 132

Joined: Mon Aug 30, 2010 3:29 pm

Location: Tasmania

Post Fri Mar 23, 2012 12:53 am

Re: detecting the players current weapons and removing them?

Check:
if (self.items & wep)
{
// do something
}

Remove:
self.items = self.items - (self.items & wep)

where 'wep' is IT_SHOTGUN etc...
<<

ceriux

User avatar

Posts: 1852

Joined: Sat Sep 06, 2008 3:30 pm

Location: Florida, USA

Post Fri Mar 23, 2012 4:03 am

Re: detecting the players current weapons and removing them?

andrewj wrote:Check:
if (self.items & wep)
{
// do something
}

Remove:
self.items = self.items - (self.items & wep)

where 'wep' is IT_SHOTGUN etc...



right, but how would i be able to keep track of which weapon? say you start with the shotgun, but you buy a... nailgun owep gets turned to 3 since shotgun would be 1. i have to keep track of the players weapon that way when they buy a new weapon the remove code i call knows which to remove. so basically if owep == this remove this weapon. i could call owep , mywep so if mywep == 1 and i purchase a nailgun since mywep is 1 it would know to call the code to remove the shotgun that way when the player is given the nailgun he doesnt have both and the wrong weapon isnt removed, i would just change mywep to the number of the current held weapon. would this work?
QuakeDB - if you have any cool quake video's please feel free to upload them on my moddb group!
<<

DukeInstinct

User avatar

Posts: 20

Joined: Sat Jul 10, 2010 11:20 pm

Location: DukeLand

Post Fri Mar 23, 2012 9:58 am

Re: detecting the players current weapons and removing them?

self.items should already be keeping track of the weapons the player possesses.

Couldn't you just set self.items to the flag of the new weapon and force the player to select the new one? Like so:

self.items = IT_SHOTGUN;

As long as you're not using self.items for things other than weapons, that should work. Otherwise, you could subtract just the weapon flags off and then add the new one.

if (self.items & IT_SHOTGUN)
self.items = self.items - IT_SHOTGUN;

and just repeat for all the other possible flags.
Image
<<

r00k

Posts: 906

Joined: Sat Nov 13, 2004 10:39 pm

Post Fri Mar 23, 2012 5:20 pm

Re: detecting the players current weapons and removing them?

You could have it so that they can sell the shotgun back to the "store" for half price.

  Code:
self.items = self.items - (self.items & IT_SHOTGUN);//the IT_SHOTGUN can be replaced with a variable of the sold item
self.weapon = 0; //this is for the hud
self.currentammo = 0;//hud
self.weaponmodel = "";//dont draw the viewmodel
self.weaponframe = 0;//reset animation


Look at the weapon touch function to get an example of how to equip the player when they buy an item.

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.
Icons provided by Aha Soft