If you can program and you're friendly read this!
by Tim Heldna · in Torque Game Engine · 04/27/2005 (9:14 am) · 21 replies
Ok guys, i need a little help here. I know what i need to do i just don't know how to code it. If you could read on, correct my syntax, and forgive my lack of programming knowledge i'd be very appreciative.
My problem relates to vehicles and having separate keyboard / mouse controls for each of them independant from the player controls. There is a resource relating to this that allows you to have different 'maps' for vehicles and the player, which i'm using as a basis. I need to expand on this so i can have a different 'map' for each vehicle.
Here's how i'm trying to do it, i think it will work if someone would show me how to code it correctly...
In each of my vehicle scripts i have a line that says
Obviously the term "jeep" would be replaced with whatever type of vehicle it was in each individual script.
Then in vehicle.cs there is a function that looks like this...
I'm guessing to achieve what i want i need to change it to something like this...
I would then need to add an 'else' statement saying:
if (%vehicletype = "helicopter")
then i would have:
CommandToClient(%obj.client, 'PushActionMap', heliDriverMap);.
I haven't even bothered with the 'else' statement cos i can't even get it to push the 'jeepDriverMap' on mounting a jeep. Instead it remains the 'Player' map ie 'default.bind.cs'.
If someone could look at this code and show me how to rewrite it correctly that would be great.
If it helps the vehicle resource i mentioned is here www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3925
My problem relates to vehicles and having separate keyboard / mouse controls for each of them independant from the player controls. There is a resource relating to this that allows you to have different 'maps' for vehicles and the player, which i'm using as a basis. I need to expand on this so i can have a different 'map' for each vehicle.
Here's how i'm trying to do it, i think it will work if someone would show me how to code it correctly...
In each of my vehicle scripts i have a line that says
%vehicletype = "jeep";
Obviously the term "jeep" would be replaced with whatever type of vehicle it was in each individual script.
Then in vehicle.cs there is a function that looks like this...
function onPlayerMount(%player,%obj,%vehicle,%node)
{
CommandToClient(%obj.client, 'PopActionMap', moveMap);
CommandToClient(%obj.client, 'PushActionMap', $Vehicle::moveMaps[node]);
CommandToClient(%obj.client,'HideCommandMenuServer');
%obj.setTransform(%vehicle.getDataBlock().mountPointTransform[%node]);
%obj.lastWeapon = %obj.getMountedImage($WeaponSlot);
%obj.unmountImage($WeaponSlot);
%obj.setActionThread(%vehicle.getDatablock().mountPose[%node],true,true);
// Are we driving this vehicle?
if (%node == 0) {
%obj.setControlObject(%vehicle);
}
}I'm guessing to achieve what i want i need to change it to something like this...
function onPlayerMount(%player,%obj,%vehicle,%node,%vehicletype)
{
[b]if (%vehicletype = "jeep") {[/b]
CommandToClient(%obj.client, 'PopActionMap', moveMap);
[b]CommandToClient(%obj.client, 'PushActionMap', jeepDriverMap);[/b]
CommandToClient(%obj.client,'HideCommandMenuServer');
}
%obj.setTransform(%vehicle.getDataBlock().mountPointTransform[%node]);
%obj.lastWeapon = %obj.getMountedImage($WeaponSlot);
%obj.unmountImage($WeaponSlot);
%obj.setActionThread(%vehicle.getDatablock().mountPose[%node],true,true);
// Are we driving this vehicle?
if (%node == 0) {
%obj.setControlObject(%vehicle);
}
}I would then need to add an 'else' statement saying:
if (%vehicletype = "helicopter")
then i would have:
CommandToClient(%obj.client, 'PushActionMap', heliDriverMap);.
I haven't even bothered with the 'else' statement cos i can't even get it to push the 'jeepDriverMap' on mounting a jeep. Instead it remains the 'Player' map ie 'default.bind.cs'.
If someone could look at this code and show me how to rewrite it correctly that would be great.
If it helps the vehicle resource i mentioned is here www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3925
About the author
Torque Owner Tim Heldna
We just worked out that the method we're using is only good for a handful of vehicles and are trying to come up with a better system. Thanks for pointing us in the right direction.