Alpha Centauri 2

Sid Meier's Alpha Centauri & Alien Crossfire => Modding => Bug/Patch Discussion => Topic started by: EmpathCrawler on September 13, 2020, 08:14:29 PM

Title: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 13, 2020, 08:14:29 PM
Tested in the scenario editor under Thinker/Scient's patch. I suppose the boil's brood trainer can have a family, too...

The Datalinks are vague, though the wording of the Brood Pit's entry suggests that the morale effects should not stack.

Quote from: Datalinks
Acts as a Children's Creche for alien units, if there is not already one at the base.

I don't know if that language is original or from the included updated datalinks mod in Scient's patch.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: bvanevery on September 13, 2020, 08:57:59 PM
I have multiple installations of SMAC on my computer.  Each one having its various patches and mods or whatever.  One that's pure and unaltered.  This is a good development practice if one reasonably anticipates doing some debugging.

There is no such entry in the original Datalinks, nor in any likely *.txt file I looked at.  I searched several files for the word "brood".

I haven't usually had reason to work with Scient's patch, as my modding is targeted at the official game installation.  It does not presume that anyone has done anything to the game binary or the various *.txt files at all, other than drop my *.txt files on top of it.  Nevertheless I do have a Scient's patch installation sitting around on my machine, from some thing I wanted to look at one month.  Like whether Scient's patch solved a particular bug I was interested in.  Anyways, examining helpx.txt the description of Brood Pit is clearly altered from the original.

So, some of the undocumented behavior anomalies of the Brood Pit were previously discovered.  And then, were they regarded as bugs or features.  And then, what Scient's patch would choose to do in the future.  And then, what would anyone else choose to do.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 13, 2020, 10:46:18 PM

There is no such entry in the original Datalinks, nor in any likely *.txt file I looked at.  I searched several files for the word "brood".


What is the unaltered Brood Pit entry? Would you quote it please?

Anyway, the language I found is also what the Alien Crossfire manual has to say:

Quote from: SMAX manual page 19
Acts as a Children’s Creche for native units, if there is not already one at the base. Decreases the cost of alien units built at the base by 25%. Gives the base a +2 Police rating. The Brood Pit is a place where alien life forms can be grown with relative ease. It also doubles as a punishment area. Becomes available upon discovery of Centauri Genetics (E7).

Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: bvanevery on September 13, 2020, 11:14:39 PM
helpx.txt:
Code: [Select]
#; Brood Pit
#HELPFAC35
+1 $LINK<lifecycle=11> bonus to native units built here. -25% cost of alien units. Negative $LINK<LIFECYCLE=130004> effects
cancelled in base square. Base also receives a $LINK<+2 POLICE=130005> rating.

I can't at this time verify any "SMAX manual page 19".    My GOG installation contains Manual.PDF.  Page 19 is about something completely different, specifically what a "turn" in the game is.  Probably to be expected early in a game manual.  Searching for the word "brood" in fact yields nothing at all.  Looking at the entries under Facilities, it looks like Manual.PDF only documents SMAC, not Alien Crossfire.

I have a vague memory of the GOG version having some other files when I bought it.  Wonder where they are.

My GOG Galaxy isn't even working.  It's an older version of it.  I saw something on GOG's site the other week that they were releasing some new beta version of it.  Being a beta, I didn't want it.   Well maybe I'm forced.

Oh wait, here it goes.  "GOG is updating.  3%..."  It was so slow to react, that I thought it was dead, and had time to make this post.

Ok that was a little clunky and laggy, but I finally got a .zip of manuals downloaded into a somewhat obscure GOG Galaxy folder.  I've copied them to my "usual" GOG Games folder.  "Sid Meier's Alien Crossfire - manual.pdf", page 19.  Yep, it's as you quoted.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 13, 2020, 11:21:08 PM
So the updated Datalinks included with my patch are not my work. GooglyBoogly was the one at the time working on trying to revise/update them based on information from the community. I may have made some minor or small changes based on binary patches to allow for greater modding flexibility.

Also, I think in my readme I state that there is a fix for this issue but upon recent analysis this and two other fixes weren't applied to binary:
[BUG] Fixed the CC/BP combat bonus bug.
[BUG][EXPLOIT] Fixed the AI base trading exploit. (credit to kryub)
[EXPLOIT] Fixed the energy stockpile exploit. (credit to kyrub)

Lastly, I thought I had decompiled the functions related to this but it looks like I didn't (get_basic_offense/get_basic_defense). Doing that now. They look fairly straightforward.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 14, 2020, 12:48:06 AM
Awesome, thanks!
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 14, 2020, 05:39:45 AM
Initial drafts. I'll do some testing tomorrow and finalize them then look for ways to fix buggy behavior.

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L180
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L252
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 14, 2020, 09:40:19 PM
Guess I should have learned C++ in school...
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 15, 2020, 04:03:31 AM
A bit under the weather today. I'll set aside some time this week to work on code review and regression testing of these two functions. My guess is it will mostly be some minor clean up and optimizations. The code was fairly straightforward to decompile.

Let me know if you have any specific questions on what a line of code is doing.

The code causing double increase for offense is from here:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L199
To here:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L203

And for defense here:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L271
To here:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L275

Here are quick excerpts from text files and manuals.

SMACX Manual, pg 19; Brood Pit:
"Acts as a Children’s Creche for native units, if there is not already one at the base."

helpx.txt, line 1689-1690; Brood Pit:
"Negative LIFECYCLE effects cancelled in base square."

