Game Development Community

Setting up a Max weapon count for a player?

by Michael Cozzolino · in Torque Game Engine · 07/29/2002 (8:41 am) · 4 replies

I'm using Tim Newell's Inventory manager and I was hoping someone could point me in the direction of how to create a max weapon count so the player can only hold say 2 or three weapons at a time.


Thanks, Coz

About the author

Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489


#1
07/29/2002 (8:47 am)
This is just off the top of my head, but you could probably do something as simple as having a variable to hold the number of weapons the player currently has. Then somewhere like Weapon::onPickup() you'd increment that variable. Then as a weapon is atempted to be picked up, you just check that variable to see if they are allowed to. That check would probably be in ShapeBase::pickup() in inventory.cs.
#2
07/29/2002 (10:27 am)
Although your logic was correct I needed to do the check in Weapon::onPickup in weapon.cs

Thanks for the help.

Now I need to figure out how to throw weapons :)
#3
07/29/2002 (10:35 am)
Glad you got it working.

I'm curious tho, why do you need to do it Weapon::onPickup? Its called after ShapeBase::pickup, so I was thinking that you'd want to make the check as soon as possible. From ShapBase::pickup you can get access to the datablock of the item that was just picked up, and thus determine if its a weapon or not.

I'm not actually sure, when does it actually "pick up" the item from the game world, ie remove it from being drawn? I think you're only requirement would be to check before that is being done, wouldn't it?

At any rate, good to hear you're on the right track.
#4
07/29/2002 (10:53 am)
Your right. I was just being lazy :) so I did it in Weapon.cs