Author Topic: Brick Explosion  (Read 1286 times)

so lately I tried to make a brick explosion which is like the jeep explosion but sommons bricks instead of tires.
then as someone with no experience at coding, I tried to edit it:
i first edited Jeep_Explosion.cs so it is stored in Vehicle_Jeep



original
Code: [Select]
//jeep_explosion.cs


//initial jeep explosion, jeep loses wheels and is burned
//  we use the default vehicle explosion, but add wheels debris

// Debris
////////////
datablock ParticleData(jeepTireDebrisTrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = -0.5;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 150;
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.0 0.0 0.0 0.0";
colors[1] = "0.0 0.0 0.0 0.250";
   colors[2] = "0.0 0.0 0.0 0.0";

sizes[0] = 1.50;
sizes[1] = 2.50;
   sizes[2] = 3.50;

times[0] = 0.0;
times[1] = 0.1;
   times[2] = 1.0;
};

datablock ParticleEmitterData(jeepTireDebrisTrailEmitter)
{
   ejectionPeriodMS = 90;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionOffset   = 1.0;
   thetaMin         = 0;
   thetaMax         = 0;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "jeepTireDebrisTrailParticle";
};
datablock DebrisData(jeepTireDebris)
{
   emitters = "JeepTireDebrisTrailEmitter";

shapeFile = "./jeepTire.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;
};


// Explosion
////////////
datablock ExplosionData(jeepExplosion : vehicleExplosion)
{
   debris = jeepTireDebris;
   debrisNum = 4;
   debrisNumVariance = 0;
   debrisPhiMin = 0;
   debrisPhiMax = 360;
   debrisThetaMin = 40;
   debrisThetaMax = 85;
   debrisVelocity = 14;
   debrisVelocityVariance = 3;
};


// Projectile - you can't spawn explosions on the server, so we use a short-lived projectile
/////////////////////////////////
datablock ProjectileData(jeepExplosionProjectile : vehicleExplosionProjectile)
{
   directDamage        = 0;
   radiusDamage        = 0;
   damageRadius        = 0;
   explosion           = jeepExplosion;

   directDamageType  = $DamageType::VehicleExplosion;
   radiusDamageType  = $DamageType::VehicleExplosion;

   explodeOnDeath = 1;

   armingDelay         = 0;
   lifetime            = 0;

   uiName = "Jeep Explosion";
};
modified
Code: [Select]
//jeep_explosion.cs


//initial jeep explosion, jeep loses wheels and is burned
//  we use the default vehicle explosion, but add wheels debris

// Debris
////////////
datablock ParticleData(jeepTireDebrisTrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = -0.5;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 150;
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.0 0.0 0.0 0.0";
colors[1] = "0.0 0.0 0.0 0.250";
   colors[2] = "0.0 0.0 0.0 0.0";

sizes[0] = 1.50;
sizes[1] = 2.50;
   sizes[2] = 3.50;

times[0] = 0.0;
times[1] = 0.1;
   times[2] = 1.0;
};

datablock ParticleEmitterData(jeepTireDebrisTrailEmitter)
{
   ejectionPeriodMS = 90;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionOffset   = 1.0;
   thetaMin         = 0;
   thetaMax         = 0;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "jeepTireDebrisTrailParticle";
};
datablock DebrisData(jeepTireDebris)
{
   emitters = "JeepTireDebrisTrailEmitter";

shapeFile = "./block.dts"; //EDIT
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;
};


// Explosion
////////////
datablock ExplosionData(jeepExplosion : vehicleExplosion)
{
   debris = jeepTireDebris;
   debrisNum = 6; //EDIT
   debrisNumVariance = 0;
   debrisPhiMin = 0;
   debrisPhiMax = 360;
   debrisThetaMin = 40;
   debrisThetaMax = 85;
   debrisVelocity = 14;
   debrisVelocityVariance = 3;
};