conceptsx.txt, line 247-248:
A unit with a "+" sign after its morale possesses a combat bonus from its location in a base with a Children's Creche.

SMAC Manual, pg 166; Children’s Creche:
All negative morale effects are cancelled for units in base square; instead such units receive a +1 morale modifier.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 17, 2020, 04:24:19 AM
Ran both functions through a battery of automated tests and corrected a couple of issues that are now live. The only thing left is the more in depth assembly regression checks I run everything through.

This is a great breakdown of issues:
https://web.archive.org/web/20160313051407/http://civgaming.net/smac/acad_morale.shtml

Basically, I think there are three main issues with the code.
* Brood Pit double bonus with Creche
* SE morale issues with CC
* Headquarters doesn't give defense bonus as stated in manual: SMAC pg 104 > "Units in a headquarters base automatically gain +1 Morale when defending."

If anyone can think of others, let me know. Still have some other threads to read through and piece together any other problems.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: bvanevery on September 17, 2020, 04:44:40 AM
Wow the stock binary MORALE bugs for a Children's Creche are insane.  I'd heard about that, but I'd never seriously looked into it.  So -2 MORALE for Wealth can actually be a bonus!  Just wow.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 17, 2020, 05:34:08 PM
Ran both functions through a battery of automated tests and corrected a couple of issues that are now live. The only thing left is the more in depth assembly regression checks I run everything through.

This is a great breakdown of issues:
https://web.archive.org/web/20160313051407/http://civgaming.net/smac/acad_morale.shtml

Basically, I think there are three main issues with the code.
* Brood Pit double bonus with Creche
* SE morale issues with CC
* Headquarters doesn't give defense bonus as stated in manual: SMAC pg 104 > "Units in a headquarters base automatically gain +1 Morale when defending."

If anyone can think of others, let me know. Still have some other threads to read through and piece together any other problems.


I knew it was a mess from back in the day, but I forgot to what extent. There is also this page in the wiki here that duplicates some of that information while maybe adding more: http://alphacentauri2.info/wiki/Morale_(Advanced) (http://alphacentauri2.info/wiki/Morale_(Advanced))

I just verified the lack of a Headquarters defensive bonus. Pretty minor, though it could marginally help out the AI in the early game against native life/Deirdre worm rush.

I couldn't make heads or tails of the Drone Riots effect on morale, either. It added a (-) symbol but with no apparent change to the battle odds math. Here's the check in your code:

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L1956
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 17, 2020, 11:04:04 PM
Awesome! The wiki has a good outline of the issues. I think all or at least most of the problems with CC/BP and morale revolve around these two get_basic functions. Once I finish vetting code is 1-1 copy of original assembly, I'll try to summarize each issue, problematic code and suggest a way of fixing it via code. Once there is some kind of consensus, I'll apply/push fixes. It's nice that the project is getting to the point where I can work on some of these long standing problems at the code level.

I've started to go through existing references to CC/BP in code I've already decompiled and add comments what mechanic it's tied to. I figured this might be a good way to narrow down other potential problems. So far, haven't seen anything that's stood out other than this:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L1941
Basically, it's halving negative effects of the base morale of a unit based on its home base. So this is independent of whether unit is inside a base that has a CC or BP. Although, for BP it never reaches this area of code since it exits out here:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L1926

Yeah, I agree about HQ bonus. I don't really see this being left out as a balance issue since it's pretty narrow scope. My guess is just an oversight.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 17, 2020, 11:12:49 PM
I couldn't make heads or tails of the Drone Riots effect on morale, either. It added a (-) symbol but with no apparent change to the battle odds math. Here's the check in your code:

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L1956

Forgot to add break down of this code. So first it checks if that boolean parameter (checkDroneRiot) is set to true. Skimming through references, it looks like it's only set to false mostly on display code. Might end up renaming variable once more code is decompiled. Anyway, next it checks to see if the unit's home base is valid (I think it will be -1 for independent units). Then it checks to see if the home base has flag set indicating drone riots. Lastly, it checks to see if the faction rules MORALE variable is not set or false (!false == true).

MORALE = Morale modifier (if 0, indicates an exemption from negative modifiers from other sources).

If all these conditions are met, it subtracts 1 from morale local variable (--) then uses range function that basically bounds value between 0 and 6.

Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 18, 2020, 03:51:52 AM
Forgot to add break down of this code. So first it checks if that boolean parameter (checkDroneRiot) is set to true. Skimming through references, it looks like it's only set to false mostly on display code. Might end up renaming variable once more code is decompiled. Anyway, next it checks to see if the unit's home base is valid (I think it will be -1 for independent units). Then it checks to see if the home base has flag set indicating drone riots. Lastly, it checks to see if the faction rules MORALE variable is not set or false (!false == true).

MORALE = Morale modifier (if 0, indicates an exemption from negative modifiers from other sources).

If all these conditions are met, it subtracts 1 from morale local variable (--) then uses range function that basically bounds value between 0 and 6.

Bingo: Calling the range function in the riot check is a huge problem that actually isn't related to the Creche. If there is any reason for a unit to have negative morale penalties applied before the check, but its home base is rioting, the penalties will be voided because the range function in the riot check will reset the "morale" variable to 0, yes? Same if SE MORALE is net 0. Then the 0 will be applied to the unit's intrinsic morale from Veh[vehID].morale, returning the intrinsic morale unaffected.

With zero or negative MORALE SE, a rioting home base is better or the same as a peaceful one and a Creche doesn't matter:

