From e93efa685c1cf271bd6f7d9406b9f47313be0002 Mon Sep 17 00:00:00 2001 From: ChocoTaco Date: Sat, 4 Mar 2023 17:36:39 -0500 Subject: [PATCH] Mortar/Missile reload changes --- Classic/scripts/autoexec/TacoOverrides.cs | 16 +- Classic/scripts/projectiles.cs | 26 +- Classic/scripts/weapons/missileLauncher.cs | 856 +++++++++++++++++++++ Classic/scripts/weapons/mortar.cs | 824 ++++++++++++++++++++ 4 files changed, 1701 insertions(+), 21 deletions(-) mode change 100755 => 100644 Classic/scripts/autoexec/TacoOverrides.cs create mode 100644 Classic/scripts/weapons/missileLauncher.cs create mode 100644 Classic/scripts/weapons/mortar.cs diff --git a/Classic/scripts/autoexec/TacoOverrides.cs b/Classic/scripts/autoexec/TacoOverrides.cs old mode 100755 new mode 100644 index 0558596..5b995b1 --- a/Classic/scripts/autoexec/TacoOverrides.cs +++ b/Classic/scripts/autoexec/TacoOverrides.cs @@ -324,15 +324,15 @@ function serverCmdScopeCommanderMap(%client, %scope) } //Mortar Throw Reload Fix -function ShapeBase::throwWeapon(%this) -{ - if((%this.getMountedImage($WeaponSlot).getName() $= "MortarImage" || %this.getMountedImage($WeaponSlot).getName() $= "MissileLauncherImage" || %this.getMountedImage($WeaponSlot).getName() $= "ShockLanceImage") && - (%this.getImageState($WeaponSlot) $= "Reload" || %this.getImageState($WeaponSlot) $= "Fire")){ - return; - } +// function ShapeBase::throwWeapon(%this) +// { +// if((%this.getMountedImage($WeaponSlot).getName() $= "MortarImage" || %this.getMountedImage($WeaponSlot).getName() $= "MissileLauncherImage" || %this.getMountedImage($WeaponSlot).getName() $= "ShockLanceImage") && +// (%this.getImageState($WeaponSlot) $= "Reload" || %this.getImageState($WeaponSlot) $= "Fire")){ +// return; +// } - parent::throwWeapon(%this); -} +// parent::throwWeapon(%this); +// } // Added object check diff --git a/Classic/scripts/projectiles.cs b/Classic/scripts/projectiles.cs index 9f24021..1ba0fd7 100644 --- a/Classic/scripts/projectiles.cs +++ b/Classic/scripts/projectiles.cs @@ -62,20 +62,21 @@ function ShapeBaseImageData::onFire(%data, %obj, %slot) { // --------------------------------------------------------------------------- // z0dd - ZOD, 9/3/02. Anti rapid fire mortar/missile fix. - if (%obj.cantFire !$= "") - { - return 0; - } + // if (%obj.cantFire !$= "") + // { + // return 0; + // } - %wpnName = %data.getName(); - if((%wpnName $= "MortarImage") || (%wpnName $= "MissileLauncherImage")) - { - %obj.cantFire = 1; - %preventTime = %data.stateTimeoutValue[4]; - //%preventTime = (%data.stateTimeoutValue[4] + %data.stateTimeoutValue[3]) - 0.032; - %obj.reloadSchedule = schedule(%preventTime * 1000, %obj, resetFire, %obj); - } + // %wpnName = %data.getName(); + // if((%wpnName $= "MortarImage") || (%wpnName $= "MissileLauncherImage")) + // { + // %obj.cantFire = 1; + // %preventTime = %data.stateTimeoutValue[4]; + // //%preventTime = (%data.stateTimeoutValue[4] + %data.stateTimeoutValue[3]) - 0.032; + // %obj.reloadSchedule = schedule(%preventTime * 1000, %obj, resetFire, %obj); + // } // --------------------------------------------------------------------------- + %obj.lfireTime[%data.getName()] = getSimTime(); %data.lightStart = getSimTime(); @@ -411,7 +412,6 @@ function ShockLanceImage::onFire(%this, %obj, %slot) %obj.cantfire = 1; %preventTime = %this.stateTimeoutValue[4]; - //%preventTime = (%data.stateTimeoutValue[4] + %data.stateTimeoutValue[3]) - 0.032; %obj.reloadSchedule = schedule(%preventTime * 1000, %obj, resetFire, %obj); if( %obj.getEnergyLevel() < %this.minEnergy ) // z0dd - ZOD, 5/22/03. Check energy level first diff --git a/Classic/scripts/weapons/missileLauncher.cs b/Classic/scripts/weapons/missileLauncher.cs new file mode 100644 index 0000000..abaec08 --- /dev/null +++ b/Classic/scripts/weapons/missileLauncher.cs @@ -0,0 +1,856 @@ +//-------------------------------------- +// Missile launcher +//-------------------------------------- + +//-------------------------------------------------------------------------- +// Sounds +//-------------------------------------- +datablock AudioProfile(MissileSwitchSound) +{ + filename = "fx/weapons/missile_launcher_activate.wav"; + description = AudioClosest3d; + preload = true; +}; + +datablock AudioProfile(MissileFireSound) +{ + filename = "fx/weapons/missile_fire.WAV"; + description = AudioDefault3d; + preload = true; +}; + +datablock AudioProfile(MissileProjectileSound) +{ + filename = "fx/weapons/missile_projectile.wav"; + description = ProjectileLooping3d; + preload = true; +}; + +datablock AudioProfile(MissileReloadSound) +{ + filename = "fx/weapons/weapon.missilereload.wav"; + description = AudioClosest3d; + preload = true; +}; + +datablock AudioProfile(MissileLockSound) +{ + filename = "fx/weapons/missile_launcher_searching.WAV"; + description = AudioClosest3d; + preload = true; +}; + +datablock AudioProfile(MissileExplosionSound) +{ + filename = "fx/explosions/explosion.xpl23.wav"; + description = AudioBIGExplosion3d; + preload = true; +}; + +datablock AudioProfile(MissileDryFireSound) +{ + filename = "fx/weapons/missile_launcher_dryfire.wav"; + description = AudioClose3d; + preload = true; +}; + + +//---------------------------------------------------------------------------- +// Splash Debris +//---------------------------------------------------------------------------- +datablock ParticleData( MDebrisSmokeParticle ) +{ + dragCoeffiecient = 1.0; + gravityCoefficient = 0.10; + inheritedVelFactor = 0.1; + + lifetimeMS = 1000; + lifetimeVarianceMS = 100; + + textureName = "particleTest"; + +// useInvAlpha = true; + + spinRandomMin = -60.0; + spinRandomMax = 60.0; + + colors[0] = "0.7 0.8 1.0 1.0"; + colors[1] = "0.7 0.8 1.0 0.5"; + colors[2] = "0.7 0.8 1.0 0.0"; + sizes[0] = 0.0; + sizes[1] = 0.8; + sizes[2] = 0.8; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; +}; + +datablock ParticleEmitterData( MDebrisSmokeEmitter ) +{ + ejectionPeriodMS = 10; + periodVarianceMS = 1; + + ejectionVelocity = 1.0; // A little oomph at the back end + velocityVariance = 0.2; + + thetaMin = 0.0; + thetaMax = 40.0; + + particles = "MDebrisSmokeParticle"; +}; + + +datablock DebrisData( MissileSplashDebris ) +{ + emitters[0] = MDebrisSmokeEmitter; + + explodeOnMaxBounce = true; + + elasticity = 0.4; + friction = 0.2; + + lifetime = 0.3; + lifetimeVariance = 0.1; + + numBounces = 1; +}; + + +//---------------------------------------------------------------------------- +// Missile smoke spike (for debris) +//---------------------------------------------------------------------------- +datablock ParticleData( MissileSmokeSpike ) +{ + dragCoeffiecient = 1.0; + gravityCoefficient = 0.0; + inheritedVelFactor = 0.2; + + lifetimeMS = 1000; + lifetimeVarianceMS = 100; + + textureName = "particleTest"; + + useInvAlpha = true; + + spinRandomMin = -60.0; + spinRandomMax = 60.0; + + colors[0] = "0.6 0.6 0.6 1.0"; + colors[1] = "0.4 0.4 0.4 0.5"; + colors[2] = "0.4 0.4 0.4 0.0"; + sizes[0] = 0.0; + sizes[1] = 1.0; + sizes[2] = 0.5; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; +}; + +datablock ParticleEmitterData( MissileSmokeSpikeEmitter ) +{ + ejectionPeriodMS = 7; + periodVarianceMS = 1; + + ejectionVelocity = 1.0; // A little oomph at the back end + velocityVariance = 0.2; + + thetaMin = 0.0; + thetaMax = 40.0; + + particles = "MissileSmokeSpike"; +}; + + +//---------------------------------------------------------------------------- +// Explosion smoke particles +//---------------------------------------------------------------------------- + +datablock ParticleData(MissileExplosionSmoke) +{ + dragCoeffiecient = 0.3; + gravityCoefficient = -0.2; + inheritedVelFactor = 0.025; + + lifetimeMS = 1250; + lifetimeVarianceMS = 0; + + textureName = "particleTest"; + + useInvAlpha = true; + spinRandomMin = -100.0; + spinRandomMax = 100.0; + + textureName = "special/Smoke/bigSmoke"; + + colors[0] = "1.0 0.7 0.0 1.0"; + colors[1] = "0.4 0.4 0.4 0.5"; + colors[2] = "0.4 0.4 0.4 0.0"; + sizes[0] = 1.0; + sizes[1] = 3.0; + sizes[2] = 1.0; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; + +}; + +datablock ParticleEmitterData(MissileExplosionSmokeEMitter) +{ + ejectionOffset = 0.0; + ejectionPeriodMS = 5; + periodVarianceMS = 0; + + ejectionVelocity = 3.25; + velocityVariance = 0.25; + + thetaMin = 0.0; + thetaMax = 180.0; + + lifetimeMS = 250; + + particles = "MissileExplosionSmoke"; +}; + + + +datablock DebrisData( MissileSpikeDebris ) +{ + emitters[0] = MissileSmokeSpikeEmitter; + explodeOnMaxBounce = true; + elasticity = 0.4; + friction = 0.2; + lifetime = 0.3; + lifetimeVariance = 0.02; +}; + + +//--------------------------------------------------------------------------- +// Explosions +//--------------------------------------------------------------------------- +datablock ExplosionData(MissileExplosion) +{ + explosionShape = "effect_plasma_explosion.dts"; + playSpeed = 1.5; + soundProfile = MissileExplosionSound; + faceViewer = true; + + sizes[0] = "0.5 0.5 0.5"; + sizes[1] = "0.5 0.5 0.5"; + sizes[2] = "0.5 0.5 0.5"; + + emitter[0] = MissileExplosionSmokeEmitter; + + debris = MissileSpikeDebris; + debrisThetaMin = 10; + debrisThetaMax = 170; + debrisNum = 8; + debrisNumVariance = 6; + debrisVelocity = 15.0; + debrisVelocityVariance = 2.0; + + shakeCamera = true; + camShakeFreq = "6.0 7.0 7.0"; + camShakeAmp = "70.0 70.0 70.0"; + camShakeDuration = 1.0; + camShakeRadius = 7.0; +}; + +datablock ExplosionData(MissileSplashExplosion) +{ + explosionShape = "disc_explosion.dts"; + + faceViewer = true; + explosionScale = "1.0 1.0 1.0"; + + debris = MissileSplashDebris; + debrisThetaMin = 10; + debrisThetaMax = 80; + debrisNum = 10; + debrisVelocity = 10.0; + debrisVelocityVariance = 4.0; + + sizes[0] = "0.35 0.35 0.35"; + sizes[1] = "0.15 0.15 0.15"; + sizes[2] = "0.15 0.15 0.15"; + sizes[3] = "0.15 0.15 0.15"; + + times[0] = 0.0; + times[1] = 0.333; + times[2] = 0.666; + times[3] = 1.0; + +}; + +//-------------------------------------------------------------------------- +// Splash +//-------------------------------------------------------------------------- +datablock ParticleData(MissileMist) +{ + dragCoefficient = 2.0; + gravityCoefficient = -0.05; + inheritedVelFactor = 0.0; + constantAcceleration = 0.0; + lifetimeMS = 400; + lifetimeVarianceMS = 100; + useInvAlpha = false; + spinRandomMin = -90.0; + spinRandomMax = 500.0; + textureName = "particleTest"; + colors[0] = "0.7 0.8 1.0 1.0"; + colors[1] = "0.7 0.8 1.0 0.5"; + colors[2] = "0.7 0.8 1.0 0.0"; + sizes[0] = 0.5; + sizes[1] = 0.5; + sizes[2] = 0.8; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; +}; + +datablock ParticleEmitterData(MissileMistEmitter) +{ + ejectionPeriodMS = 5; + periodVarianceMS = 0; + ejectionVelocity = 6.0; + velocityVariance = 4.0; + ejectionOffset = 0.0; + thetaMin = 85; + thetaMax = 85; + phiReferenceVel = 0; + phiVariance = 360; + overrideAdvances = false; + lifetimeMS = 250; + particles = "MissileMist"; +}; + +datablock ParticleData( MissileSplashParticle ) +{ + dragCoefficient = 1; + gravityCoefficient = 0.2; + inheritedVelFactor = 0.2; + constantAcceleration = -0.0; + lifetimeMS = 600; + lifetimeVarianceMS = 0; + textureName = "special/droplet"; + colors[0] = "0.7 0.8 1.0 1.0"; + colors[1] = "0.7 0.8 1.0 0.5"; + colors[2] = "0.7 0.8 1.0 0.0"; + sizes[0] = 0.5; + sizes[1] = 0.5; + sizes[2] = 0.5; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; +}; + +datablock ParticleEmitterData( MissileSplashEmitter ) +{ + ejectionPeriodMS = 1; + periodVarianceMS = 0; + ejectionVelocity = 6; + velocityVariance = 3.0; + ejectionOffset = 0.0; + thetaMin = 60; + thetaMax = 80; + phiReferenceVel = 0; + phiVariance = 360; + overrideAdvances = false; + orientParticles = true; + lifetimeMS = 100; + particles = "MissileSplashParticle"; +}; + + +datablock SplashData(MissileSplash) +{ + numSegments = 15; + ejectionFreq = 0.0001; + ejectionAngle = 45; + ringLifetime = 0.5; + lifetimeMS = 400; + velocity = 5.0; + startRadius = 0.0; + acceleration = -3.0; + texWrap = 5.0; + + explosion = MissileSplashExplosion; + + texture = "special/water2"; + + emitter[0] = MissileSplashEmitter; + emitter[1] = MissileMistEmitter; + + colors[0] = "0.7 0.8 1.0 0.0"; + colors[1] = "0.7 0.8 1.0 1.0"; + colors[2] = "0.7 0.8 1.0 0.0"; + colors[3] = "0.7 0.8 1.0 0.0"; + times[0] = 0.0; + times[1] = 0.4; + times[2] = 0.8; + times[3] = 1.0; +}; + +//-------------------------------------------------------------------------- +// Particle effects +//-------------------------------------- +datablock ParticleData(MissileSmokeParticle) +{ + dragCoeffiecient = 0.0; + gravityCoefficient = -0.02; + inheritedVelFactor = 0.1; + + lifetimeMS = 1200; + lifetimeVarianceMS = 100; + + textureName = "particleTest"; + + useInvAlpha = true; + spinRandomMin = -90.0; + spinRandomMax = 90.0; + + colors[0] = "1.0 0.75 0.0 0.0"; + colors[1] = "0.5 0.5 0.5 1.0"; + colors[2] = "0.3 0.3 0.3 0.0"; + sizes[0] = 1; + sizes[1] = 2; + sizes[2] = 3; + times[0] = 0.0; + times[1] = 0.1; + times[2] = 1.0; + +}; + +datablock ParticleEmitterData(MissileSmokeEmitter) +{ + ejectionPeriodMS = 10; + periodVarianceMS = 0; + + ejectionVelocity = 1.5; + velocityVariance = 0.3; + + thetaMin = 0.0; + thetaMax = 50.0; + + particles = "MissileSmokeParticle"; +}; + +datablock ParticleData(MissileFireParticle) +{ + dragCoeffiecient = 0.0; + gravityCoefficient = 0.0; + inheritedVelFactor = 1.0; + + lifetimeMS = 300; + lifetimeVarianceMS = 000; + + textureName = "particleTest"; + + spinRandomMin = -135; + spinRandomMax = 135; + + colors[0] = "1.0 0.75 0.2 1.0"; + colors[1] = "1.0 0.5 0.0 1.0"; + colors[2] = "1.0 0.40 0.0 0.0"; + sizes[0] = 0; + sizes[1] = 1; + sizes[2] = 1.5; + times[0] = 0.0; + times[1] = 0.3; + times[2] = 1.0; +}; + +datablock ParticleEmitterData(MissileFireEmitter) +{ + ejectionPeriodMS = 15; + periodVarianceMS = 0; + + ejectionVelocity = 15.0; + velocityVariance = 0.0; + + thetaMin = 0.0; + thetaMax = 0.0; + + particles = "MissileFireParticle"; +}; + +datablock ParticleData(MissilePuffParticle) +{ + dragCoeffiecient = 0.0; + gravityCoefficient = 0.0; + inheritedVelFactor = 0.0; + + lifetimeMS = 500; + lifetimeVarianceMS = 300; + + textureName = "particleTest"; + + spinRandomMin = -135; + spinRandomMax = 135; + + colors[0] = "1.0 1.0 1.0 0.5"; + colors[1] = "0.7 0.7 0.7 0.0"; + sizes[0] = 0.25; + sizes[1] = 1.0; + times[0] = 0.0; + times[1] = 1.0; +}; + +datablock ParticleEmitterData(MissilePuffEmitter) +{ + ejectionPeriodMS = 50; + periodVarianceMS = 3; + + ejectionVelocity = 0.5; + velocityVariance = 0.0; + + thetaMin = 0.0; + thetaMax = 90.0; + + particles = "MissilePuffParticle"; +}; + +datablock ParticleData(MissileLauncherExhaustParticle) +{ + dragCoeffiecient = 0.0; + gravityCoefficient = 0.01; + inheritedVelFactor = 1.0; + + lifetimeMS = 500; + lifetimeVarianceMS = 300; + + textureName = "particleTest"; + + useInvAlpha = true; + spinRandomMin = -135; + spinRandomMax = 135; + + colors[0] = "1.0 1.0 1.0 0.5"; + colors[1] = "0.7 0.7 0.7 0.0"; + sizes[0] = 0.25; + sizes[1] = 1.0; + times[0] = 0.0; + times[1] = 1.0; +}; + +datablock ParticleEmitterData(MissileLauncherExhaustEmitter) +{ + ejectionPeriodMS = 15; + periodVarianceMS = 0; + + ejectionVelocity = 3.0; + velocityVariance = 0.0; + + thetaMin = 0.0; + thetaMax = 20.0; + + particles = "MissileLauncherExhaustParticle"; +}; + +//-------------------------------------------------------------------------- +// Debris +//-------------------------------------- +datablock DebrisData( FlechetteDebris ) +{ + shapeName = "weapon_missile_fleschette.dts"; + + lifetime = 5.0; + + minSpinSpeed = -320.0; + maxSpinSpeed = 320.0; + + elasticity = 0.2; + friction = 0.3; + + numBounces = 3; + + gravModifier = 0.40; + + staticOnMaxBounce = true; +}; + +//-------------------------------------------------------------------------- +// Projectile +//-------------------------------------- +datablock SeekerProjectileData(ShoulderMissile) +{ + casingShapeName = "weapon_missile_casement.dts"; + projectileShapeName = "weapon_missile_projectile.dts"; + hasDamageRadius = true; + indirectDamage = 0.8; + damageRadius = 8.0; + radiusDamageType = $DamageType::Missile; + kickBackStrength = 2000; + + explosion = "MissileExplosion"; + splash = MissileSplash; + velInheritFactor = 1.0; // to compensate for slow starting velocity, this value + // is cranked up to full so the missile doesn't start + // out behind the player when the player is moving + // very quickly - bramage + + baseEmitter = MissileSmokeEmitter; + delayEmitter = MissileFireEmitter; + puffEmitter = MissilePuffEmitter; + bubbleEmitter = GrenadeBubbleEmitter; + bubbleEmitTime = 1.0; + + exhaustEmitter = MissileLauncherExhaustEmitter; + exhaustTimeMs = 300; + exhaustNodeName = "muzzlePoint1"; + + lifetimeMS = 7000; // z0dd - ZOD, 4/14/02. Was 6000 + muzzleVelocity = 10.0; + maxVelocity = 90.0; // z0dd - ZOD, 4/14/02. Was 80.0 + turningSpeed = 110.0; + acceleration = 200.0; + + proximityRadius = 3; + + terrainAvoidanceSpeed = 180; + terrainScanAhead = 25; + terrainHeightFail = 12; + terrainAvoidanceRadius = 100; + + flareDistance = 200; + flareAngle = 30; + + sound = MissileProjectileSound; + + hasLight = true; + lightRadius = 5.0; + lightColor = "0.2 0.05 0"; + + useFlechette = true; + flechetteDelayMs = 550; + casingDeb = FlechetteDebris; + + explodeOnWaterImpact = false; +}; + +datablock LinearProjectileData(Rocket) +{ + projectileShapeName = "weapon_missile_projectile.dts"; + emitterDelay = -1; + baseEmitter = MissileSmokeEmitter; + delayEmitter = MissileFireEmitter; + bubbleEmitter = GrenadeBubbleEmitter; + bubbleEmitTime = 1.0; + directDamage = 0.0; + hasDamageRadius = true; + indirectDamage = 0.5; + damageRadius = 7.5; + radiusDamageType = $DamageType::Missile; + kickBackStrength = 2000; + sound = MissileProjectileSound; + explosion = "MissileExplosion"; + underwaterExplosion = "UnderwaterDiscExplosion"; + splash = MissileSplash; + dryVelocity = 90; + wetVelocity = 50; + velInheritFactor = 0.75; + fizzleTimeMS = 5000; + lifetimeMS = 5000; + explodeOnDeath = true; + reflectOnWaterImpactAngle = 15.0; + explodeOnWaterImpact = false; + deflectionOnWaterImpact = 20.0; + fizzleUnderwaterMS = 5000; +// activateDelayMS = 200; + hasLight = true; + lightRadius = 6.0; + lightColor = "0.175 0.175 0.5"; +}; + +//-------------------------------------------------------------------------- +// Ammo +//-------------------------------------- + +datablock ItemData(MissileLauncherAmmo) +{ + className = Ammo; + catagory = "Ammo"; + shapeFile = "ammo_missile.dts"; + mass = 1; + elasticity = 0.2; + friction = 0.6; + pickupRadius = 2; + pickUpName = "some missiles"; + + computeCRC = true; + +}; + +//-------------------------------------------------------------------------- +// Weapon +//-------------------------------------- +datablock ItemData(MissileLauncher) +{ + className = Weapon; + catagory = "Spawn Items"; + shapeFile = "weapon_missile.dts"; + image = MissileLauncherImage; + mass = 1; + elasticity = 0.2; + friction = 0.6; + pickupRadius = 2; + pickUpName = "a missile launcher"; + + computeCRC = true; + emap = true; +}; + +datablock ShapeBaseImageData(MissileLauncherImage) +{ + className = WeaponImage; + shapeFile = "weapon_missile.dts"; + item = MissileLauncher; + ammo = MissileLauncherAmmo; + offset = "0 0 0"; + armThread = lookms; + emap = true; + + projectile = ShoulderMissile; + projectileType = SeekerProjectile; + + isSeeker = true; + seekRadius = 400; + maxSeekAngle = 8; + seekTime = 0.5; + minSeekHeat = $Host::ClassicLoadMissileChanges ? 1.0 : 0.6; // the heat that must be present on a target to lock it. // z0dd - ZOD, 8/22/02. Was 0.7 + + // only target objects outside this range + minTargetingDistance = 40; + + stateName[0] = "Activate"; + stateTransitionOnTimeout[0] = "ActivateReady"; + stateTimeoutValue[0] = 0.5; + stateSequence[0] = "Activate"; + stateSound[0] = MissileSwitchSound; + + stateName[1] = "ActivateReady"; + stateTransitionOnAmmo[1] = "Ready"; + stateTransitionOnNoAmmo[1] = "FirstLoad"; + + stateName[2] = "Ready"; + stateTransitionOnNoAmmo[2] = "NoAmmo"; + stateTransitionOnTriggerDown[2] = "CheckWet"; + + stateName[3] = "Fire"; + stateTransitionOnTimeout[3] = "Reload"; + stateTimeoutValue[3] = 0.4; + stateFire[3] = true; + stateRecoil[3] = LightRecoil; + stateAllowImageChange[3] = false; + stateSequence[3] = "Fire"; + stateScript[3] = "onFire"; + stateSound[3] = MissileFireSound; + + stateName[4] = "Reload"; + stateTransitionOnNoAmmo[4] = "NoAmmo"; + stateTransitionOnTimeout[4] = "Ready"; + stateTimeoutValue[4] = 2.5; + stateAllowImageChange[4] = false; + stateSequence[4] = "Reload"; + stateSound[4] = MissileReloadSound; + + stateName[5] = "NoAmmo"; + stateTransitionOnAmmo[5] = "Reload"; + stateSequence[5] = "NoAmmo"; + stateTransitionOnTriggerDown[5] = "DryFire"; + + stateName[6] = "DryFire"; + stateSound[6] = MissileDryFireSound; + stateTimeoutValue[6] = 1.0; + stateTransitionOnTimeout[6] = "ActivateReady"; + + stateName[7] = "CheckTarget"; + // z0dd - ZOD, 5/07/04. Shoot one off if gameplay changes are in affect. + //stateTransitionOnNoTarget[7] = "DryFire"; + stateTransitionOnNoTarget[7] = $Host::ClassicLoadMissileChanges ? "DumbFire" : "DryFire"; + stateTransitionOnTarget[7] = "Fire"; + + stateName[8] = "CheckWet"; + stateTransitionOnWet[8] = "WetFire"; + stateTransitionOnNotWet[8] = "CheckTarget"; + + stateName[9] = "WetFire"; + stateTransitionOnNoAmmo[9] = "NoAmmo"; + stateTransitionOnTimeout[9] = "Reload"; + stateSound[9] = MissileFireSound; + stateRecoil[3] = LightRecoil; + stateTimeoutValue[9] = 0.4; + stateSequence[3] = "Fire"; + stateScript[9] = "onWetFire"; + stateAllowImageChange[9] = false; + + stateName[10] = "DumbFire"; + stateTransitionOnTimeout[10] = "Reload"; + stateTimeoutValue[10] = 0.4; + stateFire[10] = true; + stateRecoil[10] = LightRecoil; + stateAllowImageChange[10] = false; + stateSequence[10] = "Fire"; + stateScript[10] = "onDumbFire"; + stateSound[10] = MissileFireSound; + + stateName[11] = "FirstLoad"; + stateTransitionOnAmmo[11] = "Ready"; +}; + +function MissileLauncherImage::onDumbFire(%data,%obj,%slot) +{ + %data.lightStart = getSimTime(); + %p = new (LinearProjectile)() { + dataBlock = Rocket; + initialDirection = MatrixMulVector("0 0 0 0 0 1 0", %obj.getMuzzleVector(%slot)); + initialPosition = %obj.getMuzzlePoint(%slot); + sourceObject = %obj; + sourceSlot = %slot; + }; + %obj.lastProjectile = %p; + MissionCleanup.add(%p); + if(%obj.client) + %obj.client.projectile = %p; + + %obj.decInventory(%data.ammo, 1); + return %p; +} +function MissileLauncherImage::onUnmount(%this,%obj,%slot){ + parent::onUnmount(%this,%obj,%slot); + if(isEventPending(%obj.reloadDelaySch)) + cancel(%obj.reloadDelaySch); +} +function MissileLauncherImage::onMount(%this,%obj,%slot){ + + if(%obj.getClassName() !$= "Player") + return; + + if (%this.armthread $= "") + %obj.setArmThread(look); + else + %obj.setArmThread(%this.armThread); + + if(%obj.getMountedImage($WeaponSlot).ammo !$= ""){ + if (%obj.getInventory(%this.ammo)){ + + %fireAndReloadTime = mFloor((%this.stateTimeoutValue[4] + %this.stateTimeoutValue[3]) * 1000); + + if(%obj.lfireTime[%this.getName()] && (getSimTime() - %obj.lfireTime[%this.getName()]) < %fireAndReloadTime){ + if(isEventPending(%obj.reloadDelaySch)){ + cancel(%obj.reloadDelaySch); + } + %time = mFloor(%fireAndReloadTime - (getSimTime() - %obj.lfireTime[%this.getName()])); + %obj.reloadDelaySch = schedule(%time, 0, "ammoStateDelay", %obj, %slot, true); + } + else{ + %obj.setImageAmmo(%slot,true); + } + } + } + + %obj.client.setWeaponsHudActive(%this.item); + if(%obj.getMountedImage($WeaponSlot).ammo !$= "") + %obj.client.setAmmoHudCount(%obj.getInventory(%this.ammo)); + else + %obj.client.setAmmoHudCount(-1); +} \ No newline at end of file diff --git a/Classic/scripts/weapons/mortar.cs b/Classic/scripts/weapons/mortar.cs new file mode 100644 index 0000000..876ee09 --- /dev/null +++ b/Classic/scripts/weapons/mortar.cs @@ -0,0 +1,824 @@ +//-------------------------------------- +// Mortar +//-------------------------------------- + +//-------------------------------------------------------------------------- +// Sounds +//-------------------------------------- +datablock AudioProfile(MortarSwitchSound) +{ + filename = "fx/weapons/mortar_activate.wav"; + description = AudioClosest3d; + preload = true; +}; + +datablock AudioProfile(MortarReloadSound) +{ + filename = "fx/weapons/mortar_reload.wav"; + description = AudioClosest3d; + preload = true; +}; + +datablock AudioProfile(MortarIdleSound) +{ + //filename = "fx/weapons/weapon.mortarIdle.wav"; + filename = "fx/weapons/plasma_rifle_idle.wav"; + description = ClosestLooping3d; + preload = true; +}; + +datablock AudioProfile(MortarFireSound) +{ + filename = "fx/weapons/mortar_fire.wav"; + description = AudioDefault3d; + preload = true; +}; + +datablock AudioProfile(MortarProjectileSound) +{ + filename = "fx/weapons/mortar_projectile.wav"; + description = ProjectileLooping3d; + preload = true; +}; + +datablock AudioProfile(MortarExplosionSound) +{ + filename = "fx/weapons/mortar_explode.wav"; + description = AudioBIGExplosion3d; + preload = true; +}; + +datablock AudioProfile(UnderwaterMortarExplosionSound) +{ + filename = "fx/weapons/mortar_explode_UW.wav"; + description = AudioBIGExplosion3d; + preload = true; +}; + +datablock AudioProfile(MortarDryFireSound) +{ + filename = "fx/weapons/mortar_dryfire.wav"; + description = AudioClose3d; + preload = true; +}; + +//---------------------------------------------------------------------------- +// Bubbles +//---------------------------------------------------------------------------- +datablock ParticleData(MortarBubbleParticle) +{ + dragCoefficient = 0.0; + gravityCoefficient = -0.25; + inheritedVelFactor = 0.0; + constantAcceleration = 0.0; + lifetimeMS = 1500; + lifetimeVarianceMS = 600; + useInvAlpha = false; + textureName = "special/bubbles"; + + spinRandomMin = -100.0; + spinRandomMax = 100.0; + + colors[0] = "0.7 0.8 1.0 0.4"; + colors[1] = "0.7 0.8 1.0 0.4"; + colors[2] = "0.7 0.8 1.0 0.0"; + sizes[0] = 0.8; + sizes[1] = 0.8; + sizes[2] = 0.8; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; +}; + +datablock ParticleEmitterData(MortarBubbleEmitter) +{ + ejectionPeriodMS = 9; + periodVarianceMS = 0; + ejectionVelocity = 1.0; + ejectionOffset = 0.1; + velocityVariance = 0.5; + thetaMin = 0; + thetaMax = 80; + phiReferenceVel = 0; + phiVariance = 360; + overrideAdvances = false; + particles = "MortarBubbleParticle"; +}; + +//-------------------------------------------------------------------------- +// Splash +//-------------------------------------------------------------------------- +datablock ParticleData( MortarSplashParticle ) +{ + dragCoefficient = 1; + gravityCoefficient = 0.0; + inheritedVelFactor = 0.2; + constantAcceleration = -1.4; + lifetimeMS = 300; + lifetimeVarianceMS = 0; + textureName = "special/droplet"; + colors[0] = "0.7 0.8 1.0 1.0"; + colors[1] = "0.7 0.8 1.0 0.5"; + colors[2] = "0.7 0.8 1.0 0.0"; + sizes[0] = 0.05; + sizes[1] = 0.2; + sizes[2] = 0.2; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; +}; + +datablock ParticleEmitterData( MortarSplashEmitter ) +{ + ejectionPeriodMS = 4; + periodVarianceMS = 0; + ejectionVelocity = 3; + velocityVariance = 1.0; + ejectionOffset = 0.0; + thetaMin = 0; + thetaMax = 50; + phiReferenceVel = 0; + phiVariance = 360; + overrideAdvances = false; + orientParticles = true; + lifetimeMS = 100; + particles = "MortarSplashParticle"; +}; + + +datablock SplashData(MortarSplash) +{ + numSegments = 10; + ejectionFreq = 10; + ejectionAngle = 20; + ringLifetime = 0.4; + lifetimeMS = 400; + velocity = 3.0; + startRadius = 0.0; + acceleration = -3.0; + texWrap = 5.0; + + texture = "special/water2"; + + emitter[0] = MortarSplashEmitter; + + colors[0] = "0.7 0.8 1.0 0.0"; + colors[1] = "0.7 0.8 1.0 1.0"; + colors[2] = "0.7 0.8 1.0 0.0"; + colors[3] = "0.7 0.8 1.0 0.0"; + times[0] = 0.0; + times[1] = 0.4; + times[2] = 0.8; + times[3] = 1.0; +}; + +//--------------------------------------------------------------------------- +// Mortar Shockwaves +//--------------------------------------------------------------------------- +datablock ShockwaveData(UnderwaterMortarShockwave) +{ + width = 6.0; + numSegments = 32; + numVertSegments = 6; + velocity = 10; + acceleration = 20.0; + lifetimeMS = 900; + height = 1.0; + verticalCurve = 0.5; + is2D = false; + + texture[0] = "special/shockwave4"; + texture[1] = "special/gradient"; + texWrap = 6.0; + + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; + + colors[0] = "0.4 0.4 1.0 0.50"; + colors[1] = "0.4 0.4 1.0 0.25"; + colors[2] = "0.4 0.4 1.0 0.0"; + + mapToTerrain = true; + orientToNormal = false; + renderBottom = false; +}; + +datablock ShockwaveData(MortarShockwave) +{ + width = 6.0; + numSegments = 32; + numVertSegments = 6; + velocity = 15; + acceleration = 20.0; + lifetimeMS = 500; + height = 1.0; + verticalCurve = 0.5; + is2D = false; + + texture[0] = "special/shockwave4"; + texture[1] = "special/gradient"; + texWrap = 6.0; + + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; + + colors[0] = "0.4 1.0 0.4 0.50"; + colors[1] = "0.4 1.0 0.4 0.25"; + colors[2] = "0.4 1.0 0.4 0.0"; + + mapToTerrain = true; + orientToNormal = false; + renderBottom = false; +}; + + +//-------------------------------------------------------------------------- +// Mortar Explosion Particle effects +//-------------------------------------- +datablock ParticleData( MortarCrescentParticle ) +{ + dragCoefficient = 2; + gravityCoefficient = 0.0; + inheritedVelFactor = 0.2; + constantAcceleration = -0.0; + lifetimeMS = 600; + lifetimeVarianceMS = 000; + textureName = "special/crescent3"; + colors[0] = "0.7 1.0 0.7 1.0"; + colors[1] = "0.7 1.0 0.7 0.5"; + colors[2] = "0.7 1.0 0.7 0.0"; + sizes[0] = 4.0; + sizes[1] = 8.0; + sizes[2] = 9.0; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; +}; + +datablock ParticleEmitterData( MortarCrescentEmitter ) +{ + ejectionPeriodMS = 25; + periodVarianceMS = 0; + ejectionVelocity = 40; + velocityVariance = 5.0; + ejectionOffset = 0.0; + thetaMin = 0; + thetaMax = 80; + phiReferenceVel = 0; + phiVariance = 360; + overrideAdvances = false; + orientParticles = true; + lifetimeMS = 200; + particles = "MortarCrescentParticle"; +}; + + +datablock ParticleData(MortarExplosionSmoke) +{ + dragCoeffiecient = 0.4; + gravityCoefficient = -0.30; // rises slowly + inheritedVelFactor = 0.025; + + lifetimeMS = 1250; + lifetimeVarianceMS = 500; + + textureName = "particleTest"; + + useInvAlpha = true; + spinRandomMin = -100.0; + spinRandomMax = 100.0; + + textureName = "special/Smoke/bigSmoke"; + + colors[0] = "0.7 0.7 0.7 0.0"; + colors[1] = "0.4 0.4 0.4 0.5"; + colors[2] = "0.4 0.4 0.4 0.5"; + colors[3] = "0.4 0.4 0.4 0.0"; + sizes[0] = 5.0; + sizes[1] = 6.0; + sizes[2] = 10.0; + sizes[3] = 12.0; + times[0] = 0.0; + times[1] = 0.333; + times[2] = 0.666; + times[3] = 1.0; + + + +}; + +datablock ParticleEmitterData(MortarExplosionSmokeEmitter) +{ + ejectionPeriodMS = 10; + periodVarianceMS = 0; + + ejectionOffset = 8.0; + + + ejectionVelocity = 1.25; + velocityVariance = 1.2; + + thetaMin = 0.0; + thetaMax = 90.0; + + lifetimeMS = 500; + + particles = "MortarExplosionSmoke"; + +}; + +//--------------------------------------------------------------------------- +// Underwater Explosion +//--------------------------------------------------------------------------- +datablock ParticleData(UnderwaterExplosionSparks) +{ + dragCoefficient = 0; + gravityCoefficient = 0.0; + inheritedVelFactor = 0.2; + constantAcceleration = 0.0; + lifetimeMS = 500; + lifetimeVarianceMS = 350; + textureName = "special/crescent3"; + colors[0] = "0.4 0.4 1.0 1.0"; + colors[1] = "0.4 0.4 1.0 1.0"; + colors[2] = "0.4 0.4 1.0 0.0"; + sizes[0] = 3.5; + sizes[1] = 3.5; + sizes[2] = 3.5; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; + +}; + +datablock ParticleEmitterData(UnderwaterExplosionSparksEmitter) +{ + ejectionPeriodMS = 2; + periodVarianceMS = 0; + ejectionVelocity = 17; + velocityVariance = 4; + ejectionOffset = 0.0; + thetaMin = 0; + thetaMax = 60; + phiReferenceVel = 0; + phiVariance = 360; + overrideAdvances = false; + orientParticles = true; + lifetimeMS = 100; + particles = "UnderwaterExplosionSparks"; +}; + +datablock ParticleData(MortarExplosionBubbleParticle) +{ + dragCoefficient = 0.0; + gravityCoefficient = -0.25; + inheritedVelFactor = 0.0; + constantAcceleration = 0.0; + lifetimeMS = 1500; + lifetimeVarianceMS = 600; + useInvAlpha = false; + textureName = "special/bubbles"; + + spinRandomMin = -100.0; + spinRandomMax = 100.0; + + colors[0] = "0.7 0.8 1.0 0.0"; + colors[1] = "0.7 0.8 1.0 0.4"; + colors[2] = "0.7 0.8 1.0 0.0"; + sizes[0] = 2.0; + sizes[1] = 2.0; + sizes[2] = 2.0; + times[0] = 0.0; + times[1] = 0.8; + times[2] = 1.0; +}; +datablock ParticleEmitterData(MortarExplosionBubbleEmitter) +{ + ejectionPeriodMS = 5; + periodVarianceMS = 0; + ejectionVelocity = 1.0; + ejectionOffset = 7.0; + velocityVariance = 0.5; + thetaMin = 0; + thetaMax = 80; + phiReferenceVel = 0; + phiVariance = 360; + overrideAdvances = false; + particles = "MortarExplosionBubbleParticle"; +}; + +datablock DebrisData( UnderwaterMortarDebris ) +{ + emitters[0] = MortarExplosionBubbleEmitter; + + explodeOnMaxBounce = true; + + elasticity = 0.4; + friction = 0.2; + + lifetime = 1.5; + lifetimeVariance = 0.2; + + numBounces = 1; +}; + +datablock ExplosionData(UnderwaterMortarSubExplosion1) +{ + explosionShape = "disc_explosion.dts"; + faceViewer = true; + delayMS = 100; + offset = 3.0; + playSpeed = 1.5; + + sizes[0] = "0.75 0.75 0.75"; + sizes[1] = "1.0 1.0 1.0"; + sizes[2] = "0.5 0.5 0.5"; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; + +}; + +datablock ExplosionData(UnderwaterMortarSubExplosion2) +{ + explosionShape = "disc_explosion.dts"; + faceViewer = true; + delayMS = 50; + offset = 3.0; + playSpeed = 0.75; + + sizes[0] = "1.5 1.5 1.5"; + sizes[1] = "1.5 1.5 1.5"; + sizes[2] = "1.0 1.0 1.0"; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; +}; + +datablock ExplosionData(UnderwaterMortarSubExplosion3) +{ + explosionShape = "disc_explosion.dts"; + faceViewer = true; + delayMS = 0; + offset = 0.0; + playSpeed = 0.5; + + sizes[0] = "1.0 1.0 1.0"; + sizes[1] = "2.0 2.0 2.0"; + sizes[2] = "1.5 1.5 1.5"; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; + +}; + +datablock ExplosionData(UnderwaterMortarExplosion) +{ + soundProfile = UnderwaterMortarExplosionSound; + + shockwave = UnderwaterMortarShockwave; + shockwaveOnTerrain = true; + + subExplosion[0] = UnderwaterMortarSubExplosion1; + subExplosion[1] = UnderwaterMortarSubExplosion2; + subExplosion[2] = UnderwaterMortarSubExplosion3; + + emitter[0] = MortarExplosionBubbleEmitter; + emitter[1] = UnderwaterExplosionSparksEmitter; + + shakeCamera = true; + camShakeFreq = "8.0 9.0 7.0"; + camShakeAmp = "100.0 100.0 100.0"; + camShakeDuration = 1.3; + camShakeRadius = 25.0; +}; + + +//--------------------------------------------------------------------------- +// Explosion +//--------------------------------------------------------------------------- + +datablock ExplosionData(MortarSubExplosion1) +{ + explosionShape = "mortar_explosion.dts"; + faceViewer = true; + + delayMS = 100; + + offset = 5.0; + + playSpeed = 1.5; + + sizes[0] = "0.5 0.5 0.5"; + sizes[1] = "0.5 0.5 0.5"; + times[0] = 0.0; + times[1] = 1.0; + +}; + +datablock ExplosionData(MortarSubExplosion2) +{ + explosionShape = "mortar_explosion.dts"; + faceViewer = true; + + delayMS = 50; + + offset = 5.0; + + playSpeed = 1.0; + + sizes[0] = "1.0 1.0 1.0"; + sizes[1] = "1.0 1.0 1.0"; + times[0] = 0.0; + times[1] = 1.0; +}; + +datablock ExplosionData(MortarSubExplosion3) +{ + explosionShape = "mortar_explosion.dts"; + faceViewer = true; + delayMS = 0; + offset = 0.0; + playSpeed = 0.7; + + sizes[0] = "1.0 1.0 1.0"; + sizes[1] = "2.0 2.0 2.0"; + times[0] = 0.0; + times[1] = 1.0; + +}; + +datablock ExplosionData(MortarExplosion) +{ + soundProfile = MortarExplosionSound; + + shockwave = MortarShockwave; + shockwaveOnTerrain = true; + + subExplosion[0] = MortarSubExplosion1; + subExplosion[1] = MortarSubExplosion2; + subExplosion[2] = MortarSubExplosion3; + + emitter[0] = MortarExplosionSmokeEmitter; + emitter[1] = MortarCrescentEmitter; + + shakeCamera = true; + camShakeFreq = "8.0 9.0 7.0"; + camShakeAmp = "100.0 100.0 100.0"; + camShakeDuration = 1.3; + camShakeRadius = 25.0; +}; + +//--------------------------------------------------------------------------- +// Smoke particles +//--------------------------------------------------------------------------- +datablock ParticleData(MortarSmokeParticle) +{ + dragCoeffiecient = 0.4; + gravityCoefficient = -0.3; // rises slowly + inheritedVelFactor = 0.125; + + lifetimeMS = 1200; + lifetimeVarianceMS = 200; + useInvAlpha = true; + spinRandomMin = -100.0; + spinRandomMax = 100.0; + + animateTexture = false; + + textureName = "special/Smoke/bigSmoke"; + + colors[0] = "0.7 1.0 0.7 0.5"; + colors[1] = "0.3 0.7 0.3 0.8"; + colors[2] = "0.0 0.0 0.0 0.0"; + sizes[0] = 1.0; + sizes[1] = 2.0; + sizes[2] = 4.5; + times[0] = 0.0; + times[1] = 0.5; + times[2] = 1.0; + +}; + + +datablock ParticleEmitterData(MortarSmokeEmitter) +{ + ejectionPeriodMS = 10; + periodVarianceMS = 3; + + ejectionVelocity = 2.25; + velocityVariance = 0.55; + + thetaMin = 0.0; + thetaMax = 40.0; + + particles = "MortarSmokeParticle"; +}; + + +//-------------------------------------------------------------------------- +// Projectile +//-------------------------------------- +datablock GrenadeProjectileData(MortarShot) +{ + projectileShapeName = "mortar_projectile.dts"; + emitterDelay = -1; + directDamage = 0.0; + hasDamageRadius = true; + indirectDamage = 1.0; + damageRadius = 19.0; // z0dd - ZOD, 8/13/02. Was 20.0 + radiusDamageType = $DamageType::Mortar; + kickBackStrength = 2500; + + explosion = "MortarExplosion"; + underwaterExplosion = "UnderwaterMortarExplosion"; + velInheritFactor = 0.5; + splash = MortarSplash; + depthTolerance = 10.0; // depth at which it uses underwater explosion + + baseEmitter = MortarSmokeEmitter; + bubbleEmitter = MortarBubbleEmitter; + + grenadeElasticity = 0.15; + grenadeFriction = 0.4; + armingDelayMS = 1500; // z0dd - ZOD, 4/14/02. Was 2000 + + gravityMod = 1.1; // z0dd - ZOD, 5/18/02. Make mortar projectile heavier, less floaty + muzzleVelocity = 75.95; // z0dd - ZOD, 8/13/02. More velocity to compensate for higher gravity. Was 63.7 + drag = 0.1; + sound = MortarProjectileSound; + + hasLight = true; + lightRadius = 4; + lightColor = "0.05 0.2 0.05"; + + hasLightUnderwaterColor = true; + underWaterLightColor = "0.05 0.075 0.2"; + + // z0dd - ZOD, 5/22/03. Limit the mortars effective range to around 450 meters. + // Addresses long range mortar spam exploit. + explodeOnDeath = $Host::ClassicLoadMortarChanges ? true : false; + fizzleTimeMS = $Host::ClassicLoadMortarChanges ? 8000 : -1; + lifetimeMS = $Host::ClassicLoadMortarChanges ? 10000 : -1; + fizzleUnderwaterMS = $Host::ClassicLoadMortarChanges ? 8000 : -1; + reflectOnWaterImpactAngle = 0.0; + explodeOnWaterImpact = false; + deflectionOnWaterImpact = 0.0; +}; + +// z0dd - ZOD, 5/20/03. New block, spawn this at end of MortarShots lifetime. +datablock ItemData(MortarGrenadeThrown) +{ + className = Weapon; + shapeFile = "mortar_projectile.dts"; + mass = 0.7; + elasticity = 0.15; + friction = 1; + pickupRadius = 2; + maxDamage = 0.5; + explosion = "mortarExplosion"; + underwaterExplosion = UnderwaterMortarExplosion; + indirectDamage = 1.0; + damageRadius = 19.0; + radiusDamageType = $DamageType::Mortar; + kickBackStrength = 2500; +}; + +//-------------------------------------------------------------------------- +// Ammo +//-------------------------------------- + +datablock ItemData(MortarAmmo) +{ + className = Ammo; + catagory = "Ammo"; + shapeFile = "ammo_mortar.dts"; + mass = 1; + elasticity = 0.2; + friction = 0.6; + pickupRadius = 2; + pickUpName = "some mortar ammo"; + computeCRC = true; +}; + +//-------------------------------------------------------------------------- +// Weapon +//-------------------------------------- +datablock ItemData(Mortar) +{ + className = Weapon; + catagory = "Spawn Items"; + shapeFile = "weapon_mortar.dts"; + image = MortarImage; + mass = 1; + elasticity = 0.2; + friction = 0.6; + pickupRadius = 2; + pickUpName = "a mortar gun"; + computeCRC = true; + emap = true; +}; + +datablock ShapeBaseImageData(MortarImage) +{ + className = WeaponImage; + shapeFile = "weapon_mortar.dts"; + item = Mortar; + ammo = MortarAmmo; + offset = "0 0 0"; + emap = true; + + projectile = MortarShot; + projectileType = GrenadeProjectile; + + stateName[0] = "Activate"; + stateTransitionOnTimeout[0] = "ActivateReady"; + stateTimeoutValue[0] = 0.5; + stateSequence[0] = "Activate"; + stateSound[0] = MortarSwitchSound; + + stateName[1] = "ActivateReady"; + stateTransitionOnAmmo[1] = "Ready"; + stateTransitionOnNoAmmo[1] = "FirstLoad"; + + stateName[2] = "Ready"; + stateTransitionOnNoAmmo[2] = "NoAmmo"; + stateTransitionOnTriggerDown[2] = "Fire"; + stateSound[2] = MortarIdleSound; + + stateName[3] = "Fire"; + stateSequence[3] = "Recoil"; + stateTransitionOnTimeout[3] = "Reload"; + stateTimeoutValue[3] = 0.8; + stateFire[3] = true; + stateRecoil[3] = LightRecoil; + stateAllowImageChange[3] = false; + stateScript[3] = "onFire"; + stateSound[3] = MortarFireSound; + + stateName[4] = "Reload"; + stateTransitionOnNoAmmo[4] = "NoAmmo"; + stateTransitionOnTimeout[4] = "Ready"; + stateTimeoutValue[4] = 2.0; + stateAllowImageChange[4] = false; + stateSequence[4] = "Reload"; + stateSound[4] = MortarReloadSound; + + stateName[5] = "NoAmmo"; + stateTransitionOnAmmo[5] = "Reload"; + stateSequence[5] = "NoAmmo"; + stateTransitionOnTriggerDown[5] = "DryFire"; + + stateName[6] = "DryFire"; + stateSound[6] = MortarDryFireSound; + stateTimeoutValue[6] = 1.5; + stateTransitionOnTimeout[6] = "NoAmmo"; + + stateName[7] = "FirstLoad"; + stateTransitionOnAmmo[7] = "Ready"; +}; + +function MortarImage::onUnmount(%this,%obj,%slot){ + parent::onUnmount(%this,%obj,%slot); + if(isEventPending(%obj.reloadDelaySch)) + cancel(%obj.reloadDelaySch); +} +function MortarImage::onMount(%this,%obj,%slot){ + + if(%obj.getClassName() !$= "Player") + return; + + if (%this.armthread $= "") + %obj.setArmThread(look); + else + %obj.setArmThread(%this.armThread); + + if(%obj.getMountedImage($WeaponSlot).ammo !$= ""){ + if (%obj.getInventory(%this.ammo)){ + %fireAndReloadTime = mFloor((%this.stateTimeoutValue[4] + %this.stateTimeoutValue[3]) * 1000); + if(%obj.lfireTime[%this.getName()] && (getSimTime() - %obj.lfireTime[%this.getName()]) < %fireAndReloadTime){ + if(isEventPending(%obj.reloadDelaySch)){ + cancel(%obj.reloadDelaySch); + } + %time = mFloor(%fireAndReloadTime - (getSimTime() - %obj.lfireTime[%this.getName()])); + %obj.reloadDelaySch = schedule(%time, 0, "ammoStateDelay", %obj, %slot, true); + } + else{ + %obj.setImageAmmo(%slot,true); + } + } + } + + %obj.client.setWeaponsHudActive(%this.item); + if(%obj.getMountedImage($WeaponSlot).ammo !$= "") + %obj.client.setAmmoHudCount(%obj.getInventory(%this.ammo)); + else + %obj.client.setAmmoHudCount(-1); +} + +function ammoStateDelay(%obj, %slot, %state){ + if(isObject(%obj) && %obj.getState() !$= "Dead") + %obj.setImageAmmo(%slot, %state); +} \ No newline at end of file