Author Topic: NEW: Editing Weapons  (Read 4865 times)

I got bored and finally figured out how to change a projectile of one gun (say, a minigun) to that of another (say, the Nerf Maverick). I'd decided that I wanted to make a whole "Nerf" set (for personal uses, because they would be using other's models, and I couldnt model a good gun for my life), but can't figure out how to save it as a different gun. I'd tried saving changing most of the names "Minigun" I could find to "NerfMinigun", renamed the .cs file and weapon_minigun to weapon_nerfminigun, but it now comes up in the weapons/wrench list as "Minigun" and it fires blanks. In the add-ons check list, though, it says "NerfMinigun" and "Minigun" isn't even exsistant (purposeful, I edited the original Minigun file). Any help/tips would be appreciated! Thanks!

NEW PROBLEM: Same with the minigun, my shotgun will not fire. It's Ephi's sawn-off, jsyk, and I've done everything in my knowledge to fix it. Tell me if you need the new script.
« Last Edit: August 11, 2009, 01:30:55 PM by Dapizzanator »


New, new code, with Chrono's replacements:
Code: [Select]
datablock ParticleData(NerfMinigunSmokeParticle)
{
dragCoefficient      = 4;
gravityCoefficient   = -1.0;
inheritedVelFactor   = 0.2;
constantAcceleration = 0.0;
lifetimeMS           = 425;
lifetimeVarianceMS   = 55;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0]     = "0.5 0.5 0.5 0.7";
colors[1]     = "0.5 0.5 0.5 0.0";
sizes[0]      = 0.05;
sizes[1]      = 0.25;

useInvAlpha = false;
};
datablock ParticleEmitterData(NerfMinigunSmokeEmitter)
{
   ejectionPeriodMS = 10;
   periodVarianceMS = 0;
   ejectionVelocity = 1.0;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "NerfMinigunSmokeParticle";
};


//bullet trail effects
datablock ParticleData(NerfMinigunbulletTrailParticle)
{
dragCoefficient      = 3;
gravityCoefficient   = -0.0;
inheritedVelFactor   = 1.0;
constantAcceleration = 0.0;
lifetimeMS           = 525;
lifetimeVarianceMS   = 55;
textureName          = "base/data/particles/dot";
spinSpeed = 10.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0]     = "0.9 0.0 0.0 0.8";
colors[1]     = "0.9 0.3 0.0 0.6";
colors[2]     = "0.9 0.3 0.0 0.0";
sizes[0]      = 0.06;
sizes[1]      = 0.06;
sizes[2]   = 0.01;
times[0]      = 0.0;
times[1]   = 0.9;
times[2]      = 1.0;

useInvAlpha = false;
};
datablock ParticleEmitterData(NerfMinigunbulletTrailEmitter)
{
   ejectionPeriodMS = 8;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "NerfMinigunbulletTrailParticle";
};

AddDamageType("NerfMinigun",   '<bitmap:add-ons/Weapon_Minigun/CI_Minigun> %1',    '%2 <bitmap:add-ons/Weapon_Minigun/CI_Minigun> %1',0.5,1);
datablock ProjectileData(MaverickProjectile)
{
   projectileShapeName = "./empty.dts";
   directDamage        = 15;
   directDamageType    = $DamageType::NerfMinigun;
   radiusDamageType    = $DamageType::NerfMinigun;

   brickExplosionRadius = 0;
   brickExplosionImpact = true;          //destroy a brick if we hit it directly?
   brickExplosionForce  = 10;
   brickExplosionMaxVolume = 15;          //max volume of bricks that we can destroy
   brickExplosionMaxVolumeFloating = 20;  //max volume of bricks that we can destroy if they aren't connected to the ground

   impactImpulse      = 400;
   verticalImpulse   = 300;
   explosion           = GunExplosion;
   particleEmitter     = NerfMinigunbulletTrailEmitter;

   muzzleVelocity      = 180;
   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";
};

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

// Basic Item Properties
shapeFile = "Add-ons/Weapon_Minigun/Minigun.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "NerfMinigun";
iconName = "Add-ons/Weapon_Minigun/icon_Minigun";
doColorShift = true;
colorShiftColor = (180/255) SPC (180/255) SPC (180/255) SPC (255/255);

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