-2 MORALE (morale = -1), no Creche, Drone Riot (morale = range(-2, 0, 6) = 0!!!), Disciplined = range(0+2, 0, 6) = 2 but really should be 0 (Very Green)
-2 MORALE (morale = -1), no Creche, no Drone Riot, Disciplined = range(-1+2,0,6) = 1 (Green, correct)

-2 MORALE (morale = -1), Creche (morale = 0 due to rounding), Drone Riot (range(-1,0,6) = 0!!!), Disciplined = range(0+2,0,6) = 2 but really should be 1 (Green) as that would be the Creche compensating for the morale negatives but not the riot.
-2 MORALE (morale = -1), Creche (morale = 0), no Drone Riot, Disciplined = range(0+2,0,6) = 2 (Disciplined, correct)

These values explain why somebody thought riots gave bonuses, which I suppose is true in a certain sense. The riot check should really apply a -1 modifier no matter what at the end of the morale calculation, I think.


Also, and this is unrelated to morale, but it is documented that the aliens get +1 RESEARCH in addition to PLANET from the Manifold Nexus (aka Temple?): https://github.com/b-casey/OpenSMACX/blob/defe36bdb1604c738f9cdf842ce1c8caabc456f1/src/faction.cpp#L720
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: bvanevery on September 18, 2020, 05:14:59 AM
Yes, it's in the Datalinks under "Basic Concepts.. Landmarks, Volcanoes, Etc."
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 18, 2020, 05:38:19 AM
Also, and this is unrelated to morale, but it is documented that the aliens get +1 RESEARCH in addition to PLANET from the Manifold Nexus (aka Temple?): https://github.com/b-casey/OpenSMACX/blob/defe36bdb1604c738f9cdf842ce1c8caabc456f1/src/faction.cpp#L720

Yes, it's in the Datalinks under "Basic Concepts.. Landmarks, Volcanoes, Etc."

Ahh, I see it in conceptsx.txt. I think I thought it was undocumented because it's not listed in manual. I'll update code comment to reflect that. If you see anything else that looks off in the code, definitely let me know!

Bingo: Calling the range function in the riot check is a huge problem that actually isn't related to the Creche. If there is any reason for a unit to have negative morale penalties applied before the check, but its home base is rioting, the penalties will be voided because the range function in the riot check will reset the "morale" variable to 0, yes? Same if SE MORALE is net 0. Then the 0 will be applied to the unit's intrinsic morale from Veh[vehID].morale, returning the intrinsic morale unaffected.

With zero or negative MORALE SE, a rioting home base is better or the same as a peaceful one and a Creche doesn't matter:

-2 MORALE (morale = -1), no Creche, Drone Riot (morale = range(-2, 0, 6) = 0!!!), Disciplined = range(0+2, 0, 6) = 2 but really should be 0 (Very Green)
-2 MORALE (morale = -1), no Creche, no Drone Riot, Disciplined = range(-1+2,0,6) = 1 (Green, correct)

-2 MORALE (morale = -1), Creche (morale = 0 due to rounding), Drone Riot (range(-1,0,6) = 0!!!), Disciplined = range(0+2,0,6) = 2 but really should be 1 (Green) as that would be the Creche compensating for the morale negatives but not the riot.
-2 MORALE (morale = -1), Creche (morale = 0), no Drone Riot, Disciplined = range(0+2,0,6) = 2 (Disciplined, correct)

These values explain why somebody thought riots gave bonuses, which I suppose is true in a certain sense. The riot check should really apply a -1 modifier no matter what at the end of the morale calculation, I think.

I completely agree. At first I didn't quite understand but breakdown was helpful. This is definitely one of the bugs outlined in the wiki and in Maniac's write up. I'll correct this in my next commit.


Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 18, 2020, 05:11:16 PM
I completely agree. At first I didn't quite understand but breakdown was helpful. This is definitely one of the bugs outlined in the wiki and in Maniac's write up. I'll correct this in my next commit.

Can't wait to brag about figuring out a 21 year old bug to Brian Reynolds if I ever meet him. 8) I'm really happy to compile a little code in my head and work these bugs out if you do all the coding itself! :)

Now, here's my little treatise on the Children's Creche/Brood Pit...

Awesome! The wiki has a good outline of the issues. I think all or at least most of the problems with CC/BP and morale revolve around these two get_basic functions. Once I finish vetting code is 1-1 copy of original assembly, I'll try to summarize each issue, problematic code and suggest a way of fixing it via code. Once there is some kind of consensus, I'll apply/push fixes. It's nice that the project is getting to the point where I can work on some of these long standing problems at the code level.

I've started to go through existing references to CC/BP in code I've already decompiled and add comments what mechanic it's tied to. I figured this might be a good way to narrow down other potential problems. So far, haven't seen anything that's stood out other than this:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L1941
Basically, it's halving negative effects of the base morale of a unit based on its home base. So this is independent of whether unit is inside a base that has a CC or BP. Although, for BP it never reaches this area of code since it exits out here:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L1926

Yeah, I agree about HQ bonus. I don't really see this being left out as a balance issue since it's pretty narrow scope. My guess is just an oversight.

I tried to do my homework about what the developers intended the Children's Creche to do but it's really obscure. It's pretty clear that the Children's Creche (and Brood Pit) do not operate as how manual states:

Quote from: SMAC manual, p. 166
Base receives +2 on growth scale and +2 (sic) on efficiency scale. All negative morale effects are cancelled for units in base square; instead such units receive a +1 morale modifier. Reduces base’s vulnerability to enemy mind control.

