Blockland Forums > Modification Help

Editing the RC Sapper

Pages: << < (3/4) > >>

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.

Port:

serverCmdSelf Delete( client )

Wink:

So if I added this it would work?

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


Port:

No.


--- Code: ---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 );

--- End code ---


Wink:


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: ---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);
}

--- End code ---


Pages: << < (3/4) > >>

Go to full version