For reference, from previous post.
my nuclear reactor script
event nuclearReactor(every, 10)
{
playnum=0;
while (playnum < multiPlayerMaxPlayers)
{
initEnumStruct(FALSE,nucReactor,playnum,playnum);
structure = enumStruct();
while(structure != NULLOBJECT)
{
if(structureComplete(structure))
{
addPower(4,playnum);
}
structure = enumStruct();
}
playnum=playnum+1;
}
}
strata's "soft" power cap, this is from the source of 1.12 build 7-1
PowerCap.slo:
/* Power Cap script. (C) TWZ, 2001-03
*
* This script assigns a "soft" limit to how much power
* the player can store in their reserves. Excess power
* gradually dissipates.
*
* This results in a power limit based upon how much power
* the player generates per second. It is related as follows:
*
* (limit) = startCap + (genRate) * capRate
*
* (genRate) = ((limit) - startCap) / capRate
*
* where genRate is the player's power generator output per second.
*
* See the matching VLO file for the actual values.
*
* */
private INT startCap, capRate;
private INT power, num;
event CapMe(every, 11)
{
power = playerPower(selectedPlayer);
if (power > startCap)
{
if (capRate > 0)
{
num = (power - startCap) / capRate;
setPowerLevel(power - num, selectedPlayer);
}
}
}
while were at it (it is public after all), look at the way the active mines are stored. this is done because of some very pesky and pervasive multiplayer issues.
LandMine.slo:
/* ************************** */
/* */
/* Warzone Land Mines */
/* (c) 2002-3, Strata/TWZ */
/* */
/* ************************** */
// Static variables defined in the VLO
private FEATURESTAT Mine;
private STRUCTURESTAT BuildMine[8];
private WEAPON Explosion[8];
private WEAPON Fizzle, Blip;
private BODY Miner[2];
// Used for tweaking and debugging
private INT setRange, actRange;
private INT debug;
// Temporary script variables
private INT player;
private INT count;
private INT temp, tempp;
private BOOL NotReady;
private STRUCTURE strucMine;
private FEATURE testMine;
private DROID target;
event CheckMines(every, 10)
{
// Scan all active landmines. Detonate if necessary.
// Must do this to all players, for MP compatibility
player = 0;
while (player < 8)
{
if (debug > 0) {setPowerLevel(1000,player);}
initGetFeature(Mine, player, selectedPlayer);
testMine = getFeature(selectedPlayer);
while (testMine != NULLOBJECT)
{
// Retrieve type & player info from the mine
temp = testMine.health / 10;
tempp = testMine.health - 10 * temp;
// The player can see their own mines only.
if (tempp > 4)
{fireWeaponAtLoc(Blip, testMine.x, testMine.y);}
if (debug > 0) {setPowerLevel(1200,player);}
target = droidTargetInArea(player, player, (testMine.x - actRange), (testMine.y - actRange), (testMine.x + actRange), (testMine.y + actRange));
if (target != NULLOBJECT)
{
if (debug > 0) {setPowerLevel(1300,player);}
// Rule 1: Only ground units may detonate land mines.
// (Also note that the mine layer borg does not "trip" them ;) )
if ((target.z < testMine.z + 96) and (target.body != Miner[0]))
{
if (debug > 0) {setPowerLevel(2000+100*temp,player);}
// Make sure only a mine can go boom.
if (temp < 8)
{
if (target.body == Miner[1])
{
if (debug > 0) {setPowerLevel(7770,player);}
// Mine Sweeper 'borg gets lucky!
fireWeaponAtObj(Fizzle, testMine);
}
else
{
if (debug > 0) {setPowerLevel(6660,player);}
// Anyone else, well... >B}
fireWeaponAtObj(Explosion[temp], target);
}
destroyFeature(testMine);
}
}
}
testMine = getFeature(selectedPlayer);
}
player = player + 1;
}
// Activate newly set mines when the owner is at a "safe" distance
//
// Again, this must be done for all players to be MP compatible
player = 0;
while (player < 8)
{
count = 0;
while (count < 8)
{
initEnumStruct(FALSE, BuildMine[count], player, player);
strucMine= enumStruct();
while (strucMine!= NULLOBJECT)
{
if (structureComplete(strucMine))
{
NotReady = droidInRange(player, strucMine.x, strucMine.y, setRange);
if (NotReady)
{
target = droidTargetInArea(player, player, (strucMine.x - actRange), (strucMine.y - actRange), (strucMine.x + actRange), (strucMine.y + actRange));
if (target != NULLOBJECT)
{
// Mine layer droids can activate their own mines
if (target.body == Miner[0]) { NotReady= FALSE; }
}
}
if (NotReady== FALSE)
{
testMine = addFeature(Mine, strucMine.x, strucMine.y);
// Encode the mine's type into the feature's health stat
// *** NOTE! *** Mine must not be declared indestructible via WZCK //
if (player == selectedPlayer)
{temp = 10 * count + 8;}
else
{temp = 10 * count + 3;}
forceDamageObject(testMine, temp);
destroyStructure(strucMine);
}
}
strucMine = enumStruct();
}
count = count + 1;
}
player = player + 1;
}
}