I'm not sure what scient is saying as I never got into anything that advanced, but I always assumed they simply took the combat morale stat used in BG and stripped combat effects from it intending to use it for dialog only, but forgot to remove the reset. There is a value in the CHR files that supposedly determines how quickly morale resets (it is the "morale recovery" field in Near Infinity), though I can't remember if it works.
http://www.idi.ntnu....i/download.html
One warning... In my evil play through of the game, where Dak'kon would have had low Morale, I removed him from the party at one point and he turned red and hostile/ran away. He turned to normal after resting.

Dak'kon's Zerth Blade
Started by
-Guest-
, Aug 02 2008 07:20 AM
22 replies to this topic
#21
--Platter--
Posted 27 August 2008 - 03:13 PM
#22
Posted 27 August 2008 - 04:42 PM
Hey Platter, just want to say thanks for time and effort you've put into sorting out various bugs.
You are correct that for PC's (anyone who can join party) morale is not used in combat. Majority of morale checks see whether or not the creature obj file has NPC/PC flag set, and if its PC they skip over it. PC's that are not part of group are considered NPC's which was a source of many headaches when I was coming up with a solution.
The only place morale is used for PC's are script action/trigger functions, when Dak levels up, and a reset on RestParty() or 8 game hours. In vanilla game, reset was to 10 which would break Dak's quest without some metagaming. There was also a bug in script action functions (and else where in morale code) where if morale fell below 0, it would roll over to 20. Someone messed up sign check big time. I guess they figured that morale was always going to be ~10.
For NPC's, there are specific functions which deal with how they lose morale when taking damage as well as how they regain it. There is a check if morale recovery time is 0 (Ravel and other high level NPC's) and if so in vanilla game set it to 10 and exits out. This would prevent them from having their morale broken.
Further down if recovery time is not zero (most have 60), there is a check whether enough game time has pasted to meet 60 RT seconds (I think it's RT). If so, it compared current morale to 10 and then either add/sub one in the direction of 10. This allowed NPC's to gradually regain morale and break out of flee mode. Then at very end is a check comparing current morale to morale breaking point, which for most is 5. If it is less than or equal to this value, NPC turns yellow and runs for his/her life.
If you are interested I put up a changelog in thread for next release of FixPack of how I sorted it:
http://www.shsforums...showtopic=35981
Eventually, at some point I'm going to post my notes about what sections of code in exe do what and interesting areas to look at.
edit:
Most likely you got Dak's morale below 5 so as soon as he left party he became a NPC. Now since the NPC flag is set, he is following NPC rules for morale. Since his breaking point is 5 and he is now a NPC, he failed this check and thus turned hostile/yellow. After resting (RestParty) his morale got reset to 10 which allowed him to become normal again. I tried to do the same thing with Morte (set his morale to 0) but for some reason he wasn't being passed to morale check function. I'll have to do some more checking to see if I can reproduce this and come up with a solution either way. That would be bad if Dak morale got down below 5 (which is possible) and he got stuck in perma flee mode. This may be possible by setting PC's morale breaking point to -1 so they will never break but I'm going to see if I can come up with a better solution.
edit edit edit:
Ignore my last comments. My cheatbook wasn't setting my PC's morale to zero for some reason. I guess when you restructure party player# don't get updated. The problem with NPC'ed PC's who had their morale altered below 6 going into flee mode happens for all PC's. I think it is only possible to get Dak morale down that low without cheating. Regardless, I'll think of a solution. Again, thank you for pointing this out. I spent so much time trying to think of ways that morale system might mess up but I never thought of it working too well. Sigh.
You are correct that for PC's (anyone who can join party) morale is not used in combat. Majority of morale checks see whether or not the creature obj file has NPC/PC flag set, and if its PC they skip over it. PC's that are not part of group are considered NPC's which was a source of many headaches when I was coming up with a solution.
The only place morale is used for PC's are script action/trigger functions, when Dak levels up, and a reset on RestParty() or 8 game hours. In vanilla game, reset was to 10 which would break Dak's quest without some metagaming. There was also a bug in script action functions (and else where in morale code) where if morale fell below 0, it would roll over to 20. Someone messed up sign check big time. I guess they figured that morale was always going to be ~10.
For NPC's, there are specific functions which deal with how they lose morale when taking damage as well as how they regain it. There is a check if morale recovery time is 0 (Ravel and other high level NPC's) and if so in vanilla game set it to 10 and exits out. This would prevent them from having their morale broken.
Further down if recovery time is not zero (most have 60), there is a check whether enough game time has pasted to meet 60 RT seconds (I think it's RT). If so, it compared current morale to 10 and then either add/sub one in the direction of 10. This allowed NPC's to gradually regain morale and break out of flee mode. Then at very end is a check comparing current morale to morale breaking point, which for most is 5. If it is less than or equal to this value, NPC turns yellow and runs for his/her life.
If you are interested I put up a changelog in thread for next release of FixPack of how I sorted it:
http://www.shsforums...showtopic=35981
Eventually, at some point I'm going to post my notes about what sections of code in exe do what and interesting areas to look at.
edit:
Most likely you got Dak's morale below 5 so as soon as he left party he became a NPC. Now since the NPC flag is set, he is following NPC rules for morale. Since his breaking point is 5 and he is now a NPC, he failed this check and thus turned hostile/yellow. After resting (RestParty) his morale got reset to 10 which allowed him to become normal again. I tried to do the same thing with Morte (set his morale to 0) but for some reason he wasn't being passed to morale check function. I'll have to do some more checking to see if I can reproduce this and come up with a solution either way. That would be bad if Dak morale got down below 5 (which is possible) and he got stuck in perma flee mode. This may be possible by setting PC's morale breaking point to -1 so they will never break but I'm going to see if I can come up with a better solution.
edit edit edit:
Ignore my last comments. My cheatbook wasn't setting my PC's morale to zero for some reason. I guess when you restructure party player# don't get updated. The problem with NPC'ed PC's who had their morale altered below 6 going into flee mode happens for all PC's. I think it is only possible to get Dak morale down that low without cheating. Regardless, I'll think of a solution. Again, thank you for pointing this out. I spent so much time trying to think of ways that morale system might mess up but I never thought of it working too well. Sigh.
Edited by scient, 27 August 2008 - 07:35 PM.
Those interested in the classic TBS game Sid Meier's Alpha Centauri / Alien Crossover should check out the unofficial patch I work on here.
#23
Posted 27 August 2008 - 09:54 PM
Actually, I came up with an easy way to identify NPC'ed PC's from standard NPC's. This bug where PC's booted from group with low morale could go into flee mode is completely sorted. There is a function used in lots of places to get the id number of PC. The same function is used to check if PC leveling up is Dak so it knows to access sword upgrade code or not. All it needs is the current NPC/PC name. If it is one of the 7 joinable PC's or TNO, it returns 0-7. Otherwise it returns -1. This may be a script function, I dunno.
Now that I've got an easy way to tell if a NPC is a PC, I'm going to revise / roll back some of my morale patches that were solely to prevent bugs when PC was a NPC.
edit:
Revised morale system to prevent this bug as well as made it more efficient. See stickied thread for details.
Now that I've got an easy way to tell if a NPC is a PC, I'm going to revise / roll back some of my morale patches that were solely to prevent bugs when PC was a NPC.
edit:
Revised morale system to prevent this bug as well as made it more efficient. See stickied thread for details.
Edited by scient, 28 August 2008 - 11:49 AM.
Those interested in the classic TBS game Sid Meier's Alpha Centauri / Alien Crossover should check out the unofficial patch I work on here.