Author Topic: Editing the RC Sapper  (Read 1771 times)


I would like to edit the RC Sapper so that is doesn't explode. As of now, it explodes when it touches players and other RC's, and when it hits objects while moving at fast speeds. It also explodes when it falls from high places.


It would be great if someone could either tell me how to do this, or do it themselves and give me a link to it or something. I know that someone has already done this, so it can't be too tough.


Incase your wondering, I am doing this because I want to race them, and it is hard to race them if they explode on impact.


If they don't explode there is not really a point in them at all.

I want to race them, like I said in my first message.

I want to race them, like I said in my first message.
Why not just race vehicles?

Join Blur's server to find out. They are a nice size for 32x32 sized roads and are fun to drive because they drift a little.

Why not just race vehicles?
The sappers are actually a lot of fun to race.

Code: [Select]
exec("./playertype.cs");
exec("./emitters.cs");

datablock ItemData(BombBotItem)
{
category = "Item";  // Mission editor category
equipment = true;

//its already a member of item namespace so dont break it
//className = "Item"; // For inventory system

// Basic Item Properties
   shapeFile = "./rcbombItem.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "RC Sapper";
iconName = "./icon_rc_bomb";
doColorShift = false;
colorShiftColor = "0.200 0.200 0.200 1.000";

// Dynamic properties defined by the scripts
image = BombBotImage;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(BombBotImage)
{
   // Basic Item properties
   shapeFile = "./rcbombItem.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0.2";
   rotation = eulerToMatrix("0 0 0");
   eyeOffset = "0.005 1.1 -1.25";
   eyeRotation = eulerToMatrix("-28 4 4");

   doColorShift = true;
colorShiftColor = BombBotItem.colorShiftColor;
   

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off. 
   correctMuzzleVector = false;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "ToolImage";

   // Projectile && Ammo.
   item = BombBotItem;

   //melee particles shoot from eye node for consistancy
   melee = true;
   //raise your arm up or not
   armReady = true;

   doColorShift = true;
   minShotTime = 15000;
   colorShiftColor = BombBotItem.colorShiftColor; //"0.200 0.200 0.200 1.000";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.5;
stateTransitionOnTimeout[0]       = "Ready";

stateName[1]                     = "Ready";
stateScript[1]                  = "onUse";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;

stateName[2]                    = "Fire";
stateTransitionOnTriggerUp[2] = "Ready";
stateScript[2]                  = "onFire";
};

function BombBotImage::onMount(%this, %obj, %slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime() && %this.usedsapper == 1)
{
centerprint(%obj.client,"Can't deploy another RC Sapper yet!<br><br>Give it a while to respawn..." ,5);
serverCmdUnUseTool(%obj.client);
return;
%obj.playThread(2, undo);
}


%obj.playthread(1, armReadyBoth);
}

function BombBotImage::onUnMount(%this,%obj,%slot)
{
Parent::onUnMount(%this, %obj, %slot);

fixArmReady(%obj);
}

function BombBotImage::onFire(%this, %obj, %slot)
{
%obj.lastFireTime = getSimTime();
%this.usedsapper = 1;
SpawnBomber(%obj.client);
%obj.playThread(1, plant);
%obj.playThread(2, activate2);
serverCmdUnUseTool(%obj.client);
}

function SpawnBomber(%client)
{
%obj = %client.player;
%pos = vectorAdd(%obj.getTransform(), vectorScale(%obj.getForwardVector(), 4)) @ getWords(%obj.getTransform(), 3, 6);


%bot = new AIPlayer()
{
datablock = "bomberbotArmor";
position = %pos;
};
%bot.setTransform(%pos);

%client.setcontrolobject(%bot);
%client.player.bomberbotarmor = %bot;

%bot.name = "RC Bomb";
%bot.bomberOwner = %client;
%bot.minigame = %obj.client.minigame;
%bot.client = %bot;
%bot.tdmTeam = %obj.client.tdmTeam;
%bot.player = %bot;
}

function bomberbotarmor::onDisabled(%this,%obj,%state)
{
bomberbotarmorExplosion(%obj);
}

function bomberbotarmor::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getclassname() $= "Player" || %col.getclassname() $= "WheeledVehicle" || %col.getclassname() $= "FlyingVehicle" || %col.getclassname() $= "AIPlayer")
{
bomberbotarmorExplosion(%obj);
}
}

function bomberbotarmor::onTrigger(%this, %obj, %slot, %val)
{
if(%val == 1 && %slot == 4)
{
bomberbotarmorExplosion(%obj);
}
}

function bomberbotarmorExplosion(%obj)
{
if(isObject(%obj.getControllingClient()))
%obj.getControllingClient().setControlObject(%obj.getControllingClient().player);

%projectile = gravityrocketProjectile;
%p = new Projectile()
{
dataBlock = %projectile;
initialVelocity = "0 0 1";
initialPosition = %obj.getPosition();
sourceObject = %obj.bomberOwner.player;
sourceSlot = %slot;
client = %obj.bomberOwner;
};

MissionCleanup.add(%p);
%p.explode();

%obj.schedule(10, delete);
}
Copy and paste this into the Server.cs in Weapon_RCBomb this is the exact same code except with the impact function removed


After pasting that into the file it wouldn't save it. It said the file could not be created and to make sure that the path and file name are correct. Am I doing something wrong?


Save it to the desktop, then copy and paste it back into the zip file.

