Game Development Community

Get weapon mounted ?

by Michael Cozzolino · in Torque Game Engine · 06/05/2003 (11:42 am) · 2 replies

I am trying to figure out how to get the name of the weapon I'm currently holding when ammo is added to inventory.

So in a sense I want to do something like

*** pseudocode ***

if( %weapon $= "Crossbow" && %this..getName() $= "CrossbowAmmo" )
{

Do something useful
}

Thanks


Coz

Edited to fix dumb sentence

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/05/2003 (10:17 pm)
What you need to do is the following.

I'm going to assume you have the %client that you want to do this to.

//Get the ID of the ShapeBaseImageData that we have mounted
//This will be like "1253" or "2048", or something to that regard
%slotZeroMount = %client.getControlObject().getMountedImage(0);
%slotOneMount = %client.getControlObject().getMountedImage(1);

Now that you have access to the ShapeBaseImageData you can pull your info out, that you want, such as:

item = VulcanCannon;
ammo = RifleAmmo;
projectile = RifleProjectile;
projectileType = Projectile;
casing = RifleShell;

..................
So, if I had my VulcanCannon attached to slot 0, I could do:

%weapon = %slotZeroMount.item;

Now %weapon has the word "VulcanCannon" stored in it.

..................

Or I can type

%ammoType = %slotZeroMount.ammo;

Now %ammoType has the word "RifleAmmo" stored in it.

..................


And, if we want to be fancy, we can do something like:

%ammoName = %slotZeroMount.ammo.pickUpName;

or

%ammoMax = %slotZeroMount.ammo.maxInventory;

And in my case, %ammoName would have "rifle ammo" stored in it, or %ammoMax would be 50.

..................

Hope this helps
#2
06/06/2003 (9:43 am)
Oh I see what you are doing. I think I may have figured out another way. I new I did this before it was in a resource I actually submitted. Getting my head back into scripting after a long layoff.


%weapon = %obj.getMountedImage($WeaponSlot).item.getName();