Game Development Community

How can i equip an arbitrary weapon to the player.

by Kyrah Abattoir · in Torque 3D Professional · 12/02/2011 (2:53 pm) · 5 replies

As far as i understand, in it's default state, T3D 1.2 require you to specify how many copies of each weapon the player can carry and which ammunitions to use.

Now i'm planning to entirely ignore the default torque weapon inventory system for my own, different system.

Thing is there is a good chance that my inventory system will allow duplicate weapons with different stats and in general something more complex than the fixed size weapon inventory.

Now lets say i make a weapon, can i simply mount it on the player and load the ammo for it?

Also, can i dismount the weapon but keep it "loaded" in the game so i can re-mount in the same state it was?

This would save me from having to serialize/deserialize the weapon status (quality, amunitions left in clip, attached optics, ...)

#1
12/03/2011 (11:52 pm)
For sure yes to your first question. It's the stock inventory scripts that require datablock settings for things to be used, so if you're not using them then you can do whatever you like.

The second part is a bit trickier. Since ShapeBaseImages aren't objects and don't really exist in their own right, you'll need to write your own logic for that. It might be as simple as creating a ScriptObject to represent the weapon when it is stored, and setting flags and variables on that object. Then when you load up your weapon again, you read the values off that object and perform the necessary modifications.

I decided I didn't like the fact that Images aren't first-rate objects, and ported most of their functionality (i.e., the state machine) to the Item class. I still haven't ported that work to T3D, but I had a fairly good system working. Benefits included the fact that every single weapon item existed continuously, independent of it being held in someone's hand.
#2
12/04/2011 (7:52 am)
OKay so since ShapeBaseImages cease to exist when they are unmounted what you suggest is that i use a scriptobject to do some form of serialization process am i right?

So the shapebaseimage becomes the representation of the useable object, while the scriptobject is the inventory representation of this object.
#4
12/05/2011 (1:28 pm)
If you mean serialization as in saving the mission state, you might have to do more work. But if you just mean inventory storage, then yeah, that's basically it. You could always just add lots of members to your Player object, but I prefer a multi-object approach. Though you might not want to bloat the object count too severely; if you have large numbers of players and items, I'm not sure what sort of performance hit this would entail.
#5
12/05/2011 (4:38 pm)
Okay hm... can i tie those objects in some way to the player object? a bit like you can stick other objects in a simgroup?