Loot wagon conflict with diplomacy gift caravan, and extremely low castle income

Users who are viewing this thread

TheMageLord

The Handyman Can
Knight at Arms
I noticed the loot wagons bug out once you get a chancellor. Checking the source, I found that dplmc_spt_gift_caravan and spt_player_loot_wagon are both set to the same thing: 21. This makes the diplomacy code take over for loot wagons as soon as you have a chancellor, which deletes the wagon when it hits a center and acts like it was a gift caravan.

I also noticed that the code for calculating rent for castles has:
(party_slot_eq, ":center_no", slot_party_type, spt_castle),
(assign, ":cur_rents", -250),

Is that assign supposed to be there? What that effectively does is completely erase all the calculations for castle rents and just sets it to -250 if it's a castle, then having a blacksmith adds 50 making it 200. The actual rent ingame on my castle seemed to perpetually be 200, I didn't bother checking how the code got there but I guess it must be taking the -200 as a positive (which meant me building the blacksmith probably cut my income, lol).
 
TheMageLord said:
I noticed the loot wagons bug out once you get a chancellor. Checking the source, I found that dplmc_spt_gift_caravan and spt_player_loot_wagon are both set to the same thing: 21. This makes the diplomacy code take over for loot wagons as soon as you have a chancellor, which deletes the wagon when it hits a center and acts like it was a gift caravan.

I also noticed that the code for calculating rent for castles has:
(party_slot_eq, ":center_no", slot_party_type, spt_castle),
(assign, ":cur_rents", -250),

Is that assign supposed to be there? What that effectively does is completely erase all the calculations for castle rents and just sets it to -250 if it's a castle, then having a blacksmith adds 50 making it 200. The actual rent ingame on my castle seemed to perpetually be 200, I didn't bother checking how the code got there but I guess it must be taking the -200 as a positive (which meant me building the blacksmith probably cut my income, lol).

Caravan - wow, I though I changed this, maybe enter Moto and me (we did a lot of changes in constants. py) lost this. Thank you.
Castles - idea is that Castles have low rent, however, I should lool into at this.

 
I also notice that the realistic casualties thing doesn't actually work for preserving the troops. It adds them to prisoners if you win, but if you retreat they all stay dead.

It makes things a bit funny. If you kill 150 men and survive, 50 of them are alive as prisoners. If you kill 150 men and die, they're all dead. So either way the enemy party loses. I thought realistic casualties was a really nice addition, so it's a shame it doesn't quite work properly. Having a third of the enemy survive when you fight a battle and are forced to retreat would be nice.

-edit- Removal of troops seems to be hard coded, but adding them back if they're counted as wounded works. Just adding a few lines to the bottom of count_mission_casualties_from_agents solves this little inconsistency. Actually, moving the prisoner gaining bit there makes sense too - that way you actually see who got knocked out instead of killed in your casualty report before the prisoner window. Every live battle situation calls up the script anyway. I just gutted the realistic casualties parts from the mission templates and added the blue bit at the end of the mission casualties script (part of it included to show where I put it).

      (else_try),
        (party_add_members, "p_enemy_casualties", ":agent_troop_id", 1),
        (try_begin),
          (agent_is_wounded, ":cur_agent"),
          (party_wound_members, "p_enemy_casualties", ":agent_troop_id", 1),
      (else_try),
          (store_random_in_range, ":random_no", 1, 4),
          (eq,":random_no", 1),
          (party_wound_members, "p_enemy_casualties", ":agent_troop_id", 1),
          (party_wound_members, "p_total_enemy_casualties", ":agent_troop_id", 1),
          (party_add_members, ":agent_party", ":agent_troop_id", 1),
          (party_wound_members, ":agent_party", ":agent_troop_id", 1),

        (try_end),
      (try_end),

By doing that it now functions much more smoothly - if you retreat the enemy party has the troops that the game automatically removes re-added to it in a wounded state, if you win they're in total_enemy_casualties as prisoners, and in both cases you get the result displayed for the player in the battle casualty report.

It's not really needed for friendly parties, since they already benefit from the same thing automatically due to the surgery skill (even with 0 skill they still get saved part of the time).
 
I'm glad to read about your research in the brytenwalda module system, TheMageLord. All your contributions are welcome!  :grin:

