script 476 (int begin, int button, int superThreshold) { begin = !!begin; superThreshold = condFalse(superThreshold, 26); button = condFalse(button, BT_ALTATTACK); int pln = PlayerNumber(); if (pln == -1) { terminate; } int curstate = MissileCheckStates[pln]; if (curstate == begin) { terminate; } MissileCheckStates[pln] = begin; int chargelevel = 0; int couldsuper, cansuper = 0, givesuper = 0, canmissile = 0, isfiring = 0; while (MissileCheckStates[pln]) { // There's a dirty joke somewhere in here. if (CheckInventory("BorphMallAcquired") || CheckInventory("SpeedBoosterActive")) { MissileCheckStates[pln] = 0; break; } cansuper = !!CheckInventory("SuperMissileAmmo"); canmissile = !!CheckInventory("MissileAmmo"); isfiring = keyDown(button); // Clear out the trigger if we can hold for super missiles // - if we only have normal missiles, this could waste bandwidth if (cansuper && CheckInventory("DakkaBeamCanMissile")) { TakeInventory("DakkaBeamCanMissile", 0x7FFFFFFF); } // chargan if (isfiring && cansuper) { chargelevel++; } else { // Let go of the trigger before charged? fire a normal missile if (chargelevel > 0 && cansuper && !couldsuper) { GiveInventory("DakkaBeamCanMissile", 1); } chargelevel = 0; } givesuper = chargelevel >= superThreshold; givesuper &= cansuper; // Handle no-super-missiles here if (!cansuper) { if (isfiring && canmissile && !CheckInventory("DakkaBeamCanMissile")) { GiveInventory("DakkaBeamCanMissile", 1); } else if (CheckInventory("DakkaBeamCanMissile")) { TakeInventory("DakkaBeamCanMissile", 0x7FFFFFFF); } } // LOCKED AND LOADED if (givesuper && !couldsuper) { ActivatorSound("supermissile/ready", 127); } // If we let go of the trigger, either send the super missile signal // (if charged), or clear the signal if there (if not) if (!givesuper) { if (couldsuper) { GiveInventory("DakkaBeamCanSuper", 1); } else if (CheckInventory("DakkaBeamCanSuper")) { TakeInventory("DakkaBeamCanSuper", 0x7FFFFFFF); } } couldsuper = givesuper; Delay(1); } }