How do I add "everyone charge on death" option to Diplomacy's deathcam?

Users who are viewing this thread

I've seen some mods have something like this: when you die, all your troops automatically charge. Is there a way to add this to Diplomacy? While Diplomacy has battle continuation, there are no automatic orders given out when you get knocked out.

Thanks in advance
 
You mean this part that already exists?
Code:
    (try_begin),
      (eq, "$g_dplmc_charge_when_dead", 1),
      (team_get_movement_order, ":cur_order", ":player_team", grc_everyone),
      (neq, ":cur_order", mordr_charge),
      (team_give_order, ":player_team", grc_everyone, mordr_charge),
    (try_end),
It probably depends on what version of diplomacy you're running whether that option is available or not.
 
I'm using Diplomacy 4.3 and there's no such feature :sad: what do I need to do in order to activate it?

I downloaded the Diplomacy 4.3 source and yes, it has those lines of code in it. Unfortunately, the charge on death doesn't work. I even compiled the mod from the source and it still doesn't work.
 
Looks like it's an option that was never explicitly set. Insert the following menu options above the terrain advantage one to make use the the global
Code:
      ("dplmc_charge_when_dead",[ (eq, "$g_dplmc_battle_continuation", 0),(assign, reg0, "$g_dplmc_charge_when_dead"),],
        "{reg0?Dis:En}able allies running around like headless chickens after player falls.",
       [
           (store_sub, "$g_dplmc_charge_when_dead", 1, "$g_dplmc_charge_when_dead"),
           (jump_to_menu, "mnu_dplmc_preferences"),
        ]),
 
Allright, I added this to module_game_menus above the terrain_advantage bit and there is such an option in the game now. Unfortunately, there is still no charge command given when the player dies  :sad: Also, the setting gets reset to "disabled" after each battle for some reason.

Maybe I put it in the wrong place though? Here's where I pasted that code: http://i.imgur.com/q2cDqmM.jpg
 
That should work, unless the value of that unused global is something else in your savegame. Try explicitly setting $g_dplmc_charge_when_dead as follows in the previous option
Code:
      ("dplmc_enable_battle_continuation",[ (eq, "$g_dplmc_battle_continuation", 1),],"Enable Diplomacy battle continuation.",
       [
           (assign, "$g_dplmc_battle_continuation", 0),
           (assign, "$g_dplmc_charge_when_dead", 1),
           (jump_to_menu, "mnu_dplmc_preferences"),
        ]),
 
You should probably add a bit to set fire at will as well. One time in TLD I caught a headshot and all my elves were lined up with nothing but their little knives...
 
Like this? http://i.imgur.com/ulDeI5R.jpg

Still doesn't work  :???: the allies won't charge when I fall, and the menu option gets reset to "disabled" after each battle for some reason. This is for both a new game and a saved one.

Here are my game_menus and mission_templates files along with the variables.txt: https://drive.google.com/file/d/0B5iWoeRgDkvORk9nMHAxR19XLUU/view?usp=sharing
Now, I don't know much about Python (the only programming language I know is Java) but these pieces of code look correct to me...
By the way, what's "reg0", is that just a temporary variable or something?
 
reg0 is just there so we use one menu option to toggle Enable/Disable instead of two.
Right, the problem is there's places in combat template where $g_dplmc_charge_when_dead is set for you at the beginning of missions. In lead_charge this is 0 (so they won't charge), whereas in siege contexts they will. They're on lines 2548/3091/3188/3315, get rid of them and you should be fine for now.
 
Holy crap, it worked! Thank you so much!

By the way, what do I add to mission_templates so that the "fire at will" command is also given once the player dies?

Code:
(try_begin),
      (eq, "$g_dplmc_charge_when_dead", 1),
      (team_get_movement_order, ":cur_order", ":player_team", grc_everyone),
      (neq, ":cur_order", mordr_charge),
      (team_give_order, ":player_team", grc_everyone, mordr_charge),