////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(NerfMinigunImage)
{
   // Basic Item properties
   shapeFile = "Add-ons/Weapon_Minigun/Minigun.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 1.0 -0.85";
   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 = BowItem;
   ammo = " ";
   projectile = MaverickProjectile;
   projectileType = Projectile;

casing = GunShellDebris;
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;
   LarmReady = true;

   doColorShift = true;
   colorShiftColor = NerfMinigunItem.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.15;
stateTransitionOnTimeout[0]     = "Ready";
stateSound[0] = weaponSwitchSound;

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

stateName[2]                    = "Spinup";
stateAllowImageChange[2]        = false;
stateTransitionOnTimeout[2]     = "Fire";
stateTimeoutValue[2]            = 1.00;
stateWaitForTimeout[2] = true;
//stateSound[2] = NerfMinigunShot1Sound;
stateSequence[2] = "Spin";
stateTransitionOnTriggerUp[2]   = "Ready";
//stateSequenceOnTimeout[2] = "Spin";

stateName[3]                    = "Fire";
stateTransitionOnTimeout[3]     = "Smoke";
stateTimeoutValue[3]            = 0.01;
stateFire[3]                    = true;
stateAllowImageChange[3]        = false;
//stateSequence[3]                = "Fire";
stateScript[3]                  = "onFire";
stateWaitForTimeout[3] = true;
stateEmitter[3] = gunFlashEmitter;
stateEmitterTime[3] = 0.01;
stateEmitterNode[3] = "muzzleNode";
stateSound[3] = gunShot1Sound;
stateEjectShell[3]        = true;

stateName[4] = "Smoke";
stateEmitter[4] = NerfMinigunSmokeEmitter;
stateEmitterTime[4] = 0.05;
stateEmitterNode[4] = "muzzleNode";
stateTimeoutValue[4]            = 0.01;
stateTransitionOnTimeout[4]     = "Check";

stateName[5] = "Check";
stateTransitionOnTriggerUp[5]   = "Slow";
stateTransitionOnTriggerDown[5] = "Fire";

stateName[6] = "Slow";
stateTransitionOnTriggerDown[6] = "Fire";
//stateSequence[6]                = "ready";
stateEmitter[6] = NerfMinigunSmokeEmitter;
stateEmitterTime[6] = 1.00;
stateEmitterNode[6] = "muzzleNode";
stateAllowImageChange[6]        = false;
stateTransitionOnTimeout[6]     = "Ready";
stateTimeoutValue[6]            = 1.00;
stateWaitForTimeout[6] = true;

};

function NerfMinigunImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this,%obj,%slot);
%obj.playThread(0, armreadyboth);
}

function NerfMinigunImage::onUnMount(%this,%obj,%slot)
{
Parent::onMount(%this,%obj,%slot);
%obj.playThread(0, root);
}

function NerfMinigunImage::onFire(%this,%obj,%slot)
{
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-1")));

%projectile = %this.projectile;
%spread = 0.00185;
%shellcount = 1;

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;
}
« Last Edit: August 08, 2009, 11:59:23 PM by Dapizzanator »

It is still all minigun, not nerfminigun.

Use ctrl h in the script and replace minigun with Nerfminigun

alright. I'll try that.
Edit: Everythings great, except the Projectile isn't existant. Do I need to copy the Maverick projectile from its folder and stick it in the nerfminigun somewhere? Or, rename MaverickProjectile?
« Last Edit: August 08, 2009, 10:37:37 PM by Dapizzanator »

Do: Ctrl+h
Find: "./NerfMinigun.dts";
Replace with: "Add-ons/Weapon_Minigun/Minigun.dts";
Find: "Weapon_NerfMinigun/CI_NerfMinigun"
Replace with: "Weapon_Minigun/CI_Minigun"
Find: "./icon_NerfMinigun";
Replace With: "Add-ons/Weapon_Minigun/icon_Minigun";

And lastly, are you sure you want this for the projectile?
Code: [Select]
datablock ProjectileData(NerfMinigunProjectile)
{
   projectileShapeName = "./empty.dts";
   directDamage        = 15;
   directDamageType    = $DamageType::NerfMinigun;
   radiusDamageType    = $DamageType::NerfMinigun;

   brickExplosionRadius = 0;
   brickExplosionImpact = true;          //destroy a brick if we hit it directly?
   brickExplosionForce  = 10;
   brickExplosionMaxVolume = 15;          //max volume of bricks that we can destroy
   brickExplosionMaxVolumeFloating = 20;  //max volume of bricks that we can destroy if they aren't connected to the ground

   impactImpulse      = 400;
   verticalImpulse   = 300;
   explosion           = GunExplosion;
   particleEmitter     = NerfMinigunbulletTrailEmitter;

   muzzleVelocity      = 180;
   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";
};

I don't think that's very suiting. Expecially with the shape.

(Note: I referenced Add-ons/Weapon_Minigun even though it wasn't a default add-on only because he intended it for private use.)

What do you mean "not suiting"?

projectileShapeName = "./empty.dts";
explosion           = GunExplosion;
impactImpulse        = 400;
verticalImpulse     = 300;
gravityMod = 0.0;

well, either way, I got it working, just missing model again... I think it was one of the replacements. The projectiles work, but it shows a gray gun.

Do: Ctrl+h
Find: "./NerfMinigun.dts";
Replace with: "Add-ons/Weapon_Minigun/Minigun.dts";
Find: "Weapon_NerfMinigun/CI_NerfMinigun"
Replace with: "Weapon_Minigun/CI_Minigun"
Find: "./icon_NerfMinigun";
Replace With: "Add-ons/Weapon_Minigun/icon_Minigun";

 Crap. Shotgun Problems. Please read the first post.
« Last Edit: August 11, 2009, 01:31:40 PM by Dapizzanator »


Tell me if you need the new script
we need the new one, or we can't help the problem

we need the new one, or we can't help the problem
Duh. Alright. Sorry for my stupidity.
Code: [Select]
//audio
datablock AudioProfile(NerfShotgunReloadSound)
{
   filename    = "./NerfShotgunReload.wav";
   description = AudioClose3d;
   preload = true;
};

//shell
datablock DebrisData(NerfShotgunShellDebris)
{
shapeFile = "./NerfShotgunShell.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;
};

//emitter
datablock ParticleData(NerfShotgunSmokeParticle)
{
dragCoefficient      = 3;
gravityCoefficient   = -0.5;
inheritedVelFactor   = 0.2;
constantAcceleration = 0.0;
lifetimeMS           = 525;
lifetimeVarianceMS   = 55;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0]     = "0.5 0.5 0.5 0.5";
colors[1]     = "0.5 0.5 0.5 0.0";
sizes[0]      = 0.15;
sizes[1]      = 0.1;

useInvAlpha = false;
};
datablock ParticleEmitterData(NerfShotgunSmokeEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 1.0;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "ShotgunSmokeParticle";
};

