SP Info Module System Some code to make mod testing easier

Users who are viewing this thread

MartinF

Squire
When modding, you tend to have to test a lot. Which means running MNB, starting a new game and then you have to go through the whole spiel of character creation. Then, depending on what you want to test, you have to scour the map for bandits, etc.

While more experienced modders probably have tools in their mod to deal with easy testing, I thought I'd help those starting out by posting a few small tools they can add to their testmod to make life a lot easier.

First. Quick character creation.

This will let you skip all of the steps of the character creation and put you on the map within 20 mouseclicks (and one key stroke.. I have a lot of characters named 'a' :smile:).
in module_game_menus.py, at the very start are the male/female questions that start character creation. Change to the following by copy/pasting the blue part. Now when you start a new game, the middle option will be 'Quick Character' and this will skip all the questions and go straight to the character window. You'll only have to spend 4 stat points (put these in str), no skill points and like 5 weapon proficiency points.

("start_male",[],"Male",
[
(troop_set_type,"trp_player",0),
(assign,"$character_gender",tf_male),
(jump_to_menu,"mnu_start_character_1"),
]
),

############## MF for testing start ####################

("start_mod",[(eq,1,1),],"Quick Character (for mod testing)",
[
(troop_set_type,"trp_player",0),
(assign,"$character_gender",tf_male),
(troop_raise_attribute, "trp_player",ca_intelligence,-4), #so you dont need to wait time picking extra skills
(change_screen_return, 0),
]
),
############## MF for testing end ####################


("start_female",[],"Female",
[
(troop_set_type,"trp_player",1),
(assign,"$character_gender",tf_female),
(jump_to_menu,"mnu_start_character_1")
]
),

Second. Camp menu for modding tools

Now I use a special camp menu that lets me access some functions that make life a lot easier.

In module_game_menus.py, search for "You set up camp". This will show you the following menu:

