I am making a weapon, and I'm trying to make it Slow down the player when he's shot.
Well isn't working, and when I set it to %obj, it's applied to me.
If anyone can help me it would be very cool.
Code:
//audio
datablock AudioProfile(BigKillFireSound)
{
filename = "./BigKill_Fire.wav";
description = AudioClose3d;
preload = true;
};
datablock PlayerData(BigKillArmor : PlayerStandardArmor)
{
runForce = 3 * 180;
runEnergyDrain = 0;
minRunEnergy = 0;
runForce = 100 * 60;
runEnergyDrain = 0;
minRunEnergy = 0;
maxForwardSpeed = 0;
maxBackwardSpeed = 0;
maxSideSpeed = 0;
maxForwardCrouchSpeed = 3;
maxBackwardCrouchSpeed = 2;
maxSideCrouchSpeed = 2;
jumpForce = 10 * 90; //8.3 * 90;
jumpEnergyDrain = 0;
minJumpEnergy = 0;
jumpDelay = 0;
//firstpersononly = 1;
minJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;
canRide = true;
showEnergyBar = false;
runSurfaceAngle = 55;
jumpSurfaceAngle = 55;
isSurvivor = 1;
};
datablock ParticleData(BigKillTrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 120;
lifetimeVarianceMS = 0;
spinSpeed = 3999.0;
spinRandomMin = -3999.0;
spinRandomMax = 3999.0;
useInvAlpha = false;
animateTexture = false;
//framesPerSec = 1;
textureName = "base/data/particles/dot";
//animTexName = "~/data/particles/dot";
// Interpolation variables
colors[0] = "0.1 0.4 0.7 1";
colors[1] = "0 0.1 0.3 1";
colors[2] = "0 0.1 0.2 1";
sizes[0] = 0.6;
sizes[1] = 0.3;
sizes[2] = 0.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(BigKillTrailEmitter)
{
ejectionPeriodMS = 2;
periodVarianceMS = 0;
ejectionVelocity = 0; //0.25;
velocityVariance = 0; //0.10;
ejectionOffset = 0;
thetaMin = 0.0;
thetaMax = 90.0;
particles = BigKillTrailParticle;
useEmitterColors = true;
};
datablock ParticleData(BigKillExplosionParticle)
{
dragCoefficient = 8;
gravityCoefficient = 1;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 700;
lifetimeVarianceMS = 400;
textureName = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0] = "0.9 0.9 0.9 0.3";
colors[1] = "0.9 0.5 0.6 0.0";
sizes[0] = 2.25;
sizes[1] = 2.75;
useInvAlpha = true;
};
datablock ParticleEmitterData(BigKillExplosionEmitter)
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 2;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 89;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "BigKillExplosionParticle";
useEmitterColors = true;
};
datablock ParticleData(BigKillExplosionRingParticle)
{
dragCoefficient = 8;
gravityCoefficient = -0.5;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 50;
lifetimeVarianceMS = 35;
textureName = "base/data/particles/star1";
spinSpeed = 500.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0] = "0.1 0.4 0.7 1";
colors[1] = "0 0.1 0.3 1";
sizes[0] = 5;
sizes[1] = 5;
useInvAlpha = false;
};
datablock ParticleEmitterData(BigKillExplosionRingEmitter)
{
lifeTimeMS = 50;
ejectionPeriodMS = 3;
periodVarianceMS = 0;
ejectionVelocity = 0;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 89;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "BigKillExplosionRingParticle";
useEmitterColors = true;
uiName = "Gun Hit Flash";
};
datablock ExplosionData(BigKillExplosion)
{
//explosionShape = "";
soundProfile = bulletHitSound;
lifeTimeMS = 150;
particleEmitter = BigKillExplosionEmitter;
particleDensity = 5;
particleRadius = 0.2;
emitter[0] = BigKillExplosionRingEmitter;
faceViewer = true;
explosionScale = "1 1 1";
shakeCamera = true;
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";
impulseRadius = 2;
impulseForce = 2500;
};
datablock ProjectileData(BigKillTracerProjectile)
{
directDamage = 35;
directDamageType = $DamageType::Gun;
radiusDamageType = $DamageType::Gun;
brickExplosionRadius = 0;
brickExplosionImpact = true; //destroy a brick if we hit it directly?
brickExplosionForce = 10;
brickExplosionMaxVolume = 1; //max volume of bricks that we can destroy
brickExplosionMaxVolumeFloating = 2; //max volume of bricks that we can destroy if they aren't connected to the ground
impactImpulse = 1000;
verticalImpulse = 500;
explosion = BigKillExplosion;
particleEmitter = "BigKillTrailEmitter";
muzzleVelocity = 200;
velInheritFactor = 0;
armingDelay = 0;
lifetime = 1000;
fadeDelay = 700;
bounceElasticity = 0.5;
bounceFriction = 0.10;
isBallistic = true;
gravityMod = 0.0;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
};
//////////
// item //
//////////
datablock ItemData(BigKillItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./Big_Kill.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "Big Kill";
iconName = "./icon_revolver";
doColorShift = true;
colorShiftColor = "0.73 0.73 0.73 1.000";
// Dynamic properties defined by the scripts
image = BigKillImage;
canDrop = true;
//Ammo Guns Parameters
maxAmmo = 6;
canReload = 1;
};
AddDamageType("BigKill", '<bitmap:add-ons/Weapon_BigKill/CI_revolver> %1', '%2 <bitmap:add-ons/Weapon_BigKill/CI_revolver> %1',0.75,1);
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(BigKillImage)
{
// Basic Item properties
shapeFile = "./Big_Kill.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 = BigKillItem;
ammo = " ";
projectile = BigKillProjectile;
projectileType = Projectile;
casing = GunShellDebris;
shellExitDir = "1.0 0.1 1.0";
shellExitOffset = "0 0 0";
shellExitVariance = 10.0;
shellVelocity = 5.0;
//melee particles shoot from eye node for consistancy
melee = false;
//raise your arm up or not
armReady = true;
doColorShift = true;
colorShiftColor = BigKillItem.colorShiftColor;
// 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.
raycastWeaponRange = 200; //varies
raycastWeaponTargets =
$TypeMasks::PlayerObjectType | //AI/Players
$TypeMasks::StaticObjectType | //Static Shapes
$TypeMasks::TerrainObjectType | //Terrain
$TypeMasks::VehicleObjectType | //Terrain
$TypeMasks::FXBrickObjectType; //Bricks
raycastExplosionProjectile = BigKillTracerProjectile;
raycastExplosionBrickSound = bulletHitSound;
raycastExplosionPlayerSound = bulletHitSound;
raycastDirectDamage = 1;
raycastDirectDamageType = $DamageType::BigKill;
raycastSpreadAmt = 0.0006; //varies
raycastSpreadCount = 1;
raycastTracerProjectile = BigKillTracerProjectile;
raycastFromMuzzle = true;
// Initial start up state
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.15;
stateSequence[0] = "Activate";
stateTransitionOnTimeout[0] = "LoadCheckA";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnNoAmmo[1] = "ReloadStart";
stateTransitionOnTriggerDown[1] = "Fire";
stateAllowImageChange[1] = true;
stateSequence[1] = "ready";
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "Smoke";
stateTimeoutValue[2] = 0.05;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateScript[2] = "onFire";
stateSequence[2] = "Fire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = BigKillfireSound;
stateName[3] = "Smoke";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.1;
stateEmitterNode[3] = "muzzleNode";
stateTransitionOnTriggerUp[3] = "Wait";
stateName[4] = "Wait";
stateEjectShell[2] = false;
stateTimeoutValue[4] = 1.5;
stateTransitionOnTimeout[4] = "LoadCheckA";
//Torque switches states instantly if there is an ammo/noammo state, regardless of stateWaitForTimeout
stateName[5] = "LoadCheckA";
stateScript[5] = "onLoadCheck";
stateTimeoutValue[5] = 0.01;
stateTransitionOnTimeout[5] = "LoadCheckB";
stateName[6] = "LoadCheckB";
stateTransitionOnAmmo[6] = "Ready";
stateTransitionOnNoAmmo[6] = "ReloadWait";
stateName[7] = "ReloadWait";
stateTimeoutValue[7] = 0.5;
stateScript[7] = "";
stateTransitionOnTimeout[7] = "ReloadStart";
stateWaitForTimeout[7] = true;
stateName[8] = "ReloadStart";
stateTimeoutValue[8] = 0.05;
stateScript[8] = "onReloadStart";
stateTransitionOnTimeout[8] = "Shell1";
stateWaitForTimeout[8] = true;
stateSound[8] = Block_MoveBrick_Sound;
stateName[9] = "Shell1";
stateEjectShell[9] = true;
stateTimeoutValue[9] = 0.0001;
stateTransitionOnTimeout[9] = "Shell2";
stateWaitForTimeout[9] = true;
stateName[10] = "Shell2";
stateEjectShell[10] = true;
stateTimeoutValue[10] = 0.0001;
stateTransitionOnTimeout[10] = "Shell3";
stateWaitForTimeout[10] = true;
stateName[11] = "Shell3";
stateEjectShell[11] = true;
stateTimeoutValue[11] = 0.0001;
stateTransitionOnTimeout[11] = "Shell4";
stateWaitForTimeout[11] = true;
stateName[12] = "Shell4";
stateEjectShell[12] = true;
stateTimeoutValue[12] = 0.0001;
stateTransitionOnTimeout[12] = "Shell5";
stateWaitForTimeout[12] = true;
stateName[13] = "Shell5";
stateEjectShell[13] = true;
stateTimeoutValue[13] = 0.0001;
stateTransitionOnTimeout[13] = "Shell6";
stateWaitForTimeout[13] = true;
stateName[14] = "Shell6";
stateEjectShell[12] = true;
stateTimeoutValue[14] = 0.0001;
stateTransitionOnTimeout[14] = "Reloaded";
stateWaitForTimeout[14] = true;
stateName[15] = "Reloaded";
stateTimeoutValue[15] = 0.5;
stateScript[15] = "onReloaded";
stateTransitionOnTimeout[15] = "Ready";
stateSound[15] = Block_PlantBrick_Sound;
};
function BigKillImage::OnHitObject(%this, %obj, %col, %fade, %pos, %normal)
{
if(%col.getType() & $TypeMasks::PlayerObjectType)
{
%col.pushDataBlock("BigKillArmor");
%col.BigKillReset(5000,BigKillReset);
}
}
function BigKillImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() >= 1.0)
return;
if(vectorLen(%obj.getVelocity()) > 0.1)
{
%this.raycastSpreadAmt = 0.0050;
%this.raycastWeaponRange = 85;
}
else
{
%this.raycastSpreadAmt = 0.0012;
%this.raycastWeaponRange = 200;
}
if(%obj.toolAmmo[%obj.currTool] > 0)
{
Parent::onFire(%this,%obj,%slot);
%obj.toolAmmo[%obj.currTool]--;
}
else if(%this.item.maxAmmo == 0)
{
Parent::onFire(%this,%obj,%slot);
}
%obj.playThread(2, activate);
%obj.playThread(3, plant);
}
function BigKillImage::onReloadStart(%this,%obj,%slot)
{
%obj.toolAmmo[%obj.currTool] = 0;
%obj.playThread(2, activate);
%obj.playThread(3, plant);
}
function BigKillImage::onReloaded(%this,%obj,%slot)
{
%obj.playThread(2, shiftleft);
%obj.toolAmmo[%obj.currTool] = %this.item.maxAmmo;
%obj.setImageAmmo(%slot,1);
}
function player::BigKillReset(%this, %obj, %col, %fade, %pos, %normal)
{
%col.popDatablock(BigKillArmor.getID());
}