// Projectile - you can't spawn explosions on the server, so we use a short-lived projectile
/////////////////////////////////
datablock ProjectileData(jeepExplosionProjectile : vehicleExplosionProjectile)
{
   directDamage        = 0;
   radiusDamage        = 0;
   damageRadius        = 0;
   explosion           = jeepExplosion;

   directDamageType  = $DamageType::VehicleExplosion;
   radiusDamageType  = $DamageType::VehicleExplosion;

   explodeOnDeath = 1;

   armingDelay         = 0;
   lifetime            = 0;

   uiName = "Brick Explosion"; //EDIT
};



and also edited server.cs

original
Code: [Select]
// support stuff for the jeep vehicle
exec("./jeep_Tire.cs");
exec("./jeep_Explosion.cs");
exec("./jeep_FinalExplosion.cs");
exec("./jeep_Spring.cs");


// Sounds //
////////////
datablock AudioProfile(fastImpactSound)
{
   filename    = "./fastimpact.WAV";
   description = AudioDefault3d;
   preload = true;
};
datablock AudioProfile(slowImpactSound)
{
   filename    = "./slowimpact.wav";
   description = AudioDefault3d;
   preload = true;
};


// Vehicle //
/////////////
datablock WheeledVehicleData(JeepVehicle)
{
category = "Vehicles";
displayName = " ";
shapeFile = "./jeep.dts"; //"~/data/shapes/skivehicle.dts"; //
emap = true;
minMountDist = 3;
   
   numMountPoints = 7;
   mountThread[0] = "sit";
   mountThread[1] = "sit";
   mountThread[2] = "sit";
   mountThread[3] = "sit";
   mountThread[4] = "sit";
   mountThread[5] = "root";
   mountThread[6] = "root";
   mountThread[7] = "sit";

maxDamage = 200.00;
destroyedLevel = 200.00;
speedDamageScale = 1.04;
collDamageThresholdVel = 20.0;
collDamageMultiplier   = 0.02;

massCenter = "0 0 0";
   //massBox = "2 5 1";

maxSteeringAngle = 0.9785;  // Maximum steering angle, should match animation
integration = 4;           // Force integration time: TickSec/Rate
tireEmitter = VehicleTireEmitter; // All the tires use the same dust emitter

// 3rd person camera settings
cameraRoll = false;         // Roll the camera with the vehicle
cameraMaxDist = 13;         // Far distance from vehicle
cameraOffset = 7.5;        // Vertical offset from camera mount point
cameraLag = 0.0;           // Velocity lag of camera
cameraDecay = 0.75;        // Decay per sec. rate of velocity lag
cameraTilt = 0.4;
   collisionTol = 0.1;        // Collision distance tolerance
   contactTol = 0.1;

useEyePoint = false;

defaultTire = jeepTire;
defaultSpring = jeepSpring;
//flatTire = jeepFlatTire;
//flatSpring = jeepFlatSpring;

   numWheels = 4;

// Rigid Body
mass = 300;
density = 5.0;
drag = 1.6;
bodyFriction = 0.6;
bodyRestitution = 0.6;
minImpactSpeed = 10;        // Impacts over this invoke the script callback
softImpactSpeed = 10;       // Play SoftImpact Sound
hardImpactSpeed = 15;      // Play HardImpact Sound
groundImpactMinSpeed    = 10.0;

// Engine
engineTorque = 12000; //4000;       // Engine power
engineBrake = 2000;         // Braking when throttle is 0
brakeTorque = 50000;        // When brakes are applied
maxWheelSpeed = 30;        // Engine scale by current speed / max speed

rollForce = 900;
yawForce = 600;
pitchForce = 1000;
rotationalDrag = 0.2;

   // Advanced Steering
   steeringAutoReturn = true;
   steeringAutoReturnRate = 0.9;
   steeringAutoReturnMaxSpeed = 10;
   steeringUseStrafeSteering = true;
   steeringStrafeSteeringRate = 0.1;

// Energy
maxEnergy = 100;
jetForce = 3000;
minJetEnergy = 30;
jetEnergyDrain = 2;

splash = vehicleSplash;
splashVelocity = 4.0;
splashAngle = 67.0;
splashFreqMod = 300.0;
splashVelEpsilon = 0.60;
bubbleEmitTime = 1.4;
splashEmitter[0] = vehicleFoamDropletsEmitter;
splashEmitter[1] = vehicleFoamEmitter;
splashEmitter[2] = vehicleBubbleEmitter;
mediumSplashSoundVelocity = 10.0;   
hardSplashSoundVelocity = 20.0;   
exitSplashSoundVelocity = 5.0;

//mediumSplashSound = "";
//hardSplashSound = "";
//exitSplashSound = "";

// Sounds
//   jetSound = ScoutThrustSound;
//engineSound = idleSound;
//squealSound = skidSound;
softImpactSound = slowImpactSound;
hardImpactSound = fastImpactSound;
//wheelImpactSound = slowImpactSound;

//   explosion = VehicleExplosion;
justcollided = 0;

   uiName = "Jeep ";
rideable = true;
lookUpLimit = 0.65;
lookDownLimit = 0.45;

paintable = true;
   
   damageEmitter[0] = VehicleBurnEmitter;
damageEmitterOffset[0] = "0.0 0.0 0.0 ";
damageLevelTolerance[0] = 0.99;

   damageEmitter[1] = VehicleBurnEmitter;
damageEmitterOffset[1] = "0.0 0.0 0.0 ";
damageLevelTolerance[1] = 1.0;

   numDmgEmitterAreas = 1;

   initialExplosionProjectile = jeepExplosionProjectile;
   initialExplosionOffset = 0;         //offset only uses a z value for now

   burnTime = 4000;

   finalExplosionProjectile = jeepFinalExplosionProjectile;
   finalExplosionOffset = 0.5;          //offset only uses a z value for now

   minRunOverSpeed    = 4;   //how fast you need to be going to run someone over (do damage)
   runOverDamageScale = 8;   //when you run over someone, speed * runoverdamagescale = damage amt
   runOverPushScale   = 1.2; //how hard a person you're running over gets pushed

   //protection for passengers
   protectPassengersBurn   = false;  //protect passengers from the burning effect of explosions?
   protectPassengersRadius = true;  //protect passengers from radius damage (explosions) ?
   protectPassengersDirect = false; //protect passengers from direct damage (bullets) ?
};
modified
Code: [Select]
// support stuff for the jeep vehicle
exec("./jeep_BrickExplosion.cs");
i guess there's something weird about it being that small....



