Modding Q&A [For Quick Questions and Answers]

正在查看此主题的用户

状态
不接受进一步回复。
Hi all,

I have a question. I am working on a mod that I hope to release some time this year, and I have found several bits and bobs in other mods that I'd like to use. I always make a point of asking someone for permission before using their stuff, but what do I do if I can't find the name of the person who made it, or if they don't show up in member searches? And what if the member in question has been inactive for years?

I wouldn't want to step on any toes, so thought I'd ask here.

Thanks in advance

-Rob
 
插入代码块:
troop_set_inventory_slot                 = 1543  # (troop_set_inventory_slot, <troop_id>, <inventory_slot_no>, <item_id>),
                                                 # Puts the specified item into troop's equipment or inventory slot. Be careful with setting equipment slots this way.

Any reason why we should be careful?

Edit:

插入代码块:
[
     (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
     (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
     ],
Another question. As far as I understand the 12 or 0 at the end is troops to spawn. Can someone explain this bit, like why does the game spawn like all troops anyway?
 
about troop_set_inventory_slot, it probably says to be carefull because that operation WILL override any other item that was in that slot
 
I have a town with 3 villages in very close proximity. One of the villages is white and is owned by no one when you start a new game despite easily being in the catchment zone. When I move that village over the other side of the town it becomes owned as normal but then one of the other villages that was ok before is now unowned in it's place. It is the only village in the entire map which does this. Any ideas on the cause, I haven't edited the parties.py in quite a while now.
 
You might just have too many villages in total. There is no "radius"; at the beginning of the game a script gives villages to castles (1 each) and then to towns, regardless of distance. I can't remember if there's some implicit limit to the number of villages a town can have though.
 
module system itself cant handle strings, tought you can kinda hack it using fake_key strings and the new operations that handle it
 
How do I make agents switch from walking to running or from running to walking? And how to make agents walk around randomly?
 
This code doesn't send the player into the menu- it only send the player to the party screen then back to the map:
[anyone|plyr,"prisoner_chat_noble", [(eq,"$g_talk_troop","trp_knight_2_7"),(main_party_has_troop, "trp_npc_adonja"),(check_quest_active, "qst_hunt_down_count_stephan"),], "Stephan... Do you remember attacking some Mystmountains many years back? The Catsclaw Clan will always remember. We will duel to the death you and I.", "prisoner_chat_stephan_duel",[]],
  [anyone,"prisoner_chat_stephan_duel", [], "So be it, knave. May the best man win.", "close_window",[(jump_to_menu, "mnu_stephan_duel_menu"),]],

  ("stephan_duel_menu",0,
  "You give Stephan his weapons back, and prepare to duel...",
... the menu never appears. No compile errors.
 
I would highly recommend against using prisoner_chat, it doesn't have many of the conversation globals initialized and the issue with the party screen as you've seen. You're better off triggering it with the npc grievance/map talk mechanism, which can jump to a menu.
 
Hello!

I've made  simple_trigger:

# Training Grounds
  (1 * 1,
  [(try_for_range, ":cur_castle", castles_begin, castles_end),
    (party_slot_eq, ":cur_castle", slot_center_has_training_grounds, 1),

     
 
(party_get_slot, ":party_faction", ":cur_castle", slot_center_original_faction),
(party_get_slot, ":party_culture", ":cur_castle", slot_faction_culture),

(assign, reg6, ":party_faction"),
        (assign, reg7, ":party_culture"), 

  (faction_get_slot, ":party_template_d", ":party_faction", slot_faction_reinforcements_d),
  (str_store_party_name, s6, ":party_template_d"),
 
  (party_add_template, ":cur_castle", ":party_template_d"),
 
  (party_add_template, ":cur_castle", "pt_steppe_bandits"),
 
  (str_store_party_name, s4, ":cur_castle"),
  (display_log_message, "@Training Grounds in {s4} has trained new reinforcements.",0x477e46),
  (display_log_message, "@Faction {reg6} has trained new reinforcements.",0x477e46),
  (display_log_message, "@Culture {reg7} has trained new reinforcements.",0x477e46),
  (display_log_message, "@:party_template_d {s6}.",0x477e46),
    (try_end),
    ]),

I wanted to make a trigger which would add to every castle (with Training Grounds built). When I try this I got reinforcements from pt_steppe_bandits but nothing from slot_faction_reinforcements_d for each faction. (yes, I have made this template so it is not blank).

I think that I messed up with code which takes the faction and culture from castle_party... But I am too weak in coding to understand  what I've done wrong.

So, a help, please?
 
Try to assign registers and string registers before you use them. str_store_party_name won't work with templates, parties only. You can use str_store_faction_name instead of the id as a register. Even if you've made the party templates in the right order, there's nothing magical assigning it to slot_faction_reinforcements_d. If you wanted the current faction you should be using store_faction_of_party, not a slot value.
 
Ok, this is what I did:

I have this ready to go:
from party_templates
("kingdom_1_reinforcements_a", "{!}kingdom_1_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_swadian_recruit,3,7),(trp_swadian_militia,3,7),(trp_swadian_footman,2,4),(trp_swadian_skirmisher,2,4),(trp_swadian_man_at_arms,2,4)]),
("kingdom_1_reinforcements_b", "{!}kingdom_1_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_swadian_crossbowman,4,7),(trp_swadian_infantry,3,7),(trp_swadian_sergeant,3,6), ]),
("kingdom_1_reinforcements_c", "{!}kingdom_1_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_swadian_knight,6,14)]),
("kingdom_1_reinforcements_d", "{!}kingdom_1_reinforcements_d", 0, 0, fac_commoners, 0, [(trp_mlk_culture_commisar,3,7),(trp_mlk_political_commisar,3,7)]),
("kingdom_1_reinforcements_e", "{!}kingdom_1_reinforcements_e", 0, 0, fac_commoners, 0, [(trp_mlk_internal_affairs_commisar,3,5),(trp_mlk_elite_prop_guard,1,3)]),

("kingdom_2_reinforcements_a", "{!}kingdom_2_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_vaegir_recruit,5,10),(trp_vaegir_footman,2,4)]),
("kingdom_2_reinforcements_b", "{!}kingdom_2_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_vaegir_veteran,2,4),(trp_vaegir_skirmisher,2,4),(trp_vaegir_footman,1,2)]),
("kingdom_2_reinforcements_c", "{!}kingdom_2_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_weimear_armored_archer_schutze,3,5), (trp_vaegir_horseman,4,4),(trp_weimear_knecht_schutze,1,3),(trp_weimear_flak_heavy_archer,1,2),(trp_weimear_flak_37,1,2)]),
("kingdom_2_reinforcements_d", "{!}kingdom_2_reinforcements_d", 0, 0, fac_commoners, 0, [(trp_weimear_flak_57_archer,1,2), (trp_weimear_panzer_schutze,1,1),(trp_weimear_sieg_stuhrmer,1,2),(trp_weimear_deithwen_marder,1,4),(trp_weimear_commando_panzer_buddhae,2,5)]),
("kingdom_2_reinforcements_e", "{!}kingdom_2_reinforcements_e", 0, 0, fac_commoners, 0, [(trp_weimear_commando_oberstuhrmer,1,1), (trp_weimear_commando_fuhrer,1,2),(trp_weimear_deithwen_nashorn,1,1),(trp_vaegir_volks_major,1,2),(trp_weimear_deithwen_royal_tiger,2,5)]),

("kingdom_3_reinforcements_a", "{!}kingdom_3_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_khergit_tribesman,3,5),(trp_khergit_skirmisher,4,9)]),
("kingdom_3_reinforcements_b", "{!}kingdom_3_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_khergit_horseman,2,4),(trp_khergit_horse_archer,2,4),(trp_khergit_skirmisher,1,2)]),
("kingdom_3_reinforcements_c", "{!}kingdom_3_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_khergit_horseman,2,4),(trp_khergit_veteran_horse_archer,2,3)]),
("kingdom_3_reinforcements_d", "{!}kingdom_3_reinforcements_d", 0, 0, fac_commoners, 0, [(trp_khergit_horseman,2,4),(trp_khergit_veteran_horse_archer,2,3)]),
("kingdom_3_reinforcements_e", "{!}kingdom_3_reinforcements_e", 0, 0, fac_commoners, 0, [(trp_khergit_horseman,2,4),(trp_khergit_veteran_horse_archer,2,3)]),

("kingdom_4_reinforcements_a", "{!}kingdom_4_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_nord_footman,5,10),(trp_nord_recruit,2,4),(trp_nord_huntsman,2,5),(trp_nord_archer,2,3),(trp_nord_footman,1,2)]),
("kingdom_4_reinforcements_b", "{!}kingdom_4_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_nord_warrior,3,5),(trp_nord_champion,1,3),(trp_orc_warg_scout,1,4),(trp_orc_warg_raider,1,2),(trp_orc_warg_gladiator,1,2)]),
("kingdom_4_reinforcements_c", "{!}kingdom_4_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_uruk_warg_ranger,3,5), (trp_uruk_grunt,4,4),(trp_uruk_corporal,1,3),(trp_elf_druid_apprentice,1,2),(trp_elf_druid,1,2)]),
("kingdom_4_reinforcements_d", "{!}kingdom_4_reinforcements_d", 0, 0, fac_commoners, 0, [(trp_council_mage,1,2), (trp_council_elder,1,1),(trp_council_white_mage,1,2),(trp_uruk_commander,1,4),(trp_uruk_veteran,2,5)]),
("kingdom_4_reinforcements_e", "{!}kingdom_4_reinforcements_e", 0, 0, fac_commoners, 0, [(trp_council_lord_of_darkness,1,1), (trp_council_high_vayyal,1,2),(trp_council_archmage_vayyal,1,1),(trp_uruk_hero,1,2),(trp_council_dark_lord,2,5)]),

("kingdom_5_reinforcements_a", "{!}kingdom_5_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_rhodok_tribesman,5,10),(trp_rhodok_spearman,2,4),(trp_rhodok_crossbowman,3,6),(trp_rhodok_trained_crossbowman,2,4),(trp_rhodok_veteran_spearman,2,3)]),
("kingdom_5_reinforcements_b", "{!}kingdom_5_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_rhodok_veteran_crossbowman,1,2),(trp_rena_sergeant_pikeman,2,4),(trp_rena_conquista,3,6),(trp_rhodok_sharpshooter,2,4),(trp_rena_hussarian,2,4)]),
("kingdom_5_reinforcements_c", "{!}kingdom_5_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_rena_royal_marksman,2,2),(trp_rena_conquista_sergeant,1,2),(trp_rena_marksman,1,5),(trp_rena_officer_pikeman,1,2),(trp_rena_musketeer,2,4)]),
("kingdom_5_reinforcements_d", "{!}kingdom_5_reinforcements_d", 0, 0, fac_commoners, 0, [(trp_rena_musk_commander,2,2),(trp_rena_arm_firemaster,1,4),(trp_rena_elite_hussarian,2,5),(trp_rena_commander_pikeman,1,2),(trp_rena_sapper,1,2)]),
("kingdom_5_reinforcements_e", "{!}kingdom_5_reinforcements_e", 0, 0, fac_commoners, 0, [(trp_rena_elite_pikeman,1,1),(trp_rena_sapper,3,5),(trp_rena_elite_hussarian,1,2)]),

("kingdom_6_reinforcements_a", "{!}kingdom_6_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_sarranid_recruit,5,10),(trp_sarranid_footman,2,4)]),
("kingdom_6_reinforcements_b", "{!}kingdom_6_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_sarranid_skirmisher,2,4),(trp_sarranid_veteran_footman,2,3),(trp_sarranid_footman,1,3)]),
("kingdom_6_reinforcements_c", "{!}kingdom_6_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_sarranid_horseman,3,5)]),
("kingdom_6_reinforcements_d", "{!}kingdom_6_reinforcements_d", 0, 0, fac_commoners, 0, [(trp_sarranid_horseman,3,5)]),
("kingdom_6_reinforcements_e", "{!}kingdom_6_reinforcements_e", 0, 0, fac_commoners, 0, [(trp_sarranid_horseman,3,5)]),
("kingdom_mercenary_hero", "{!}kingdom_mercenary_hero", icon_flagbearer_a|carries_goods(16) |pf_show_faction,0,fac_commoners,soldier_personality,[(trp_mercenary_hero_leader,1,1),(trp_mercenary_companions,4,12),(trp_mercenary_horseman,4,:cool:,(trp_mercenary_crossbowman,10,30),(trp_hired_blade,5,10),(trp_watchman,5,20)] ),

then :

module_simple_triggers:
(2 * 1,
  [(try_for_range, ":party_no", castles_begin, castles_end),
     
      (party_slot_eq, ":party_no", slot_center_has_barracks, 1),

 
      #(call_script, "script_cf_reinforce_party_soldiers", ":party_no",3),
  (call_script, "script_cf_reinforce_party_barracks", ":party_no"),
  #(call_script, "script_cf_reinforce_party", ":party_no"),
 
  (display_message, "@debug Barracks", 0xFFFF00),
    (try_end),
    ]),

then I tried script_cf_reinforce_party - the castle gets its reinforcements BUT from previous owner of towns/castle culture not from the players culture. At least this is best I could do.

So I duplicated this script (script_cf_reinforce_party) and changed (besides debug messages) ONLY one thing: I've forced it to choose random from 75, 77 so it would guarantee choosing of
(assign, ":party_template", ":party_template_d"), 
and added party_templates_d and _e

below is the mine version: script cf_reinforce_party_barracks (change in red)

# script_cf_reinforce_barracks
  # Input: arg1 = party_no,
  # Output: none
  # Adds reinforcement to party according to its type and faction
  # Called from several places, simple_triggers for centers, script_hire_men_to_kingdom_hero_party for hero parties
  ("cf_reinforce_party_barracks",
    [
      (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),
      (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),
(faction_get_slot, ":party_template_d", ":party_faction", slot_faction_reinforcements_d),
  (faction_get_slot, ":party_template_e", ":party_faction", slot_faction_reinforcements_e),

      (assign, ":party_template", 0),
    (store_random_in_range, ":rand", 75, 77),    #forced random to get party_template_d
      (try_begin),
        (this_or_next|eq, ":party_type", spt_town),
        (eq, ":party_type", spt_castle),  #CASTLE OR TOWN
        (try_begin),
          (lt, ":rand", 25),
          (assign, ":party_template", ":party_template_a"),
        (else_try),
          (lt, ":rand", 45),
          (assign, ":party_template", ":party_template_b"),
        (else_try),
  (lt, ":rand", 65),
  (assign, ":party_template", ":party_template_c"),
(else_try),
  (lt, ":rand", 80),
  (assign, ":party_template", ":party_template_d"), 
(else_try),
  (assign, ":party_template", ":party_template_e"),   
        (try_end),
      (else_try),
        (eq, ":party_type", spt_kingdom_hero_party),
        (try_begin),
          (lt, ":rand", 25),
          (assign, ":party_template", ":party_template_a"),
        (else_try),
          (lt, ":rand", 45),
          (assign, ":party_template", ":party_template_b"),
      (else_try),
  (lt, ":rand", 65),
  (assign, ":party_template", ":party_template_c"),
(else_try),
  (lt, ":rand", 80),
  (assign, ":party_template", ":party_template_d"), 
(else_try),
  (assign, ":party_template", ":party_template_e"),   
        (try_end),
      (else_try),
      (try_end),

  (assign, reg9, ":party_template"), 
  (display_message, "@party_template  {reg9}", 0xFFFF00),
 
      (try_begin),
        (gt, ":party_template", 0),
        (party_add_template, ":party_no", ":party_template"),
      (try_end),
  ]),

And THIS tiny change makes that in-game I don;t get any reinforcements to the castle. Why? I don't get it? It is just forcing game to change random into specified amount but this doesn't work.

Till now I've tried doing this again and again from scratch making also new scripts, but nothing works. I've also tried to run another modified script
# script_cf_reinforce_party_soldiers
  # Input: arg1 = party_no,
  # Input: arg2 = soldiers_rank,
  # Output: none
  # Adds reinforcement to party according to its type and faction
  # Called from several places, simple_triggers for centers, script_hire_men_to_kingdom_hero_party for hero parties
  ("cf_reinforce_party_soldiers",
    [
      (store_script_param_1, ":party_no"),
  (store_script_param_2, ":rand"),
 
  (assign, reg6, ":party_no"),
      (assign, reg7, ":rand"), 
  (display_message, "@debug party_no  {reg6}", 0xFFFF00),
  (display_message, "@debug rand  {reg7}", 0xFFFF00),
     
      (store_faction_of_party, ":party_faction", ":party_no"),
     
     

 
       
       
     
  (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),
  (faction_get_slot, ":party_template_d", ":party_faction", slot_faction_reinforcements_d),
  (faction_get_slot, ":party_template_e", ":party_faction", slot_faction_reinforcements_e),
     
      (try_begin),
          (eq, ":rand", 1),
          (assign, ":party_template", ":party_template_a"),
        (else_try),
          (eq, ":rand", 2),
          (assign, ":party_template", ":party_template_b"),
        (else_try),
  (eq, ":rand", 3),
  (assign, ":party_template", ":party_template_c"),
(else_try),
  (eq, ":rand", 4),
  (assign, ":party_template", ":party_template_d"), 
(else_try),
  (eq, ":rand", 5),
  (assign, ":party_template", ":party_template_e"),
        (try_end),



 
  (assign, reg9, ":party_template"), 
  (display_message, "@Debug party_template  {reg9}", 0xFFFF00),
 
      (try_begin),
        (gt, ":party_template", 0),
        (party_add_template, ":party_no", ":party_template"),
      (try_end),
  ]),

but still the only one script working is the original one. BTW: Debug messages from original script gives back ID's of party templates from 46 to 76 which is (pt_kingdom_1_reinforcements_a = 46 to pt_kingdom_6_reinforcements_e = 75) but my versions give back only 0.

How I make a code that would add castle reinforcements referred to player's culture?
 
状态
不接受进一步回复。
后退
顶部 底部