Jump to content


Morale, Morale Break & Fatigue


  • Please log in to reply
8 replies to this topic

#1 -Demivrgvs-

-Demivrgvs-
  • Guest

Posted 28 September 2012 - 01:25 PM

I'm sorry for resurrecting something I posted on G3 some time ago, but I got no reply there, and I hope the god-of-BGexe have some insight on this matter or can easily check it.

Quoting myself: "Does anyone knows exactly how these stats work?

More precisely:
- Which actions/effects lowers the 'morale' stat?
- why setting 'morale break' to 1 completely prevents morale failure?
- Is there any way to inc/dec 'morale' and 'morale recovery' outside of scripts?

- Which actions/effects increases the 'fatigue' stat?
- Should I assume that resting automatically sets 'fatigue' stat to 0?
- Does fatigue really work as negative luck effect? Aka, does it affect morale too? What about luck's -x dmg per die effect?

Thanks
Demi"

#2 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 28 September 2012 - 04:08 PM

Here is a brief morale rundown in code that checks every tick whether to PANIC!!
BOOL CCreatureObject::IsMoraleIntact() {
  limit m_BaseStats.morale {0,20};
  if (moraleRecovery == 0) m_BaseStats.morale = 10;
  if (STONE_DEATH) m_BaseStats.morale = 10;
  if (moraleRecovery != 0 &&
	 m_nTimeFree % (moraleRecovery * TICKS_PER_SECOND) == 0) {
	   //moraleRecovery (0-UINT_MAX): how many seconds to adjust base morale
	   if (m_BaseStats.morale > 10) m_BaseStats.morale--;
	   if (m_BaseStats.morale > 10) {
		 m_BaseStats.morale--;
	   } else if (m_BaseStats.morale < 10) {
		 m_BaseStats.morale++;
	   }
	   //morale (0-20): the actual morale, gravitates towards the value of 10
	   //morale is incremented by -1 (reduced) on processing of Died() trigger
	   //Effect #23 (as in bard song) sets morale to 10
	   //Effect #130 (Bless) adds nParam1 to morale (and other things)
  }

  if (!IsCurrentActionInterruptible()) return TRUE;
  if (m_BaseStats.morale > moraleBreak ||
	 moraleBreak == 0) return TRUE;
	 //moraleBreak (0-20): the point at which morale breaks
	 //Effect #106 sets the morale breaking point
	
  return FALSE;
} //if FALSE, the creature goes into morale failure

I haven't tested this in-game. Theoretically you can set the morale break to 10 or above, and your character/creature will always panic!
There are probably other things other than the above comments that affect morale; I haven't discovered them yet if they do.
Setting moraleBreak to 1 mostly but shouldn't completely prevent morale failure, since getting a morale of 1 will cause break. It is probably very unlikely that you get this though, since only so many party members can die at once. You can try this though with repetitive Ctrl-Y and Ctrl-R - Khalid seems to break down like this a lot. :)

I haven't gone much into fatigue, but will have a look.

Edited by Ascension64, 28 September 2012 - 04:12 PM.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#3 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 28 September 2012 - 05:41 PM

Now on to fatigue in pseudocode:
void CCreatureObject::CheckFatigue() {
  if (!party member) return;
  if (!my turn to check) return;

  //fatigue level increments by 1 every 4 hours
  //adjust for constitution bonus to fatigue
  nFatigueLevel = nGameTime - nTicksLastRested / 4 hours; //4 * 5 * 60 * 15
  nFatigueBonus = GetFatigueBonus(constitution);
  nFatigueLevel = nFatigueLevel - nFatigueBonus >= 0 ? nFatigueLevel - nFatigueBonus : 0;

  if (nFatigueLevel > m_BaseStats.fatigue) {
    ApplyEffect(EFFECT_FATIGUE_MOD, nParam1 = nFatigueLevel, nParam2 = 1); //modifies the m_BaseStats.fatigue
    nLuckMod = GetFatigueLuckModifier(column = 0, row = nFatigueLevel); //FATIGMOD.2DA
    cdsCurrent.luck += nLuckMod;
    //if a luck modifier applies, then the game tells the player this
    if (nLuckMod) {
	  Display portrait icon(0x27); //ICON_FATIGUE
	  Print event message("Fatigued");
    }
    if (nFatigueLevel > 6) {
	  Play soundset(TIRED);
    }
  } else if {nFatigueLevel < m_BaseStats.fatigue) {
    //if someone changed nFatigueLevel, or loading a game, resets
    nFatigueLevel = m_BaseStats.fatigue;
    nTicksLastRested = nGameTime - 4 hours * nFatigueLevel; //4 * 5 * 60 * 15
    if (nFatigueLevel > 6) {
	  Play soundset(TIRED);
    }
  }
 
  return;
}

