Player Faction Specific Units

正在查看此主题的用户

Is it possible when you start your own faction in Mount&Blade - Warband to make it so that you have units specific to that faction? Perhaps villages you control would produce these units rather then the old ones? Is this possible? What would the process be?

- Ryan Paul Fialcowitz
 
Yes, it's possible, and lots of mods have done this. 

Basically, there is code that determines what soldiers you can recruit from villages; it reads slot_faction_tier_1_troop from the Faction that is the "original culture".  You can make the change really easily, by simply changing the original culture to the player's culture, and then giving them the appropriate troop type.
 
I like "Custom Commander's" approach. When you recruit villagers, you have the choice to recruit peasants or personal recruits. The latter are new units only you can own and they kick ass.
The "Diplomacy" mod lets you choose your faction culture and in "Custom Settlements", this was possible too.
 
xenoargh 说:
Yes, it's possible, and lots of mods have done this. 

Basically, there is code that determines what soldiers you can recruit from villages; it reads slot_faction_tier_1_troop from the Faction that is the "original culture".  You can make the change really easily, by simply changing the original culture to the player's culture, and then giving them the appropriate troop type.

Would it be possible to make it so that a village would produce units specific to what faction controls it even if it changes through conquest? It seems your method, if I understand correctly, would just make the village give the new troop type and never the old one. I'd like to have villages produce the new troops only when I take them over and then only so long as I control them. Lastly what file is slot_faction_tier_1_troop in?

-Ryan Paul Fialcowitz
 
Yes. You can make some small changes to make villages produce recruits base on the faction it belongs to.

"slot_faction_tier_1_troop" is defined in module_constants and used mainly in module_scripts (may be some other modules). Do a "search in files" or similar operation in your text editor.
 
SPD_Phoenix 说:
Yes. You can make some small changes to make villages produce recruits base on the faction it belongs to.

Specifically how would I do this?

- Ryan Paul Fialcowitz
 