i also modified the base zip file

original

only the brick.dts has been added with no scripts
affecting it
modified


the brick.dts model is this:
click to enlarge

and when using it ingame it acts like nothing has been changed...

First of all, you'll have to change all of the datablock names so it doesn't overwrite the Jeep's stuff.
So whenever you see
Code: [Select]
datablock BLAHBLAHData(SomeName)
Change SomeName to a unique name.

Next. In the server.cs you're telling it to execute the file jeep_BrickExplosion.cs. But if you look in your folder, the file is called jeep_Explosion.cs, so the file you're telling it to execute doesn't exist.
But since you're only having 1 line of code in your server.cs, I suggest moving all of the code in jeep_Explosion.cs to the server.cs(because it's annoying when people only have 1 line of code in their server.cs).

You're also telling it to use the model block.dts, which doesn't exist. You're file is called brick.dts.

Also, when you rename the datablocks, you'll have to set some of the things in the datablocks to the appropriate names.

You used block.dts in the scripts but the file is named brick.cs.

Also, you might as well delete your server.cs file and rename your jeep_explosion.cs file server.cs. This doesn't really make a difference, though.

updated it with all your tips, still not working, console gives no detail about it

updated it with all your tips, still not working, console gives no detail about it
Welp. Give us the code so we can see what you're doing wrong.

Welp. Give us the code so we can see what you're doing wrong.
alright, check your private messages


