Here's the .cs for each gun. (NOTE:The only thing changed between each gun is the UI name.)
// ============================================================
// Project : Weapon_AWP
// File : .\server.cs
// Copyright :
// Author : MunK and Cyanian
// Created on : Sunday, July 25, 2010 12:50 PM
//
// Editor : TorqueDev v. 1.2.3430.42233
//
// Description : Script by MunK
// : Models and animations by Cyanian
// : Thanks to Jookia and Space Guy for their scripts.
// ============================================================
//Requires Gun Addon to be enabled.
%error = ForceRequiredAddOn("weapon_gun");
if(%error == $Error::AddOn_Disabled)
{
awpitem.uiName = "";
}
if(%error == $Error::AddOn_NotFound)
{
//we don't have the gun, so we're screwed :D
error("ERROR: weapon_awp - required add-on weapon_gun not found");
return;
}
exec("./hitboxes.cs");
//audio
datablock AudioProfile(awpShotSound)
{
filename = "./AWPshot.wav";
description = AudioClose3d;
preload = true;
};
//shell
datablock DebrisData(awpShellDebris)
{
shapeFile = "./gunShell.dts";
lifetime = 2.0;
minSpinSpeed = -400.0;
maxSpinSpeed = 200.0;
elasticity = 0.5;
friction = 0.2;
numBounces = 3;
staticOnMaxBounce = true;
snapOnMaxBounce = false;
fade = true;
gravModifier = 2;
};
AddDamageType("AWP", '<bitmap:add-ons/Weapon_AWP/CI_AWP> %1', '%2 <bitmap:add-ons/Weapon_AWP/CI_AWP> %1',0.2,1);
AddDamageType("AWPhead",'<bitmap:add-ons/Weapon_AWP/CI_AWP_Headshot> %1','%2 <bitmap:add-ons/Weapon_AWP/CI_AWP_Headshot> %1',2,1);
datablock ProjectileData(awpProjectile)
{
projectileShapeName = "Add-ons/Weapon_gun/bullet.dts";
directDamage = 115;
directDamageType = $DamageType::AWP;
radiusDamageType = $DamageType::AWP;
brickExplosionRadius = 0;
brickExplosionImpact = true; //destroy a brick if we hit it directly?
brickExplosionForce = 10;
brickExplosionMaxVolume = 1; //max volume of bricks that we can destroy
brickExplosionMaxVolumeFloati ng = 2; //max volume of bricks that we can destroy if they aren't connected to the ground
impactImpulse = 400;
verticalImpulse = 400;
explosion = gunExplosion;
particleEmitter = ""; //bulletTrailEmitter;
muzzleVelocity = 100000;
velInheritFactor = 1;
armingDelay = 00;
lifetime = 4000;
fadeDelay = 3500;
bounceElasticity = 0.5;
bounceFriction = 0.20;
isBallistic = false;
gravityMod = 0.0;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
uiName = "AWP Bullet";
};
//////////
// item //
//////////
datablock ItemData(AWPItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./AWPnohands.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "AWP Sun In Leo";
iconName = "Add-Ons/Weapon_AWP/AWP_Icon";
doColorShift = true;
colorShiftColor = "0.25 0.25 0.25 1.000";
// Dynamic properties defined by the scripts
image = awpImage;
canDrop = true;
//Ammo Guns Parameters
maxAmmo = 10;
canReload = 1;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(awpScopedImage)
{
// Basic Item properties
shapeFile = "./AWP43.dts";
emap = true;
// Specify mount point & offset for 3rd person, and eye offset
// for first person rendering.
mountPoint = 0;
offset = "0 0 0";
eyeOffset = ".05383 .12 -0.33778"; //-Right +Left, +Back -Front, -Down +Up
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 = AwpItem;
ammo = " ";
projectile = awpProjectile;
projectileType = Projectile;
casing = awpShellDebris;
shellExitDir = "1.0 -1.3 1.0";
shellExitOffset = "0 0 0";
shellExitVariance = 15.0;
shellVelocity = 7.0;
//melee particles shoot from eye node for consistancy
melee = false;
//raise your arm up or not
armReady = true;
doColorShift = true;
colorShiftColor = awpItem.colorShiftColor;//"0.400 0.196 0 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.2;
stateTransitionOnTimeout[0] = "Ready";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Fire";
stateAllowImageChange[1] = true;
stateSequence[1] = "Ready";
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "Smoke";
stateTimeoutValue[2] = 0.14;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateSequence[2] = "Fire";
stateScript[2] = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = awpShotSound;
stateEjectShell[2] = true;
stateName[3] = "Smoke";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3] = 1.5;
stateTransitionOnTimeout[3] = "roostering";
stateName[4] = "roostering";
stateSequence[4] = "rooster";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 1.5;
};
datablock ShapeBaseImageData(awpImage)
{
// Basic Item properties
shapeFile = "./AWP43.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 = AwpItem;
ammo = " ";
projectile = awpProjectile;
projectileType = Projectile;
casing = awpShellDebris;
shellExitDir = "1.0 -1.3 1.0";
shellExitOffset = "0 0 0";
shellExitVariance = 15.0;
shellVelocity = 7.0;
//melee particles shoot from eye node for consistancy
melee = false;
//raise your arm up or not
armReady = true;
doColorShift = true;
colorShiftColor = awpItem.colorShiftColor;//"0.400 0.196 0 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] = 1.5;
stateSequence[0] = "rooster";
stateTransitionOnTimeout[0] = "Ready";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Fire";
stateAllowImageChange[1] = true;
stateSequence[1] = "Ready";
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "Smoke";
stateTimeoutValue[2] = 0.14;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateSequence[2] = "Fire";
stateScript[2] = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = awpShotSound;
stateEjectShell[2] = true;
stateName[3] = "Smoke";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3] = 0.01;
stateTransitionOnTimeout[3] = "roostering";
stateName[4] = "roostering";
stateSequence[4] = "rooster";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 1.5;
};
function awpImage::onMount(%this, %obj, %slot)
{
%obj.hidenode("RHand");
%obj.hidenode("LHand");
}
function awpImage::onUnMount(%this, %obj, %slot)
{
%obj.unhidenode("RHand");
%obj.unhidenode("LHand");
}
function awpscopedImage::onMount(%this, %obj, %slot)
{
%obj.hidenode("RHand");
%obj.hidenode("LHand");
}
function awpscopedImage::onUnMount(%this, %obj, %slot)
{
%obj.unhidenode("RHand");
%obj.unhidenode("LHand");
}
function awpscopedImage::onFire(%this,%obj,%slot)
{
awpSpawnProj(%this,%obj,%slot);
}
function awpImage::onFire(%this,%obj,%slot)
{
awpSpawnProj(%this,%obj,%slot);
}
//Thanks to HellsHero for this part:
function awpSpawnProj(%this,%obj,%slot)
{
if(vectorLen(%obj.getVelocity()) < 1 && (getSimTime() - %obj.lastShotTime) > 1000)
%spread = 0.0003;
else
%spread = 0.0009;
if(vectorLen(%obj.getVelocity()) < 1 && (getSimTime() - %obj.lastShotTime) > 1500 && %obj.getMountedImage(0) == nameToID(awpscopedImage))
%spread = 0.0001;
else if((getSimTime() - %obj.lastShotTime) < 1500 && %obj.getMountedImage(0) == nameToID(awpscopedImage))
%spread = 0.0006;
%projectile = awpprojectile;
%obj.lastShotTime = getSimTime();
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
return %p;
}
function awpprojectile::Damage(%this, %obj, %col, %fade, %pos, %normal)
{
if(%col.getClassName() $="Player" || %col.getClassName() $= "AIPlayer")
{
if(%col.getClassName() $= "AIPlayer")
{
%oldClient = %col.client;
%col.client = BotConnection;
%hitBoxList = getHitbox(%obj, %col, %pos);
%col.client = %oldClient;
}
else
{
%hitBoxList = getHitbox(%obj, %col, %pos);
}
if(strReplace(%hitBoxList, "headskin", "BAM") $= %hitBoxList)
{
parent::Damage(%this, %obj, %col, %fade, %pos, %normal);
}
else
{
%obj.client.centerPrint("\c6HeadShot!",3);
%obj.client.play2D(rewardSound);
%col.damage(%obj, %pos, (125 * getWord(%obj.getScale(),2)), $DamageType::AWPhead);
}
}
else
{
parent::Damage(%this, %obj, %col, %fade, %pos, %normal);
}
}
package awpPackage
{
function armor::onTrigger(%this, %obj, %triggerNum, %val)
{
%client = %obj.client;
if(%triggerNum == 4 && %obj.isImageMounted(AWPImage) && %val)
{
%obj.mountImage(awpScopedImage, 0);
%client.setControlCameraFov(23);
}
else if(%triggerNum == 4 && %obj.isImageMounted(awpscopedImage) && %val)
{
%obj.mountImage(awpImage, 0);
%client.setControlCameraFov(90);
}
Parent::onTrigger(%this, %obj, %triggerNum, %val);
}
};
activatePackage(awpPackage);
The console log states the following:
Loading Add-on: Weapon_AWPBOOM (CRC:1037388878)
Executing Add-ons/Weapon_AWPBOOM/server.cs.
Executing Add-ons/Weapon_AWPBOOM/hitboxes.cs.
WARNING: AddDamageType() - AWP file "add-ons/Weapon_AWP/CI_AWP.png" does not exist!
WARNING: AddDamageType() - AWPhead file "add-ons/Weapon_AWP/CI_AWP_Headshot.png" does not exist!
ProjectileData - awpProjectile(696) - invalid value for muzzleVelocity: Must be between 0 and 200
Activating package: awpPackage
package awpPackage is already active.
0 datablocks added