(try_end),
I tried simply adding "mordr_fire_at_will" after "mordr_charge" but it didn't work.

edit: nevermind, I solved it like this:
Code:
(try_begin),
      (eq, "$g_dplmc_charge_when_dead", 1),
      (team_get_movement_order, ":cur_order", ":player_team", grc_everyone),
      (neq, ":cur_order", mordr_charge),
      (team_give_order, ":player_team", grc_everyone, mordr_charge),	  
      (team_give_order, ":player_team", grc_everyone, mordr_fire_at_will),
(try_end),
Though this approach has a flaw: if my last command before death was, in fact, a charge order, then there won't be a "fire at will" command given. Is there any way to fix this?

Oh, and one more thing: is it enough to only replace mission_templates.txt and menus.txt in my Diplomacy folder with the new ones in order for the changes to apply? Or do some other files (such as variable_uses.txt or variables.txt) need to be replaced as well?
 
Should be fine, the variable was there before. Firing order and weapon order are different from movement order, however. Use
Code:
team_get_hold_fire_order
to check the former and
Code:
team_get_weapon_usage_order
for the latter. These should be checked in a separate code block as they are independent.
Code:
    (try_begin),
      (eq, "$g_dplmc_charge_when_dead", 1),
      (set_show_messages, 0),
      (try_begin),
        (team_get_movement_order, ":cur_order", ":player_team", grc_everyone),
        (neq, ":cur_order", mordr_charge),
        (team_give_order, ":player_team", grc_everyone, mordr_charge),
      (try_end),
      (try_begin),
        (team_get_weapon_usage_order, ":cur_order", ":player_team", grc_everyone),
        (neq, ":cur_order", mordr_use_any_weapon),
        (team_give_order, ":player_team", grc_everyone, mordr_use_any_weapon),
      (try_end),
      (try_begin),
        (team_get_hold_fire_order, ":cur_order", ":player_team", grc_everyone),
        (neq, ":cur_order", mordr_fire_at_will),
        (team_give_order, ":player_team", grc_everyone, mordr_fire_at_will),
      (try_end),
      (set_show_messages, 1),
    (try_end),
 
I found another serious bug.

Basically, any change to module_game_menus creates weird artifacts in the game, such as this: http://i.imgur.com/zUvQN4Q.jpg or this: http://i.imgur.com/aY6IJjt.jpg

So I guess this file is NOT to be edited under any circumstances. Which means that the variable g_charge_when_dead cannot be changed from the menus.

I found a workaround by changing this piece of code in missions_templates:
Code:
(try_begin),
      (eq, "$g_dplmc_charge_when_dead", 1),
      (team_get_movement_order, ":cur_order", ":player_team", grc_everyone),
      (neq, ":cur_order", mordr_charge),
      (team_give_order, ":player_team", grc_everyone, mordr_charge),
(try_end),

to this:
Code:
(assign, "$g_dplmc_charge_when_dead", 1),
(try_begin),
      (eq, "$g_dplmc_charge_when_dead", 1),
      (team_get_movement_order, ":cur_order", ":player_team", grc_everyone),
      (neq, ":cur_order", mordr_charge),
      (team_give_order, ":player_team", grc_everyone, mordr_charge),
(try_end),

So I compiled the module and only replaced missions_templates.txt in my Diplomacy folder while leaving menus.txt intact. Now I don't have menu errors and charge on death works. I found one minor side effect though: now, under camp -> Diplomacy options, turning "battle continuation" on/off does nothing: it's on by default regardless of the setting. But this shouldn't be a problem since I'd never want to turn it off anyway.
Do you think there might be other side effects though?

P.S. your solution to making use of "fire at will" and "use any weapons" orders didn't work, unfortunately (no orders are given at all). I've found a workaround though:
Code:
(assign, "$g_dplmc_charge_when_dead", 1),
(try_begin),
       (eq, "$g_dplmc_charge_when_dead", 1),
       (team_get_movement_order, ":cur_order", ":player_team", grc_everyone),
       (neq, ":cur_order", mordr_charge),
       (team_give_order, ":player_team", grc_everyone, mordr_charge),
       (team_give_order, ":player_team", grc_everyone, mordr_use_any_weapon),
       (team_give_order, ":player_team", grc_everyone, mordr_fire_at_will),
