Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
I have some skybox problems after including some osp's to my mod. (expanded horizons and realistic colours 1.22)

Il get some screenies of it if it helps. Basically I have the skybox and then a big white mass between it and the ground.

EDIT:
Big Images
1FA24E532A8691D5AF71AC4876F3324FB5D59240

F632625618B81E65FF8B6130BE0A56A9C11C778B
 
Hello guys I was looking at the Module System Documentation Tutorial and the Module system is different to mine, is there anywhere i could find an updated tutorial of this or similar.
 
jik's .PDF tutorial is the most recent comprehensive MS tutorial. It is stickied in the Tutorials sub-board.
My syntax tutorial is the most recently written general coding tutorial. It is also stickied in the Tutorials sub-board.

Merging to the Q&A thread.
 
Can anyone tell me why I get this error?
Code:
  File "C:\Users\Administrator\Desktop\Mod Merger\modx_mission_templates.py", li
ne 284
    ])
    ^
SyntaxError: invalid syntax
Here is the code
Code:
accuracy_change = (
  ti_on_item_wielded, 0, 0, [],
  [
    (store_trigger_param_1, ":agent"),
    (store_trigger_param_2, ":item_id"),

    (store_skill_level, ":power_draw", "skl_power_draw", ":agent"),
    (store_sub, ":accuracy", 100, ":power_draw"),

    (item_get_type, ":item_type", ":item_id"),
    (try_begin),
      (eq, ":item_type", itp_type_bow,
      (agent_set_accuracy_modifier, ":agent", ":accuracy"),
    (else_try),
      (agent_set_accuracy_modifier, ":agent", 100),
    (try_end),
  ])
 
Using a party slot for troops is wrong. A troop ("trp_kingdom_1_lord") is not a party.
Anyway, if you are trying to add a special global template, you don't need slots at all.

Do this:

1. Define pt_common_reinforcements_a, pt_common_reinforcements_b and pt_common_reinforcements_c. Judging by your careless writing you'll likely have syntax errors. Double check everything for spelling and syntax and make sure it compiles without errors. Don't come back here if you can't do this step, you only need to be careful.

Ok, the compiler actually was doing this (for some reason changing capital letters to normal ones and storing them in ID file).

Anyways, I tried to add the extra loop (try_begin), (try_end) and add condition on center ownership into lord recruitment part. It compiles but no troops are recruited and garrisons are all 0.

I don't try to get rid of original reinforcements, just add an extra one.

I don't understand why it screws up the garrisons, since they're before the lords parties.

I'm using this condition to assign the reinforcements.
    (party_slot_eq, "p_village_12", slot_town_lord,":troop_lord"),


Thanks for your help
 
A sad lack of python skills has led to difficulties in trying to integrate diplomacy into 1.151.  Specifically, 1.151 adds a few extra commas into module_mission_templates.py

For instance.....

1.143
      common_music_situation_update,
      custom_battle_check_victory_condition,
      common_battle_victory_display,
      custom_battle_check_defeat_condition,
    ]
##diplomacy begin
+ dplmc_battle_mode_triggers,
##diplomacy end
  ),

1.151
      common_music_situation_update,
      custom_battle_check_victory_condition,
      common_battle_victory_display,
      custom_battle_check_defeat_condition,
    ],
##diplomacy begin
+ dplmc_battle_mode_triggers,
##diplomacy end
  ),

Presumably this affects which parts of the code are associated with each other.  When compiling, I get the following error:

  File "C:\Program Files (x86)\Mount&Blade Warband\Modules\MyMod\Module System\M
odule_system 1.151\module_mission_templates.py", line 2895, in <module>
    + dplmc_battle_mode_triggers,
TypeError: bad operand type for unary +: 'list'

On the plus side, this is the only compiler error I'm getting (so far).

Any ideas?

Cheers
 
JuJu70 said:
Ok, the compiler actually was doing this (for some reason changing capital letters to normal ones and storing them in ID file).
Identifiers are case insensitive when written as a string (inside quotes), but when used as python variables (not quoted) the processing scripts convert all identifiers to lower case before comparing or writing them to ID_*.py files.

Incidentally, this design causes the module system building scripts to be much slower than they could be: converting to lower case was the highest usage of CPU time by any function and a large proportion of the total time, measured with the python profiling module a while ago; I think it is much better for the building scripts to fail immediately with an error if an identifier with capitals or other invalid characters is used, making the often used normal cases faster at the expense of requiring users to fix occasional mistakes.
 
Sorry, one more question, how do you make certain interfaces ( I guess I may call it that) such as MM and NW's Class selection, or Secession artillery cannon selection.  Thanks everyone for your time.

Edit** Anyone know any good coding tutorials?
 
Is it possible to play a sound as troops march? Kinda like a chant.
What difference does itp_secondary make?
I'd like my soldiers to carry swords but never use it, or rarely use it. Instead use the Sarissa.
 