I tried to find any mention of changes in the readme.txt file, which included official patch notes, but I didn't see it. I wonder if changes happened after the manuals were printed and Firaxis failed to document it.

Guessing from what they seemed to intend by the code, it looks like they changed their mind and only wanted to halve negative morale effects (but everywhere?) and additionally (not instead) give +1 morale when engaging in combat in the base square regardless of morale.

There is also the blurb, which actually meshes well with game mechanics in this case.

Quote from: Col. Santiago
Proper care and education for our children (GROWTH) remains a cornerstone of our entire colonization effort. Children not only shape our future; they determine in many ways our present. Men and women work harder knowing their children are safe and close at hand. (EFFIC) And never forget that, with children present, parents will defend their home to the death.

To me, this is a compelling indication to actually restrict all Creche/Pit effects to the base square as stated in the manual. What difference would it make to Recon Rover Rick if his kids are in daycare or not while he's way out in the field? Why would he fight better than Scout Patrol Steve if Rick's kids were at the Creche but Steve's kids were at grandma's because his base didn't have a Creche?

Gameplay wise, it is also a simplification for the player with low MORALE. The + and - modifiers are inscrutable. You don't have to wonder which unit has marginally better or worse morale out in the field because they will all have the same. If you have bad MORALE, stay at home.

It would also make sense to riot check the base being defended rather than the defending unit's home base. It's charming that a unit is sad if its base is revolting, but again that's pretty complicated to keep track of on a unit by unit basis. It also makes sense that a base that's rioting would be harder to defend than one that is not. All of those hordes of AI Probes inciting drone riots would finally be of use to them, too!

So this is what I think the basic code should be for attacking from a base square with a Creche/Pit (ignoring the niche stuff for now):

Code: [Select]
moraleModifier = socialMoraleModifier + localRiotMalus
if (inCrecheBase and moraleModifier < 0) {
  moraleModifier = moraleModifier / 2 + 1
} else if (inCrecheBase) {
  moraleModifier += 1
}
attackMorale = range(moraleModifier + Veh[vehID].morale, 0, 6)

Which in manual-speak would better read more like: "Units attacking or defending from the base square receive a +1 morale modifier. Additionally, negative morale modifiers are halved." The halving is actually truncating the result, not rounding, TIL.

This is how the math works out, but check me. I included canceling negative morale as the manual states for comparsion:

Code: [Select]
          No Riots                          Drone Riots
MORALE SE Modifier CC Halves+1 CC Cancels+1 Modifier-1 CC Halves+1 CC Cancels+1
-------------------------------------------------------------------------------
       -4       -3           0            1         -4          -1            1
       -3       -2           0            1         -3           0            1
       -2       -1           1            1         -2           0            1
       -1       -1           1            1         -2           0            1
        0        0           1            1         -1           1            1
        1        1           2            2          0           1            1
        2        1           2            2          0           1            1
        3        2           3            3          1           2            2
        4        3           4            4          2           3            3

Defending requires more thought due to both the positive MORALE bonuses and Soporific Gas Pods and I'm tired right now.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 19, 2020, 11:45:18 PM
I went over it again since I've been laid up all day with allergies and, well, it's really wacky. Ignoring the psi parts, this is a pseudocode version of morale_veh.

The variable that morale_veh calls "morale" I am calling "moraleModifier" because that is a better description of what it is during this function: a modifier that is then applied to the veh's intrinsic morale.

Code: [Select]
morale_veh() {
  moraleModifier = factionMORALESE // initialize modifier with direct MORALE SE value

  // changes the MORALE value into the actual -3 -2 -1 -1 0 1 1 2 3 modifier scale

  if (moraleModifier <= -2) {
    moraleModifier++
  } else if (moraleModifier >= 2) {
    moraleModifier--
  }

  // This is the unused Morale faction "rule" which can give flat morale bonuses
  // or negatives or give a limited immunity to negative modifiers... see below

  if (moraleRule < 0) {
    moraleModifier -= moraleRule
  }

  // Creche check.
  // None of this works as the manual says it does.
  // First, it checks the unit's HOME base for a Creche not the base square where it is.
  // Second, it halves then rounds towards zero (integer math?) the negative modifiers
  //  thus far AND NO OTHERS.
  if (homeBaseHasCreche && moraleModifier < 0) {
    moraleModifier /= 2
    // math examples: -3 / 2 = -1, 1 / 2 = 0
  }

  // if the Morale "rule" is positive, add that value to the modifier.

  if (moraleRule > 0) {
    moraleModifier += moraleRule
  }

  // The Morale "flag" is moraleRule == 0
  // If the flag is set and if at this point the modifier is less than 0, reset to 0.
  // This only gives immunity to MORALE SE modifiers or itself AND NO OTHERS.
  if (moraleFlag && moraleModifier < 0) {
    moraleModifier = 0
  }

  // BUGGED
  // Drone Riot check
  // If the unit's HOME base is rioting, -1 morale
  // AFAIK this is an undocumented effect of Drone Riots
  // The way morale_veh function is coded allows for disabling this effect
  // This is how it should work. The way it's written in the code is bugged.
  if (homeRioting) {
    moraleModifier--
  }

  // add the modifier to the intrinsic morale and return. Range makes sure the value is
  // between Very Green and Elite.
  morale = moraleModifier + Veh[vehID].morale;
  return range(morale, 0, 6);
}