I deleted this function and everything below it - function bomberbotarmor::onDisabled(%this,%obj,%state) - And now it seems to work like I wanted it to. The only thing that helped me was saving it to desktop first, so thankyou Greek2me, and thankyou everyone else for your efforts.
« Last Edit: December 23, 2011, 09:10:14 PM by Wink »

Ok, new problem. I want the RC to explode when the player Ctrl K's. How do I do this? If only I new the command for client Ctrl K, I could maybe script it myself.

serverCmdSelf Delete( client )

So if I added this it would work?

function bomberbotarmor::onserverCmdSelf Delete (client)
{
   bomberbotarmorExplosion(%obj);
}
                     

No.

Code: [Select]
package bomberBotPackage
{
function serverCmdSelf Delete( %cl )
{
// your code either goes here
parent::serverCmdSelf Delete( %cl );
// or here, depends on what your code is
}
};
activatePackage( bomberBotPackage );


Someone please tell me why this didnt work. The only time I want the RC to blow up is when the controller right clicks and when the controller Ctrl K's. I added Port's package near the bottom.

Code: [Select]
exec("./playertype.cs");
exec("./emitters.cs");

datablock ItemData(BombBotItem)
{
category = "Item";  // Mission editor category
equipment = true;

//its already a member of item namespace so dont break it
//className = "Item"; // For inventory system

// Basic Item Properties
   shapeFile = "./rcbombItem.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "RC Sapper";
iconName = "./icon_rc_bomb";
doColorShift = false;
colorShiftColor = "0.200 0.200 0.200 1.000";

// Dynamic properties defined by the scripts
image = BombBotImage;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(BombBotImage)
{
   // Basic Item properties
   shapeFile = "./rcbombItem.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0.2";
   rotation = eulerToMatrix("0 0 0");
   eyeOffset = "0.005 1.1 -1.25";
   eyeRotation = eulerToMatrix("-28 4 4");

   doColorShift = true;
colorShiftColor = BombBotItem.colorShiftColor;
  

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off.  
   correctMuzzleVector = false;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "ToolImage";

   // Projectile && Ammo.
   item = BombBotItem;

   //melee particles shoot from eye node for consistancy
   melee = true;
   //raise your arm up or not
   armReady = true;

   doColorShift = true;
   minShotTime = 15000;
   colorShiftColor = BombBotItem.colorShiftColor; //"0.200 0.200 0.200 1.000";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.5;
stateTransitionOnTimeout[0]       = "Ready";

stateName[1]                     = "Ready";
stateScript[1]                  = "onUse";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;

stateName[2]                    = "Fire";
stateTransitionOnTriggerUp[2] = "Ready";
stateScript[2]                  = "onFire";
};

function BombBotImage::onMount(%this, %obj, %slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime() && %this.usedsapper == 1)
{
centerprint(%obj.client,"Can't deploy another RC Sapper yet!<br><br>Give it a while to respawn..." ,5);
serverCmdUnUseTool(%obj.client);
return;
%obj.playThread(2, undo);
}


%obj.playthread(1, armReadyBoth);
}

function BombBotImage::onUnMount(%this,%obj,%slot)
{
Parent::onUnMount(%this, %obj, %slot);

fixArmReady(%obj);
}

function BombBotImage::onFire(%this, %obj, %slot)
{
%obj.lastFireTime = getSimTime();
%this.usedsapper = 1;
SpawnBomber(%obj.client);
%obj.playThread(1, plant);
%obj.playThread(2, activate2);
serverCmdUnUseTool(%obj.client);
}

function SpawnBomber(%client)
{
%obj = %client.player;
%pos = vectorAdd(%obj.getTransform(), vectorScale(%obj.getForwardVector(), 4)) @ getWords(%obj.getTransform(), 3, 6);


%bot = new AIPlayer()
{
datablock = "bomberbotArmor";
position = %pos;
};
%bot.setTransform(%pos);

%client.setcontrolobject(%bot);
%client.player.bomberbotarmor = %bot;

%bot.name = "RC Bomb";
%bot.bomberOwner = %client;
%bot.minigame = %obj.client.minigame;
%bot.client = %bot;
%bot.tdmTeam = %obj.client.tdmTeam;
%bot.player = %bot;
}

function bomberbotarmor::onDisabled(%this,%obj,%state)
{
bomberbotarmorExplosion(%obj);
}

function bomberbotarmor::onTrigger(%this, %obj, %slot, %val)
{
if(%val == 1 && %slot == 4)
{
bomberbotarmorExplosion(%obj);
}
}

package bomberBotPackage
{
function serverCmdSelf Delete( %cl )
{
// your code either goes here
parent::serverCmdSelf Delete( %cl );
// or here, depends on what your code is
}
};
activatePackage( bomberBotPackage );

function bomberbotarmorExplosion(%obj)
{
if(isObject(%obj.getControllingClient()))
%obj.getControllingClient().setControlObject(%obj.getControllingClient().player);

%projectile = gravityrocketProjectile;
%p = new Projectile()
{
dataBlock = %projectile;
initialVelocity = "0 0 1";
initialPosition = %obj.getPosition();
sourceObject = %obj.bomberOwner.player;
sourceSlot = %slot;
client = %obj.bomberOwner;
};

MissionCleanup.add(%p);
%p.explode();

%obj.schedule(10, delete);
}
« Last Edit: December 24, 2011, 10:39:27 AM by Wink »