JuJu70 said:
Using a party slot for troops is wrong. A troop ("trp_kingdom_1_lord") is not a party.
Anyway, if you are trying to add a special global template, you don't need slots at all.

Do this:

1. Define pt_common_reinforcements_a, pt_common_reinforcements_b and pt_common_reinforcements_c. Judging by your careless writing you'll likely have syntax errors. Double check everything for spelling and syntax and make sure it compiles without errors. Don't come back here if you can't do this step, you only need to be careful.

Ok, the compiler actually was doing this (for some reason changing capital letters to normal ones and storing them in ID file).

Anyways, I tried to add the extra loop (try_begin), (try_end) and add condition on center ownership into lord recruitment part. It compiles but no troops are recruited and garrisons are all 0.

I don't try to get rid of original reinforcements, just add an extra one.

I don't understand why it screws up the garrisons, since they're before the lords parties.

I'm using this condition to assign the reinforcements.
    (party_slot_eq, "p_village_12", slot_town_lord,":troop_lord"),


Thanks for your help
Try again. Change ONLY the reinforcement script, don't mess with the trigger code. Use the exact code I provided. Just insert the bold part, with your condition.
About your problem, it seems that you inserted a condition that fails in the trigger code. Remove it.

This:
    (party_slot_eq, "p_village_12", slot_town_lord,":troop_lord"),
Means: reinforce the owner of village_12 with special troops.
Maybe try explaining what exactly are you trying to do, you said earlier you want ALL lords to get special reinforcements if some condition is met.
 
Caba`drin said:
Superelastic said:
A sad lack of python skills has led to difficulties in trying to integrate diplomacy into 1.151.  Specifically, 1.151 adds a few extra commas into module_mission_templates.py
Remove the comma after the bracket you show bolded in the 1.151 spoiler so it matches the 1.143 one.

Cheers Caba`drin, I have done that and it fixed that compiler error but left me with this one:

  File "C:\Program Files (x86)\Mount&Blade Warband\Modules\MyMod\Module System\Module_system 1.151\module_mission_templates.py", line 3239, in <module>
    (try_end),
TypeError: 'tuple' object is not callable

Line 3239 is the last (try_end) in the following block:

              ##diplomacy begin
              (try_begin),
                (eq, "$g_dplmc_battle_continuation", 0),
                (eq, "$g_dplmc_cam_activated", 0),
                (assign, ":num_allies", 0),
                (try_for_agents, ":agent"),
                (agent_is_ally, ":agent"),
                (agent_is_alive, ":agent"),
                (val_add, ":num_allies", 1),
                (try_end),
                (gt, ":num_allies", 0),
                (try_begin),
                  (eq, "$g_dplmc_cam_activated", 0),
                  #(store_mission_timer_a, "$g_dplmc_main_hero_fallen_seconds"),
                  (assign, "$g_dplmc_cam_activated", 1),
                  (display_message, "@You have been knocked out by the enemy. Watch your men continue the fight without you or press Tab to retreat."),
                  (display_message, "@To watch the fight you can use 'w, a, s, d, numpad_+/numpad_-' to move and 'numpad_1,2,3,4,6,8' to rotate the cam."),
                (try_end),
              (else_try),
              ##diplomacy end
              (assign, "$pin_player_fallen", 1),
              (str_store_string, s5, "str_retreat"),
              (call_script, "script_simulate_retreat", 5, 20, 0),
              (assign, "$g_battle_result", -1),
              (set_mission_result,-1),
              (call_script, "script_count_mission_casualties_from_agents"),
              (finish_mission,0)
              ##diplomacy begin
              (try_end),
              ##diplomacy end

              ]),

I appreciate your help but feel free to tell me to go away, learn python, then try again.
 
Somebody said:
(finish_mission,0) needs a trailing comma.

Worked!  Thanks Somebody.  Compiled with no errors....let's go see if it's ok in game.

*update* initial indications are it seems fine, options and battle continuation working ok.  Now to have another crack at PBOD.

*edit* It's Diplomacy 4.2 by the way, manually added rather modmerged.
 
This:
          (party_slot_eq, "p_village_12", slot_town_lord,":troop_lord"),
Means: reinforce the owner of village_12 with special troops.
Maybe try explaining what exactly are you trying to do, you said earlier you want ALL lords to get special reinforcements if some condition is met.

I want 2 things:

1.an owner of some centers to get 'special' reinforcements
2. All lords who have very few troops but have money to be able to hire some merc group

I thought the 1st one would be easier, since Caba'Drin said for the second I need to change the triggers.

So for the first I add this to reinforce_party

(store_script_param_2, ":troop_no"),<- I assume this should come from Creating hero parties script
(try_begin),
    (party_slot_eq, "p_village_12", slot_town_lord,":troop_no"),
    (assign, ":party_template", "pt_common_reinforcements_a"),
(try_end),
(else_try),
....random assignment stuff

I put it in after the castles/towns. But everything gets screwed up - no garrisons, no armies.