Now just the conventional morale bits of...

Code: [Select]
get_basic_offense(){
  morale = morale_veh(attacker)
 
  if (attacker is in a base square) {
    // Another Creche check!
    // If THIS base has a Creche...
    if (baseHasCreche) {

      // Flat +1 morale increase.
      // Documented in manual except this time the check is in this base
      // not the attacker's home. Incoherent.
      // Note: This increase can go above the Elite bonus cap unless
      // the unit is artillery due to a check way below...
     
      morale++

      // BUGGED!!!
      // Drumroll please for the most frakked bug in Creche morale math...

      // If the attacker's MORALE SE is less than or equal to -2
      // Add 1, then subtract value from present morale.
      // Subtracting a negative number is ADDITIVE.
      // A faction with -4 MORALE SE will get a +3 bonus
      // to their attack on top of the +1 bonus from just having the Creche.

      if (attackerMORALESE <= -2) {
        attackerMORALESE++
      }
      morale -= attackerMORALESE //(+50% attack bonus at -4 MORALE)
    }
 
    // Special rules if the attacker is artillery and in a base.
    // I'm not sure if I read all of this right.
    if (artyCombat) {

      // Attacking artillery gets +1 morale if its MORALE SE is 2 or 3
      // This undoes the adjustment that creates the morale modifier scale from MORALE SE
      // Documented??

      if (factionMORALESE is either 2 or 3) {
        morale++
      }

      // Soporific gas pods help a defender if attacker is arty??
      // Soporific gas pods should only work when a unit is attacking, yes?
      if (defender has soporific gas pods) {
        morale--
      } else {
        // some more morale for artillery if firing from base?
        morale++
      }
    }
  } // End of in base condition

  // This range function makes sure artillery morale will never be lower than
  // Green or higher than Elite. Artillery will never benefit from the potentially
  // over 50% bonus that Creche's can provide while other units can.
  if (artyCombat again) {
    morale = range(morale, 1, 6)
  }
}
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 20, 2020, 04:56:27 AM
Great break down! I've almost finished say_morale() too which I think might help give some insight into the whole +/- display of morale as well.

I agree about moraleMod or something being a better way to describe variable. I'll just change ret value to range(Veh[vehID].morale + moraleMod, 0, 6) or something.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 20, 2020, 04:40:34 PM
Great break down! I've almost finished say_morale() too which I think might help give some insight into the whole +/- display of morale as well.

I agree about moraleMod or something being a better way to describe variable. I'll just change ret value to range(Veh[vehID].morale + moraleMod, 0, 6) or something.

Nice! I've started building a morale computer in Google Sheets but it's really rough right now. I want to be able to get all permutations of actual morale just by adjusting intrinsic veh and MORALE SE values.

The division between what adjustments are calculated in morale_veh versus get_basic_offense/defense is weird. A lot of judgment calls about the order of operations need to be made to untangle all of this. Did anybody know about the artillery special treatment??
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 20, 2020, 09:33:21 PM
Nice! I've started building a morale computer in Google Sheets but it's really rough right now. I want to be able to get all permutations of actual morale just by adjusting intrinsic veh and MORALE SE values.

Yeah, I think that will be helpful. The say_morale() should also help get a better idea what is visible to player and inconsistency with minus and pluses.

The division between what adjustments are calculated in morale_veh versus get_basic_offense/defense is weird. A lot of judgment calls about the order of operations need to be made to untangle all of this. Did anybody know about the artillery special treatment??

I forgot to add last night, I'm not 100% sure isArtyCombat is the correct name for that parameter. The other two I'm certain about: PSI and bombardment (missile or artillery). I think I thought at some point this was for pure artillery combat (vs one sided bombardment like missile or artillery hitting non-artillery unit). That's on my todo as part of clean up to identify true meaning.

Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 20, 2020, 10:23:58 PM
Nice! I've started building a morale computer in Google Sheets but it's really rough right now. I want to be able to get all permutations of actual morale just by adjusting intrinsic veh and MORALE SE values.


Yeah, I think that will be helpful. The say_morale() should also help get a better idea what is visible to player and inconsistency with minus and pluses.

The division between what adjustments are calculated in morale_veh versus get_basic_offense/defense is weird. A lot of judgment calls about the order of operations need to be made to untangle all of this. Did anybody know about the artillery special treatment??


I forgot to add last night, I'm not 100% sure isArtyCombat is the correct name for that parameter. The other two I'm certain about: PSI and bombardment (missile or artillery). I think I thought at some point this was for pure artillery combat (vs one sided bombardment like missile or artillery hitting non-artillery unit). That's on my todo as part of clean up to identify true meaning.




Ahh, ok, I missed your comment in the code regarding arty.

I've started to convert the advanced morale wiki page into a more organized and systematic treatment of what you've uncovered thus far. The probe team and native life code looked whole and consistent so I did a write up. The Creche and Brood Pit problems are too annoying to deal with right now. :D

http://alphacentauri2.info/wiki/Morale_(Advanced) (http://alphacentauri2.info/wiki/Morale_(Advanced))
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 22, 2020, 03:15:51 AM
Saw your latest Github push and I'm reading through say_morale now. It looks to me that the intention behind the + and - symbols were to be a visual hint of the effective morale of a unit should it actually enter combat next to its intrinsic morale and each symbol represented one unit of morale. But it's an awful system because only the least documented of all bonuses are given symbols while some others aren't. Positive MORALE SE bonuses on defense, for example. It also forgets the documented but unimplemented HQ defense. I did a quick Ctrl F search for "+" in the manual and didn't see any explanation.

