OSP Code SP [WB] Prebattle Orders Kit v0.8 Beta

Caba`drin

Count
M&BWBWF&SNWVC
Best answers
0
The goal here is to cater to those who want an added level of strategy in the planning of their battle engagements--or, more pointedly, to get beyond the repetitive keystrokes of giving the same orders at the start of each battle. It is also the first step in an attempt to respond to the various comments and suggestions around this community to implement pre-battle setup and options (cf. calls for a "deployment phase").

The Prebattle Orders kit adds to the pre-battle menu options that the player is presented with during any field encounter with an enemy party. At the most basic, with 1 point of Tactics skill in the party, there are two additional options: rather than just "Charge the Enemy" one can "Take the Field" and your party begins holding position, or "Lead your Troops" and your party begins following you. Add another point of Tactics skill to the party and another menu item appears: "Plan your battle with the enemy".

When planning your battle with the enemy, a presentation similar to the "heads-up" battle menu appears, allowing you to customize 4 orders (eventually to be scaled by tactics skill) to each of your divisions. Movement orders can be repeated up to 4 times. Across the bottom of the presentation are options to Reassess--return to the encounter menu; Scrap all--clear all orders; Prepare Orders--preview the order set up on the right panel; and Dispatch Orders--store the orders and return to the encounter menu.

Orders to specify to each division which Weapon Type to use, whether or not to use shields, and for ranged units, whether to avoid melee or not (skirmish) have been added. In the display where orders are selected, there are now two "pages"--one for forming up, and the second to outline which weapons to use.

Screenshots Galore
[spoiler="Plan Battle with Enemy" Screen]
[/spoiler]
Version 0.8 Beta --
]

Code
Considering its size, I opted to not place the code in spoilers here. Instead it can be downloaded from the M&B Repository: Repository kit download.

The following are modified:
  • 2 triggers added to lead_charge to give the orders
  • 5 scripts to run the presentation and store the orders
  • 4 menu options added to two menus (simple_encounter and join_battle)
  • 1 condition operation added to all menu options of simple_encounter and join_battle
  • 1 presentation added
  • 1 mesh defined, from Native materials
  • 3 constants defined
  • 0 globals added; globals from the heads-up battle presentation and custom battle setup are used
  • 0 slots added; party slots 250-350 (for centers) are used for "p_main_party"

As always, comments, questions, criticisms, suggestions are more than welcome.

Checklist to Version 1
  • Bug testing and squarshing
  • Wrap for installation via sphere's ModMerger
  • Move to M&B Repository
  • Allow movement orders to be repeated (Stand Closer x2 or Move Forward x2)
  • Inclusion of my Weapon Type and Skirmish Mode orders
  • Cleaning up the presentation
  • Scale the number of orders available to Tactics skill

v0.8
  • Weapon Type, Shield Use and Skirmish orders added
  • In-battle order-selection for the above orders akin to Native
v0.71
  • Quick string bug when merging with other mods fixed
v0.7
  • Movement orders can be repeated up to 4 times
  • Move Forward/Back 10 bugs fixed. Given 3 seconds after mission start
  • Move Forward/Back 10 tied to "Hold" order
  • Presentation cleaned, text scaled to fit
  • Bug where "Lead Troops"/"Take Field" orders carried over to next battle fixed
v0.55
  • Choosing 'Lead your Troops' or 'Take the Field' won't overwrite the first stored order
 

Ashmond

Sergeant at Arms
WB
Best answers
0
Congratulations on such a fine accomplishment!  I've been waiting for this since I first played Warband. 

Can't wait to take this for a spin and, also, looking forward to the weapon type inclusion.  For the tactical scaling, at what level are you considering as the "full feature" requirement?
 

Lumos

Section Moderator
WBWF&SNWM&BVC
Best answers
0
:shock:
I thought of creating something like a Heroes (or Medieval II: total War) tactics screen, but I might needn't. This looks awesome!
 

Ashmond

Sergeant at Arms
WB
Best answers
0
Stitched it, tried it, loved it, and no glitches that I noticed after ten battles.
 

ripple

Knight
Best answers
0
Wow, I managed to add it without screwing up (too many times). Seems to work good, will test some more. Great job and thanks.
 

Ashmond

Sergeant at Arms
WB
Best answers
0
Vlejundo, you have a "1" where a "0" should be just after the first chunk.  Make sure you got all of the "encounter_*" tuples.

# add
#  (party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
# to the conditions block, the first [stuff] after the ("encounter_", label.
# "encounter_attack" is included as an example
# So, add the above line to "encounter_: _attack", _order_attack", _leave", _retreat", _surrender"

First chunk end: 

        (set_jump_mission,"mt_lead_charge"),
        (call_script, "script_setup_random_scene"),
        (assign, "$g_next_menu", "mnu_simple_encounter"),
        (jump_to_menu, "mnu_battle_debrief"),
        (change_screen_mission),
      ]),
## PreBattle Orders End
  ("encounter_attack",
      [
        (eq, "$encountered_party_friendly", 0),
        (neg|troop_is_wounded, "trp_player"),
## PreBattle Orders Begin
(party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
## PreBattle Orders End
      ],

next between chunks:

("encounter_order_attack",
      [
        (eq, "$encountered_party_friendly", 0),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),(ge, reg0, 4),
## PreBattle Orders Begin
(party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
## PreBattle Orders End

then:

("encounter_leave",[
          (eq,"$cant_leave_encounter", 0),
## PreBattle Orders Begin
  (party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
  ## PreBattle Orders End

also:

("encounter_surrender",[
        (eq,"$cant_leave_encounter", 1),
## PreBattle Orders Begin
(party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
## PreBattle Orders End
          ],"Surrender.",[(assign,"$g_player_surrenders",1)]),

finally:

("encounter_retreat",[
        (eq,"$cant_leave_encounter", 1),
        (call_script, "script_get_max_skill_of_player_party", "skl_tactics"),
        (assign, ":max_skill", reg0),
        (val_add, ":max_skill", 4),


        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy", 0),
        (assign, ":enemy_party_strength", reg0),
        (val_div, ":enemy_party_strength", 2),

        (val_div, ":enemy_party_strength", ":max_skill"),
        (val_max, ":enemy_party_strength", 1),

        (call_script, "script_party_count_fit_regulars", "p_main_party"),
        (assign, ":player_count", reg0),
        (ge, ":player_count", ":enemy_party_strength"),
## PreBattle Orders Begin
(party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
## PreBattle Orders End
        ],"Pull back, leaving some soldiers behind to cover your retreat.",

Second chunk end:

        (jump_to_menu, "mnu_battle_debrief"),
        (change_screen_mission),
      ]),
## PreBattle Orders End     
  ("join_attack",
      [
        (neg|troop_is_wounded, "trp_player"),
## PreBattle Orders Begin
(party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
## PreBattle Orders End

next:

("join_order_attack",
      [
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (ge, reg0, 3),
## PreBattle Orders Begin
(party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
## PreBattle Orders End

lastly:

("join_leave",
  [
    ## PreBattle Orders Begin
(party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
## PreBattle Orders End
  ],"Leave.",
 

Caba`drin

