Zaitenko的最近内容

  1. Modding Q&A [For Quick Questions and Answers]

    demize2010 说:
    Hey guys, is there an operation to change inter-faction relations mid game?

    The idea being that by completeing a quest you make on faction like another faction more.

    Also is there a way to force factions to be permanately at peace or at war with each other both via the module system and via an operation?

    Cheers in advance!

    Hey,

    Yes you can change faction relations easily using a couple of scripts.
    And to lock two factions at war/peace you can negate some things in the script that makes them go to war or peace and simply declare at game start that you want them to be at war or peace.

    To set a relation between two kingdoms use the set_relation operation. Example:
    插入代码块:
    (set_relation, ":kingdom_a", ":kingdom_b", "10")

    To make two kingdoms go to war with eachother use call the script script_diplomacy_start_war_between_kingdoms. Example:

    插入代码块:
    (call_script, "script_diplomacy_start_war_between_kingdoms", "fac_kingdom_1", "fac_kingdom_2"),

    To make two kingdoms be permanently at war with eachother, add something like this to the "randomly_start_war_peace" script.

    插入代码块:
               (assign, ":jumpout", 0),
               (try_begin),
                   (this_or_next|eq, "fac_your_first_kd", ":cur_kingdom"),
                   (eq, "fac_your_second_kingdom", ":cur_kingdom"),
                   (this_or_next|eq, "fac_your_first_kingdom", ":cur_kingdom_2"),
                   (eq, "fac_your_second_kingdom", ":cur_kingdom_2"),
                   (assign, ":jumpout", 1),
               (try_end),
               (eq, ":jumpout", 0),

    Add it just before this line:
    插入代码块:
               (call_script, "script_diplomacy_start_peace_between_kingdoms", ":cur_kingdom", ":cur_kingdom_2"),


    That will make it stop them from randomly going to peace with eachother.

    An easier solution, tho abit of a hax job imho is to make the two go to war every time two kingdoms go to peace.(the system will still give a message telling you they are at peace unless you negate that tho).

    Did this anwser your problem or do you have further questions?

    Zait
  2. Whats in a name? (Messing with names)

    Hmm. Do you want to be able to create a new troop in mid game with a new name, or use an old troop with a new name?
    Or actually use the SAME troop and just change the name of him/her? Here I'm talking about the displayed name, but something tells me that's not what you want to do.

    I'm starting work in 7 minutes but this sounds like something worth digging into so I'll do that after work if you haven't gotten it solved :eek:

    Edit: If it IS only the displayed name I know it's doable and easy.
  3. NEW factions? edited - new question

    It might be alot more complicated, or quite easy.

    You see that depends on if you don't want it to spawn from the entire faction - should they capture a new castle or town - or if you just don't want that castle to spawn them?

    For the entire faction to not spawn any caravans you can make easy adjustments in module_triggers.py.

    Find this passage:

    插入代码块:
    (try_begin),
            (store_random_in_range, ":random_no", 0, 100),
            (lt, ":random_no", 10),
            (call_script, "script_create_kingdom_party_if_below_limit", ":kingdom", spt_kingdom_caravan),
          (try_end),

    And change it to this:

    插入代码块:
    (neg|eq, ":kingdom", "fac_enter_your_faction_name_here"),
            (try_begin),
            (store_random_in_range, ":random_no", 0, 100),
            (lt, ":random_no", 10),
            (call_script, "script_create_kingdom_party_if_below_limit", ":kingdom", spt_kingdom_caravan),
          (try_end),

    Otherwise... It will be alot trickier. And I can't look into it atm, need sleep. Long day today aswell >.<

    Hope that helped atleast!

    Zait


  4. NEW factions? edited - new question

    Sorry mate, I worked late last night. Will see if I can look at what you need to do for caravans tonight if no one else has anwserd. Haven't got the code here at work as you may understand :razz:
  5. What's wrong with this code?

    No it's me that fecked up :razz:

    I use :center_no more often. I'll change that. And you are correct, just change it to ":center".

    Sorry again.
  6. NEW factions? edited - new question

    Easy my friend.

    You must go to the dreaded module_scripts.py! There you must seek the early declarations for this most evil passage:

    插入代码块:
     #pass 1: Give one village to each castle and town
          (try_for_range, ":cur_center", walled_centers_begin, walled_centers_end),
            (assign, ":min_dist", 999999),
            (assign, ":min_dist_village", -1),
            (try_for_range, ":cur_village", villages_begin, villages_end),
              (store_distance_to_party_from_party, ":cur_dist", ":cur_village", ":cur_center"),
              (lt, ":cur_dist", ":min_dist"),
              (assign, ":min_dist", ":cur_dist"),
              (assign, ":min_dist_village", ":cur_village"),
            (try_end),
            (party_set_slot, ":min_dist_village", slot_village_bound_center, ":cur_center"),
            (store_faction_of_party, ":town_faction", ":cur_center"),
            (call_script, "script_give_center_to_faction_aux", ":min_dist_village", ":town_faction"),
          (try_end),


    Now! Behold your solution. Change the begining to resemble this!

    插入代码块:
    (try_for_range, ":cur_center", walled_centers_begin, walled_centers_end),
            (neg|eq, ":cur_center", "p_insert_name_of_your_castle_here"),

    And tremble and despair! The village will belong to someone else. :smile:

    In case you don't quite understand what I did, I simply found the passage that gives the villages to castles and then say:
    Unless it's this castle! Don't give any to that one.

    Hope that helps!
  7. What's wrong with this code?

    DMcain, I've tried to anwser your questions in the script exchange. That is not this exact code but a modified (and better imho) form of it.
    If you got more questions after reading it feel free to pm me :smile:
  8. PYTHON SCRIPT/SCHEME EXCHANGE

    Zaitenko's Reinforcement Script

    Allright I've made a modification to M&B that makes the castles/towns get reinforcements from their respective villages when they go below a number of troops in their garrisons.
    I did it because I got tired of being able to tear down town defenses with alot less men than the castle/town by just attacking it repeatedly.

    And when you had taken a castle/town I've never seen an npc lord that got command of it reinforce the garrison himself.

    The modification makes Reinforcement parties spawn from the villages and travel to the castles/towns and then join them upon arrival.
    It's set not to reinforce player owned towns/castles, but that is a personal preferance and easy to change.

    To the code!!

    In module_triggers we add this code. Basicly it's the main code that determins if a party should spawn, where it should go and what template it should use.

    I do believe you can add the code anywhere you like in module_triggers. Afaik there are no hardwired triggers.

    插入代码块:
    (36, 0, 0.0, [], [  ## Set the reinforcements interval to 36 Game hours. Change as you feel like.
                         (try_for_range, ":center", walled_centers_begin, walled_centers_end),
                             (store_faction_of_party, ":faction", ":center"),
                             (party_get_num_companions, ":garrison", ":center"),
                             (faction_get_slot, ":party_template_a", ":faction", slot_faction_reinforcements_a),
                             (faction_get_slot, ":party_template_b", ":faction", slot_faction_reinforcements_b),
                             (faction_get_slot, ":party_template_c", ":faction", slot_faction_reinforcements_c),
                             (assign, ":party_template", 0),
                             (try_begin),
                                 (party_slot_eq, ":center", slot_party_type, spt_town),
                                 (lt, ":garrison", 200),            ## Under this number of troops will towns get reinforcements
                                 (assign, ":party_template", "pt_reinforcements"),
                             (else_try),
                                 (party_slot_eq, ":center", slot_party_type, spt_castle),
                                 (lt, ":garrison", 70),            ## Under this number of troops will castles get reinforcements
                                 (assign, ":party_template", "pt_reinforcements"),
                             (try_end),
                             (try_begin),
                                 (gt, ":party_template", 0),
                                 (try_for_range, ":village_reinforcements", villages_begin, villages_end),
                                     (try_begin),
                                         (party_slot_eq, ":center", slot_party_type, spt_castle),  ## For Castles
                                         (party_slot_eq, ":village_reinforcements", slot_village_bound_center, ":center"),
                                         (party_slot_eq, ":village_reinforcements", slot_village_state, svs_normal), ## Not if the village is being raided or is looted
                                         (neg|party_slot_eq, ":center", slot_town_lord, "trp_player"),  ## Not a player owned center
                                         (spawn_around_party, ":village_reinforcements", ":party_template"),
                                         (assign, ":result", reg0),
                                         (store_random_in_range, ":rand", 0, 100),
                                         (try_begin),
                                             (is_between, ":rand", 0, 45),  ## Get weakest template
                                             (party_add_template, ":result", ":party_template_a"),
                                         (else_try),
                                             (is_between, ":rand", 45, 85), ## Get stronger template
                                             (party_add_template, ":result", ":party_template_b"),
                                         (else_try),
                                             (ge, ":rand", 85), ## Get strongest template
                                             (party_add_template, ":result", ":party_template_c"),
                                         (try_end),
                                         (party_set_faction, ":result", ":faction"),
                                         (party_set_slot, ":result", slot_party_type, spt_reinforcement_party),
                                         (party_set_slot, ":result", slot_party_ai_object, ":center"),
                                         (str_store_party_name, s14, ":village_reinforcements"),
                                         (party_set_name, ":result", "@Reinforcements from {s14}"),
                                         (party_set_ai_behavior,":result",ai_bhvr_travel_to_party),
                                         (party_set_ai_object,":result", ":center"),
                                         (party_set_flags, ":result", pf_default_behavior, 1),
                                     (else_try),        
                                         (party_slot_eq, ":center", slot_party_type, spt_town), ## For Towns
                                         (party_slot_eq, ":village_reinforcements", slot_village_bound_center, ":center"),
                                         (party_slot_eq, ":village_reinforcements", slot_village_state, svs_normal), ## Not if the village is being raided or is looted
                                         (neg|party_slot_eq, ":center", slot_town_lord, "trp_player"), ## Not a player owned center
                                         (spawn_around_party, ":village_reinforcements", ":party_template"),
                                         (assign, ":result", reg0),
                                         (store_random_in_range, ":rand", 0, 100),
                                         (try_begin),
                                             (is_between, ":rand", 0, 45),  ## Get weakest template
                                             (party_add_template, ":result", ":party_template_a"),
                                         (else_try),
                                             (is_between, ":rand", 40, 85), ## Get stronger template
                                             (party_add_template, ":result", ":party_template_b"),
                                         (else_try),
                                             (ge, ":rand", 85), ## Get strongest template
                                             (party_add_template, ":result", ":party_template_c"),
                                         (try_end),
                                         (party_set_faction, ":result", ":faction"),
                                         (party_set_slot, ":result", slot_party_type, spt_reinforcement_party),
                                         (party_set_slot, ":result", slot_party_ai_object, ":center"),
                                         (str_store_party_name, s14, ":village_reinforcements"),
                                         (party_set_name, ":result", "@Reinforcements from {s14}"),
                                         (party_set_ai_behavior,":result",ai_bhvr_travel_to_party),
                                         (party_set_ai_object,":result", ":center"),
                                         (party_set_flags, ":result", pf_default_behavior, 1),
                                     (try_end),
                                 (try_end),
                             (try_end),
                         (try_end)])

    Okay, that's a chunk of code that I've tried to comment for clarity on some parts of it.
    The reinforcements will come even if the center is being besieged, but they will come as a small party(or well, as you have defined the reinforcements in you module_party_templates) so keep an eye open while resting at a castle/town and you can intercept them before they sneak in. This makes the most sense to me, but if you don't want them to come if the castle is being besieged, simply add this code

    插入代码块:
    (party_get_slot, ":besieged", ":center", slot_center_is_besieged_by),
                             (neg|ge, ":besieged", 0), #Town/castle is under siege jump out

    after the begining

    插入代码块:
    (try_for_range, ":center", walled_centers_begin, walled_centers_end),

    I have not given that thorough testing, but I'm pretty sure that will work.

    Two rather critical but very small steps will follow. First add this anywhere after the hardwired code in module_party_templates:

    插入代码块:
    ("reinforcements","Reinforcements",icon_axeman|pf_show_faction,0,fac_commoners,soldier_personality,[]),

    Now to the next step. You may or may not have noticed that I gave the reinforcement party a party type slot called: spt_reinforcement_party
    Well there is no such thing if you don't create it. So open up module_constants which is where(afaik) all the diffrent slot types are stored.
    Add this line of code where the rest of the slot_party_type value's are.

    插入代码块:
    spt_reinforcement_party = 14

    Take notice, if you have modded in other party types your 14 slot may be taken and you may have to give it another slot value.

    Easily done. Are we done? No.

    At the moment we got reinforcement parties travelling allright, but they are not joining the town/castle. For this to work, we need module_simple_triggers.

    I put this code close to the #Troop AI: Merchants thinking line.

    插入代码块:
    (0.2,  #Every 0.2 game hours will the game check if there are any reinforcements in the centers.
       [
           (try_for_parties, ":party_no"), 
             (party_slot_eq, ":party_no", slot_party_type, spt_reinforcement_party),  #Find parties of the type spt_reinforcement_party
             (party_is_in_any_town, ":party_no"),  # Is the party in any town?
             (party_get_cur_town, ":cur_center", ":party_no"), #What town are they in?
             (call_script, "script_party_add_party_companions", ":cur_center", ":party_no"), #Add the party to the center, which is infact a party ;)
             (party_clear, ":party_no"), #Not sure if this cleaning up is necessary, but it's a precaution so we don't have a bundle of templates lying around.
           (try_end), 
        ]),

    Then ofcourse you can add some hip dialoge to them if you please. I did this quickly:

    插入代码块:
    # Reinforcements
      [party_tpl|pt_reinforcements,"start", [(eq,"$talk_context",tc_party_encounter),
                                             (party_get_slot, ":ai_object", "$g_encountered_party", slot_party_ai_object),
                                             (str_store_party_name,s21,":ai_object"),
                                             (str_store_party_name, s20, "$g_encountered_party")],
       "Who goes there? We are {s20}.\ We're on our way to {s21}.", "reinforcements_intro",[]],
      [anyone|plyr, "reinforcements_intro", [], "I am {playername}. I'm just passing by.", "close_window",[]],
      [anyone|plyr, "reinforcements_intro", [], "I am {playername}. And I'm here to stop you from reaching your destination!.", "reinforcement_hostile",[]],
      [party_tpl|pt_reinforcements,"reinforcement_hostile", [(faction_get_slot, ":faction_leader", "$g_encountered_party_faction",slot_faction_leader),
                                                             (str_store_troop_name, s9, ":faction_leader"),],
                                                             "What!? We are under the protection of {s9}!\ Be certain he will take vengance!", "reinforcements_attack",[]],
      [anyone|plyr, "reinforcements_attack", [], "Fine let him! I will kill him after I've dealt with you!", "close_window",[(call_script, "script_make_kingdom_hostile_to_player", "$g_encountered_party_faction", -1),
                                                                                                                              (encounter_attack,0)]],
      [anyone|plyr, "reinforcements_attack", [], "Allright, go! But you have not seen the last of me!", "close_window",[]],

    Haven't really had chance to test it yet but I think it'll work.

    And there you have it. Hope you like it!

    Zait

    Edit - Working On:
    Anyway, I've updated  the script due to a simple copy/paste err of mine. The script still worked fine but it took the garrison size from the garrison AND the potential parties resting at the castle/town. This was not intended and it's been fixed. If you run the script in your mod, re-copy paste the part that goes into module_triggers.py.

    Thanks NCrawler for dialogue correction.
  9. What's wrong with this code?

    I've actually changed the code to send reinforcements in small parties from the villages that belong to those Towns/Castles.

    This requires a little bit more than some code in triggers tho.

    I'm happy to see that my little project seems to be of interest to some.
  10. What editor do you use to mod?

    I use Python 2.5 IDLE (noob >.<)

    For modding in new models I use Maya 7.0 and PS CS2 for texturing.

    Zait
  11. How would I get this to work?

    Solved it.

    simple_triggers is the key :wink:
  12. How would I get this to work?

    Say for simplicity I'd like a kingdom caravan to become a part of the garrison when it reaches it's destination. Anyone have a clue how I'd be able to do that? I'm working on code to make the villages reinforce the garrisons of the castles and towns by sending small parties to them. The...
  13. regional recruits

    Exactly what do you want to accomplish?

    Every village should have their own unique recruit?

    At the moment you're center get's the troop it's supposed to have available from these lines primarily:

    插入代码块:
           (party_get_slot, ":center_culture", ":center_no", slot_center_culture),
           (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),

    Now, if you want a diffrent troop for each village you might specify the troop for each village much as is done currently for slot_faction_tier_1_troop).
    Add this under Party in module_constants.py:

    插入代码块:
    slot_village_recruits           = 46

    Then, in module_scripts.py scroll up to the declarations for villages.
    Add your new declarations after this clump of code:
    插入代码块:
          (party_set_slot,"p_castle_1", slot_center_siege_with_belfry,   0),
          (party_set_slot,"p_castle_2", slot_center_siege_with_belfry,   1),
          (party_set_slot,"p_castle_3", slot_center_siege_with_belfry,   0),
          (party_set_slot,"p_castle_4", slot_center_siege_with_belfry,   0),
          (party_set_slot,"p_castle_5", slot_center_siege_with_belfry,   0),
          (party_set_slot,"p_castle_6", slot_center_siege_with_belfry,   0),
          (party_set_slot,"p_castle_7", slot_center_siege_with_belfry,   1),
          (party_set_slot,"p_castle_8", slot_center_siege_with_belfry,   1),
          (party_set_slot,"p_castle_9", slot_center_siege_with_belfry,   1),
          (party_set_slot,"p_castle_10", slot_center_siege_with_belfry,   0),
          (party_set_slot,"p_castle_11", slot_center_siege_with_belfry,   1),

    Now to what you add here. You're going to have to add each troop as it is done with the faction slots.
    Something like this:

    插入代码块:
          (party_set_slot, "p_village_1", slot_village_recruits, "trp_your_troop_for_village_1"),
          (party_set_slot, "p_village_2", slot_village_recruits, "trp_your_troop_for_village_2"),
          (party_set_slot, "p_village_3", slot_village_recruits, "trp_your_troop_for_village_3"),
          (party_set_slot, "p_village_4", slot_village_recruits, "trp_your_troop_for_village_4"),
          (party_set_slot, "p_village_5", slot_village_recruits, "trp_your_troop_for_village_5"),
          (party_set_slot, "p_village_6", slot_village_recruits, "trp_your_troop_for_village_6"),
          (party_set_slot, "p_village_7", slot_village_recruits, "trp_your_troop_for_village_7"),
          (party_set_slot, "p_village_8", slot_village_recruits, "trp_your_troop_for_village_8"),
          (party_set_slot, "p_village_9", slot_village_recruits, "trp_your_troop_for_village_9"),
          (party_set_slot, "p_village_10", slot_village_recruits, "trp_your_troop_for_village_10"),
          .......
          (party_set_slot, "p_village_58", slot_village_recruits, "trp_your_troop_for_village_58"),
          (party_set_slot, "p_village_59", slot_village_recruits, "trp_your_troop_for_village_59"),
          (party_set_slot, "p_village_60", slot_village_recruits, "trp_your_troop_for_village_60"),

    Now if you modify the code part you talked about changing to what I post below you'll get what you want.

         
    插入代码块:
     (store_script_param, ":center_no", 1),
           (party_get_slot, ":player_relation", ":center_no", slot_center_player_relation),
           (party_get_slot, ":volunteer_troop", ":center_no", slot_village_recruits),    #added
           (assign, ":volunteer_troop_tier", 1),
           (store_div, ":tier_upgrades", ":player_relation", 10),
           (try_for_range, ":unused", 0, ":tier_upgrades"),
             (store_random_in_range, ":random_no", 0, 100),
             (lt, ":random_no", 10),
             (store_random_in_range, ":random_no", 0, 2),
             (troop_get_upgrade_troop, ":upgrade_troop_no", ":volunteer_troop", ":random_no"),

    Hope that helps!

    Zait
  14. Inventory Management as party skill?

    It looks hardcoded to me. Not done extensive searching but a quick look made me feel like it.

    From module skills:
    #Hardcoded skills are {names (indexes, beginning with 0)}:
    # Trade (1)
    # Leadership (2)
    # Prisoner Management (3)
    # First Aid (9)
    # Surgery (10)
    # Wound Treatment (11)
    # Inventory Management (12)
    # Spotting (13)
    # Pathfinding (14)
    # Tactics (15)
    # Tracking (16)
    # Trainer (17)
    # Engineer (1:cool:
    # Horse Archery (24)
    # Riding (25)
    # Athletics (26)
    # Shield (27)
    # Weapon Master (2:cool:
    # Power Draw (34)
    # Power Throw (35)
    # Power Strike (36)
    # Ironflesh (37)
    #
    # The effects of these skills can only be removed if the skill is disabled with sf_inactive flag.
    # If you want to add a new skill, use the reserved skills or use non-hardcoded skills.

    >.<
  15. What's wrong with this code?

    This problem has been solved.

    For reference so that no one tears their brain out due to this rather simple problem I'll say the solution.

    (100, 0, 0.0, [], [(try_for_range, ":center", walled_centers_begin, walled_centers_end),
                            (store_faction_of_party, ":faction", ":center"),
                            (party_collect_attachments_to_party, ":center", "p_collective_ally"),
                            (party_get_num_companions, ":garrison", "p_collective_ally"),
                            (faction_get_slot, ":party_template_a", ":faction", slot_faction_reinforcements_a),
                            (faction_get_slot, ":party_template_b", ":faction", slot_faction_reinforcements_b),
                            (faction_get_slot, ":party_template_c", ":faction", slot_faction_reinforcements_c),
                            (assign, ":party_template", 0),
                            (try_begin),
                                (party_slot_eq, ":center", slot_party_type, spt_town),
                                (lt, ":garrison", 150),
                                (store_random_in_range, ":rand", 0, 100),
                                (try_begin),
                                    (is_between, ":rand", 0, 40),
                                    (assign, ":party_template", ":party_template_a"),
                                (else_try),
                                    (is_between, ":rand", 40, 90),
                                    (assign, ":party_template", ":party_template_b"),
                                (else_try),
                                    (ge, ":rand", 90),
                                    (assign, ":party_template", ":party_template_c"),
                                (try_end),
                            (else_try),
                                (party_slot_eq, ":center", slot_party_type, spt_castle),
                                (lt, ":garrison", 50),
                                (store_random_in_range, ":rand", 0, 100),
                                (try_begin),
                                    (is_between, ":rand", 0, 40),
                                    (assign, ":party_template", ":party_template_a"),
                                (else_try),
                                    (is_between, ":rand", 40, 90),
                                    (assign, ":party_template", ":party_template_b"),
                                (else_try),
                                    (ge, ":rand", 90),
                                    (assign, ":party_template", ":party_template_c"),
                                (try_end),
                            (try_end),
                            (try_begin),
                                (gt, ":party_template", 0),
                                (party_add_template, ":center", ":party_template"),
                            (try_end),
                        (try_end)]

    And there you go, a script that makes the garrisons fill in a slow speed if they go below a certain limit.
    Nothing fancy but it makes the game abit richer(imho) :wink:
后退
顶部 底部