Game Development Community

Adding a new action map

by Mike Stoddart · in Torque Game Engine · 08/31/2002 (7:48 pm) · 0 replies

I'm trying to add a new action map for when the player is mounted on a vehicle. Essentially I want to prevent the player from being able to use keys that let them change weapons, jump and other such actions.

So I added a new file vehicleMap.cs with the following:

Quote:// vehicleMap.cs

if ( isObject( vehicleMap ) )
vehicleMap.delete();
new ActionMap(vehicleMap);


//------------------------------------------------------------------------------
// Non-remapable binds
//------------------------------------------------------------------------------

function escapeFromGame()
{
if ( $Server::ServerType $= "SinglePlayer" )
MessageBoxYesNo( "Quit Mission", "Exit from this Mission?", "disconnect();", "");
else
MessageBoxYesNo( "Disconnect", "Disconnect from the server?", "disconnect();", "");
}

vehicleMap.bindCmd(keyboard, "escape", "", "escapeFromGame();");
vehicleMap.bindcmd(keyboard, "F2", "", "PlayerListGui.toggle();");
etc.....

And I execute the script with no problems.

I added the following code that gets executed in the player.cs file when you collide with the vehicle to mount you:

Quote: if ((%this.className $= "WheeledVehicleData") && %obj.mountVehicle &&
%obj.getState() $= "Move" && %col.mountable)
{
echo("Mounting vehicle");

moveMap.pop();
vehicleMap.push();

I figured that I should pop the moveMap so it is no longer used, and push the vehicleMap so it is used instead.

Then when the player dismounts, I'll reverse the above with:

Quote: moveMap.pop();
vehicleMap.push();

However, the new vehicleMap doesn't seem to work. At least I don't think it does. It seems as though I'm still using the moveMap as I can still wave (which I didn't include in the vehicleMap) and the spacebar still works, even though I haven't defined it in vehicleMap.

Is there something else that I should be doing? Should I add the new vehicleMap into config.cs along with the moveMap keys?

Any suggestions are most welcome. Thanks!