Author Topic: Check if player is in a team?  (Read 670 times)

I have 0 knowledge of torque.
Below is my edited version of the old Taser, which is an edit of IBan's CityRPG taser.

Code: [Select]
//tasergun - Whites out then tumbles the player.
datablock AudioProfile(taserExplosionSound)
{
   filename    = "./bulletHit.wav";
   description = AudioClose3d;
   preload = true;
};

datablock AudioProfile(taserFireSound)
{
   filename    = "./gunShot1.wav";
   description = AudioClosest3d;
   preload = true;
};


//arrow trail
datablock ParticleData(taserTrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 2000;
lifetimeVarianceMS = 0;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = false;
animateTexture = false;
//framesPerSec = 1;

textureName = "base/data/particles/ring";
//animTexName = "~/data/particles/dot";

// Interpolation variables
colors[0] = "1 1 1 0.2";
colors[1] = "1 1 1 0.0";
sizes[0] = 0.2;
sizes[1] = 0.01;
times[0] = 0.0;
times[1] = 1.0;
};

datablock ParticleEmitterData(taserTrailEmitter)
{
   ejectionPeriodMS = 2;
   periodVarianceMS = 0;

   ejectionVelocity = 0; //0.25;
   velocityVariance = 0; //0.10;

   ejectionOffset = 0;

   thetaMin         = 0.0;
   thetaMax         = 90.0; 

   particles = taserTrailParticle;
};

//effects
datablock ParticleData(taserExplosionParticle)
{
dragCoefficient      = 5;
gravityCoefficient   = 0.1;
inheritedVelFactor   = 0.2;
constantAcceleration = 0.0;
lifetimeMS           = 500;
lifetimeVarianceMS   = 300;
textureName          = "base/data/particles/chunk";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0.9 0.9 0.6 0.9";
colors[1]     = "0.9 0.5 0.6 0.0";
sizes[0]      = 0.25;
sizes[1]      = 0.0;
};

datablock ParticleEmitterData(taserExplosionEmitter)
{
   ejectionPeriodMS = 7;
   periodVarianceMS = 0;
   ejectionVelocity = 5;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "taserExplosionParticle";
};

datablock ExplosionData(taserExplosion)
{
   //explosionShape = "";
soundProfile = taserExplosionSound;

   lifeTimeMS = 150;

   particleEmitter = taserExplosionEmitter;
   particleDensity = 10;
   particleRadius = 0.2;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = false;
   camShakeFreq = "10.0 11.0 10.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;

   // Dynamic light
   lightStartRadius = 0;
   lightEndRadius = 2;
   lightStartColor = "0.3 0.6 0.7";
   lightEndColor = "0 0 0";
};


//projectile
AddDamageType("taserDirect",   '<bitmap:add-ons/Weapon_Gun/CI_gun> %1',    '%2 <bitmap:add-ons/Weapon_Gun/CI_gun> %1',1,1);

datablock ProjectileData(taserProjectile)
{
   projectileShapeName = "./projectile_hookshot.dts";

   directDamage        = 0;
   directDamageType    = $DamageType::taserDirect;

   radiusDamage        = 0;
   damageRadius        = 0;
   radiusDamageType    = $DamageType::taserDirect;

   explosion           = taserExplosion;
   particleEmitter     = taserTrailEmitter;

   muzzleVelocity      = 100;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 750;
   fadeDelay           = 3500;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = true;
   gravityMod = 0.2;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";
};


//////////
// item //
//////////
datablock ItemData(taserItem)
{
cost = 600;
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

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

//gui stuff
uiName = "Taser";
iconName = "./icon_gun";
doColorShift = true;
colorShiftColor = "0.898039 0.898039 0.000000 1.000000";

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

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

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "0 0 0" );

   // 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 = true;

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

   // Projectile && Ammo.
   item = taserItem;
   ammo = " ";
   projectile = taserProjectile;
   projectileType = Projectile;

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

   doColorShift = true;
   colorShiftColor = taserItem.colorShiftColor;//"0.400 0.196 0 1.000";

   //casing = " ";

   // 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";
stateSound[0] = weaponSwitchSound;

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

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Reload";
stateTimeoutValue[2]            = 0.5;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateSound[2] = taserFireSound;

stateName[3] = "Reload";
stateSequence[3]                = "Reload";
stateAllowImageChange[3]        = false;
stateTimeoutValue[3]            = 0.5;
stateWaitForTimeout[3] = true;
stateTransitionOnTimeout[3]     = "Check";

stateName[4] = "Check";
stateTransitionOnTriggerUp[4] = "StopFire";
stateTransitionOnTriggerDown[4] = "Fire";

stateName[5]                    = "StopFire";
stateTransitionOnTimeout[5]     = "Ready";
stateTimeoutValue[5]            = 0.5;
stateAllowImageChange[5]        = false;
stateWaitForTimeout[5] = true;
//stateSequence[5]                = "Reload";
stateScript[5]                  = "onStopFire";


};

function taserProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getclassname() $= "Player"){
if(!minigamecandamage(%obj, %col) || %col.taserned == 1){
echo("Cant damage or is taserned");
return;
}
if(%col.police == 1){
messageclient(%client,"","You cannot taser police officers.");
return;
}
%col.cantdie = 1;
%newvec = %col.getvelocity();
%newvec = VectorAdd(%vec, "8 8 8");
%col.setvelocity(%newvec);
tumble(%col, 15000);
%col.setwhiteout(1.2);
schedule(3500,0,"Throb",%col);
%col.playthread(2, armattack);
schedule(5000,0,"Detwitch",%col);
%col.taserned = 1;
schedule(4000,0,"Detaser",%col);
%col.undie = schedule(15000,0,"Undie",%col);
}
}

function ServerCmdTumbleMe(%client)
{
%col = %client.player;
%newvec = %col.getvelocity();
%newvec = VectorAdd(%vec, "8 8 8");
%col.setvelocity(%newvec);
tumble(%col, 9999999999999999999999);
%col.setwhiteout(1.2);
schedule(3500,0,"Throb",%col);
}

function Throb(%obj, %inc)
{
%obj.setwhiteout(0.25);
if(%inc == 6)
{

return;
}
schedule(3000,0,"Throb",%obj,%inc + 1);
}

function detwitch(%obj)
{
%obj.playthread(2, root);
}

function Detaser(%obj)
{
%obj.taserned = 0;
}

function Undie(%obj)
{
%obj.cantdie = 0;
}

This caught my eye. How do I change it so it checks if player is in the same team and can't taser them?
Code: [Select]
if(%col.police == 1){
messageclient(%client,"","You cannot taser police officers.");
return;
}

And no this isn't going to be a public add-on, so ignore any other things, like that it uses the default gun sounds/icon/mesh.

There is no default team system, so it probably varies depending on what gamemode you're using for teams.

Try using MinigameCanDamage

if(MinigameCanDamage(%obj,%col))
    //taser
else
    //don't taser
« Last Edit: August 14, 2013, 02:32:32 PM by Headcrab Zombie »

Removed the police part. Slayer already does everything else. Can't tumble team mates.