So why does it fail?
 
JuJu70 said:
This:
          (party_slot_eq, "p_village_12", slot_town_lord,":troop_lord"),
Means: reinforce the owner of village_12 with special troops.
Maybe try explaining what exactly are you trying to do, you said earlier you want ALL lords to get special reinforcements if some condition is met.

I want 2 things:

1.an owner of some centers to get 'special' reinforcements
2. All lords who have very few troops but have money to be able to hire some merc group

I thought the 1st one would be easier, since Caba'Drin said for the second I need to change the triggers.

So for the first I add this to reinforce_party

(store_script_param_2, ":troop_no"),<- I assume this should come from Creating hero parties script
(try_begin),
    (party_slot_eq, "p_village_12", slot_town_lord,":troop_no"),
    (assign, ":party_template", "pt_common_reinforcements_a"),
(try_end),
(else_try),
....random assignment stuff

I put it in after the castles/towns. But everything gets screwed up - no garrisons, no armies.

So why does it fail?
That code looks messy.. you put a second parameter - do you supply it when calling the script? There's an "else_try" hanging freely where it shouldn't be.

Tell you what, here's the whole reinforce script so you can correct yours. If your error is elsewhere (like triggers messed up by experiments), better start with a fresh module system and try again.
Definitely go through the module system tutorial, or you won't get anywhere.
  # script_cf_reinforce_party
  # Input: arg1 = party_no,
  # Output: none
  # Adds reinforcement to party according to its type and faction
  ("cf_reinforce_party",
    [
      (store_script_param_1, ":party_no"),
     
      (store_faction_of_party, ":party_faction", ":party_no"),
      (party_get_slot, ":party_type",":party_no", slot_party_type),

#Rebellion changes begin:
      (try_begin),
        (eq, ":party_type", spt_kingdom_hero_party),
        (party_stack_get_troop_id, ":leader", ":party_no"),
        (troop_get_slot, ":party_faction",  ":leader", slot_troop_original_faction),
#            (this_or_next|is_between, ":party_faction", rebel_factions_begin, rebel_factions_end),
#            (faction_get_slot, ":target_faction", ":party_faction", slot_faction_rebellion_target),
#            (assign, ":party_faction", ":target_faction"),
#            (assign, ":party_faction", "fac_kingdom_1"),
      (try_end),
#Rebellion changes end

      (try_begin),
        (eq, ":party_faction", "fac_player_supporters_faction"),
        (party_get_slot, ":town_lord", ":party_no", slot_town_lord),
        (try_begin),
          (gt, ":town_lord", 0),
          (troop_get_slot, ":party_faction", ":town_lord", slot_troop_original_faction),
        (else_try),
          (party_get_slot, ":party_faction", ":party_no", slot_center_original_faction),
        (try_end),
      (try_end),
     
      (faction_get_slot, ":party_template_a", ":party_faction", slot_faction_reinforcements_a),
      (faction_get_slot, ":party_template_b", ":party_faction", slot_faction_reinforcements_b),
      (faction_get_slot, ":party_template_c", ":party_faction", slot_faction_reinforcements_c),

      (assign, ":party_template", 0),
      (store_random_in_range, ":rand", 0, 100),
      (try_begin),
        (this_or_next|eq, ":party_type", spt_town),
        (eq, ":party_type", spt_castle),  #CASTLE OR TOWN
        (try_begin),
          (lt, ":rand", 65),
          (assign, ":party_template", ":party_template_a"),
        (else_try),
          (assign, ":party_template", ":party_template_b"),
        (try_end),
      (else_try),
        (eq, ":party_type", spt_kingdom_hero_party),
        (try_begin),
          (lt, ":rand", 50),
          (assign, ":party_template", ":party_template_a"),
        (else_try),
          (lt, ":rand", 75),
          (assign, ":party_template", ":party_template_b"),
        (else_try),
          (assign, ":party_template", ":party_template_c"),
        (try_end),
      (else_try),
      (try_end),

      (try_begin),
        (eq, ":party_type", spt_kingdom_hero_party),
        (party_stack_get_troop_id, ":troop_lord", ":party_no", 0),
        (party_slot_eq, "p_village_12", slot_town_lord,":troop_lord"),
        (assign, ":party_template", "pt_common_reinforcements_a"),
      (try_end),


      (try_begin),
        (gt, ":party_template", 0),
        (party_add_template, ":party_no", ":party_template"),
      (try_end),
  ]),
 
That code looks messy.. you put a second parameter - do you supply it when calling the script? There's an "else_try" hanging freely where it shouldn't be.


Thanks for the code I will try it

I put my special part before native random recruitment that's why there was (else_try) (it wasn't hanging).

A question - reinforce_party script is being called from form_hero_party script for ":troop_no". So that ":troop_no" is not "remembered" (that what i was trying to store)?

Question 2 - is there a better compiler?
 
Status
Not open for further replies.
Back
Top Bottom