Fire Two Weapons at the same time
by Britt Scott · in Torque Game Engine · 08/11/2008 (12:24 am) · 8 replies
I was wondering how to get two weapons to fire at the same time or get a weapon with a different mount to fire, that has inherited values? I have a Gun that works fine on the first mount. The second Gun that has inherited values mounts on the second mount, but doesn't fire. Thanks in Advance!
About the author
Attended Brown College in Mendota Heights, MN for Game Design and Development. Projects include the Mech Starter Kit and the Battle Frog. Currently working toward a game design career.
#2
08/11/2008 (9:27 am)
I was hoping for a way to do this purely in TorqueScript, but I'll give this a shot.
#3
Don't know if this will work or I may have forgotten something. This is ofcourse absolutely ugly and, like I already wrote in the comment, it doesn't use the states of the weaponImage. It should just create/fire a projectile.
edit: forgot a bracket
08/11/2008 (1:08 pm)
You could perhaps fire a projectile from the weaponImage by calling this in the Armor::onTrigger method (server/scripts/player.cs)function Armor::onTrigger(%this, %obj, %triggerNum, %val)
{
// This method is invoked when the player receives a trigger
// move event. The player automatically triggers slot 0 and
// slot one off of triggers # 0 & 1. Trigger # 2 is also used
// as the jump key.
if(%triggerNum == 1)
{
// No weaponfire sound, reload state or anything like that
%slotToFire = 1; // Change to the slot of your choice, or just remove this variable and hardcode it
%obj.getMountedImage(%slotToFire).onFire(%obj, %slotToFire);
}
}Don't know if this will work or I may have forgotten something. This is ofcourse absolutely ugly and, like I already wrote in the comment, it doesn't use the states of the weaponImage. It should just create/fire a projectile.
edit: forgot a bracket
#4
08/11/2008 (11:33 pm)
The weaponImages do fire. Right now, I have it setup where you can hold both mouse buttons to fire both weapons. The only problem is that the second weapon fires from the first weapon's muzzlepoint.
#5
08/12/2008 (1:55 am)
Are you using the same weaponImage for both weapons? If so you should try to make the second weaponImage a different one and change the mountpoint.
#6
08/12/2008 (7:39 pm)
Yes, I am. Can I not add another weapon datablock in the same .CS file? I made copies of the itemdata and shapedata. I don't change the Projectile datablock. Is it possible to set which weaponimage is used based on which mouse button is pressed or do just have to manually switch weapons? Thanks for the help so far!
#7
There are several resources which show you how to set up dual wielding, but if I remember correctly they use the left and right mouse buttons. With the code I provided in my first reply it is possible to fire both weapons, at the same time, with the left mouse button.
08/18/2008 (7:39 am)
Yes, you can define another weapon datablock, or anything you can imagine, in the same .cs file. You should however only need to copy the weaponImageData and change the mountpoint in the second weaponImage.There are several resources which show you how to set up dual wielding, but if I remember correctly they use the left and right mouse buttons. With the code I provided in my first reply it is possible to fire both weapons, at the same time, with the left mouse button.
#8
08/18/2008 (9:01 am)
Thanks, guess I'll just have to give in and do some engine changes.
Torque 3D Owner Vincent D
In Player.cpp in Player::updateMove( .. ) replace the lines at the top of the method below the comment
for example to look like this
// Trigger images if (mDamageState == Enabled) { setImageTriggerState(0,move->trigger[0]);// Vincent: weaponSLot 0 and 1 are triggerd with left mouse button!! setImageTriggerState(1,move->trigger[0]); setImageTriggerState(2,move->trigger[1]);// weaponslot 2 should be triggered with the right button }Now when you mount a weaponImage on mount0 and/or mount1 they will both fire
hope this helps