Effect #93 modifies fatigue (it looks like only permanent timings work, since the derived fatigue stat doesn't seem to be used - though I haven't extensively looked at this).
The fatigue depends on the game time and when the player last rested. This is re-calculated every time. The effect of increasing fatigue is seen above in the code; it applies luck change and then modifies the base stats fatigue.
If you load a game, and the time last rested isn't set yet, the game uses the base stats fatigue to re-calculate this. I guess modders can use this by making an effect that increases the base stats fatigue, which the game will adjust the time last rested.

If you try to decrease the base stats fatigue level, nothing happens.

The effect of fatigue, is thus, a semi-closed feature, and changes the luck modifier, which in turn affects all things that luck affects normally.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#4 -Demivrgvs-

-Demivrgvs-
  • Guest

Posted 29 September 2012 - 05:17 AM

Thanks A64! I knew you could help me!

So, let's see if I've understood everything.

Morale & Break Morale
- Morale value is the current morale lvl of the character. The one displayed by the cre file is the base one (e.g. most characters has 10), to which it automatically return depending on the recovery rate (generally 1 point is recovered every 60 seconds).
- the only things which currently lowers Morale are -1 for each died party member, +1 from Bless/Chant and -1 from Bad Chant (what about luck opcode?)
- the only opcodes which would allow me to directly mess with Morale are Bless and Bad Chant, because opcode 23 only reset the default value (*)

- When Morale is < Morale Break the character panics (e.g. Minsc and Yoshi have morale break 2 and 5 respectively, which means that even under the negative effects of Chant Minsc will never panic because with 4 died party members he would still have Morale 5, Yoshi instead panics)
- Break Morale value can be easily messed with via opcode 106, allowing me to alter the value with items, spells or abilities

(*) Well, at first sight I thought this was a huge problem, but if I wanted an ability to lowers target morale by 1 I can instead raise its Morale Break by 1 achieving pretty much the same result. Am I correct? :)

Fatigue
- characters gain -1 fatigue every 4 hours, does that mean every 1200 real seconds?
- with vanilla's tables characters start to gain penalties at fatigue 7, thus after 8400 sec, aka 140 minutes of real time
- regardless of how I tweak fatigmod.2da characters the trigger for fatigue icon and sound is at fatigue 7, correct?
- I can increase (cause fatigue), but I cannot decrease ("cure" fatigue) nor set the current fatigue level via opcode 93, correct? :(

#5 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 29 September 2012 - 04:09 PM

Morale & Break Morale

You pretty much have it.

- the only things which currently lowers Morale are -1 for each died party member, +1 from Bless/Chant and -1 from Bad Chant (what about luck opcode?)

Luck only changes luck, not morale. There may be other things that change it, but they are the only ones I know about at the moment. I don't think Chant and Bad Chant affect morale at all. They do affect luck though, and set the relevant state flags.

- the only opcodes which would allow me to directly mess with Morale are Bless and Bad Chant, because opcode 23 only reset the default value (*)

You can change morale break or use bless.

- When Morale is < Morale Break the character panics (e.g. Minsc and Yoshi have morale break 2 and 5 respectively, which means that even under the negative effects of Chant Minsc will never panic because with 4 died party members he would still have Morale 5, Yoshi instead panics)

Slight correction, when morale <= morale break.

(*) Well, at first sight I thought this was a huge problem, but if I wanted an ability to lowers target morale by 1 I can instead raise its Morale Break by 1 achieving pretty much the same result. Am I correct? :)

