DDR cf_preparesbattle #203
-
Hi Chris, I'm trying to understand the purpose behind cf_preparesbattle. My understanding is that it gets set upon entering battle, and gets reset once no foes are left in the location at the end of the nights battles. Then it is only used by the frontend to give battle related text. One potential anomaly I've come across is that cf_preparesbattle gets reset unconditionally as part of StartDawn, but then also conditionally at the end of the Night processing as well; this makes me think that it perhaps shouldn't get reset as part of StartDawn ? The-Lords-Of-Midnight/main/midnight/src/tme/scenarios/ddr/ddr_character.cpp Lines 1360 to 1370 in f0242bb |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The character has two battles flags that cover being in battle - cf_preparesbattle and cf_inbattle cf_preparesbattle is set when the player moves a character in to battle with CMD_Attack or on a failed CMD_Approach. It is purely there for the UI to show "Prepares to do battle on the UI screen, and this is a one off deal. Essentially as soon as night processing starts the flag is reset ( ie: StartDawn - ( think StartNightProcessing to be more accurate ) from that point on the lord will likely move to cf_inbattle. Resetting cf_preparesbattle anywhere else other than StartDawn is probably superfluous because it can't get set again. I suspect that I reset it as belt and braces at some point. As you can see line 107 used to reset cf_inbattle so I probably reset both, but sometime later I removed the cf_inbattle for some reason. I should have likely just deleted the lines. cf_inbattle is used to check if certain things can happen during night processing etc, and will be reset at the start of every night processing cycle or when a character leaves a location. |
Beta Was this translation helpful? Give feedback.
-
Just want to be sure about this, as the code goes to some length to recheck whether any foes remain in the location at the end of the night, before resetting cf_preparesbattle. It's almost as if it is trying to leave cf_preparesbattle on at the end of the Night processing, so that if the character is still with foes, then perhaps the UI continues to show "Prepares to do battle..." the next morning ? In which case perhaps cf_preparesbattle should not be getting reset unconditionally on StartDawn ? |
Beta Was this translation helpful? Give feedback.
Ok, checked this over in the original code and you are correct but it's much more straightforward than this. The code that prints the "prepares to do battle" text used in CheckPlace - checks the number of enemies at the location. So from the moment a lord moves in to battle via Attack or Approach, they will see this message. And they will see it for as long as the lord is in a location with an enemy.
I've obviously tried to simplify it to a flag so the GetInfo didn't need to be called, probably when merging LoM and DDR. I will alter this flag for mine. It affects this call from the UI.
It needs to be set as part of CMD_Attack / _Approach, and be set/reset at the end of the characters batt…