About your first question altoghether, I still don't know why you don't use this burst fire code.
I've tried with multiple devices in one ship and it worked fine...
// This machine is meant for handling several weapons' burst fire mode. Original idea and code by Mularac,
// moved into a whole new level by Old Dragon and efficiently re-coded by Arparso.
// Edited to fit the War Begins Mod by Mularac
MACHINE "Burst"
STATE Default
// Initialization
//
// Select all burst fire devices, put them into the BurstWeapons-selection and
// prepare supporting arrays storing the remaining burst shots and targetted ships
RULE event In
:action
// select all burst fire weapons
BurstWeapons := GetFreeSel();
Select(BurstWeapons, s.device & (s.devType=#burst_pbeam | s.devType=#AFRailgun | s.devType=#AFRailgunL | s.devType=#heavy_railgun)); // expandable with additional burst weapon types
ExecList(BurstWeapons,
Debug("requesting fire event for", s.this, "on", s.this:owner);
RequestFiredEvent(s.this, 1);
);
// prepare array for remaining burst shots
RemainingBurstShots := GetFreeSel();
Dim(RemainingBurstShots, AllNumOf(BurstWeapons));
// prepare array for burst weapon targets
BurstTargets := GetFreeSel();
Dim(BurstTargets, AllNumOf(BurstWeapons));
:end
END
// Fire Event
//
// A burst weapon has fired, initialize burst strength and count subsequent shots,
// disable weapon after burst
RULE event Fired
condition InSelection(BurstWeapons,E.location)
:action
// Debug(e.Location, "on", e.Location:owner, "fired at", e.Location:target);
// get index of fired weapon in selection
E.index := IndexOf(BurstWeapons, e.Location);
// get the remaining burst shots of fired weapon
E.remainingBurstShots := GetN(RemainingBurstShots, E.index);
// if 0 burst shots remain, this marks the start of a new burst
if(E.remainingBurstShots = 0,
// calculate burst length, depending on weapon type
ChooseFirst(
E.Location:devType=#burst_pbeam,
E.remainingBurstShots := 2;
,E.Location:devType=#AFRailgun,
E.remainingBurstShots := Round(Rnd(10,18))
,E.Location:devType=#AFRailgunl,
E.remainingBurstShots := Round(Rnd(18,28))
, E.location:devType=#heavy_railgun,
E.remainingBurstShots := 4
);
// save burst length in array
SetN(RemainingBurstShots, E.index, E.remainingBurstShots);
// Debug("Initialized burst with", E.remainingBurstShots, "shots");
, //else
// remaining burst shots was greater than 0 - continue burst fire
E.remainingBurstShots := E.remainingBurstShots - 1;
// save remaining burst length in array
SetN(RemainingBurstShots, E.index, E.remainingBurstShots);
// Debug(E.remainingBurstShots, "burst shots remaining");
// this was the last shot?
If(E.remainingBurstShots = 0,
// store current target for later use
SetN(BurstTargets, E.index, E.location:target);
// disable weapon
LocalEvent(DisableBurstWeapon, E.dev := P.Location);
);
);
:end
END
// Disable Burst Weapon
//
// a full burst was finished... weapon gets disabled for a certain period of time
RULE event DisableBurstWeapon
condition InSelection(BurstWeapons,E.dev)
:action
EnableDevice(E.dev, 0);
Debug("Burst weapon", e.dev,"getting ready for new burst");
ChooseFirst(
E.dev:devType=#burst_pbeam,
Timer(EnableBurstWeapon, 5, e.dev:=p.dev);
,E.dev:devType=#AFRailgun,
Timer(EnableBurstWeapon, Rnd(0.6,1.2), E.dev:=P.dev);
,E.dev:devType=#AFRailgunl,
Timer(EnableBurstWeapon, Rnd(0.3,0.8), E.dev:=P.dev);
, E.dev:devType=#heavy_railgun,
Timer(EnableBurstWeapon, Rnd(0.8,1.2), E.dev:=P.dev);
);
:end
END
// Enable burst weapon
//
// Weapon has recharged - enable it and continue fire at old target, if possible
RULE event EnableBurstWeapon
condition E.dev:device&IsValid(E.dev)&InSelection(BurstWeapons,E.dev)
:action
EnableDevice(E.dev, 1);
E.index := IndexOf(BurstWeapons, e.dev);
// get old target from array
E.target := GetN(BurstTargets, E.index);
// if target is still valid, continue fire...
If(IsValid(E.target),
TargetWeapon(E.dev, E.target);
,
// else remove old target from array
SetN(BurstTargets, E.index, 0);
);
:end
END
Rule event LongRangeArrived
:action
// New ship has arrived
//
// check, if the new ship carries burst weapons
// ... if it does, add those weapons to the BurstWeapon-selection and expand supporting arrays
// select new burst weapons, if there are any
Debug("...........", e.ship);
E.NewBurstWeapons := GetFreeSel();
SelectDevices(E.NewBurstWeapons, E.ship, s.devType=#heavy_railgun | s.devType=#AFRailgun | s.devType=#AFRailgunL);
E.count := AllNumOf(E.NewBurstWeapons);
// yeah, there is at least one new burst weapon in the scene
If(E.count > 0,
// expand BurstWeapon-selection to make room for the additional weapons
E.oldCount := AllNumOf(BurstWeapons);
Dim(BurstWeapons, E.oldCount + E.count);
// now add each new weapon to the BurstWeapon-selection and request a fire event
E.index := 0;
ExecList(E.NewBurstWeapons,
Debug("requesting fire event for", s.this, "on", s.this:owner);
RequestFiredEvent(s.this, 1);
// add new weapon to selection
SetN(BurstWeapons, E.oldCount + E.index, s.this);
E.index := E.index + 1;
);
// expand arrays for burst weapon targets and remaining burst shots
Dim(BurstTargets, E.oldCount + E.count);
Dim(remainingBurstShots, E.oldCount + E.count);
);
DeleteSelect(E.NewBurstWeapons);
:end
END
END
END
It's been edited to fit the WB mod, but all you need to do is change the according devicetypes to the ones you'll be using.