Author Topic: Death...  (Read 2037 times)

How would i get
Code: [Select]
armor::onremoveto spawn something after you die.

Code: [Select]
function Armor::onRemove(%this, %obj){
%client = %obj.client;
%maxitems = 5;
%client.lastpos = %obj.gettransform();
%client.maxitems = %maxitems;
for(%i=0;%i < %maxitems;%i++)
{
%client.tool[%i] = %obj.tool[%i];
}
if(!isObject(%obj.client.player) && isObject(%client)){
%client.flag = new StaticShape()
{
   position = %client.lastpos;
   datablock = Flag;
   scale = "1 1 1";
   rotation = "1 0 0 -90";
};
%client.flag.setshapename(%client.name);
}
}


//Make a StaticShape of the model
datablock StaticShapeData(Flag)
{
category = "Static Shapes";   //Mission editor category
item = Flag;
shapeFile = "./shapes/Flag.dts";
};

Also your going to need to have it auto-remove when the client leaves the game.

Code: [Select]
function Armor::onRemove(%this, %obj){
%client = %obj.client;
%maxitems = 5;
%client.lastpos = %obj.gettransform();
%client.maxitems = %maxitems;
for(%i=0;%i < %maxitems;%i++)
{
%client.tool[%i] = %obj.tool[%i];
}
if(!isObject(%obj.client.player) && isObject(%client)){
%client.flag = new StaticShape()
{
   position = %client.lastpos;
   datablock = Flag;
   scale = "1 1 1";
   rotation = "1 0 0 -90";
};
%client.flag.setshapename(%client.name);
}
}


//Make a StaticShape of the model
datablock StaticShapeData(Flag)
{
category = "Static Shapes";   //Mission editor category
item = Flag;
shapeFile = "./shapes/Flag.dts";
};

Also your going to need to have it auto-remove when the client leaves the game.
Got any help on making it go away once they respawn?

Code: [Select]
package DeflagSpawn {
function GameConnection::spawnPlayer(%this)
{
if(isObject(%this.flag)){
%this.flag.delete();
}
parent::spawnPlayer(%this);
}
};
activatepackage(Deflagspawn);

Code: [Select]
package DeflagSpawn {
function GameConnection::spawnPlayer(%this)
{
if(isObject(%this.flag)){
%this.flag.delete();
}
parent::spawnPlayer(%this);
}
};
activatepackage(Deflagspawn);
Thanks yet again aloshi,you are the best coder i know besides badspot.

I think Randy, Space Guy and Aloshi are about equal.

Armor::onRemove would be when the player has been dead for a few seconds and clients can respawn before that without a "flag" to delete, then when their still-dead body dissapears it leaves a permaflag.

A better idea would be to use a package with GameConnection::onDeath:

Code: [Select]
package DeathCheck
{
function GameConnection::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc)
{
  if(isObject(%this.player))
  {
   %flag = new Item()
   {
     datablock = flagItem;
     position = %this.player.position;
     rotation = "0 0 0 0";
   };
   %flag.schedule(7500,0,delete);
  }
  Parent::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc);
}
};
activatePackage(DeathCheck);

You have to define the item "flagItem" somewhere else along with code to mount it/etc when picked up.

I actually have a CTF mode for the Team Deathmatch but it is very buggy and unreleased.

so would i need to use any one aloshi's script for the "flag" popping down or  just yours.

Cant you just make a check for the state.

State checks would have to be in repeated, every few ms checks. With about 8 players and a check every 100 milliseconds that's a lot of extra load on the server.

You'd only need my code, plus your own defining what "flagItem" is.

datablock ItemData(flagItem)
{
   category = "Weapon";  // Mission editor category
   className = "Weapon"; // For inventory system

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

   //gui stuff
   uiName = "";
   iconName = "base/client/ui/itemIcons/wand.png";
   doColorShift = true;
   colorShiftColor = "0 255 0 1.000";

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

function flagItem::onPickup(%this, %item, %obj, %amount)
{
 //Extra code depending on what happens when picked up.
 //Change the "image" variable in the item and add Parent::onPickup(%this, %flag, %obj, %amount);
 //to the code for standard pickup including deleting item, adding to inventory, etc.
}

Code: [Select]
package DeathCheck
{
function GameConnection::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc)
{
  if(isObject(%this.player))
  {
   %flag = new Item()
   {
     datablock = flagItem;
     position = %this.player.position;
     rotation = "0 0 0 0";
   };
   %flag.schedule(7500,0,delete);
  }
  Parent::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc);
}
};
activatePackage(DeathCheck);
But then you have a body and a grave overlapping, which looks just ew.


I think Randy, Space Guy and Aloshi are about equal.
MasterCE yelled at me again, he says he feels insulted....that tis all.

I think Randy, Space Guy and Aloshi are about equal.
MasterCE yelled at me again, he says he feels insulted....that tis all.

Why?

CTF?

Capture the Flag.
« Last Edit: June 23, 2007, 04:30:29 AM by MrPickel »