//-------------------------------------- // Minigun //-------------------------------------- //-------------------------------------------------------------------------- // Ammo //-------------------------------------- datablock ItemData(MMinigunAmmo) { className = Ammo; catagory = "Ammo"; shapeFile = "ammo_chaingun.dts"; mass = 1; elasticity = 0.2; friction = 0.6; pickupRadius = 2; pickUpName = "some minigun ammo"; }; //-------------------------------------------------------------------------- // Weapon //-------------------------------------- datablock ShapeBaseImageData(MMinigunImage) { className = WeaponImage; shapeFile = "weapon_chaingun.dts"; item = MMinigun; ammo = MMinigunAmmo; projectile = ChaingunBullet; projectileType = TracerProjectile; emap = true; casing = ShellDebris; shellExitDir = "1.0 0.3 1.0"; shellExitOffset = "0.15 -0.56 -0.1"; shellExitVariance = 15.0; shellVelocity = 3.0; projectileSpread = 7.5 / 1000.0; //-------------------------------------- stateName[0] = "Activate"; stateSequence[0] = "Activate"; stateSound[0] = ChaingunSwitchSound; stateAllowImageChange[0] = false; // stateTimeoutValue[0] = 0.5; stateTransitionOnTimeout[0] = "Ready"; stateTransitionOnNoAmmo[0] = "NoAmmo"; //-------------------------------------- stateName[1] = "Ready"; stateSpinThread[1] = Stop; // stateTransitionOnTriggerDown[1] = "Spinup"; stateTransitionOnNoAmmo[1] = "NoAmmo"; //-------------------------------------- stateName[2] = "NoAmmo"; stateTransitionOnAmmo[2] = "Ready"; stateSpinThread[2] = Stop; stateTransitionOnTriggerDown[2] = "DryFire"; //-------------------------------------- stateName[3] = "Spinup"; stateScript[3] = "onSpinup"; stateSpinThread[3] = SpinUp; stateSound[3] = ChaingunSpinupSound; // stateTimeoutValue[3] = 0.5; stateWaitForTimeout[3] = false; stateTransitionOnTimeout[3] = "Fire"; stateTransitionOnTriggerUp[3] = "Spindown"; //-------------------------------------- stateName[4] = "Fire"; stateSequence[4] = "Fire"; stateSequenceRandomFlash[4] = true; stateSpinThread[4] = FullSpeed; stateSound[4] = ChaingunFireSound; //stateRecoil[4] = LightRecoil; stateAllowImageChange[4] = false; stateScript[4] = "onFire"; stateFire[4] = true; stateEjectShell[4] = true; // stateTimeoutValue[4] = 0.193; stateTransitionOnTimeout[4] = "Fire"; stateTransitionOnTriggerUp[4] = "Spindown"; stateTransitionOnNoAmmo[4] = "EmptySpindown"; //-------------------------------------- stateName[5] = "Spindown"; stateScript[5] = "onSpindown"; stateSound[5] = ChaingunSpinDownSound; stateSpinThread[5] = SpinDown; // stateTimeoutValue[5] = 1.0; stateWaitForTimeout[5] = true; stateTransitionOnTimeout[5] = "Ready"; stateTransitionOnTriggerDown[5] = "Spinup"; //-------------------------------------- stateName[6] = "EmptySpindown"; stateSound[6] = ChaingunSpinDownSound; stateSpinThread[6] = SpinDown; stateScript[6] = "onSpindown"; // stateTimeoutValue[6] = 0.5; stateTransitionOnTimeout[6] = "NoAmmo"; //-------------------------------------- stateName[7] = "DryFire"; stateSound[7] = ChaingunDryFireSound; stateTimeoutValue[7] = 0.5; stateTransitionOnTimeout[7] = "NoAmmo"; }; datablock ShapeBaseImageData(MMGun2Image) : MMinigunImage { offset = "-0.2 0 0"; stateScript[3] = "onFire"; }; datablock ShapeBaseImageData(MMGun3Image) : MMinigunImage { offset = "-0.0 0.3 0"; shapeFile = "pack_upgrade_ammo.dts"; }; datablock ItemData(MMinigun) { className = Weapon; catagory = "Spawn Items"; shapeFile = "weapon_chaingun.dts"; image = MMinigunImage; mass = 1; elasticity = 0.2; friction = 0.6; pickupRadius = 2; pickUpName = "a minigun"; emap = true; }; function MMinigunImage::onMount(%this,%obj,%slot) { Parent::onMount(%this, %obj, %slot); commandToClient( %obj.client, 'BottomPrint', "a Minigun", 3, 1); %obj.mountImage(MMGun2Image, 4); %obj.mountImage(MMGun3Image, 5); } function MMinigunImage::onSpindown(%this,%obj,%slot) { %obj.MMSpunUp = false; %obj.setImageTrigger(4, false); } function MMinigunImage::onSpinup(%this,%obj,%slot) { %obj.setImageTrigger(4, true); } function MMinigunImage::onUnmount(%this,%obj,%slot) { Parent::onUnmount(%this, %obj, %slot); %obj.unmountImage(4); %obj.unmountImage(5); } function MMinigunImage::onFire(%data, %obj, %slot) { %vector = %obj.getMuzzleVector(%slot); %x = (getRandom() - 0.5) * 2 * 3.1415926 * %data.projectileSpread; %y = (getRandom() - 0.5) * 2 * 3.1415926 * %data.projectileSpread; %z = (getRandom() - 0.5) * 2 * 3.1415926 * %data.projectileSpread; %mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z); %vector = MatrixMulVector(%mat, %vector); %p = new (%data.projectileType)() { dataBlock = %data.projectile; initialDirection = %vector; initialPosition = %obj.getMuzzlePoint(%slot); sourceObject = %obj; sourceSlot = %slot; }; MissionCleanup.add(%p); %obj.MechSpunUp = true; %obj.decInventory(%data.ammo,2); %obj.lastProjectile = %p; %client.projectile = %p; return MMGun2Image::onFire(MMGun2Image,%obj,4); // Call the second image fire } function MMGun2Image::onFire(%data,%obj,%slot) { if(!%obj.MMSpunUp) return false; %vector = %obj.getMuzzleVector(%slot); %x = (getRandom() - 0.5) * 2 * 3.1415926 * %data.projectileSpread; %y = (getRandom() - 0.5) * 2 * 3.1415926 * %data.projectileSpread; %z = (getRandom() - 0.5) * 2 * 3.1415926 * %data.projectileSpread; %mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z); %vector = MatrixMulVector(%mat, %vector); %p = new (%data.projectileType)() { dataBlock = %data.projectile; initialDirection = %vector; initialPosition = %obj.getMuzzlePoint(%slot); sourceObject = %obj; sourceSlot = %slot; }; MissionCleanup.add(%p); %obj.lastProjectile = %p; %client.projectile = %p; }