Game Development Community

Getting weapon inventory count

by Michael Cozzolino · in Torque Game Engine · 06/10/2003 (7:01 am) · 2 replies

Ok here is what i'm trying to do.

I am trying to have my player only be able to have 2 weapons. My problem is that I don't know how to get the amount of weapons the player currently has in their inventory. 2nd I don't know if I should try to do this check in Weapon::onPickup or Weapon::onInventory I would assume on pickup.

In my player datablock I have:
maxWeapons = 2;

I access that in Weapon::onPickup with :

%MaxWeapons = %shape.getdatablock().maxWeapons;

So I need to do something like

if(%CurrentWeaponCount < %MaxWeapons)
{
Pick up Weapon
}

I need to know how to get %CurrentWeaponCount

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
06/10/2003 (8:01 am)
have a look at server\scripts\inventory.cs
#2
06/11/2003 (5:17 am)
Ok I think I figured it out. Seems to work.


if(%%shape.weaponSlotCount < %MaxWeapons)
{
Pick up Weapon
}


Thanks for pointing me in the right direction.

I had a moment of clarity at work and it hit me.

I usually figure things out when I'm at work. I would write psuedocode for my programming projects during work. Funny how my mind works sometimes :)

Thanks again Ron.