Count
M&BWBWF&SNWVC
Best answers
0
@ Vlejundo: Actually, from what you describe, it would appear that there is a mistake in module_presentations.py because the menu option is not able to find the presentation. Check to make sure you added it and did not misplace any ) ] , etc and if you stuck it at the bottom on of the module_presentations file that you placed it within the final ]

Ashmond is correct, too however, but I don't think that is what is causing the errors you are seeing.

@All: thank you for the kind words. I'm glad it is working for you and proving enjoyable. Do let me know if there's something that could be improved. As for bugs I am aware of, there is one: if you have orders stored, but you choose "Take the field" or "Lead your troops", the next time you go to the order screen, the first order will be erased. This will be fixed in the next upload.

@Ashmond, et al.: I haven't really decided how it would be best to scale orders via tactics, but it seems that it would make sense to have the complexity of the orders a player can give based on their skill level. When I add my weapon type and skirmish orders, they will likely need to go another "page" and I'll move the native weapon orders to that page, too. Perhaps that page will need another tactics bump to get to. Further, once I work out how to record that you want infantry to Stand closer x3 and then Step forward x2, perhaps the ability to add that multiplier will require a tactics bump, too. Another alternative would be to have a static number of orders that one could give, depending on tactics, and if you try to give too many orders then those get reset to "None"...I suppose it is rather clear I haven't come to much of a consensus on tactics scaling, other than that may be needed to balance the feature and fit it into the rest of the game.
 

leandrojas_

Squire
Best answers
0
Wow!
Great!
I have two questions:
You think that is compatible with the rank form by motomataru?
Have you thought about making your own form ranks?
I think you would do a great job.