https://github.com/b-casey/OpenSMACX/blob/4d9c8b8d4bb51ce2584fc5f2172e4f73ba14ecbc/src/veh.cpp#L61 (https://github.com/b-casey/OpenSMACX/blob/4d9c8b8d4bb51ce2584fc5f2172e4f73ba14ecbc/src/veh.cpp#L61)

So it starts the morale string with the morale rank or lifecycle.  ;b;

Combat units with a rioting home base get a (-) to represent its morale penalty and that's the only reason why the minus appears.  ;b;

If the unit is in a base that has a Creche/Pit, it then attempts to count a + for every morale upgrade it thinks the Creche is adding, I think. Sometimes it removes the riot (-) but other times it doesn't. What a mess. :doh

After some concatenation it adds a (d) if the unit is the designated defender. Never noticed that, and it's not morale-related!  ;q;

Not really sure what can be done. Do people like the (++++) and (-)(+++)? Can it be better? There isn't a lot of room down there next to words like Commando or Demon Boil.



I'm nearly done with my morale calculator. Right now this is what I'm thinking based on developer intentions and rationalizing confusing mechanics. Under this algorithm, a Creche does turn out to be powerful for a low MORALE faction but exclusively when put on the defensive in a base. For example, a Gaian unit (-1 MORALE, units start at Very Green) would defend a base with a Children's Creche at the effective level of Disciplined. But outside the base, it would revert to Very Green. A Spartan unit (+2 MORALE) would defend a Creched base at Veteran level. I wonder if AI Spartans have secretly suffered the most from the Creche bug since it would punish high morale.

Code: [Select]
math to determine the correct moraleSocialModifier value goes here. Need to do an adjustment to get the correct scale, and undo it on +2 and +3 MORALE when unit is defending. That is all default behavior.

int moraleModifier = moraleSocialModifier + moraleRuleModifier

if (inBaseWithCreche and moraleModifier < 0) { // Brood Pit logic needed here. Manual indicates Creche/Pit effects should be limited to base square.
  moraleModifier /= 2 // Rounds result towards 0. Manual says negs are cancelled but code consistently "halves" negs like this.
}
if (inBaseWithRiot) { // Undocumented AFAIK and poorly indicated. Easier to understand if it's in the base where the unit is.
  moraleModifier--
}
if (defending and soporificAttacker) { // Placed here due to rule flag, see below.
  moraleModifier -= 2
}
if (ruleflag and moraleModifier < 0) {
// Rule flag implies it's supposed to provide absolute immunity to negative morale modifiers.
// Not used by the game's default 14 factions so probably not worth a lot of debate.
  moraleModifier = 0
}
if (inBaseWithCreche) { // Manual indicates Creche/Pit effects should be limited to base square.
  moraleModifier++ // Flat +1 morale is in manual and current code.
}
if (defending and inBaseWithHQ) {
  // Documented but unimplemented. Would be cool.
  // Thinker now has auto-HQ relocation code for the AI so it might be a marginal buff for them.
  moraleModifier++
}

return range(vehMorale + moraleModifier, 0, 6)
[/font]
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 22, 2020, 05:52:03 PM
Ahh, ok, I missed your comment in the code regarding arty.

I've started to convert the advanced morale wiki page into a more organized and systematic treatment of what you've uncovered thus far. The probe team and native life code looked whole and consistent so I did a write up. The Creche and Brood Pit problems are too annoying to deal with right now. :D

http://alphacentauri2.info/wiki/Morale_(Advanced) (http://alphacentauri2.info/wiki/Morale_(Advanced))


No worries. That comment was more for myself too. I'm fairly certain now it's not artillery related. Possibly something to do with calculating a defender's offense or maybe duels (although this would be artillery related that I'm leaning against). I may have to wait until I finish battle_compute() and best_defender(), the two functions that call get_basic_offense(). Those both are doable at this stage. Will work on them after I finish vetting some of net new code. I'll likely change that param to a more generic name while I vet get_basic_offense().

Awesome work with updating wiki!

Saw your latest Github push and I'm reading through say_morale now. It looks to me that the intention behind the + and - symbols were to be a visual hint of the effective morale of a unit should it actually enter combat next to its intrinsic morale and each symbol represented one unit of morale. But it's an awful system because only the least documented of all bonuses are given symbols while some others aren't. Positive MORALE SE bonuses on defense, for example. It also forgets the documented but unimplemented HQ defense. I did a quick Ctrl F search for "+" in the manual and didn't see any explanation.

https://github.com/b-casey/OpenSMACX/blob/4d9c8b8d4bb51ce2584fc5f2172e4f73ba14ecbc/src/veh.cpp#L61 (https://github.com/b-casey/OpenSMACX/blob/4d9c8b8d4bb51ce2584fc5f2172e4f73ba14ecbc/src/veh.cpp#L61)

So it starts the morale string with the morale rank or lifecycle.  ;b;

Combat units with a rioting home base get a (-) to represent its morale penalty and that's the only reason why the minus appears.  ;b;

If the unit is in a base that has a Creche/Pit, it then attempts to count a + for every morale upgrade it thinks the Creche is adding, I think. Sometimes it removes the riot (-) but other times it doesn't. What a mess. :doh

After some concatenation it adds a (d) if the unit is the designated defender. Never noticed that, and it's not morale-related!  ;q;

