Hi, all! I'm working on my first mod and am focusing on just getting the code done. It's SUPPOSED to be a bomb, that drops straight down, and explodes on impact. I thought that would be pretty simple and some people may even consider downloading it. Anyways... Originally I was basing my script off of the frag grenade (nice explosion, plus it exit from your inventory). Only then did I learn that it's 15 printed pages long. After some tinkering, I encountered problems with the pin pull, the charge time, the animation, the shrapnel... and I decided it would be easier just to modify the gun, which I have limited experience with. I tried to first change projectile direction and speed, along with the gravity, so the bullet (bomb) always goes down. Then I wanted the thing to actually explode (I don't have the graphic yet, but I think I can just enlarge that from the RL or grenade). And of course, It should exit from your inventory. Right now.... it doesn't really work. I haven't gotten rid of the shell, so it's the only indication of an explosion, as it rides the shockwave (I think). If you touch it or are close to the ground when you use the bomb, it hurts you (I haven't changed damage from that of the base bullet). I thought I could get it to drop from your inventory by Copy/Pasting the part of the script that that "slot", "CurSlot" and those, assuming they were what did the trick. I got it to the point where you have to switch slots when you use it and the image disappears from in front of you. Help please? (I didn't change many of the names, and yes, I know I have two sets of explosions)
//bomb.cs
//audio
datablock AudioProfile(gunShot1Sound)
{
filename = "./gunShot1.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(bulletHitSound)
{
filename = "./bulletHit.wav";
description = AudioClose3d;
preload = true;
};
//shell
datablock DebrisData(gunShellDebris)
{
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;
};
//muzzle flash effects
datablock AudioProfile(fragGrenadeExplosionSound)
{
filename = "./FragExplode.wav";
description = AudioDefault3d;
preload = false;
};
datablock AudioProfile(fragGrenadeBounceSound)
{
filename = "./fragGrenadeBounce.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(fragGrenadeFireSound)
{
filename = "./fragGrenadeFire.wav";
description = AudioClosest3d;
preload = true;
};
datablock DebrisData(fragGrenadePinDebris)
{
shapeFile = "./FragGrenadepin.dts";
lifetime = 5.0;
minSpinSpeed = -400.0;
maxSpinSpeed = 200.0;
elasticity = 0.5;
friction = 0.2;
numBounces = 3;
staticOnMaxBounce = true;
snapOnMaxBounce = false;
fade = true;
gravModifier = 2;
};
datablock ParticleData(fragGrenadeExplosionParticle)
{
dragCoefficient = 1.0;
windCoefficient = 0.0;
gravityCoefficient = -0.2;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 4000;
lifetimeVarianceMS = 3990;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = true;
animateTexture = false;
//framesPerSec = 1;
textureName = "base/data/particles/cloud";
//animTexName = "~/data/particles/cloud";
// Interpolation variables
colors[0] = "0.2 0.2 0.2 1.0";
colors[1] = "0.25 0.25 0.25 0.2";
colors[2] = "0.4 0.4 0.4 0.0";
sizes[0] = 2.0;
sizes[1] = 10.0;
sizes[2] = 13.0;
times[0] = 0.0;
times[1] = 0.1;
times[2] = 1.0;
};
datablock ParticleEmitterData(fragGrenadeExplosionEmitter)
{
ejectionPeriodMS = 7;
periodVarianceMS = 0;
lifeTimeMS = 21;
ejectionVelocity = 10;
velocityVariance = 1.0;
ejectionOffset = 1.0;
thetaMin = 0;
thetaMax = 0;
phiReferenceVel = 0;
phiVariance = 90;
overrideAdvance = false;
particles = "fragGrenadeExplosionParticle";
};
datablock ParticleData(fragGrenadeExplosionParticle2)
{
dragCoefficient = 1.0;
windCoefficient = 0.0;
gravityCoefficient = -0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 4000;
lifetimeVarianceMS = 3990;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = true;
animateTexture = false;
//framesPerSec = 1;
textureName = "base/data/particles/cloud";
//animTexName = "~/data/particles/cloud";
// Interpolation variables
colors[0] = "0.2 0.2 0.2 0.0";
colors[1] = "0.25 0.25 0.25 0.2";
colors[2] = "0.4 0.4 0.4 0.0";
sizes[0] = 2.0;
sizes[1] = 10.0;
sizes[2] = 3.0;
times[0] = 0.0;
times[1] = 0.1;
times[2] = 1.0;
};
datablock ParticleEmitterData(fragGrenadeExplosionEmitter2)
{
ejectionPeriodMS = 20;
periodVarianceMS = 0;
lifetimeMS = 120;
ejectionVelocity = 15;
velocityVariance = 5.0;
ejectionOffset = 0.0;
thetaMin = 85;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "fragGrenadeExplosionParticle2";
};
datablock ParticleData(fragGrenadeExplosionParticle3)
{
dragCoefficient = 1.0;
windCoefficient = 0.0;
gravityCoefficient = -0.2;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 4000;
lifetimeVarianceMS = 3990;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = true;
animateTexture = false;
//framesPerSec = 1;
textureName = "base/data/particles/cloud";
//animTexName = "~/data/particles/cloud";
// Interpolation variables
colors[0] = "0.2 0.2 0.2 0.0";
colors[1] = "0.25 0.25 0.25 0.2";
colors[2] = "0.4 0.4 0.4 0.0";
sizes[0] = 2.0;
sizes[1] = 10.0;
sizes[2] = 13.0;
times[0] = 0.0;
times[1] = 0.1;
times[2] = 1.0;
};
datablock ParticleEmitterData(fragGrenadeExplosionEmitter3)
{
ejectionPeriodMS = 10;
periodVarianceMS = 0;
lifetimeMS = 150;
ejectionVelocity = 20;
velocityVariance = 5.0;
ejectionOffset = 0.0;
thetaMin = 85;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "fragGrenadeExplosionParticle3";
};
datablock ParticleData(fragGrenadeExplosionParticle4)
{
dragCoefficient = 0.1;
windCoefficient = 0.0;
gravityCoefficient = 4.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 1000;
lifetimeVarianceMS = 500;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = true;
animateTexture = false;
//framesPerSec = 1;
textureName = "base/data/particles/chunk";
//animTexName = "~/data/particles/cloud";
// Interpolation variables
colors[0] = "0.1 0.1 0.1 1.0";
colors[1] = "0.2 0.2 0.2 0.0";
sizes[0] = 0.5;
sizes[1] = 0.13;
times[0] = 0.0;
times[1] = 1.0;
};
datablock ParticleEmitterData(fragGrenadeExplosionEmitter4)
{
ejectionPeriodMS = 1;
timeMultiple = 10;
periodVarianceMS = 0;
lifetimeMS = 15;
ejectionVelocity = 35;
velocityVariance = 5.0;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "fragGrenadeExplosionParticle4";
};
datablock ExplosionData(fragGrenadeExplosion)
{
explosionShape = "Add-Ons/Weapon_Rocket Launcher/explosionSphere1.dts";
lifeTimeMS = 150;
soundProfile = fragGrenadeExplosionSound;
emitter[0] = fragGrenadeExplosionEmitter3;
emitter[1] = fragGrenadeExplosionEmitter2;
emitter[2] = fragGrenadeExplosionEmitter4;
//emitter[1] = "";
//emitter[2] = "";
//emitter[0] = "";
particleEmitter = fragGrenadeExplosionEmitter;
particleDensity = 10;
// particleDensity = 0;
particleRadius = 1.0;
faceViewer = true;
explosionScale = "3 3 3";
shakeCamera = true;
camShakeFreq = "17.0 18.0 17.0";
camShakeAmp = "2.0 2.0 2.0";
camShakeDuration = 1.5;
camShakeRadius = 30.0;
// Dynamic light
lightStartRadius = 0;
lightEndRadius = 0;
lightStartColor = "0.45 0.3 0.1";
lightEndColor = "0 0 0";
//impulse
impulseRadius = 13;
impulseForce = 1300;
//radius damage
damageRadius = 8;
radiusDamage = 20;
};
datablock ParticleData(gunFlashParticle)
{
dragCoefficient = 3;
gravityCoefficient = -0.5;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 25;
lifetimeVarianceMS = 15;
textureName = "base/data/particles/star1";
spinSpeed = 10.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0] = "0.9 0.9 0.0 0.9";
colors[1] = "0.9 0.5 0.0 0.0";
sizes[0] = 0.5;
sizes[1] = 1.0;
useInvAlpha = false;
};
datablock ParticleEmitterData(gunFlashEmitter)
{
ejectionPeriodMS = 3;
periodVarianceMS = 0;
ejectionVelocity = 1.0;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "gunFlashParticle";
uiName = "Gun Flash";
};
datablock ParticleData(gunSmokeParticle)
{
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.9";
colors[1] = "0.5 0.5 0.5 0.0";
sizes[0] = 0.15;
sizes[1] = 0.15;
useInvAlpha = false;
};
datablock ParticleEmitterData(gunSmokeEmitter)
{
ejectionPeriodMS = 3;
periodVarianceMS = 0;
ejectionVelocity = 1.0;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "gunSmokeParticle";
uiName = "Gun Smoke";
};
datablock ParticleData(gunExplosionParticle)
{
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] = 0.25;
sizes[1] = 0.75;
useInvAlpha = true;
};
datablock ParticleEmitterData(gunExplosionEmitter)
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 2;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 89;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "gunExplosionParticle";
useEmitterColors = true;
uiName = "Gun Hit Dust";
};
datablock ParticleData(gunExplosionRingParticle)
{
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] = "1 1 0.0 0.9";
colors[1] = "0.9 0.0 0.0 0.0";
sizes[0] = 1;
sizes[1] = 0;
useInvAlpha = false;
};
datablock ParticleEmitterData(gunExplosionRingEmitter)
{
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 = "gunExplosionRingParticle";
useEmitterColors = true;
uiName = "Gun Hit Flash";
};
datablock ExplosionData(gunExplosion)
{
//explosionShape = "";
soundProfile = bulletHitSound;
lifeTimeMS = 150;
particleEmitter = gunExplosionEmitter;
particleDensity = 5;
particleRadius = 0.2;
emitter[0] = gunExplosionRingEmitter;
faceViewer = true;
explosionScale = "10 10 10";
shakeCamera = false;
camShakeFreq = "20.0 21.0 20.0";
camShakeAmp = "2.0 2.0 2.0";
camShakeDuration = 1.5;
camShakeRadius = 20.0;
// Dynamic light
lightStartRadius = 0;
lightEndRadius = 2;
lightStartColor = "0.3 0.6 0.7";
lightEndColor = "0 0 0";
};
AddDamageType("Gun", '<bitmap:add-ons/Weapon_Gun/CI_gun> %1', '%2 <bitmap:add-ons/Weapon_Gun/CI_gun> %1',0.2,1);
datablock ProjectileData(gunProjectile)
{
projectileShapeName = "./bullet.dts";
directDamage = 30;
directDamageType = $DamageType::Gun;
radiusDamageType = $DamageType::Gun;
brickExplosionRadius = 1000;
brickExplosionImpact = true; //destroy a brick if we hit it directly?
brickExplosionForce = 100;
brickExplosionMaxVolume = 500; //max volume of bricks that we can destroy
brickExplosionMaxVolumeFloati ng = 750; //max volume of bricks that we can destroy if they aren't connected to the ground
impactImpulse = 1400;
verticalImpulse = 1400;
explosion = fragGrenadeExplosion;
particleEmitter = ""; //bulletTrailEmitter;
muzzleVelocity = 0;
velInheritFactor = 0;
armingDelay = 00;
lifetime = 10000;
fadeDelay = 7500;
bounceElasticity = 0.5;
bounceFriction = 0.20;
isBallistic = false;
gravityMod = 5.0;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
uiName = "Bomb";
};
//////////
// item //
//////////
datablock ItemData(GunItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./pistol.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "Bomb";
iconName = "./icon_gun";
doColorShift = true;
colorShiftColor = "0.25 0.25 0.25 1.000";
// Dynamic properties defined by the scripts
image = gunImage;
canDrop = true;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(gunImage)
{
// Basic Item properties
shapeFile = "./pistol.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 = BowItem;
ammo = " ";
projectile = gunProjectile;
projectileType = Projectile;
casing = gunShellDebris;
shellExitDir = "0.0 0.0 -1.3";
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 = false;
doColorShift = true;
colorShiftColor = gunItem.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.
};
function gunImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
%obj.playthread(2, spearThrow);
Parent::OnFire(%this, %obj, %slot);
%currSlot = %obj.lastFragSlot;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
}
function GunImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}
package BombPackage
{
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.dataBlock $= "Bomb" && %col.canPickup)
{
for(%i=0;%i<%this.maxTools;%i++)
{
%item = %obj.tool[%i];
if(%item $= 0 || %item $= "")
{
%freeSlot = 1;
break;
}
}
if(%freeSlot)
{
%obj.pickup(%col);
return;
}
}
Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
}
};
activatePackage(BombPackage);