Mounting problems
by Edward Smith · in General Discussion · 12/08/2002 (11:31 pm) · 13 replies
I've been having mounting problems for a long time, and I have come to the point where I feel I have stuffed some of it somewhere, but I'm unsure where it is all meant to be. Because everything seems to make sense.
So can someone please help me?
Edward
So can someone please help me?
Edward
About the author
Currently working on a WW2 FPS game.
#2
anything else in mind?
12/09/2002 (12:24 am)
ahm... all I can think of is that its happening with the vehicles.anything else in mind?
#3
12/09/2002 (2:09 pm)
Like I can't even mount a wheeled Vehicle, and I can't see why not.
#4
12/09/2002 (3:13 pm)
You need to be much more specific. Post your mounting code, for starters...
#5
-------------------------------------------------
function Armor::onAdd(%this,%obj)
{
// Vehicle timeout
%obj.mountVehicle = true;
// Default dynamic armor stats
%obj.setRechargeRate(%this.rechargeRate);
%obj.setRepairRate(0);
}
-------------------------------------------------
function Armor::onMount(%this,%obj,%vehicle,%node)
{
if (%node == 0) {
%obj.setTransform("0 0 0 0 0 1 0");
%obj.setActionThread(%vehicle.getDatablock().mountPose[%node],true,true);
%obj.lastWeapon = %obj.getMountedImage($WeaponSlot);
%obj.unmountImage($WeaponSlot);
%obj.setControlObject(%vehicle);
%obj.client.setObjectActiveImage(%vehicle, 2);
}
}
function Armor::onUnmount( %this, %obj, %vehicle, %node )
{
if (%node == 0)
%obj.mountImage(%obj.lastWeapon, $WeaponSlot);
}
function Armor::doDismount(%this, %obj, %forced)
{
// This function is called by player.cc when the jump trigger
// is true while mounted
if (!%obj.isMounted())
return;
// Position above dismount point
%pos = getWords(%obj.getTransform(), 0, 2);
%oldPos = %pos;
%vec[0] = " 0 0 1";
%vec[1] = " 0 0 1";
%vec[2] = " 0 0 -1";
%vec[3] = " 1 0 0";
%vec[4] = "-1 0 0";
%impulseVec = "0 0 0";
%vec[0] = MatrixMulVector( %obj.getTransform(), %vec[0]);
// Make sure the point is valid
%pos = "0 0 0";
%numAttempts = 5;
%success = -1;
for (%i = 0; %i < %numAttempts; %i++) {
%pos = VectorAdd(%oldPos, VectorScale(%vec[%i], 3));
if (%obj.checkDismountPoint(%oldPos, %pos)) {
%success = %i;
%impulseVec = %vec[%i];
break;
}
}
if (%forced && %success == -1)
%pos = %oldPos;
%obj.mountVehicle = false;//true
%obj.schedule(4000, "MountVehicles", true);
// Position above dismount point
%obj.setTransform(%pos);
%obj.applyImpulse(%pos, VectorScale(%impulseVec, %obj.getDataBlock().mass));
%obj.setPilot(false);
%obj.vehicleTurret = "";
}
-------------------------------------------------
function Armor::onCollision(%this,%obj,%col)
{
if (%obj.getState() $= "Dead")
return;
// Try and pickup all items
if (%col.getClassName() $= "Item")
%obj.pickup(%col);
if((%this.className $= WheeledVehicleData || %this.className $= FlyingVehicleData)
&& %obj.mountVehicle && %obj.getState() $= "Move")
{
if(%col.mountable)
{
// Only mount drivers for now.
%node = 0;
%col.mountable=true;// Set Vehicle Unmountable
%col.mountObject(%obj,%node);
%obj.mVehicle = %col;
}
else
{
%obj.damage(0, VectorAdd(%obj.getPosition(),%vec), 20, "Impact");// to Run over players
// %vecLen * %this.speedDamageScale
}
}
}
-------------------------------------------------------
function Player::mountVehicles(%this,%bool)
{
// If set to false, this variable disables vehicle mounting.
%this.mountVehicle = %bool;
}
function Player::isPilot(%this)
{
%vehicle = %this.getObjectMount();
// There are two "if" statements to avoid a script warning.
if (%vehicle)
if (%vehicle.getMountNodeObject(0) == %this)
return true;
return false;
}
---------------------------------------------------
and the flying vehicle .cs which should be around somewhere, also the wheeled vehicle file from the that project on the vehicles.
I'm pretty sure that is it all. should there be any more somewhere?
Thanks!
Edward
12/10/2002 (1:23 am)
player.cs line 2655 (ok so I added alot lol)-------------------------------------------------
function Armor::onAdd(%this,%obj)
{
// Vehicle timeout
%obj.mountVehicle = true;
// Default dynamic armor stats
%obj.setRechargeRate(%this.rechargeRate);
%obj.setRepairRate(0);
}
-------------------------------------------------
function Armor::onMount(%this,%obj,%vehicle,%node)
{
if (%node == 0) {
%obj.setTransform("0 0 0 0 0 1 0");
%obj.setActionThread(%vehicle.getDatablock().mountPose[%node],true,true);
%obj.lastWeapon = %obj.getMountedImage($WeaponSlot);
%obj.unmountImage($WeaponSlot);
%obj.setControlObject(%vehicle);
%obj.client.setObjectActiveImage(%vehicle, 2);
}
}
function Armor::onUnmount( %this, %obj, %vehicle, %node )
{
if (%node == 0)
%obj.mountImage(%obj.lastWeapon, $WeaponSlot);
}
function Armor::doDismount(%this, %obj, %forced)
{
// This function is called by player.cc when the jump trigger
// is true while mounted
if (!%obj.isMounted())
return;
// Position above dismount point
%pos = getWords(%obj.getTransform(), 0, 2);
%oldPos = %pos;
%vec[0] = " 0 0 1";
%vec[1] = " 0 0 1";
%vec[2] = " 0 0 -1";
%vec[3] = " 1 0 0";
%vec[4] = "-1 0 0";
%impulseVec = "0 0 0";
%vec[0] = MatrixMulVector( %obj.getTransform(), %vec[0]);
// Make sure the point is valid
%pos = "0 0 0";
%numAttempts = 5;
%success = -1;
for (%i = 0; %i < %numAttempts; %i++) {
%pos = VectorAdd(%oldPos, VectorScale(%vec[%i], 3));
if (%obj.checkDismountPoint(%oldPos, %pos)) {
%success = %i;
%impulseVec = %vec[%i];
break;
}
}
if (%forced && %success == -1)
%pos = %oldPos;
%obj.mountVehicle = false;//true
%obj.schedule(4000, "MountVehicles", true);
// Position above dismount point
%obj.setTransform(%pos);
%obj.applyImpulse(%pos, VectorScale(%impulseVec, %obj.getDataBlock().mass));
%obj.setPilot(false);
%obj.vehicleTurret = "";
}
-------------------------------------------------
function Armor::onCollision(%this,%obj,%col)
{
if (%obj.getState() $= "Dead")
return;
// Try and pickup all items
if (%col.getClassName() $= "Item")
%obj.pickup(%col);
if((%this.className $= WheeledVehicleData || %this.className $= FlyingVehicleData)
&& %obj.mountVehicle && %obj.getState() $= "Move")
{
if(%col.mountable)
{
// Only mount drivers for now.
%node = 0;
%col.mountable=true;// Set Vehicle Unmountable
%col.mountObject(%obj,%node);
%obj.mVehicle = %col;
}
else
{
%obj.damage(0, VectorAdd(%obj.getPosition(),%vec), 20, "Impact");// to Run over players
// %vecLen * %this.speedDamageScale
}
}
}
-------------------------------------------------------
function Player::mountVehicles(%this,%bool)
{
// If set to false, this variable disables vehicle mounting.
%this.mountVehicle = %bool;
}
function Player::isPilot(%this)
{
%vehicle = %this.getObjectMount();
// There are two "if" statements to avoid a script warning.
if (%vehicle)
if (%vehicle.getMountNodeObject(0) == %this)
return true;
return false;
}
---------------------------------------------------
and the flying vehicle .cs which should be around somewhere, also the wheeled vehicle file from the that project on the vehicles.
I'm pretty sure that is it all. should there be any more somewhere?
Thanks!
Edward
#6
Because this is really confuseing to me.
Edward
12/11/2002 (10:06 pm)
Is that code ok? should it work? can anything stop it else where?Because this is really confuseing to me.
Edward
#7
You have the last line of your "Armor::onCollision"
function commented out.
// %vecLen * %this.speedDamageScale
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12/12/2002 (3:44 am)
Doubt it is your problem, but I can see one syntax error:You have the last line of your "Armor::onCollision"
function commented out.
// %vecLen * %this.speedDamageScale
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#10
12/13/2002 (7:27 pm)
Are you using the standard unmodified player datablock in server/scripts/player.cs ?
#11
12/13/2002 (10:39 pm)
no it has been moded
#12
className = Armor;
If not, you should, since your mounting methods are Armor.
Also, your vehicle model needs mount points, at least mount0.
your vehicle data block also needs, at a minimum, this:
mountPose[0] = "sitting";
numMountPoints = 1;
and your player model needs a "sitting" sequence. IF you are using the default player character, then you should be covered there.
12/13/2002 (10:50 pm)
in your playerdata block, do you still have this?className = Armor;
If not, you should, since your mounting methods are Armor.
Also, your vehicle model needs mount points, at least mount0.
your vehicle data block also needs, at a minimum, this:
mountPose[0] = "sitting";
numMountPoints = 1;
and your player model needs a "sitting" sequence. IF you are using the default player character, then you should be covered there.
#13
Thanks again!
Edward
12/13/2002 (11:58 pm)
Thanks, it works now :-), not sure how I got rid of it.Thanks again!
Edward
Torque Owner Anthony McCrary