Game Development Community

Weapon grouping

by Ronald J Nelson · in Torque Game Engine · 07/24/2008 (4:59 pm) · 6 replies

I wanted to see if someone else had already done this in hopes they can give me some pointers so I have a good direction to start.

In our game we have vehicles with multiple weapons. We want to allow the player to be able to select weapons to add into firing groups.

Now I have been in the GG community for a while now and have not seen anything like this in any resource or forum. So am asking, if you have managed to do this, would you mind just giving me a a couple of pointers on how you did it?

Thanks in advance.

#1
07/24/2008 (5:28 pm)
Add them in groups so they all fire, allow the player to customize equipped weapons, or use multiple weapons?
#2
07/24/2008 (6:25 pm)
For example the player has 2 light machine guns, 1 heavy machine gun, and a rocket launcher mounted to his vehicle. He wants to group the light machine guns and the heavy machine gun to fire at the same time in one group and leave the rocket launcher to fire as another group.
#3
07/24/2008 (7:34 pm)
Not 100% what you're looking for, but the undercode will at some point access(as one current proof-of concept model were looking at this end):

function mouseFire(%val)
{
   $mvTriggerCount0++;
   $mvTriggerCount1++;
   $mvTriggerCount2++;
   $mvTriggerCount4++;
}

function altTrigger(%val)
{
   $mvTriggerCount5++;
   $mvTriggerCount6++;
}

moveMap.bind( mouse, button0, mouseFire );
moveMap.bind( mouse, button1, altTrigger );

Where mounts are extended to a total of 8, so in this instance left click will knock out 4 weapons, and right click will knock out the other two. since you've already got that many guns mounted on a vehicle, you already know where to look for the forwarding of keybinds I'll bet. Past that point, it's should just be a case of reordering the triggercount increments based on a gui/prefab grouping header/simobjectlisting/whathaveyou. That about what you were looking for?
#4
07/24/2008 (8:31 pm)
I have to say Kirk that is a totally different way than I was considering, but yours may be the far better method.
#5
07/25/2008 (10:55 am)
Oh, don't get me wrong, unless we decide to keep it truly hyper-simplistic, this will no doubt have a few extra layers of complexity added to it as well down the line, but when you get right down to it, there's only 2 ways to fire triggers simultaneously that I'm aware of at least. Triggering multiple triggers at once, or going server-side and pulling something like:

function aiFlyingVehicle::botAutoFire(%this)
{
	if (!isObject(%this))
	{
		%this.autoFire = false;
		return;
	}
	if (!isObject(%this.target))
	{
		%this.autoFire = false;
		return;
	}
	if (%this.autoFire == true) 
	{
		%numguns = getRandom(0,%this.maxguns)+1;
		for (%i = 0; %i<= %numguns; %i++)
		{
			if (%this.isInLOS(%this.target,%i))
			{
				%this.setImageTrigger(%i,true);//<---------------------------------------- fire (mount#,bool)
				%this.setImageTrigger(%i,false);//<--------------------------------------- stop firing (mount#,bool)
				//error("Firing Slot #" @ %i @ "/" @ %this.maxguns @ ": " @ %this.getMountedImage(%i));
			}
		}
		%this.schedule(250, botAutoFire);
	}
}

as with the above wip-extracted bot firing routine, that as you can see just takes a random portion of the total, and fires those directly via server. Thing is, I'd presume (and thus could of course be dead wrong) you're talking wanting user-definable groups, so it just makes sense (to me) to go with the former example.
#6
07/25/2008 (1:39 pm)
Yup and already got it up and working today. Thanks again.