(try_end),
but again, it only works if my last order wasn't to charge  :???: I tried replacing "(neq, ":cur_order", mordr_charge)" with "(neq, ":cur_order", mordr_retreat)", but it didn't work even though "retreat" is also a movement_order, just like "charge". Not sure what else I could try.
 
nope, still nothing. The text kinda shows on the screen for a split second, then disappears and the troops are still standing there doing nothing.

Ah well, the workaround is good enough for 99% of the situations. Provided there won't be any unexpected side effects I should be fine. Thanks again for your help!
 
aleeque said:
nope, still nothing. The text kinda shows on the screen for a split second, then disappears and the troops are still standing there doing nothing.

Ah well, the workaround is good enough for 99% of the situations. Provided there won't be any unexpected side effects I should be fine. Thanks again for your help!
If the text is disappearing you might be getting an RGL error. Does other text still show up after this? (casualty reports etc)
 
Yes, all messages disappear from the screen. If I open the combat log, I see this: http://i.imgur.com/LTiqbNj.jpg

That was without the set_message commands. With them, I still get the usual deathcam controls message ("use the numpad buttons to control the camera blah blah blah") but no orders are given.
 
The problem is that you're not running your code once, it is instead run every time the trigger is activated. Which seems to happen every frame or so, generating tons of messages. And Warband does have a problem with that (by now it is actually an ingrained habit for me to check the Logs screen every time I run a script and see no error messages - it's perfectly possible they're there but so many that they're not being displayed).
 
but this code works fine though:

Code:
(assign, "$g_dplmc_charge_when_dead", 1),
(try_begin),
       (eq, "$g_dplmc_charge_when_dead", 1),
       (team_get_movement_order, ":cur_order", ":player_team", grc_archers),
       (neq, ":cur_order", mordr_charge),
       (team_give_order, ":player_team", grc_everyone, mordr_charge),
       (team_give_order, ":player_team", grc_everyone, mordr_use_any_weapon),
       (team_give_order, ":player_team", grc_everyone, mordr_fire_at_will),
(try_end),

I don't get any combat log spam in this case. The only downside to this solution is that if the archers got a "charge" command before I died, the script won't be executed. But it's a small price to pay.

Do you think there might be other side effects though? I mean, the only thing I did was remove all g_dplmc_charge_when_dead assignments in mission_templates and instead force assigning 1 to it at start of the file. I haven't tested ALL combat scenarios yet but field battles definitely work, sieges (as attackers) as well.
 
It's a bit pointless to assign it to 1 in the same code. That's probably just for a toggle option, right? You can just remove both the assign and the eq from your code and it would work the same. I'm really not sure why Somebody's last code didn't work for you.  :???: Although it looks like you probably tested it with the option disabled, or on an old save file.

Try using this
Code:
    (try_begin),
      (try_begin),
        (team_get_movement_order, ":cur_order", ":player_team", grc_everyone),
        (neq, ":cur_order", mordr_charge),
        (team_give_order, ":player_team", grc_everyone, mordr_charge),
      (try_end),
      (try_begin),
        (team_get_weapon_usage_order, ":cur_order", ":player_team", grc_everyone),
        (neq, ":cur_order", mordr_use_any_weapon),
        (team_give_order, ":player_team", grc_everyone, mordr_use_any_weapon),
      (try_end),
      (try_begin),
        (team_get_hold_fire_order, ":cur_order", ":player_team", grc_everyone),
        (neq, ":cur_order", mordr_fire_at_will),
        (team_give_order, ":player_team", grc_everyone, mordr_fire_at_will),
      (try_end),
    (try_end),
 
Back
Top Bottom