Game Development Community

Using weapons other than that on mount0?

by Josiah Wang · in Torque Game Engine · 01/15/2005 (4:37 pm) · 0 replies

In my game (where you start out as a vehicle), I have two weapons, one on mount0 and one on mount1. I fired the one on mount0 and it works. Then I switched two the one on mount1. I could then fire that weapon, but two things result:

-shapebaseimage on mount0 becomes the new weapon (essentially, the weapon on mount0 becomes the weapon on mount1)
-i cannot switch back to my original mount0 weapon

in my client/scripts/default.bind.cs, i have the following


moveMap.bindCmd(keyboard, "1", "commandToServer('use',\"Crossbow\");", "");
moveMap.bindCmd(keyboard, "2", "commandToServer('use',\"RocketLauncher\");", "");

RocketLauncher is my mount0 weapon, and crossbow is my mount1 weapon.





I later tried playing around with weapon.cs a little, and I noticed how $WeaponSlot is set to 0 at the top. So i tried changing the Weapon::onUse function from:

function Weapon::onUse(%data,%obj)
{
   // Default behavoir for all weapons is to mount it into the
   // this object's weapon slot, which is currently assumed
   // to be slot 0
   if (%obj.getMountedImage($WeaponSlot) != %data.image.getId()) {
      serverPlay3D(WeaponUseSound,%obj.getTransform());
      %obj.mountImage(%data.image, $WeaponSlot);
      if (%obj.client)
         messageClient(%obj.client, 'MsgWeaponUsed', '\c0Weapon selected');
   }
}

to:

function Weapon::onUse(%data,%obj)
{
   // Default behavoir for all weapons is to mount it into the
   // this object's weapon slot, which is currently assumed
   // to be slot 0
   if (%obj.getMountedImage($WeaponSlot) != %data.image.getId()) {
      serverPlay3D(WeaponUseSound,%obj.getTransform());
      //%obj.mountImage(%data.image, $WeaponSlot);
      if (%obj.client)
         messageClient(%obj.client, 'MsgWeaponUsed', '\c0Weapon selected');
   }
}

(all i did was comment out %obj.mountImage(%data.image, $WeaponSlot); .....)

I loaded up the game, and I tried to switch weapons. The message displayed, but I could not change weapons anymore.



What my interpretation of the code is that weapons can only be fired when they are mounted on mount0. How can I change this so that it can fire weapons from an mount point?

I'm thinking of maybe adjustng the trigger0 a little bit in the source, but I can't seem to find what i need - player.cc only has trigger[0] for animations, and flyingvehicle.cc and vehicle.cc don't have trigger[0] either.

any help on this? many thanks in advance!