Author Topic: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche  (Read 4451 times)

0 Members and 1 Guest are viewing this topic.

Offline bvanevery

  • Emperor of the Tanks
  • Thinker
  • *
  • Posts: 6370
  • €659
  • View Inventory
  • Send /Gift
  • Allows access to AC2's quiz & chess sections for 144 hours from time of use.  You can't do without Leadship  Must. have. caffeine. -Ahhhhh; good.  Premium environmentally-responsible coffee, grown with love and care by Gaian experts.  
  • Planning for the next 20 years of SMACX.
  • AC2 Hall Of Fame AC Text modder Author of at least one AAR
    • View Profile
    • Awards
Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #15 on: September 18, 2020, 05:14:59 AM »
Yes, it's in the Datalinks under "Basic Concepts.. Landmarks, Volcanoes, Etc."

Offline scient

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #16 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.



Offline EmpathCrawler

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #17 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.
« Last Edit: September 18, 2020, 10:12:44 PM by EmpathCrawler »

Offline EmpathCrawler

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #18 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)
  }
}

Offline scient

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #19 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.

Offline EmpathCrawler

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #20 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??

Offline scient

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #21 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.


Offline EmpathCrawler

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #22 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)

Offline EmpathCrawler

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #23 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

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]

Offline scient

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #24 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)


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

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


Offline scient

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #25 on: September 23, 2020, 11:31:40 PM »
Finished reviewing and finalizing get_basic_offense() and say_morale(). 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.

Offline EmpathCrawler

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #26 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

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

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
get_basic_defense: 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

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

Finished reviewing and finalizing get_basic_offense() and say_morale(). 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#L311
https://github.com/b-casey/OpenSMACX/blob/master/src/veh.cpp#L365
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



Offline scient

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #27 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

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
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
It looks like it directly adds to the Veh.morale value when one of upgrade functions is called. Here are references:

Offline EmpathCrawler

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #28 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.

Offline scient

Re: Brood Pit's attacking-from-base morale bonus stacks with Children's Creche
« Reply #29 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(). 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).

So I'm split on what the last parameter of get_basic_offense() is used for. You can see here that it's used to calculate offense of defending unit. This code path is called when combatType 2 bit flag is set (otherwise this 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.

 

* User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

* Community poll

SMAC v.4 SMAX v.2 (or previous versions)
-=-
24 (7%)
XP Compatibility patch
-=-
9 (2%)
Gog version for Windows
-=-
103 (32%)
Scient (unofficial) patch
-=-
40 (12%)
Kyrub's latest patch
-=-
14 (4%)
Yitzi's latest patch
-=-
89 (28%)
AC for Mac
-=-
3 (0%)
AC for Linux
-=-
6 (1%)
Gog version for Mac
-=-
10 (3%)
No patch
-=-
16 (5%)
Total Members Voted: 314
AC2 Wiki Logo
-click pic for wik-

* Random quote

It will happen, and it will happen in our lifetimes. Fusion Power isn't just the future. Fusion Power is now.
~ T. M. Morgan-Reilly, Morgan Metagenics

* Select your theme

*
Templates: 5: index (default), PortaMx/Mainindex (default), PortaMx/Frames (default), Display (default), GenericControls (default).
Sub templates: 8: init, html_above, body_above, portamx_above, main, portamx_below, body_below, html_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 45 - 1228KB. (show)
Queries used: 39.

[Show Queries]