Yes.

Fatigue

- characters gain -1 fatigue every 4 hours, does that mean every 1200 real seconds?

5 minutes per hour, 60 seconds a minute. So, yes, 4 x 5 x 60 = 1200 seconds. Also, think of fatigue level as something that goes up, not down like AC and THAC0. So +1 fatigue level every 4 hours (20 min game time).

- regardless of how I tweak fatigmod.2da characters the trigger for fatigue icon and sound is at fatigue 7, correct?

Rather it is just the sound that is faigmod.2da independent. The icon and the dialogue message are dependent on whether a luck mod is applicable. Hence, for example, if you want give a fatigue bonus

- I can increase (cause fatigue), but I cannot decrease ("cure" fatigue) nor set the current fatigue level via opcode 93, correct? :(

Setting the fatigue level might work just the once, until the game decides that the affected creature needs a fatigue check again (which might not be very long at all, possibly a matter of ticks rather than seconds).

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#6 -Demivrgvs-

-Demivrgvs-
  • Guest

Posted 29 September 2012 - 11:46 PM

Morale & Morale Break
Case closed. :)

Fatigue

- I can increase (cause fatigue), but I cannot decrease ("cure" fatigue) nor set the current fatigue level via opcode 93, correct? :(

Setting the fatigue level might work just the once, until the game decides that the affected creature needs a fatigue check again (which might not be very long at all, possibly a matter of ticks rather than seconds).

Sorry to bother, but assuming I'd like to create a "cure fatigue" effect does your statement mean that:
- if I make such effect set fatigue to 0 on a character with fatigue 6 the next time fatigue is checked the fatigue is again 7
or
- if I make such effect set fatigue to 0 on a character with fatigue 6 the next time fatigue is checked the fatigue is 1, but it may be 1 second after the cure because the "time trigger" is not resetted

#7 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 30 September 2012 - 12:31 AM

Sorry to bother, but assuming I'd like to create a "cure fatigue" effect does your statement mean that:
- if I make such effect set fatigue to 0 on a character with fatigue 6 the next time fatigue is checked the fatigue is again 7
or
- if I make such effect set fatigue to 0 on a character with fatigue 6 the next time fatigue is checked the fatigue is 1, but it may be 1 second after the cure because the "time trigger" is not resetted

No bother for clarifying.
-Current fatigue level is 6, base stats fatigue set to 6
-You set base stats fatigue to 0; it stays like this until the next time the engine checks
-Next time engine checks, it calculates fatigue level to be 7 (as this is based on the time last rested)
-Base stats fatigue set to 7

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#8 -Demivrgvs-

-Demivrgvs-
  • Guest

Posted 30 September 2012 - 12:57 AM

Fatigue

Sorry to bother, but assuming I'd like to create a "cure fatigue" effect does your statement mean that:
- if I make such effect set fatigue to 0 on a character with fatigue 6 the next time fatigue is checked the fatigue is again 7
or
- if I make such effect set fatigue to 0 on a character with fatigue 6 the next time fatigue is checked the fatigue is 1, but it may be 1 second after the cure because the "time trigger" is not resetted

No bother for clarifying.
-Current fatigue level is 6, base stats fatigue set to 6
-You set base stats fatigue to 0; it stays like this until the next time the engine checks
-Next time engine checks, it calculates fatigue level to be 7 (as this is based on the time last rested)
-Base stats fatigue set to 7

Short story: no "cure fatigue" effect can be achieved. :(

Last but not least, which are the actual effects applied by fatigue? Afaik luck was supposed to give/cause many things, but in the end it was just +/- attack/dmg roll, plus the +/- dmg/dice against damage dealing spells. Do you confirm these are the only effects applied by fatigue/luck? :(

#9 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 30 September 2012 - 06:36 AM

Only luck modifier is applied, which affects all kinds of things - can't remember off the top of my head.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)