Not really sure what can be done. Do people like the (++++) and (-)(+++)? Can it be better? There isn't a lot of room down there next to words like Commando or Demon Boil.

I'm nearly done with my morale calculator. Right now this is what I'm thinking based on developer intentions and rationalizing confusing mechanics. Under this algorithm, a Creche does turn out to be powerful for a low MORALE faction but exclusively when put on the defensive in a base. For example, a Gaian unit (-1 MORALE, units start at Very Green) would defend a base with a Children's Creche at the effective level of Disciplined. But outside the base, it would revert to Very Green. A Spartan unit (+2 MORALE) would defend a Creched base at Veteran level. I wonder if AI Spartans have secretly suffered the most from the Creche bug since it would punish high morale.
<snip>


Yeah, there is definitely some funky stuff with say_morale(). This is a pretty rough state draft. It will likely need some clean up so I'd hold off on using it as a definitive guide yet.

Sweet! I've finished going through and vetting the get_basic_defense() function in assembly. Caught one mistake on my end that slipped through automated tests. The other changes in the commit were to mirror original assembly (no logic changes) and minor formatting tweak for comment.

This is only line that changed from original logic, should be a 4 not a 0 to mirror original logic:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L388

Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 23, 2020, 11:31:40 PM
Finished reviewing and finalizing get_basic_offense() (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L283) and say_morale() (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L61). No real changes to get_basic_offense, logic mirrors original code. I just changed the one parameter to a more generic var name to reduce confusion until it can be identified. There were some problems with say_morale that I've corrected along with code clean up. I'll see if I can find any other morale related functions related to CC/BP bugs. Otherwise, now it's just a matter of finalizing and applying bug fixes.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 24, 2020, 12:54:01 AM
Was in the middle of typing up a reply when you replied so I hope everything I said is still relevant. I think I updated all the line numbers to their correct ones in the latest push.

Awesome work with updating wiki!

Thanks! It has been helpful during my latest SMAC phase so I like to give back.

Yeah, there is definitely some funky stuff with say_morale(). This is a pretty rough state draft. It will likely need some clean up so I'd hold off on using it as a definitive guide yet.

Sweet! I've finished going through and vetting the get_basic_defense() function in assembly. Caught one mistake on my end that slipped through automated tests. The other changes in the commit were to mirror original assembly (no logic changes) and minor formatting tweak for comment.

This is only line that changed from original logic, should be a 4 not a 0 to mirror original logic:
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L388

I realized that I'd dox myself by sharing my Google Sheet which I'm not eager to do! I'll think of something...

Couple more observations and questions:

Not only is this Brood Pit check never reached, it's also superfluous. MORALE SE doesn't affect lifecycles so there are no penalties to reverse.

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L2042 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L2042)

Wait, why did they actually stack the flat +1 morale bonus from the Brood Pit with the same one from the Creche??

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L297 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L297)

Speaking of, why does the Brood Pit (or the Children's Creche for that matter) let low MORALE SE ratings affect lifecycles?

get_basic_offense: https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L307 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L307)
get_basic_defense: https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L376 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L376)

What does this logic mean in get_basic_defense? Does it mean defending a base from wild native life gives the defender an additional +1 morale?

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L386 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L386)

Do you know where the High Morale ability (ABL_TRAINED) is accounted for? I'd expect it where I linked below but the only reference to ABL_TRAINED I found is in veh.h.

https://github.com/b-casey/OpenSMACX/blob/master/src/base.cpp#L565 (https://github.com/b-casey/OpenSMACX/blob/master/src/base.cpp#L565)

Finished reviewing and finalizing get_basic_offense() (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L283) and say_morale() (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L61). No real changes to get_basic_offense, logic mirrors original code. I just changed the one parameter to a more generic var name to reduce confusion until it can be identified. There were some problems with say_morale that I've corrected along with code clean up. I'll see if I can find any other morale related functions related to CC/BP bugs. Otherwise, now it's just a matter of finalizing and applying bug fixes.

1) The drone riot prematurely ranging moraleModifier in morale_veh was a big one and you fixed it.

2) Another big problem is this math in both get_basic_offense and get_basic_defense that leads to enormous bonuses at low MORALE rates:

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L296 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L296)
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L311 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L311)
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L365 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L365)
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L380 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L380)

moraleSEActive can only be -1, -2, or -3 at that line, therefore 1, 2, or 3 levels will be added to morale. An elite unit under -4 MORALE attacking from a Creche base will have an effective morale of 7 (see below for range issue). An elite unit under +4 MORALE would be demoted to Disciplined in the same circumstance. Even changing it to += would not make that math make sense if my calculations are correct.

3) There is also the issue of the morale value in get_basic_offense not being ranged, leading to morale attack bonuses in excess of 50%. Morale is ranged in get_basic_defense, though, so that suggests an oversight:

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L396 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L396)


Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 24, 2020, 01:18:08 AM
I realized that I'd dox myself by sharing my Google Sheet which I'm not eager to do! I'll think of something...
I think you can export as an Excel doc from Google Sheets. You might want to check what type of metadata is stored on exported file (ex. gmail account as owner/creator).

Not only is this Brood Pit check never reached, it's also superfluous. MORALE SE doesn't affect lifecycles so there are no penalties to reverse.

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L2042 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L2042)

Gotcha, that makes sense. That code was probably left in because it doesn't really affect anything.

What does this logic mean in get_basic_defense? Does it mean defending a base from wild native life gives the defender an additional +1 morale?

