Blockland Forums > Modification Help
ammo scripting help??
xxrumaroxx:
bellow this text you will find the script to a weapon, specifically the combat MG, from frogs weaponry. in this script on line 77 where it sais "max amo = 50" this refers to the maximum amount of amo the gun will be able to fire continually without stopping. in other words its the amount of amo the player will be able to fire before needing to reload, which would be 50 in this case. in order to change the max amount of amo all i need to do is change that number 50 on line 77. that i understand. in the game when im using the gun there is the amount of amo i can use before i reload then there is the amount of amo that i can reload with in this case, for the combat mg, it is 50 out of 90. so once i use all 50 shots i can reload the max allowed of 50 then i have 10 bullets left that i can reload after using the round i just loaded. so as i said i understand that to adjust the max amount of bullets that i can have in use i must adjust the # 50 on line 77 of the script, but how do i adjust the amount of bullets that i have to reload with, being 90 in this case?????
//audio
datablock AudioProfile(CombatMGFireSound)
{
filename = "./CombatMGFire.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(FWReload2Sound)
{
filename = "./FWReload2.wav";
description = AudioClose3d;
preload = true;
};
AddDamageType("CombatMG", '<bitmap:add-ons/Weapon_Frogs_Weaponry/CI_CombatMG> %1', '%2 <bitmap:add-ons/Weapon_Frogs_Weaponry/CI_CombatMG> %1',0.75,1);
datablock ProjectileData(CombatMGProjectile1)
{
projectileShapeName = "add-ons/Weapon_Gun/bullet.dts";
directDamage = 12; //9
directDamageType = $DamageType::CombatMG;
radiusDamageType = $DamageType::CombatMG;
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 = 20;
verticalImpulse = 10;
explosion = gunExplosion;
muzzleVelocity = 120;
velInheritFactor = 1;
armingDelay = 0;
lifetime = 4000;
fadeDelay = 3500;
bounceElasticity = 0.5;
bounceFriction = 0.20;
isBallistic = true;
gravityMod = 0.7;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
};
//////////
// item //
//////////
datablock ItemData(CombatMGItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./CombatMG.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "Combat MG";
iconName = "./icon_CombatMG";
doColorShift = true;
colorShiftColor = "1 1 1 1.000";
// Dynamic properties defined by the scripts
image = CombatMGImage;
canDrop = true;
maxAmmo = 50;
canReload = 1;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(CombatMGImage)
{
// Basic Item properties
shapeFile = "./CombatMG.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 = CombatMGItem;
ammo = " ";
projectile = CombatMGProjectile1;
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 = CombatMGItem.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.
// Initial start up state
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.05;
stateTransitionOnTimeout[0] = "LoadCheckA";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnNoAmmo[1] = "Reload";
stateTransitionOnTriggerDown[1] = "Fire";
stateSequence[1] = "Winddown";
stateAllowImageChange[1] = true;
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "Delay";
stateTimeoutValue[2] = 0.0001; //0.01
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateSequence[2] = "Winddown";
stateScript[2] = "onFire";
stateEjectShell[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateWaitForTimeout[2] = true;
stateSound[2] = CombatMGFireSound;
stateName[3] = "Delay";
stateTransitionOnTimeout[3] = "FireLoadCheckA";
stateTimeoutValue[3] = 0.0001; //0.025
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.03;
stateEmitterNode[3] = "muzzleNode";
statesequence[3] = "Fire";
stateName[4] = "LoadCheckA";
stateScript[4] = "onLoadCheck";
stateTimeoutValue[4] = 0.01;
stateTransitionOnTimeout[4] = "LoadCheckB";
stateName[5] = "LoadCheckB";
stateTransitionOnAmmo[5] = "Ready";
stateTransitionOnNoAmmo[5] = "Reload";
stateName[6] = "Reload";
stateTimeoutValue[6] = 1.6;
stateScript[6] = "onReloadStart";
stateTransitionOnTimeout[6] = "Wait";
stateWaitForTimeout[6] = true;
stateName[7] = "Wait";
stateTimeoutValue[7] = 0.8;
stateScript[7] = "onReloadWait";
stateTransitionOnTimeout[7] = "Reloaded";
stateName[8] = "FireLoadCheckA";
stateScript[8] = "onLoadCheck";
stateTimeoutValue[8] = 0.001; //0.01
stateTransitionOnTimeout[8] = "FireLoadCheckB";
stateName[9] = "FireLoadCheckB";
stateTransitionOnAmmo[9] = "Smoke";
stateTransitionOnNoAmmo[9] = "ReloadSmoke";
stateName[10] = "Smoke";
stateEmitter[10] = gunSmokeEmitter;
stateEmitterTime[10] = 0.05; //0.3
stateEmitterNode[10] = "muzzleNode";
stateTimeoutValue[10] = 0.0001;
stateTransitionOnTimeout[10] = "Ready";
stateTransitionOnTriggerDown[10] = "Fire";
statesequence[10] = "Winddown";
stateName[11] = "ReloadSmoke";
stateEmitter[11] = gunSmokeEmitter;
stateEmitterTime[11] = 0.3;
stateEmitterNode[11] = "muzzleNode";
stateTimeoutValue[11] = 0.2;
stateTransitionOnTimeout[11] = "Reload";
statesequence[11] = "Winddown";
stateName[12] = "Reloaded";
stateTimeoutValue[12] = 0.01;
stateScript[12] = "onReloaded";
stateTransitionOnTimeout[12] = "Ready";
};
function CombatMGImage::onFire(%this,%obj,%slot)
{
%projectile = CombatMGProjectile1;
if(vectorLen(%obj.getVelocity()) < 0.1)
{
%spread = 0.0015; //0.0025
}
else
{
%spread = 0.0025; //0.0035
}
%shellcount = 1;
%obj.playThread(2, plant);
%shellcount = 1;
%obj.toolAmmo[%obj.currTool]--;
%obj.AmmoSpent[%obj.currTool]++;
%obj.spawnExplosion(TTRecoilProjectile,"1 1 1");
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
for(%shell=0; %shell<%shellcount; %shell++)
{
%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 CombatMGImage::onReloadStart(%this,%obj,%slot)
{ commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
if(%obj.client.quantity["556rounds"] >= 1)
{
%obj.playThread(2, shiftRight);
serverPlay3D(block_MoveBrick_Sound,%obj.getPosition());
}
}
function CombatMGImage::onReloadWait(%this,%obj,%slot)
{
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
if(%obj.client.quantity["556rounds"] >= 1)
{
%obj.playThread(2, plant);
serverPlay3D(FWReload2Sound,%obj.getPosition());
}
}
function CombatMGImage::onReloaded(%this,%obj,%slot)
{
if(%obj.client.quantity["556rounds"] >= 1)
{
if(%obj.client.quantity["556rounds"] > %this.item.maxAmmo)
{
%obj.client.quantity["556rounds"] -= %obj.AmmoSpent[%obj.currTool];
%obj.toolAmmo[%obj.currTool] = %this.item.maxAmmo;
%obj.AmmoSpent[%obj.currTool] = 0;
%obj.setImageAmmo(%slot,1);
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
return;
}
if(%obj.client.quantity["556rounds"] <= %this.item.maxAmmo)
{
%obj.client.exchangebullets = %obj.client.quantity["556rounds"];
%obj.toolAmmo[%obj.currTool] = %obj.client.exchangebullets;
%obj.setImageAmmo(%slot,1);
%obj.client.quantity["556rounds"] = 0;
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
return;
}
}
}
function CombatMGProjectile1::damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getType() & $TypeMasks::PlayerObjectType)
{
%col.setVelocity(getWord(%col.getVelocity(),0)/1.2 SPC getWord(%col.getVelocity(),1)/1.2 SPC getWord(%col.getVelocity(),1.2));
}
parent::damage(%this,%obj,%col,%fade,%pos,%normal);
}
function CombatMGImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this,%obj,%slot);
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
}
function CombatMGImage::onUnMount(%this,%obj,%slot)
{
%obj.playThread(2, root);
}
Amade:
It's controlled by tier tactical and not set in this script. You can change it with the RTB pref "Starting Rifle Ammo" under the heading "Tier+Tactical Ammo".
jes00:
Please click de button next time.
xxrumaroxx:
--- Quote from: Amade on November 24, 2011, 11:20:46 AM ---It's controlled by tier tactical and not set in this script. You can change it with the RTB pref "Starting Rifle Ammo" under the heading "Tier+Tactical Ammo".
--- End quote ---
thx alot ur always there when i need some scripting help, but there's one more thing i want to know. how would i increase the maximum amount of amo allowed for me to be able to reload with. for the starting rifle amo i went in to my server preferences it was at 90 i increased it to 200 just to test it out, but the max i can increase it to is 180.what would i have to do to the TT script for the rifle amo to increase that 180. the script below is for the sports rifle amo in the TT folder. I think this is what controls the amo for the starting rifle amo but im not sure. Can some one help me with this?
//audio
datablock AudioProfile(SportRifleFireSound)
{
filename = "./Sport_Rifle_fire.3.wav";
description = AudioClose3d;
preload = true;
};
//datablock AudioProfile(SportRifleReloadSound)
//{
// filename = "./pump_shotgun_reload.wav";
// description = AudioClose3d;
// preload = true;
//};
datablock ParticleData(SportRifleCritTrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 750;
lifetimeVarianceMS = 0;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = false;
animateTexture = false;
//framesPerSec = 1;
textureName = "base/data/particles/thinring";
//animTexName = "~/data/particles/dot";
// Interpolation variables
colors[0] = "1 1 0.7 0.5";
colors[1] = "1 1 1 0.25";
colors[2] = "1 1 1 0";
sizes[0] = 0.125;
sizes[1] = 0.125;
sizes[2] = 0.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(SportRifleCritTrailEmitter)
{
ejectionPeriodMS = 10;
periodVarianceMS = 0;
ejectionVelocity = 0.1; //0.25;
velocityVariance = 0.10;
ejectionOffset = 0;
thetaMin = 0.0;
thetaMax = 90.0;
particles = SportRifleCritTrailParticle;
useEmitterColors = true;
};
datablock ParticleData(SportRifleCritTrail2Particle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 0;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = false;
animateTexture = false;
//framesPerSec = 1;
textureName = "base/data/particles/thinring";
//animTexName = "~/data/particles/dot";
// Interpolation variables
colors[0] = "1 1 0.7 0.5";
colors[1] = "1 1 1 0.25";
colors[2] = "1 1 1 0";
sizes[0] = 0.0625;
sizes[1] = 0.0625;
sizes[2] = 0.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(SportRifleCritTrail2Emitter)
{
ejectionPeriodMS = 10;
periodVarianceMS = 0;
ejectionVelocity = 0.01; //0.25;
velocityVariance = 0.10;
ejectionOffset = 0;
thetaMin = 0.0;
thetaMax = 90.0;
particles = SportRifleCritTrail2Particle;
useEmitterColors = true;
};
AddDamageType("SportRifle", '<bitmap:add-ons/Weapon_Package_Tier1/CI_SportRifle> %1', '%2 <bitmap:add-ons/Weapon_Package_Tier1/CI_SportRifle> %1',0.75,1);
AddDamageType("SportRifleHeadshot", '<bitmap:add-ons/Weapon_Package_Tier1/CI_SportRifle> <bitmap:add-ons/Weapon_Package_Tier1/CI_tactheadshot>%1', '%2 <bitmap:add-ons/Weapon_Package_Tier1/CI_SportRifle> <bitmap:add-ons/Weapon_Package_Tier1/CI_tactheadshot>%1',0.75,1);
datablock ProjectileData(SportRifleProjectile)
{
projectileShapeName = "add-ons/Weapon_Gun/bullet.dts";
directDamage = 20; //90
directDamageType = $DamageType::SportRifle;
radiusDamageType = $DamageType::SportRifle;
brickExplosionRadius = 0.2;
brickExplosionImpact = true; //destroy a brick if we hit it directly?
brickExplosionForce = 15;
brickExplosionMaxVolume = 20; //max volume of bricks that we can destroy
brickExplosionMaxVolumeFloati ng = 30; //max volume of bricks that we can destroy if they aren't connected to the ground
particleEmitter = sportRifleCritTrailEmitter;
impactImpulse = 800;
verticalImpulse = 700;
explosion = gunExplosion;
muzzleVelocity = 190;
velInheritFactor = 0;
armingDelay = 0;
lifetime = 9000;
fadeDelay = 9500;
bounceElasticity = 0.0;
bounceFriction = 0.00;
isBallistic = true;
gravityMod = 0.02;
explodeOnDeath = true;
explodeOnPlayerImpact = true;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
};
datablock ProjectileData(SportRifleWeakProjectile)
{
projectileShapeName = "add-ons/Weapon_Gun/bullet.dts";
directDamage = 13; //90
directDamageType = $DamageType::SportRifle;
radiusDamageType = $DamageType::SportRifle;
brickExplosionRadius = 0.2;
brickExplosionImpact = true; //destroy a brick if we hit it directly?
brickExplosionForce = 15;
brickExplosionMaxVolume = 20; //max volume of bricks that we can destroy
brickExplosionMaxVolumeFloati ng = 30; //max volume of bricks that we can destroy if they aren't connected to the ground
particleEmitter = sportRifleCritTrail2Emitter;
impactImpulse = 600;
verticalImpulse = 500;
explosion = gunExplosion;
muzzleVelocity = 175;
velInheritFactor = 0;
armingDelay = 10;
lifetime = 9000;
fadeDelay = 9500;
bounceElasticity = 0.0;
bounceFriction = 0.00;
isBallistic = true;
gravityMod = 0.04;
explodeOnDeath = true;
explodeOnPlayerImpact = true;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
};
//////////
// item //
//////////
datablock ItemData(SportRifleItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./Sport_Rifle.2.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "Sport Rifle";
iconName = "./icon_sportrifle";
doColorShift = true;
colorShiftColor = "0.4 0.4 0.43 1.000";
// Dynamic properties defined by the scripts
image = SportRifleImage;
canDrop = true;
//Ammo Guns Parameters
maxAmmo = 10;
canReload = 1;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(SportRifleImage)
{
// Basic Item properties
shapeFile = "./Sport_Rifle.2.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 = SportRifleItem;
ammo = " ";
projectile = SportRifleProjectile;
projectileType = Projectile;
//melee particles shoot from eye node for consistancy
melee = false;
//raise your arm up or not
armReady = true;
doColorShift = true;
colorShiftColor = SportRifleItem.colorShiftColo r;
// 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;
stateSequence[0] = "Activate";
stateTransitionOnTimeout[0] = "LoadCheckA";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnNoAmmo[1] = "Reload";
stateTransitionOnTriggerDown[1] = "Fire";
stateAllowImageChange[1] = true;
stateSequence[1] = "ready";
stateName[2] = "Fire";
stateTransitionOnTriggerUp[2] = "Smoke";
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateScript[2] = "onFire";
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = SportRiflefireSound;
stateName[3] = "Smoke";
stateEmitterTime[3] = 0.2;
stateEmitterNode[3] = "muzzleNode";
stateSound[3] = PistolClickSound;
stateTimeoutValue[3] = 0.2;
stateTransitionOnTimeout[3] = "LoadCheckA";
stateName[4] = "LoadCheckA";
stateScript[4] = "onLoadCheck";
stateTimeoutValue[4] = 0.01;
stateTransitionOnTimeout[4] = "LoadCheckB";
stateName[5] = "LoadCheckB";
stateTransitionOnAmmo[5] = "Ready";
stateTransitionOnNoAmmo[5] = "Reload";
stateName[6] = "Reload";
stateTimeoutValue[6] = 1.2;
stateScript[6] = "onReloadStart";
stateTransitionOnTimeout[6] = "Wait";
stateWaitForTimeout[6] = true;
stateName[7] = "Wait";
stateTimeoutValue[7] = 0.5;
stateScript[7] = "onReloadWait";
stateTransitionOnTimeout[7] = "Reloaded";
stateName[8] = "FireLoadCheckA";
stateScript[8] = "onLoadCheck";
stateTimeoutValue[8] = 0.01;
stateTransitionOnTimeout[8] = "FireLoadCheckB";
stateName[9] = "FireLoadCheckB";
stateTransitionOnAmmo[9] = "Ready";
stateTransitionOnNoAmmo[9] = "ReloadSmoke";
stateName[10] = "ReloadSmoke";
stateEmitter[10] = gunSmokeEmitter;
stateEmitterTime[10] = 0.3;
stateEmitterNode[10] = "muzzleNode";
stateTimeoutValue[10] = 0.2;
stateTransitionOnTimeout[10] = "Reload";
stateName[11] = "Reloaded";
stateTimeoutValue[11] = 0.1;
stateScript[11] = "onReloaded";
stateTransitionOnTimeout[11] = "Ready";
};
function SportRifleImage::onFire(%this,%obj,%slot)
{
//%obj.playThread(2, plant);
//%obj.playThread(3, activate);
//%obj.playThread(4, shiftLeft);
%obj.playThread(2, shiftAway);
//Parent::onFire(%this,%obj,%slot);
if(vectorLen(%obj.getVelocity()) < 4 && (getSimTime() - %obj.lastShotTime) > 1000)
{
%projectile = SportRifleProjectile;
%spread = 0.0001;
}
else
{
%projectile = SportRifleWeakProjectile;
%spread = 0.0009;
}
%obj.toolAmmo[%obj.currTool]--;
%obj.AmmoSpent[%obj.currTool]++;
%obj.spawnExplosion(TTRecoilProjectile,"1 1 1");
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
%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);
}
function SportRifleImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this,%obj,%slot);
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
}
function SportRifleImage::onReloadStart(%this,%obj,%slot)
{
%obj.toolAmmo[%obj.currTool] = 0;
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
if(%obj.client.quantity["556rounds"] >= 1)
{
%obj.playThread(2, shiftRight);
serverPlay3D(block_MoveBrick_Sound,%obj.getPosition());
}
}
function SportRifleImage::onReloadWait(%this,%obj,%slot)
{
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
if(%obj.client.quantity["556rounds"] >= 1)
{
%obj.playThread(2, plant);
serverPlay3D(magazineOutSound,%obj.getPosition());
}
}
function SportRifleImage::onReloaded(%this,%obj,%slot)
{
if(%obj.client.quantity["556rounds"] >= 1)
{
if(%obj.client.quantity["556rounds"] > %this.item.maxAmmo)
{
%obj.client.quantity["556rounds"] -= %obj.AmmoSpent[%obj.currTool];
%obj.toolAmmo[%obj.currTool] = %this.item.maxAmmo;
%obj.AmmoSpent[%obj.currTool] = 0;
%obj.setImageAmmo(%slot,1);
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
return;
}
if(%obj.client.quantity["556rounds"] <= %this.item.maxAmmo)
{
%obj.client.exchangebullets = %obj.client.quantity["556rounds"];
%obj.toolAmmo[%obj.currTool] = %obj.client.exchangebullets;
%obj.setImageAmmo(%slot,1);
%obj.client.quantity["556rounds"] = 0;
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>5.56 Little Rifle <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["556rounds"] @ "", 4, 2, 3, 4);
return;
}
}
}
function SportRifleProjectile::damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%this.directDamage <= 0)
return;
%damageType = $DamageType::Direct;
if(%this.DirectDamageType)
%damageType = %this.DirectDamageType;
%scale = getWord(%obj.getScale(), 2);
%directDamage = 20;
%damage = %directDamage;
%sobj = %obj.sourceObject;
if(%sobj.getType() & $TypeMasks::PlayerObjectType)
{
if(isObject(%sobj.client))
%sobj.client.play2d(bulletHitSound);
}
if(%col.getType() & $TypeMasks::PlayerObjectType)
{
%colscale = getWord(%col.getScale(),2);
if(getword(%pos, 2) > getword(%col.getWorldBoxCenter(), 2) - 3.3*%colscale)
{
%directDamage = %directDamage * 3;
%damageType = $DamageType::SportRifleHeadshot;
%col.spawnExplosion(critProjectile,%colscale);
if(isObject(%col.client))
%col.client.play2d(critRecieveSound);
if(%sobj.getType() & $TypeMasks::PlayerObjectType)
{
serverplay3d(critFireSound,%sobj.getHackPosition());
if(isObject(%sobj.client))
%sobj.client.play2d(critHitSound);
}
}
%col.damage(%obj, %pos, %directDamage, %damageType);
}
else
{
%col.damage(%obj, %pos, %directDamage, %damageType);
}
}
function SportRifleWeakProjectile::damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%this.directDamage <= 0)
return;
%damageType = $DamageType::Direct;
if(%this.DirectDamageType)
%damageType = %this.DirectDamageType;
%scale = getWord(%obj.getScale(), 2);
%directDamage = 13;
%damage = %directDamage;
%sobj = %obj.sourceObject;
if(%sobj.getType() & $TypeMasks::PlayerObjectType)
{
if(isObject(%sobj.client))
%sobj.client.play2d(bulletHitSound);
}
if(%col.getType() & $TypeMasks::PlayerObjectType)
{
%colscale = getWord(%col.getScale(),2);
if(getword(%pos, 2) > getword(%col.getWorldBoxCenter(), 2) - 3.3*%colscale)
{
%directDamage = %directDamage * 2;
%damageType = $DamageType::SportRifleHeadshot;
%col.spawnExplosion(critProjectile,%colscale);
if(isObject(%col.client))
%col.client.play2d(critRecieveSound);
if(%sobj.getType() & $TypeMasks::PlayerObjectType)
{
serverplay3d(critFireSound,%sobj.getHackPosition());
if(isObject(%sobj.client))
%sobj.client.play2d(critHitSound);
}
}
%col.damage(%obj, %pos, %directDamage, %damageType);
}
else
{
%col.damage(%obj, %pos, %directDamage, %damageType);
}
}
Amade:
Weapon_Package_Tier1/server.cs, line 13
RTB_registerPref("Starting Rifle Ammo","Tier+Tactical Ammo","$Pref::Server::TT2Ammo","int 0 180","Script_GamePreferences",15*6,0,1);
Just change the 180 to whatever you want the maximum to be, but be aware that this will affect all other weapons that use the rifle (556) ammo type in addition to the Combat MG.