/* Burst Fire Machine for Torpedos and Missles V 0.6 by Rainman The Machines parameters are: R.Weapon: The weapon that should be substituted R.SubstType: The weapon "type", that will be inserted instead of R.Weapon R.n: The Number of shots to fire, before changing it back R.chargetime: The Charge time per shot, before the weapon is fired (in seconds/shot). This should be at least as long, as the projectiles take to cover the whole range of the weapon at a given speed. R.Id: Unique weapon id, so you can reidentify the Weapon slot you used. Example: M:GetMachine("Multifire"):ChangeState(AddWeapon,R.Weapon:=YourWeapon;R.SubstType=YourSubstWeapon;R.n:=5;R.ChargeTime:=2);R.Id=5; Place an #include "Multifire.mach" statement into your main ruleset, and call M:GetMachine("Multifire"):ChangeState(Init,0); during your Scene Init event, to initialize it. It might work without initialisation, but i didn't test it. This function of this thing is basically to replace the weapon you want to burst fire with a replacement weapon, that has lower chargetime and only a set amount of ammo, which can be manipulated with the R.n parameter. After the temporary weapon has run out of Ammunition, it will create a new instance of the old device type and reduce it's ammunition counter accordingly. Additionally, after putting in the original device type, it will generate a RootEvent MultiFire_NewWeap which returns a handle to the new weapon (E.Weapon) and a handle to the last target of the burst Weapon(E.target). This is important, because your original Weapon will be deleted and you'll gonna lose the variable, that is assigned to it. The machine has an integrated stack-like struckture, so you can add as many weapons as you want, on as many ships as you want. The heavy scripting might slow it down a little, though. Bugs and Caveats: I had to put the recharge downtime at the end of the firing cycle, because if the weapon is deleted, all projectiles that have been fired from it will dissapear together with it. You might wann overwrite your sound/dialogs/xx/warn_ammodepleting.wav with silence, since you're gonna get a lot of messages whenever a burst sequence is finished. Other things i realised: The WeaponEmpty event doesn't provide a E.Weapon variable. The real Variable is E.Location... */ MACHINE "MultiFire" STATE Init RULE event In :action EnableGUIEvents(1); WeaponList:=10; SubstList:=11; WeaponCount:=12; IdList:=13; DownList:=14; ChangeState(Idle,0); :END END END STATE Idle RULE event WeaponEmpty condition InSelection(SubstList,E.Location) :action Index:=IndexOf(SubstList,E.Location); Weap:=E.Location; target:=weap:target; Id:=GetN(Idlist,Index); dt:=GetN(DownList,Index); NewWeapon:=0; Host:=E.Ship; n:=0; m:=0; Index:=IndexOf(SubstList,Weap); Damage:=Weap:Damage; EnableDevice(Weap,0); //Weap:Damage:=80; NewWeapon:=GetN(WeaponList,Index); OldCount:=GetN(WeaponCount,Index); while(n0 :action maxcount:=0; target:=R.Weapon:target; NewWeapon:=0; Damage:=0; host:=r.weapon:owner; Dim(WeaponList,AllNumOf(WeaponList)+1); SetN(WeaponList,AllNumOf(WeaponList)-1,R.Weapon:devType); Dim(IdList,AllNumOf(IdList)+1); SetN(IdList,AllNumOf(IdList)-1,R.Id); Dim(DownList,AllNumOf(DownList)+1); SetN(DownList,AllNumOf(DownList)-1,R.chargetime*R.n;); If(R.Weapon:Count