Anyway all your contributions are great!
Please continue!
This is Great! (Again)
 

Caba`drin

Count
M&BWBWF&SNWVC
Best answers
0
leandrojas_ said:
Wow!
Great!
I have two questions:
You think that is compatible with the rank form by motomataru?
Have you thought about making your own form ranks?
I think you would do a great job.

Anyway all your contributions are great!
Please continue!
This is Great! (Again)
At the moment, this shouldn't be incompatible with motomataru's formation kit, but it isn't set up with any of the formations used in that kit. So, you could use this to get your troops somewhat positioned and then use motomataru's commands to get them into full formation once in the mission.

From the onset, I've hoped to have a version that directly integrates motomataru's formations...but that may be a ways off yet.
Similarly, I'll likely end up packaging my various orders/weapon use tweaks into a single pack, and this prebattle orders and deployment into another pack with both compatible with one another and (hopefully) with motomataru's formations; that is the goal at least.

As for "my own" formation kit, I'm not sure if I have the interest in "re-making" the wheel so to speak. I've done some tinkering with motomataru's kit and have been in minimal contact with him over some possible additions that I'm working on, but I'd much rather augment that work than create some parallel project.
 

Abhuva

Knight at Arms
WB
Best answers
0
:oops: i seem to have problems getting this to work.
I followed closely the instructions, checked for all normal errors like closing brackets etc, but i keep getting a weird compiler error
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
Traceback (most recent call last):
  File "process_game_menus.py", line 47, in <module>
    save_game_menus(variables,variable_uses,tag_uses,quick_strings)
  File "process_game_menus.py", line 27, in save_game_menus
    save_statement_block(ofile,0,1, game_menu[4]  , variable_list, variable_uses
,tag_uses,quick_strings)
  File "C:\Games\Mount&Blade Warband1132\Modules\Scaedumar\Module System\Module_
system 1.132 - Kopie\process_operations.py", line 449, in save_statement_block
    save_statement(ofile,opcode,no_variables,statement,variable_list,variable_us
es,local_vars, local_var_uses,tag_uses,quick_strings)
  File "C:\Games\Mount&Blade Warband1132\Modules\Scaedumar\Module System\Module_
system 1.132 - Kopie\process_operations.py", line 400, in save_statement
    operand = process_param(statement[i + 1],variable_list,variable_uses,local_v
ars_list,local_var_uses,tag_uses,quick_strings)
  File "C:\Games\Mount&Blade Warband1132\Modules\Scaedumar\Module System\Module_
system 1.132 - Kopie\process_operations.py", line 377, in process_param
    result = insert_quick_string_with_auto_id(param[1:], quick_strings)
  File "C:\Games\Mount&Blade Warband1132\Modules\Scaedumar\Module System\Module_
system 1.132 - Kopie\process_operations.py", line 356, in insert_quick_string_wi
th_auto_id
    while quick_strings.has_key(new_auto_id):
AttributeError: 'list' object has no attribute 'has_key'
exporting simple triggers...
exporting triggers...
exporting dialogs...

After trying to hunt this down (and find my mistake cause others reported it works fine for them) i recognized that as soon as i delete the whole block from module_scripts.py the whole thing compiles without those errors (it wont work but those strange error is gone).
I checked then the spelling / brackets in module_scripts, but cant find anything wrong there.

Can anyone help me to understand what i do wrong here?

Btw, i also installed the Prebattle_deployment kit and this has worked pretty well without a single error.

Edit: I tried it now with the combined Orders & Deployment kit and gets the same compiling error... too bad, i was really hoping to get it solved =(
 

Caba`drin

Count
M&BWBWF&SNWVC
Best answers
0
@Abhuva

Hrm. I'm not sure what would cause this. I make sure to test my directions on a clean version of the module system before posting the code...so if all is correct, it does work.

Would it be possible for you to upload your edited files (particularly game_menus and scripts) to a hosting site like MediaFire? If you can, then PM me a link and I'll gladly take a look for you.
 

Abhuva

Knight at Arms
WB
Best answers
0
Thx, i will upload them on MediaFire, its the first time i use this hosting site so i appologize if there is a easier way to do it, but for now i can only give links for each file on their own =)

