14
« on: November 24, 2011, 03:36:29 AM »
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);
}