Quote
// support stuff for the jeep vehicle
exec("./server.cs"); //Remove this line. It's useless. Think about it logically. This file is named server.cs and it's automatically executed if the addon is enabled, so why are we trying to execute it again?

//jeep_explosion.cs


//initial jeep explosion, jeep loses wheels and is burned
//  we use the default vehicle explosion, but add wheels debris

// Debris
////////////
datablock ParticleData(BrickExplosion)
{
   dragCoefficient      = 3.0;
   windCoefficient      = 0.0;
   gravityCoefficient   = -0.5;
   inheritedVelFactor   = 0.0;
   constantAcceleration   = 0.0;
   lifetimeMS      = 500;
   lifetimeVarianceMS   = 150;
   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.0 0.0 0.0 0.0";
   colors[1]   = "0.0 0.0 0.0 0.250";
   colors[2]   = "0.0 0.0 0.0 0.0";

   sizes[0]   = 1.50;
   sizes[1]   = 2.50;
   sizes[2]   = 3.50;

   times[0]   = 0.0;
   times[1]   = 0.1;
   times[2]   = 1.0;
};

datablock ParticleEmitterData(BrickExplosion1)
{
   ejectionPeriodMS = 90;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionOffset   = 1.0;
   thetaMin         = 0;
   thetaMax         = 0;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "jeepTireDebrisTrailParticle"; //Change this to reference your particle datablock.
};
datablock DebrisData(jeepTireDebris) //Change the name of this or it'll overwrite the Jeep's datablock.
{
   emitters = "JeepTireDebrisTrailEmitter"; //Change this to reference your emitter datablock.

   shapeFile = "./block.dts";
   lifetime = 3.0;
   minSpinSpeed = -400.0;
   maxSpinSpeed = 200.0;
   elasticity = 0.5;
   friction = 0.2;
   numBounces = 5;
   staticOnMaxBounce = true;
   snapOnMaxBounce = false;
   fade = true;

   gravModifier = 2;
};


// Explosion
////////////
datablock ExplosionData(BrickExplosion2 : BrickExplosion3) //Change the BrickExplosion3 here to vehicleExplosion. I'll explain this in a second.
{
   debris = jeepTireDebris; //Change this to reference your debris datablock.
   debrisNum = 6;
   debrisNumVariance = 0;
   debrisPhiMin = 0;
   debrisPhiMax = 360;
   debrisThetaMin = 40;
   debrisThetaMax = 85;
   debrisVelocity = 14;
   debrisVelocityVariance = 3;
};


// Projectile - you can't spawn explosions on the server, so we use a short-lived projectile
/////////////////////////////////
datablock ProjectileData(BrickExplosion4 : BrickExplosion5) //Change the BrickExplosion5 here to vehicleExplosionProjectile. I'll explain this in a second.
{
   directDamage        = 0;
   radiusDamage        = 0;
   damageRadius        = 0;
   explosion           = jeepExplosion; //Change this to reference your explosion datablock.

   directDamageType  = $DamageType::VehicleExplosion;
   radiusDamageType  = $DamageType::VehicleExplosion;

   explodeOnDeath      = 1;

   armingDelay         = 0;
   lifetime            = 0;

   uiName = "Brick Explosion";
};
When you do datablock (myDataBlock : prevDataBlock); then myDataBlock inherits all the fields that you don't change, from prevDataBlock.
So if I did
Code: [Select]
datablock ProjectileData(prevDataBlock)
{
      directDamage = 5;
      uiName = "Fish Face";
};
And then I did
Code: [Select]
datablock ProjectileData(myDataBlock : prevDataBlock)
{
      uiName = "Super Doge";
};
Then the uiName of the second datablock would be "Super Doge", but the directDamage would be 5 because we told it to inherit from prevDataBlock and did not define the damage of myDataBlock.

I also suggest using less generic names than you are using.

Also:
Post it here.
Next time if you want help faster.

after multiple attempts, swollow helped me to clean the script and eventually redid it all from scratch, the add-on is now available here:
http://forum.blockland.us/index.php?topic=283872.0

but still thank you for your help