module_game_menu : http://www.mediafire.com/?akzzhz4pvffvzf7
module_scripts          : http://www.mediafire.com/?f35o9h99br9ktz4
module_presentation : http://www.mediafire.com/?gyxdeocm6l5ccg6
module_mission_temp: http://www.mediafire.com/?6dxdocqwgkwtjp6
module_constants      : http://www.mediafire.com/?76ttpjaa21rmuss
module_meshes          : http://www.mediafire.com/?g1qf28d6tv41j70

I merged the following mods in there: Diplomatic, Camp Entrenchment. And i am quite sure btw its a mistake on my side =) When i am the only one not getting this to work thats kinda the only option left.
Without the Prebattle Kit the compile is fine and game is running well and bugfree. With my current implementation of the Kit i get the weird error.

Thx for your help, i hope we get this solved, i am totally looking forward to use this =)
 

Kea Black

Sergeant Knight at Arms
M&BWB
Best answers
0
these are features warband definitely needs

especially the pre-battle-orders feat, one of the features that i wish to include/implement in my personal mod

i have to try this yet, but thanks for your work
 

Caba`drin

Count
M&BWBWF&SNWVC
Best answers
0
@Abhuva

I'm not sure if this will take care of your problem or not (I am away from my computer with Warband actually installed...but I have my doubts) but are two small mistakes

First, in game_menus for the menu option "join_leave" under the menu "join_battle":
Code:
      ("join_leave",[],"Leave.",
      [
        (try_begin),
           (neg|troop_is_wounded, "trp_player"),
           (call_script, "script_objectionable_action", tmt_aristocratic, "str_flee_battle"),
           (party_stack_get_troop_id, ":enemy_leader","$g_enemy_party",0),
		   (is_between, ":enemy_leader", active_npcs_begin, active_npcs_end),
           (call_script, "script_add_log_entry", logent_player_retreated_from_lord, "trp_player",  -1, ":enemy_leader", -1),
        (try_end),

        ## PreBattle Orders & Deployment Begin
		(party_slot_eq, "p_main_party", slot_party_prebattle_plan, 0),
		## PreBattle Orders & Deployment End	
        (leave_encounter),(change_screen_return)
							
		]),
      ]),
The PBOD bit should go in the closed [] before "Leave" rather than where you have placed it. Since that block is closed [] like that, it is easy to miss.

Second, with your inclusion of the triggers into the mission templates
Code:
    ]
    ##diplomacy begin
    + dplmc_battle_mode_triggers,
    ##diplomacy end
	## Prebattle Orders Deployment begins
	prebattle_orders_deployment_triggers,
	## Prebattle Orders Depleyment ends
  ),
Since you have the Diplomacy bit there, too, delete the comma from the end of teh dplmc_battle_mode_triggers and add a plus sign before the prebattle_orders_deployment_triggers,  so it looks like this:
Code:
    ]
    ##diplomacy begin
    + dplmc_battle_mode_triggers
    ##diplomacy end
	## Prebattle Orders Deployment begins
	 + prebattle_orders_deployment_triggers,
	## Prebattle Orders Depleyment ends
  ),
If that doesn't work, just replace that whole bit with
Code:
    ] + dplmc_battle_mode_triggers + prebattle_orders_deployment_triggers,
  ),
Those are the only two issues I noticed after checking each of the files.
My other wonderment is if there is a maximum length to module_scripts. My scripts push the total length to over 51K lines in your file...if there is a limit, perhaps that is why deleting the code removes the error?
 

Abhuva

Knight at Arms
WB
Best answers
0
First of all, thx for fast reply. Unfortunately neither of those suggestions solved it.
I corrected the 2 mistakes (game_menus and mission_template ones) and compiled --> the same error occurs.

I then deleted lots of scripts just to check if there really is a limit and this didnt solved it too (was down to 50k lines, another version which compiles without errors have 51k)

Somewhere is a little nasty mistake i cant find =(
I will try to install this on a fresh native module to see what happens. Did you use ModuleSystem version 1.132 ?

Edit: Tried it with a fresh Module System and it compiles well... Too bad i have no clue what this error message means, makes it hard to hunt this down

Edit2 : Getting closer to solve this =) I managed to merge Diplomacy with this Kit now successfully, i guess i found my error. In mission_templates the diplomacy mod imports from header_skills. In my other attempts i copypasted your code before this ... i guess that was what messes all up.
Now for the last part... Lets hope i can merge it with my Mod in construction =) (just posting to get myself some motivation =P )