https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L386 (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L386)
Correct. The 0 indexed faction is AI native life.

Do you know where the High Morale ability (ABL_TRAINED) is accounted for? I'd expect it where I linked below but the only reference to ABL_TRAINED I found is in veh.h.

https://github.com/b-casey/OpenSMACX/blob/master/src/base.cpp#L565 (https://github.com/b-casey/OpenSMACX/blob/master/src/base.cpp#L565)
It looks like it directly adds to the Veh.morale value when one of upgrade functions is called. Here are references:
(https://i.imgur.com/RLzhE1O.png)
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 26, 2020, 03:27:01 PM
I think you can export as an Excel doc from Google Sheets. You might want to check what type of metadata is stored on exported file (ex. gmail account as owner/creator).

I'll have access to Excel next week and will check if my exported file has any metadata or issues with the formatting. It got complicated as you'll see in my screenshot. I have an as-is calculator (including your riot zeroing out bug fix), an in progress "minimal" change model, and a simplified model. So far my impression of a "minimal" change is that it still outputs weird results. I have to double and triple check all my =IF() chains for mistakes. When I started I almost wrote it in Python but I thought a spreadsheet would have been simpler... oops.

Thanks for the Trained info. I wanted to make sure it wasn't subject to some odd Creche/Pit effect.

Haven't looked further at say_morale yet because it gives me a headache.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on September 28, 2020, 03:28:41 AM
I've pushed one of the main combat related functions that is used to calculate bonuses and penalties: battle_compute() (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L501). It's also the 21st largest function in the game, mostly due to inline optimizations of add_bat() everywhere. Use this as a rough guide, there are definitely issues with code due to length and complexity. I haven't put it through regression tests yet. The only bug fix I have for this function is related to attacking along roads (will be inserted here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L672)).

So I'm split on what the last parameter of get_basic_offense() is used for. You can see here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L914) that it's used to calculate offense of defending unit. This code path is called when combatType 2 bit flag is set (otherwise this (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L617) gets called). That bit is set when both units are artillery or certain sea/air combat situations. I think this is either a toggle to calculate offense of a defender or to signal artillery duel.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on September 30, 2020, 09:25:58 PM
I'm attaching my morale calculating spreadsheet. Ignore the last sheet because that was my first draft. I had the boolean options rendered quite nicely as checkboxes in Google Sheets but that didn't survive the export, oh well.

The first sheet is the algorithm as-is but including the riot fix.

The second sheet is the same algorithm with a few changed or tweaked parts addressing the most obvious bugs or mistakes in the math. I haven't iterated through all the combinations here. It might still spit out odd values.

The third sheet was just an example idea that tries to interpret the various sources of information into a coherent calculation.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on October 01, 2020, 05:07:09 AM
Nice break down! I'm just wrapping up testing some of other functions. Will see about proposing some code fixes this weekend.
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: scient on October 05, 2020, 02:45:36 AM
So I've been looking over everything, still haven't figured the best way to handle the SE morale. However, two simple fixes would be BP/CC double bonus and defending HQ.

Removing the double Brood Pit bonus when Children’s Creche is present is simple. I think it's pretty clear from manual and in game text files it should be an either/or situation. This is done by removing the following code segments:
From here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L416) to here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L420) and from here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L347) to here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L351).

For +1 in defending HQ, you could insert above here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L432) the following code:
Code: [Select]
if (has_fac_built(FAC_HEADQUARTERS, baseIDDef)) { // bug fix: per manual
morale++; // "Units in a headquarters base automatically gain +1 Morale when defending."
}
Title: Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
Post by: EmpathCrawler on October 05, 2020, 10:41:17 PM
So I've been looking over everything, still haven't figured the best way to handle the SE morale. However, two simple fixes would be BP/CC double bonus and defending HQ.

Removing the double Brood Pit bonus when Children’s Creche is present is simple. I think it's pretty clear from manual and in game text files it should be an either/or situation. This is done by removing the following code segments:
From here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L416) to here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L420) and from here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L347) to here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L351).

For +1 in defending HQ, you could insert above here (https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L432) the following code:
Code: [Select]
if (has_fac_built(FAC_HEADQUARTERS, baseIDDef)) { // bug fix: per manual
morale++; // "Units in a headquarters base automatically gain +1 Morale when defending."
}

Nice, that is all the lowest hanging fruit. The HQ bonus would have been really helpful for an AI Morgan I just wormed to death in my latest game.

As for the rest, I see these as the major contradictions that could make the math a lot easier if addressed:

1) The Creche MORALE-based adjustment, but not the Pit one, is doubly applied to conventional units if that unit is both homed in a Creched base and defending/sortieing from a Creched base. First in morale_veh, then in get_basic_offense/get_basic_defense. Why? Everything says that the Children's Creche effect is on units in the base square with no mention of the home base.

1b) Why does the Creche and Pit affect worms based on MORALE, anyway? You quoted helpx earlier saying the Brood Pit canceled lifecycle penalties, but there aren't any nor does MORALE affect lifecycle. Maybe whoever added the Brood Pit code didn't know that?

2) The Creche math is really wacky. What were they trying to do? I tried to make it simpler with no surprises in my sheet. Maybe it would make more sense without the duplication of effects, but I didn't model that yet.

3) The manual says that the Creche cancels all negative morale modifiers, but that is not true. It doesn't affect the (undocumented) home drone riot penalty or Soporific Gas Pods. Should it?
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 31 - 840KB. (show)
Queries used: 15.

[Show Queries]