I had not noticed this inconsistency in Realistic Casualties, too time do code little time f. What mean gutted?

 
By gutted I just mean I removed it all. Went through and removed all the realistic casualties code from mission templates (it's in all the different missions) and replaced it with the 7 lines I added to the count_mission_casualties_from_agents script. That way it all gets called after the fight when it calls for the casualties, which occurs at the end of every fight where troops can die.

Been playing a bit with it so far and haven't seen any issues with it yet. The benefit of doing it there is you actually get the results reported in the casualty report that the player sees, so if 50 of 150 of the enemy troops survive when you retreat from the castle you will see it reported.
 
TheMageLord said:
By gutted I just mean I removed it all. Went through and removed all the realistic casualties code from mission templates (it's in all the different missions) and replaced it with the 7 lines I added to the count_mission_casualties_from_agents script. That way it all gets called after the fight when it calls for the casualties, which occurs at the end of every fight where troops can die.

Been playing a bit with it so far and haven't seen any issues with it yet. The benefit of doing it there is you actually get the results reported in the casualty report that the player sees, so if 50 of 150 of the enemy troops survive when you retreat from the castle you will see it reported.

You mean that you change old code by your 7 lines in count_mission_casualties_from_agents script in mission templates, no) you added that lines en both, mt and scripts.py? But why you added a random element? (finally you will do I have recovery module system to fix this  :mrgreen:  It is end of my brytenwalda Holidays  :lol:)
 
I just mean that I removed all the parts in mission templates that you guys added for realistic casualties, and put it in count_mission_casualties_from_agents instead.

So the trigger in lead_charge is now just:

(ti_on_agent_killed_or_wounded, 0, 0, [],
      [
        (store_trigger_param_1, ":dead_agent_no"),
        (store_trigger_param_2, ":killer_agent_no"),
        (store_trigger_param_3, ":is_wounded"),

        (try_begin),
          (ge, ":dead_agent_no", 0),
          (neg|agent_is_ally, ":dead_agent_no"),
          (agent_is_human, ":dead_agent_no"),
          (agent_get_troop_id, ":dead_agent_troop_id", ":dead_agent_no"),
#menos casualties bajas chief blood
          (party_add_members, "p_total_enemy_casualties", ":dead_agent_troop_id", 1), #addition_to_p_total_enemy_casualties
          (eq, ":is_wounded", 1),
          (party_wound_members, "p_total_enemy_casualties", ":dead_agent_troop_id", 1),
        (try_end),
        (call_script, "script_apply_death_effect_on_courage_scores", ":dead_agent_no", ":killer_agent_no"),
      ]),

The end of the count_mission_casualties_from_agents now looks like this:

      #count and save killed agents in player party, ally parties and enemy parties
      (neg|agent_is_alive, ":cur_agent"),
      (agent_get_troop_id, ":agent_troop_id", ":cur_agent"),
      (try_begin),
        (eq, ":agent_party", "p_main_party"),
        (party_add_members, "p_player_casualties", ":agent_troop_id", 1),
        (try_begin),
          (agent_is_wounded, ":cur_agent"),
          (party_wound_members, "p_player_casualties", ":agent_troop_id", 1),
        (try_end),
      (else_try),
        (agent_is_ally, ":cur_agent"),
        (party_add_members, "p_ally_casualties", ":agent_troop_id", 1),
        (try_begin),
          (agent_is_wounded, ":cur_agent"),
          (party_wound_members, "p_ally_casualties", ":agent_troop_id", 1),
        (try_end),
      (else_try),
        (party_add_members, "p_enemy_casualties", ":agent_troop_id", 1),
        (try_begin),
          (agent_is_wounded, ":cur_agent"),
          (party_wound_members, "p_enemy_casualties", ":agent_troop_id", 1),
        (else_try), # added to replace realistic casualties code TML
          (store_random_in_range, ":random_no",1,4), # 1 in 3 chance of survival, only affects enemy (friendly get surgery bonuses anyway)
          (eq,":random_no", 1),
          (party_wound_members, "p_enemy_casualties", ":agent_troop_id", 1),
          (party_wound_members, "p_total_enemy_casualties", ":agent_troop_id", 1),
          (party_add_members, ":agent_party", ":agent_troop_id", 1),
          (party_wound_members, ":agent_party", ":agent_troop_id", 1), 
          # end addition TML

        (try_end),
      (try_end),
    (try_end),
    ]),

The random element is the same as the one in mission templates. I added it so that it would function the same way you intended realistic casualties to work. This is the part of your code that I removed from the mission templates:

    #Dead agents survive 1/3 of the time- more prisoners. Realistic Casualties turns off player buff.
  (store_random_in_range, ":random_no",1,4),
  (try_begin),
  (eq,":random_no", 1),
          (ge, ":dead_agent_no", 0),
          (agent_is_human, ":dead_agent_no"),
          (agent_get_troop_id, ":dead_agent_troop_id", ":dead_agent_no"),
          (eq, ":is_wounded", 0),
  (try_begin),
  (eq, "$g_realistic_casualties", 1),
  (try_begin),
  (neg|agent_is_ally, ":dead_agent_no"),
  (party_wound_members, "p_total_enemy_casualties", ":dead_agent_troop_id", 1),
  (try_end),
  (else_try),  
  (party_wound_members, "p_total_enemy_casualties", ":dead_agent_troop_id", 1),
  (try_end),  
        (try_end),

The part I added replaces all that - it has the same random element (1 in 3 chance of survival) and wounds a member of total_enemy_casualties if it triggers the same as the part I removed does. That way they still get counted for prisoners. In addition, by wounding a troop in enemy_casualties it makes the casualty report show them wounded instead of killed. And by adding and then wounding them to the original party, it replaces the troop that the game automatically removes when a troop dies.

I didn't keep the check for $g_realistic_casualties since the original code seemed a bit nonsensical about it. What it's actually doing is wounding members in total_enemy_casualties (which is only really used for giving prisoners at the end of battle) even when friendly agents die when it's set to "On." This means every time a friendly soldier is killed it has a 1 in 3 chance of healing an enemy prisoner if they are the same troop type. I guess that's unintended, but it has funny results. If I go into battle with the same faction troops I wind up with extra prisoners because my guys dieing get counted as enemy dieing in your realistic casualties code and if the equivalent troop exists in the enemy party it will effectively resurrect them as a prisoner if I win.
 
Back
Top Bottom