AddDamageType("Shotgun",   '<bitmap:add-ons/Weapon_NerfShotgun/CI_NerfShotgun> %1',    '%2 <bitmap:add-ons/Weapon_NerfShotgun/CI_NerfShotgun> %1',0.5,1);
datablock ProjectileData(NerfShotgunProjectile)
{
   projectileShapeName = "add-ons/Weapon_NerfMaverick/Dart.dts";
   directDamage        = 45;
   directDamageType    = $DamageType::Shotgun;
   radiusDamageType    = $DamageType::Shotgun;

   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
   brickExplosionMaxVolumeFloating = 30;  //max volume of bricks that we can destroy if they aren't connected to the ground

   impactImpulse      = 1200;
   verticalImpulse     = 1000;
   explosion           = gunExplosion;

   muzzleVelocity      = 150;
   velInheritFactor    = 1;

   armingDelay         = 0;
   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";
};

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

// Basic Item Properties
shapeFile = "Add-ons/Weapon_Shotgun/Shotgun.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "NerfShotgun";
iconName = "./NerfShotgunIcon";
doColorShift = true;
colorShiftColor = "0.5 0.5 0.5 1.000";

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

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(NerfShotgunImage)
{
   // Basic Item properties
   shapeFile = "Add-ons/Weapon_NerfShotgun/NerfShotgun.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 = Shotgunitem;
   ammo = " ";
   projectile = MaverickProjectile;
   projectileType = Projectile;

   casing = NerfShotgunShellDebris;
   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;
   minShotTime = 1000;

   doColorShift = true;
   colorShiftColor = NerfShotgunItem.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.15;
stateTransitionOnTimeout[0]     = "Ready";
stateSound[0]   = weaponSwitchSound;

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

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]   = gunShot1Sound;

stateName[3]   = "Smoke";
stateEmitter[3]   = NerfShotgunSmokeEmitter;
stateEmitterTime[3]   = 0.1;
stateEmitterNode[3]   = "muzzleNode";
stateTimeoutValue[3]            = 0.5;
stateTransitionOnTimeout[3]     = "Reload";

stateName[4]   = "Reload";
stateTimeoutValue[4]   = 0.3;
stateSequence[4]   = "reload";
stateTransitionOnTimeout[4]   = "Wait";
stateWaitForTimeout[4]   = true;
stateEjectShell[4]          = true;
stateSound[4]   = NerfShotgunReloadSound;

stateName[5]   = "Wait";
stateTimeoutValue[5]   = 0.1;
stateTransitionOnTimeout[5]   = "Ready";
};

function NerfShotgunImage::onFire(%this,%obj,%slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime())
return;
%obj.lastFireTime = getSimTime();
     
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-3")));
%obj.playThread(2, shiftAway);

%projectile = %this.projectile;
%spread = 0.0015;
%shellcount = 3;

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;
}

Heres the file, if you want to see other stuff: http://www.mediafire.com/download.php?mzzw2dta4hy
« Last Edit: August 11, 2009, 04:29:19 PM by Dapizzanator »

Code: [Select]
AddDamageType("Shotgun",   '<bitmap:add-ons/Weapon_NerfShotgun/CI_NerfShotgun> %1',    '%2 <bitmap:add-ons/Weapon_NerfShotgun/CI_NerfShotgun> %1',0.5,1);
datablock ProjectileData(NerfShotgunProjectile)
{
   projectileShapeName = "add-ons/Weapon_NerfMaverick/Dart.dts";
   directDamage        = 45;
   directDamageType    = $DamageType::Shotgun;
   radiusDamageType    = $DamageType::Shotgun;

////////////////
//weapon image//
////////////////
// Projectile && Ammo.
   item = Shotgunitem;
   ammo = " ";
   projectile = MaverickProjectile;
   projectileType = Projectile;
Picked the wrong places out,

Change the damage type to "NerfShotgun"
Then change the directdamagetype and the radiusDamageType in the Projectiledata to "$DamageType::NerfShotgun"

The above instructions are made, so the damage type won't take over the normal shotgun damage type

Then:
At the Weapon Image part, at the part for the ammo&projectile, change the projectile to "NerfShotgunProjectile"

The above should fix the not fire part

This is all I could find