Code:
("camp",mnf_scale_picture,
   "You set up camp. What do you want to do?",
   "none",
   [
     (assign, "$g_player_icon_state", pis_normal),
     (set_background_mesh, "mesh_pic_camp"),
    ],
    [

Underneath that are a load of menu options. We're going to add one to that, like so (blue text is new):

("camp",mnf_scale_picture,
"You set up camp. What do you want to do?",
"none",
[
(assign, "$g_player_icon_state", pis_normal),
(set_background_mesh, "mesh_pic_camp"),
],
[

("camp_modding",[],"Go to the modding menu.",
[(jump_to_menu, "mnu_camp_modding"),
]
),


("camp_action_1",[(eq,"$cheat_mode",1)],"Cheat: Walk around.",
[(set_jump_mission,"mt_ai_training"),

Now if you press the 'camp' button, the top menu option will be "Go to the modding menu". Of course for that to work, we have to make the menu! So scroll to the bottom of your module_game_menus.py and just before the final bracket add:

Code:
############## MF for testing start ####################

  ("camp_modding",0,
   "Select an option:",
   "none",
   [
     ],
    [
      ("camp_mod_1",
        [],"Increase player's renown.",
       [(str_store_string, s1, "@Player renown is increased by 100. "),
        (call_script, "script_change_troop_renown", "trp_player" ,100),
        (jump_to_menu, "mnu_camp_modding"),
        ]
       ),
### MF - change attributes and skills below, or add weapon proficiencies with (troop_raise_proficiency, "trp_player", wpt_). See header.troops.py for options  
        ("camp_mod_2",
            [],
            "Raise player's attributes and skills.",
        [
           (troop_raise_attribute, "trp_player",ca_intelligence,20),
           (troop_raise_attribute, "trp_player",ca_strength,20),
           (troop_raise_skill, "trp_player",skl_riding,10),
           (troop_raise_skill, "trp_player",skl_spotting,10),
           (troop_raise_skill, "trp_player",skl_pathfinding,10),
           (troop_raise_skill, "trp_player",skl_trainer,10),
           (troop_raise_skill, "trp_player",skl_leadership,10),
           (troop_raise_skill, "trp_player",skl_trade,10),
           (troop_raise_skill, "trp_player",skl_prisoner_management,10),
           (display_message, "@Skills and attributes raised."),
          ]
        ),      

### MF - Change items below to anything you want to test out, look in items.py for item_id
      ("camp_mod_3",
        [],
        "Add gear and gold to player.",
       [
           (troop_add_gold, "trp_player", 100000),
           (troop_add_item, "trp_player","itm_courser",imod_spirited),
           (troop_add_item, "trp_player","itm_heraldic_mail_with_surcoat",0),
           (troop_add_item, "trp_player","itm_tab_shield_small_round_c",0),
           (troop_add_item, "trp_player","itm_jousting_lance",0),
           (troop_add_item, "trp_player","itm_splinted_leather_greaves",0),
           (troop_add_item, "trp_player","itm_great_sword",imod_balanced),
           (troop_add_item, "trp_player","itm_great_helmet",imod_masterwork),
           (troop_equip_items, "trp_player"),
           (troop_add_item, "trp_player","itm_chicken",0),
           (troop_add_item, "trp_player","itm_chicken",0),
           (troop_add_item, "trp_player","itm_chicken",0),
            (display_message, "@Items added to player inventory."),
        ]
       ),
### MF - Add any units you want to test with below, look in troop.py for the troop_id      
       ("camp_mod_4",
        [],
        "Add units to player party.",
        [
          (party_add_members, "p_main_party", "trp_swadian_knight", 10),
          (party_add_members, "p_main_party", "trp_swadian_recruit", 10),
          (display_message, "@Party members added."),
         ]
        ),
       
### MF - Spawn any party you want near your party. Look in party_templates.py for pt_id
        ("camp_mod_5",
            [],
        "Spawn a party nearby",
        [
            (spawn_around_party, "p_main_party", "pt_looters"),
            (display_message, "@Party spawned nearby."),
        ]
        ),
       
      
      ("camp_mod_6",[],"Back to camp menu.",
       [(jump_to_menu, "mnu_camp"),
        ]
       ),
      ]
  ),
 
############## MF for testing end ####################

My comments in the code explain what all the bits and pieces do and how you can change them to suit your needs. I've used all this many times without problems. The only thing that seems to give the occasional problem is the spawn_near_party. If nothing shows up, just try again. And move a little bit since they often spawn right underneath your party.

These are the basic tools. They don't really affect the module much and are easily removed/disabled by commenting out the new bits.

Hope that helps you out when you're modding! Remember that you can easily adapt these to do what you want.

I got some of these ideas from the custom settlements mod, so thanks go out to them for the basis of this.
 
Last edited by a moderator:
I was going to do something like this...  MartinF, with your permission, I want to add this (pretty much as is) to the tutorial for menu creation. I will put in some explanation stuff, but it looks very helpful as is.

[EDIT]
BTW why did you set the condition for the menu option [(eq,1,1),] ?  Why put a condition at all?  I guess to turn it off by changing one of the numbers?
 
janlulhannes said:
Thanks for this!
I was just gonna request it  :shock:
I allways hated to make a new char 10000000 times a day :razz:

tell me about it.. I'm testing new code for my duel kit thing and not only do I have to keep making new chars, I have to keep dueling lords to test all the different types of responses.

On the upside, I've gotten pretty good at 1v1 combat today :grin:

(and yes I do know I can use cheats, but sometimes you just have to test things properly)
 
It also helps to make a save right before what you're going to test, since a lot of minor changes and tweaks to code aren't going to break saves. :wink:  Or at least not break them enough to be a problem for some simple testing if you're right there before what you want to test.  Something like this is definitely helpful, though, for the speed runs.  Might want to also describe how to get rid of the bik animation that plays when you start M&B so you can get right into the game?  :razz:
 
Jinnai said:
It also helps to make a save right before what you're going to test, since a lot of minor changes and tweaks to code aren't going to break saves. :wink:  Or at least not break them enough to be a problem for some simple testing if you're right there before what you want to test.  Something like this is definitely helpful, though, for the speed runs.  Might want to also describe how to get rid of the bik animation that plays when you start M&B so you can get right into the game?  :razz:

I yield the floor to you on that topic, oh wise one :wink:

And yeah the saves is a good one. I'm doing changes to dialog a lot so I believe that's not really good for savegame compatibility, plus I really need all the slots to get reset, so I'm pretty much stuck with new games, but for a lot of things I guess that's the much easier option.
 
I'm not wise, just someone with a lot of free time lately.  :razz:

Changing dialog, game menus, and mission templates will not break saves, unless you add a new global variable.  They're loaded on the fly, so no need to start a new game every time there.  But if you're changing slots around as you test your code, then yeah, depending on how and what, you probably want to start a new game.  Unless you're using new slots or the slots are set in the code you run for testing, then it doesn't really matter.  If that made sense...
 
I meant I yield the floor to you on the subject of the bik animation but that information was helpful too, thanks :smile:
 
This looks very cool, thanks very much!

For the intro movie, I just renamed the "binkplay.exe" in the M&B folder to be "binkplay_no_more.exe" and it skips it.
 
Back
Top Bottom