In mudule_script, look for script "update_npc_volunteer_troops_in_village". The current Native (version 1.113 - 1.125) assign troop base on the village culture which will not change as the village change hand. Change the code to get the faction in stead. From the faction, get the culture/culture tier_1 troop.
Native code:
  ("update_npc_volunteer_troops_in_village",
    [
      (store_script_param, ":center_no", 1),
      (party_get_slot, ":center_culture", ":center_no", slot_center_culture),
      (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),
Change to something like this:
  ("update_npc_volunteer_troops_in_village",
    [
      (store_script_param, ":center_no", 1),
  (store_faction_of_party, ":center_faction", ":center_no"),
      (faction_get_slot, ":center_culture", ":center_faction", slot_faction_culture),
      (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),
 
SPD_Phoenix 说:
("update_npc_volunteer_troops_in_village",
    [
      (store_script_param, ":center_no", 1),
  (store_faction_of_party, ":center_faction", ":center_no"),
      (faction_get_slot, ":center_culture", ":center_faction", slot_faction_culture),
      (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),

I'm getting:
ERROR: Usage of unassigned local variable: :center_faction

- Ryan Paul Fialcowitz
 
The first line looks wrong to me.  Should be:

插入代码块:
(store_script_param, ":center_no", reg1),

As for :center_faction... looks right right there.  Maybe you're referring to it elsewhere- it's a local variable, so if you need to pass it back to the Game Menu you're working on, you need to assign it to a reg variable.
 
The first line should is correct with "1" at the end (store script parameter number "1" into the local variable).

I can't figure out why you get the error for local variable ":center_faction". All looks right for me.
 
Or you can use the hard-coded function store_script_param_1(""),
It does the same thing as (store_script_param, "", 1) as far as I can tell.
I've had bad experiences with store_faction_of_party/troop coming up with -1, but that's probably just me.
Either way that variable should have been assigned a value, despite the indentation error and whatever value store_faction_of_party gives you. I've been using slot_town_lord and then store_faction_of_troop (not sure if it works for villages), which is probably a work-around.
 
I've not made any changes to the file other the the initial one described in this thread. I'm getting the error when running the bat file to change them from Python to text files. Do I need to make another change to fix the error message? What should the final script look like?

- Ryan Paul Fialcowitz
 
Yeah. Probably the function store_faction_of_party was bad.

I'm not sure if the function store_faction_of_troop or store_troop_faction will store troop's original faction or his current faction. I've never tested those two.
 
SPD_Phoenix 说:
Yeah. Probably the function store_faction_of_party was bad.

I'm not sure if the function store_faction_of_troop or store_troop_faction will store troop's original faction or his current faction. I've never tested those two.

So, what should I change it to?

- Ryan Paul Fialcowitz
 
SPD_Phoenix 说:
Yeah. Probably the function store_faction_of_party was bad.

I'm not sure if the function store_faction_of_troop or store_troop_faction will store troop's original faction or his current faction. I've never tested those two.
Just looked at it in header_operations.py. Apparently it only has a destination # (store_faction_of_party,<destination>), but Native scripts (should) use it fine by adding a second parameter for the party.
The values returned should be the current values, since there are corresponding hardcoded functions troop/party_set_faction which are called in script_change_troop_faction, so it should always get the current faction.
 
Somebody 说:
Just looked at it in header_operations.py. Apparently it only has a destination # (store_faction_of_party,<destination>), but Native scripts (should) use it fine by adding a second parameter for the party.
The values returned should be the current values, since there are corresponding hardcoded functions troop/party_set_faction which are called in script_change_troop_faction, so it should always get the current faction.

How do I add a second parameter for the party? From your post it sounds like that would make it work.

- Ryan Paul Fialcowitz
 
I look up the function "store_faction_of_party" in Native code, they all have the second parameter. That makes more sense because you have to tell which party to get the faction from. I don't think there's a problem with that function.

Here are a few examples:
(store_faction_of_party, ":town_faction", ":cur_center"),
(store_faction_of_party, ":town_faction", ":min_dist_town"),
(store_faction_of_party, ":eek:riginal_faction", ":center_no"),
...

The work a round using center owner faction is good (I used it before). Just more coding to do.
 
Alright, I'm confused. Will the script posted earlier work or not?

("update_npc_volunteer_troops_in_village",
    [
      (store_script_param, ":center_no", 1),
      (store_faction_of_party, ":center_faction", ":center_no"),
      (faction_get_slot, ":center_culture", ":center_faction", slot_faction_culture),
      (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_1_troop),

I know nothing of scripting so all the scripting talk is just over my head. If I need to change something with it what exactly needs to be changed? I sincerely appreciate everyone's help in this matter.

- Ryan Paul Fialcowitz
 
It's supposed to work. It worked for me in version 1.113. I'm not sure why it didn't work for you or in version 1.125.

Anyway, there are 3 scripts that deal with recruits. One for player to recruit from village. Two for npcs, recruit from village (very small amount) and auto reinforcement (main bulk).

I'm not a very good scripter myself. Means, I can't just type in the code and expect it will work. If you don't mind doing the testing, I can post the code for you. Which version are you using? Any additional mod?
 
SPD_Phoenix 说:
It's supposed to work. It worked for me in version 1.113. I'm not sure why it didn't work for you or in version 1.125.

Anyway, there are 3 scripts that deal with recruits. One for player to recruit from village. Two for npcs, recruit from village (very small amount) and auto reinforcement (main bulk).

I'm not a very good scripter myself. Means, I can't just type in the code and expect it will work. If you don't mind doing the testing, I can post the code for you. Which version are you using? Any additional mod?

I haven't tested it out in game yet as at the moment I don't have the game installed. I was holding off until I had a working script. As mentioned previously I got an error in the conversion from Python to text files. I would figure that would mean it wouldn't work, but I haven't actually tried it yet because every other post was suggesting it might not work and if that's the case I'm not terribly interested in another playthrough. But if you can confirm it works or a code that will work I'll help out however I can.

- Ryan Paul Fialcowitz
 
后退
顶部 底部