-------------------------------------------------------------------------------- Nuke Launcher weapon By |))efender ***Update*** Feb-15-2003 - Step #4 Had small syntax error. Should now be correct. This tutorial will go through the complete process of adding an ammunition based weapon. The weapon will be a Nuke Launcher. Step #1 Copy plasma.cs in your scripts/weapons directory. Rename it NukeLauncher. Open it up, Replace all the code with the Nuke Launcher code in section #2 Section #2 //-------------------------------------------------------------------------- // Nuke Launcher //-------------------------------------- datablock AudioProfile(BigEasyFireSound) { filename = "fx/weapons/mortar_fire.wav"; description = AudioDefault3d; preload = true; effect = BigEasyFireEffect; }; datablock AudioProfile(BigEasyProjectileSound) { filename = "fx/weapons/mortar_projectile.wav"; description = ProjectileLooping3d; preload = true; }; datablock AudioProfile(BigEasyExplosionSound) { filename = "fx/explosions/vehicle_explosion.wav"; description = AudioBIGExplosion3d; preload = true; effect = BigEasyExplosionEffect; }; datablock AudioProfile(UnderwaterBigEasyExplosionSound) { filename = "fx/weapons/mortar_explode_UW.wav"; description = AudioBIGExplosion3d; preload = true; effect = BigEasyExplosionEffect; }; //-------------------------------------------------------------------------- // BigEasy ExplosionSmoke //---------------------------------------------------------------------- datablock ParticleData(EasyExplosionSmoke) { dragCoeffiecient = 0.4; gravityCoefficient = 0; inheritedVelFactor = 0; lifetimeMS = 12000; lifetimeVarianceMS = 12000; textureName = "particleTest"; useInvAlpha = true; spinRandomMin = -100.0; spinRandomMax = 100.0; textureName = "special/Smoke/bigSmoke"; colors[0] = "0.3 0.3 0.3 0.0"; colors[1] = "0.3 0.3 0.3 1.0"; colors[2] = "0.0 0.0 0.0 0.0"; sizes[0] = 5.0; sizes[1] = 12.0; sizes[2] = 15.0; sizes[3] = 19.0; times[0] = 0.0; times[1] = 0.333; times[2] = 0.666; times[3] = 1.0; }; datablock ParticleEmitterData(EasyExplosionSmokeEmitter) { ejectionPeriodMS = 0.1; periodVarianceMS = 3; ejectionOffset = 8.0; ejectionVelocity = 3.0; velocityVariance = 1.5; thetaMin = 0.0; thetaMax = 359.0; lifetimeMS = 1000; particles = "EasyExplosionSmoke"; }; datablock ParticleData( BigEasyCrescentParticle ) { dragCoefficient = 2; gravityCoefficient = 0.0; inheritedVelFactor = 0.2; constantAcceleration = -0.0; lifetimeMS = 800; lifetimeVarianceMS = 100; textureName = "special/crescent3"; colors[0] = "0.9 0.8 0.0 1.00"; colors[1] = "0.9 0.5 0.0 0.20"; colors[2] = "0.9 0.4 0.0 0.0"; sizes[0] = 2.0; sizes[1] = 4.0; sizes[2] = 5.0; times[0] = 0.0; times[1] = 0.5; times[2] = 1.0; }; datablock ParticleEmitterData( BigEasyCrescentEmitter ) { ejectionPeriodMS = 15; periodVarianceMS = 0; ejectionVelocity = 20; velocityVariance = 10.0; ejectionOffset = 0.0; thetaMin = 0; thetaMax = 80; phiReferenceVel = 0; phiVariance = 360; overrideAdvances = false; orientParticles = true; lifetimeMS = 200; particles = "BigEasyCrescentParticle"; }; //-------------------------------------------------------------------------- // Nuke GROUND FX : Shockwave //-------------------------------------------------------------------------- datablock ShockwaveData(NukeBigEasyShockwave) { width = 100.0; numSegments = 60; numVertSegments = 6; velocity = 45; acceleration = 100.0; lifetimeMS = 12000; 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] = "1.0 0.8 0.2 1.0"; colors[1] = "1.0 0.4 0.2 1.0"; colors[2] = "1.0 0.0 0.0 0.0"; mapToTerrain = false; orientToNormal = false; renderBottom = true; }; //-------------------------------------------------------------------------- // GROUND FX : Shockwave //-------------------------------------------------------------------------- datablock ShockwaveData(BigEasyShockwave) { width = 100.0; //WAS 50.0; numSegments = 60; numVertSegments = 2; velocity = 5; acceleration = 10.0; lifetimeMS = 4000; height = 2.0; is2D = true; 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.6 0.6 1.0 1.0"; colors[1] = "0.6 0.3 1.0 0.5"; colors[2] = "0.0 0.0 1.0 0.0"; }; //--------------------------------------------------------------------------- // Smoke trailing particles //--------------------------------------------------------------------------- datablock ParticleData(BigEasySmokeParticle) { dragCoeffiecient = 0.4; gravityCoefficient = -0.5; // rises slowly inheritedVelFactor = 0.125; lifetimeMS = 800; lifetimeVarianceMS = 200; useInvAlpha = true; spinRandomMin = -100.0; spinRandomMax = 100.0; animateTexture = false; textureName = "special/Smoke/bigSmoke"; colors[0] = "1.0 0.8 0.0 1.0"; colors[1] = "1.0 0.7 0.0 0.8"; colors[2] = "1.0 0.6 0.0 0.5"; sizes[0] = 0.5; sizes[1] = 1.0; sizes[2] = 2.5; times[0] = 0.0; times[1] = 0.5; times[2] = 1.0; }; datablock ParticleEmitterData(BigEasySmokeEmitter) { ejectionPeriodMS = 10; periodVarianceMS = 3; ejectionVelocity = 4.25; velocityVariance = 0.75; thetaMin = 0.0; thetaMax = 40.0; particles = "BigEasySmokeParticle"; }; //-------------------------------------------------------------- // Nuke DEBRIS FIRE PARTICLES //-------------------------------------------------------------- datablock ParticleData(NukeDebrisFireParticle) { dragCoeffiecient = 0.0; gravityCoefficient = -0.2; inheritedVelFactor = 0.0; lifetimeMS = 1350; lifetimeVarianceMS = 0; textureName = "particleTest"; useInvAlpha = false; spinRandomMin = -160.0; spinRandomMax = 160.0; animateTexture = true; framesPerSec = 15; animTexName[0] = "special/Explosion/exp_0016"; animTexName[1] = "special/Explosion/exp_0018"; animTexName[2] = "special/Explosion/exp_0020"; animTexName[3] = "special/Explosion/exp_0022"; animTexName[4] = "special/Explosion/exp_0024"; animTexName[5] = "special/Explosion/exp_0026"; animTexName[6] = "special/Explosion/exp_0028"; animTexName[7] = "special/Explosion/exp_0030"; animTexName[8] = "special/Explosion/exp_0032"; colors[0] = "1.0 0.7 0.5 1.0"; colors[1] = "1.0 0.5 0.2 1.0"; colors[2] = "1.0 0.25 0.1 0.0"; sizes[0] = 0.5; sizes[1] = 2.0; sizes[2] = 1.0; times[0] = 0.0; times[1] = 0.2; times[2] = 1.0; }; datablock ParticleEmitterData(NukeDebrisFireEmitter) { ejectionPeriodMS = 20; periodVarianceMS = 1; ejectionVelocity = 0.25; velocityVariance = 0.0; thetaMin = 0.0; thetaMax = 30.0; particles = "NukeDebrisFireParticle"; }; //-------------------------------------------------------------- // Nuke BOMB EXPLOSION //-------------------------------------------------------------- datablock ExplosionData(NukeVehicleBombExplosion) { explosionShape = "effect_plasma_explosion.dts"; playSpeed = 0.5; soundProfile = BigEasyExplosionSound; faceViewer = true; sizes[0] = "12 12 12"; sizes[1] = "24 24 24"; times[0] = 0.0; times[1] = 1.0; emitter[0] = VehicleLGESmokeEMitter; emitter[1] = NukeDebrisFireEmitter; shockwave = NukeBigEasyShockwave; debris = VehicleFireballDebris; debrisThetaMin = 10; debrisThetaMax = 80; debrisNum = 12; debrisNumVariance = 6; debrisVelocity = 20.0; debrisVelocityVariance = 5.0; subExplosion = VLSpikeExplosion; shakeCamera = true; camShakeFreq = "4.0 5.0 4.5"; camShakeAmp = "65.0 65.0 65.0"; //was 150 camShakeDuration = 1.0; camShakeRadius = 1000.0; //was 50.0 }; //-------------------------------------------------------------------------- // Nuke : Explosion //-------------------------------------------------------------------------- datablock ExplosionData(BigEasyExplosion) { soundProfile = BigEasyExplosionSound; shockwave = BigEasyShockwave; emitter[0] = NukeDebrisFireEmitter; emitter[1] = EasyExplosionSmokeEmitter; shakeCamera = true; camShakeFreq = "4.0 5.0 4.5"; camShakeAmp = "25.0 25.0 25.0"; //was 150 camShakeDuration = 2.0; camShakeRadius = 300.0; //was 50.0 }; //-------------------------------------------------------------------------- // Projectile //-------------------------------------- datablock GrenadeProjectileData(BigEasyShot) { projectileShapeName = "mortar_projectile.dts"; emitterDelay = -1; directDamage = 0.0; hasDamageRadius = true; indirectDamage = 4.0; damageRadius = 150.0; radiusDamageType = $DamageType::Nuke; kickBackStrength = 35000; scale = "4.0 4.0 4.0"; explosion = "BigEasyExplosion"; underwaterExplosion = "UnderwaterMortarExplosion"; splash = MortarSplash; velInheritFactor = 0.5; depthTolerance = 15.0; baseEmitter = BigEasySmokeEmitter; bubbleEmitter = BigEasyBubbleEmitter; grenadeElasticity = 0.15; grenadeFriction = 0.4; armingDelayMS = 3500; muzzleVelocity = 43.7; drag = 0.1; sound = MortarProjectileSound; hasLight = true; expProj = "NukeBomb"; mortarCount = 1; lightRadius = 4; lightColor = "1.0 0.5 0.0"; hasLightUnderwaterColor = true; underWaterLightColor = "0.9 0.5 0.0"; }; //------------------------------------------------------------------- datablock GrenadeProjectileData(NukeBomb) { projectileShapeName = "mortar_projectile.dts"; emitterDelay = -1; directDamage = 0.0; hasDamageRadius = true; indirectDamage = 4.0; damageRadius = 150.0; radiusDamageType = $DamageType::Nuke; kickBackStrength = 100; explosion = "NukeVehicleBombExplosion"; underwaterExplosion = "UnderwaterGrenadeExplosion"; velInheritFactor = 0.5; splash = MortarSplash; //baseEmitter = GrenadeSmokeEmitter; bubbleEmitter = MortarBubbleEmitter; grenadeElasticity = 0.75; grenadeFriction = 0.2; armingDelayMS = 1550; muzzleVelocity = 40.0; drag = 0.1; sound = GrenadeProjectileSound; hasLight = true; lightRadius = 4; lightColor = "0.05 0.2 0.05"; hasLightUnderwaterColor = true; underWaterLightColor = "0.05 0.075 0.2"; }; function BigEasyShot::onExplode(%data, %proj, %pos, %mod) { if(%data.mortarCount == "") %data.mortarCount = 1; for(%i = 0; %i < %data.mortarCount; %i++) { %projectileSpread = 62.768 / 1000; /// %projectileSpread = 62.768 / 1000; %vector = "0 0 -1"; %x = (getRandom() - 0.5) * 2 * 3.1415926 * %projectileSpread; %y = (getRandom() - 0.5) * 2 * 3.1415926 * %projectileSpread; %z = (getRandom() - 0.5) * 2 * 3.1415926 * %projectileSpread; %mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z); %vector = MatrixMulVector(%mat, %vector); %p = new GrenadeProjectile() { dataBlock = %data.expProj; initialDirection = %vector; initialPosition = %pos; sourceObject = %proj.sourceObject; sourceSlot = %proj.client.player.slot; vehicleObject = 0; }; MissionCleanup.add(%p); } Parent::onExplode(%data, %proj, %pos, %mod); } //-------------------------------------------------------------------------- // Ammo //-------------------------------------- datablock ItemData(NukeLauncherAmmo) { className = Ammo; catagory = "Ammo"; shapeFile = "ammo_mortar.dts"; mass = 1; elasticity = 0.2; friction = 0.6; pickupRadius = 2; pickUpName = "some Nuke Launcher ammo"; computeCRC = true; }; //-------------------------------------------------------------------------- // Weapon //-------------------------------------- datablock ItemData(NukeLauncher) { className = Weapon; catagory = "Spawn Items"; shapeFile = "weapon_mortar.dts"; image = NukeLauncherImage; mass = 1; elasticity = 0.2; friction = 0.6; pickupRadius = 2; pickUpName = " a Nuke Launcher"; computeCRC = true; emap = true; }; datablock ShapeBaseImageData(NukeLauncherImage) { className = WeaponImage; shapeFile = "weapon_mortar.dts"; item = NukeLauncher; ammo = NukeLauncherAmmo; offset = "0 0 0"; emap = true; stateName[0] = "Activate"; stateTransitionOnTimeout[0] = "ActivateReady"; stateTimeoutValue[0] = 0.5; stateSequence[0] = "Activate"; stateSound[0] = MortarSwitchSound; stateName[1] = "ActivateReady"; stateTransitionOnLoaded[1] = "Ready"; stateTransitionOnNoAmmo[1] = "NoAmmo"; stateName[2] = "Ready"; stateTransitionOnNoAmmo[2] = "NoAmmo"; stateTransitionOnTriggerDown[2] = "Fire"; stateSound[2] = MortarIdleSound; stateName[3] = "Fire"; stateSequence[3] = "Recoil"; stateTransitionOnTimeout[3] = "Reload"; stateTimeoutValue[3] = 5.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"; }; function NukeLauncherImage::onFire(%data, %obj, %slot) { %data.lightStart = getSimTime(); %vehicle = 0; %p = new GrenadeProjectile() { dataBlock = "BigEasyShot"; initialDirection = %obj.getMuzzleVector(%slot); initialPosition = %obj.getMuzzlePoint(%slot); sourceObject = %obj; sourceSlot = %slot; vehicleObject = %vehicle; }; if (isObject(%obj.lastProjectile) && %obj.deleteLastProjectile) %obj.lastProjectile.delete(); %obj.lastProjectile = %p; %obj.deleteLastProjectile = %data.deleteLastProjectile; MissionCleanup.add(%p); %p.client = %obj.client; %p.client.player = %obj.client.player; %p.client.player.slot = %slot; %proj = %p.getDatablock(); // AI hook if(%obj.client) %obj.client.projectile = %p; %obj.decInventory(%data.ammo,1); return %p; } Step #3 Add your weapon and ammo to the clearInventory function: %this.setInventory(NukeLauncher,0); %this.setInventory(NukeLauncherAmmo,0); And the serverCmdGiveAll function: %player.setInventory(NukeLauncher,1); %player.setInventory(NukeLauncherAmmo,999); Step #4 Add your weapon to the $InvWeapon list in inventoryHud.cs: $InvWeapon[10] = "Nuke Launcher"; And to the $NameToInv list: $NameToInv["Nuke Launcher"] = "NukeLauncher"; Step #5 In player.cs, edit the datablocks for light, medium and heavy armors and set the limits on your flame rifle and its ammo. Example: this weapon is for heavy only. max[NukeLauncher] = 1; max[NukeLauncherAmmo] = 1; Then, around line #2470. Add your ammo type to the $ammoType array: $ammoType[6] = "NukeLauncherAmmo"; Step #6 Add your weapon the the $AmmoItem array at the top of ammopacks.cs: $AmmoItem[7] = NukeLauncherAmmo; And increase $numAmmoItems by one: $numAmmoItems = 1; Also, in the datablock for AmmoPack add a line that will increase your carrying capacity while wearing an ammo pack: max[NukeLauncherAmmo] = 2; Step #7 In weapons.cs, add your weapon to the $WeaponsHudData array: $WeaponsHudData[11, bitmapName] = "gui/hud_mortor"; $WeaponsHudData[11, itemDataName] = "NukeLauncher"; $WeaponsHudData[11, ammoDataName] = "NukeLauncherAmmo"; $WeaponsHudData[11, reticle] = "gui/ret_mortor"; $WeaponsHudData[11, visible] = "true"; And increment $WeaponsHudCount by one. $WeaponsHudCount = 1; Below that, add your new ammo type to the $AmmoIncrement array: $AmmoIncrement[NukeLauncherAmmo] = 2; Finally, add a line to exec your weapons script: exec("scripts/weapons/NukeLauncher.cs"); -------------------------------------------------------------------------------- Step #8 Now we need to add the damageTypes. in the damageTypes.cs ---------------------------------------------------------- Mini- Step #1 add this to the top section in the damageTypes.cs $DamageType::Nuke = 37; // or the next number. ---------------------------------------------------------- Mini- Step #2 add this to the top section in the damageTypes.cs $DamageTypeText[37] = "Nuke"; // or the next number. ---------------------------------------------------------- Mini- Step #3 add this to the bottom to mid section in the damageTypes.cs for each players DamageProfile and StaticShapeDamageProfile, TurretDamageProfile and the rest of thim. damageScale[$DamageType::Nuke] = 10.0; shieldDamageScale[$DamageType::Nuke] = 10.0; //-------------------------------------------------------------------------------- // // //-------------------------------------------------------------------------------- Step #9 Now we need to add the death Messages. in the deathMessages.cs Mini- Step #1 add this to the deathMessages.cs in the top section. //these used when a player kills himself (other than by using ctrl - k) $DeathMessageSelfKill[$DamageType::Nuke, 0] = 'c0%1 kills %2self with a nuke!'; $DeathMessageSelfKill[$DamageType::Nuke, 1] = 'c0%1 hugs %3 own big nuke boomie.'; $DeathMessageSelfKill[$DamageType::Nuke, 2] = 'c0%1 nukes %2self all over the map.'; $DeathMessageSelfKill[$DamageType::Nuke, 3] = 'c0%1 experiences %3 nuke's payload up close.'; $DeathMessageSelfKill[$DamageType::Nuke, 4] = 'c0%1 suffered the wrath of %3 own nuke.'; ---------------------------------------------------------- Mini- Step #2 add this to the deathMessages.cs below the last section. $DeathMessageTeamKill[$DamageType::Nuke, 0] = 'c0%4 TEAMKILLED %1 with a Nuke!'; Mini- Step #3 add this to the deathMessages.cs next to the last section. $DeathMessageSelfKill[$DamageType::Nuke, 3] = 'c0%1 experiences %3 nuke's payload up close.'; ---------------------------------------------------------- Mini- Step #4 add this to the deathMessages.cs below the last section. $DeathMessage[$DamageType::Nuke, 0] = 'c0%4 obliterates %1 with his Nuke.'; $DeathMessage[$DamageType::Nuke, 1] = 'c0%4 drops a Nuke right in %1's lap.'; $DeathMessage[$DamageType::Nuke, 2] = 'c0%4 delivers Nuke payload #%8 straight to %1.'; $DeathMessage[$DamageType::Nuke, 3] = 'c0%4 Nukes the crap out of %1.'; $DeathMessage[$DamageType::Nuke, 4] = 'c0%1 says some one Nuked my Ass.'; -------------------------------------------------------------------------------- Finally........ we have finished. -------------------------------------------------------------------------------- This Tut was compiled by |))efender on 10/27/2001