Author Topic: Recruit from your Prisoners! - Obsolete with new version of M&B  (Read 43388 times)

Leprechaun

  • Guest
Recruit from your Prisoners! - Obsolete with new version of M&B
« on: January 14, 2007, 10:40:42 AM »
I've put a mod that allows you to recruit from your prisoners on the File Repository. Their faction's standing with you ought to affect whether they will follow you or not, but this is relatively untested. Please report any problems. (Apologies if this mod has been released already, but I searched and couldn't find it.)

Updated 29th December 2006. I've re-ported it using python so you'll no longer need to start a new game to use it.

New version is up. v2.0 is for v0.808 of Mount&Blade.

Link: http://www.mbrepository.com/modules/PDdownloads/singlefile.php?cid=10&lid=153

Python source is up. See the next post for details on adding it to your own mod. Remember that I ask to be credited for the work if you use it in your own.
http://www.mbrepository.com/modules/PDdownloads/singlefile.php?cid=4&lid=321


Features

    * Recruit from your prisoners
    * Fixed conversation


With the latest version, if the prisoner refuses to join you, you cannot try again, you must sell him or kill him.

New version:
I've reworked the code to better calculate how likely the prisoner is to join your faction.


Reminder to self - update again with fixed code when you get a spare moment.
« Last Edit: March 06, 2008, 01:08:46 PM by Leprechaun »

Leprechaun

  • Guest
Re: Recruit from your Prisoners!
« Reply #1 on: January 14, 2007, 10:43:16 AM »
In module_constants:
Beneath "slot_town_import_rate_2" = 48 add "slot_prisoner_agreed = 1"

In module_dialogues:
Where it says
"[anyone|plyr,"prisoner_chat", [], "Don't try running away or trying something stupid. I will be watching you.", "prisoner_chat_2",[]],
  [anyone,"prisoner_chat_2", [], "No, I swear I won't.", "close_window",[]],"
or whatever, delete the entire lot and paste in:

Code: [Select]
  [anyone|plyr,"prisoner_chat", [[store_conversation_troop,reg(2)],[store_troop_faction,reg(3),reg(2)],[store_relation,reg(4),reg(3),"fac_player_faction"]], "Don't try running away or trying something stupid. I will be watching you.", "prisoner_chat_2",
   [[store_random_in_range,reg(5),reg(4),3]]],
  [anyone,"prisoner_chat_2", [], "No, I swear I won't.", "prisoner_chat_3",[]],
  [anyone|plyr,"prisoner_chat_3", [], "Good. You're not stupid like the rest of these scum.", "prisoner_chat_4",[]],
  [anyone|plyr,"prisoner_chat_4", [], "[End the conversation]", "prisoner_chat_5",[]],
  [anyone|plyr,"prisoner_chat_5", [], "I hope you're looking forward to life as a slave, scum.", "close_window",[]],
  [anyone|plyr,"prisoner_chat_4", [], "[Try to recruit the prisoner]", "prisoner_chat_6",[]],
  [anyone|plyr,"prisoner_chat_6", [], "Listen, scum, you have one last chance to redeem yourself before I sell you to the slave-traders.\
  Drop all your previous allegiances and swear to fight for me and obey my every order to the letter, and you'll be paid, fed and equipped.\
   If you don't....well, let's just say that life as a slave will be seemingly unending years of agony, malnutrition and beatings.\
   I'd advise you to think very, very carefully before refusing.", "prisoner_chat_7",[]],
  [anyone,"prisoner_chat_7", [[lt,reg(5),0]], "I'll show you what I think of your offer! (The prisoner spits at your feet) There. Now get lost, I'm not interested.", "prisoner_chat_8",[]],
  [anyone|plyr,"prisoner_chat_8", [], "[Kill the prisoner]", "prisoner_chat_14",[]],
  [anyone|plyr,"prisoner_chat_8", [], "[Sell the prisoner]", "prisoner_chat_10",[]],
  [anyone|plyr,"prisoner_chat_9", [], "(You advance on the prisoner with your weapon drawn)", "prisoner_chat_11",[]],
  [anyone|plyr,"prisoner_chat_4", [], "[Kill the prisoner]", "prisoner_chat_9",[]],
  [anyone|plyr,"prisoner_chat_10", [], "We have found a roaming slave trader. It's time for us to part ways. Goodbye, it was nice not to know you.", "close_window",
   [[store_conversation_troop,reg(2)],[remove_troops_from_prisoners,reg(2),1],[troop_add_gold,"trp_player",20]]],
  [anyone,"prisoner_chat_11", [], "Please, {sir/madam}, don't kill me. I am a defenceless prisoner. Surely you're not that cruel?", "prisoner_chat_12",[]],
  [anyone|plyr,"prisoner_chat_12", [], "[Kill the prisoner]", "prisoner_chat_13",[]],
  [anyone|plyr,"prisoner_chat_13", [], "Yes, idiot. I am that cruel. Prepare to die.", "prisoner_chat_14",[]],
  [anyone|plyr,"prisoner_chat_14", [], "(The prisoner struggles against his shackles, desperate to free himself and escape you, but to no avail. You slit his throat with a knife and watch, satisfied, as his corpse sags to the floor.)", "close_window",
   [[store_conversation_troop,reg(2)],[remove_troops_from_prisoners,reg(2),1]]],
  [anyone|plyr,"prisoner_chat_12", [], "[Let him live]", "prisoner_chat_15",[]],
  [anyone|plyr,"prisoner_chat_15", [], "Very well, I'll let you live. I hope you enjoy life as a slave.", "prisoner_chat_16",[]],
  [anyone,"prisoner_chat_16", [], "Oh, thank you, {sir/madam}.", "close_window",[]],
  [anyone,"prisoner_chat_7", [[ge,reg(5),0]], "Thank you for your mercy, {sir/madam}. I promise to drop all allegiances to serve you in any way I can.","prisoner_chat_17",[]],
  [anyone|plyr,"prisoner_chat_17", [], "Good. Now, I'll make the rules clear to you. There will be no discrimination against other soldiers in my army because they were once on the opposing side or were bandits. They fight for me now, as do you. Their ties with the past are broken. Think you can handle it?", "prisoner_chat_18",[]],
  [anyone,"prisoner_chat_18", [], "Yes, {sir/madam}. I will obey the rules.", "prisoner_chat_19",[]],
  [anyone|plyr, "prisoner_chat_19", [[neg|hero_can_join]],"Oh. There isn't enough room in my party for you. I will be back when I have made room.", "close_window",
   [[store_conversation_troop,reg(0)],[troop_set_slot,reg(0),slot_prisoner_agreed,1]]],
  [anyone|plyr, "prisoner_chat_19", [[hero_can_join]], "Excellent. From now on, you fight alongside these men. Help them when they need it, and they'll do the same for you. Get equipped and fed. We'll head out as soon as you're done.", "close_window",
   [[store_conversation_troop,reg(0)],[troop_join,reg(0)],[remove_troops_from_prisoners,reg(0),1]]],
  [anyone|plyr,"prisoner_chat", [[store_conversation_troop,reg(0)],[troop_get_slot,reg(1),reg(0),slot_prisoner_agreed],[eq,reg(1),1],[hero_can_join]], "All right, I have made room for you to join my party. Welcome aboard.", "close_window",
   [[store_conversation_troop,reg(0)],[troop_join,reg(0)],[remove_troops_from_prisoners,reg(0),1]]],
  [anyone|plyr,"prisoner_chat", [[store_conversation_troop,reg(0)],[troop_get_slot,reg(1),reg(0),slot_prisoner_agreed],[neg|reg(1),1],[hero_can_join]], "I am sorry, I still have no room for you. You'll have to wait a while longer, I'm afraid.", "close_window",[]],
« Last Edit: January 15, 2007, 04:13:36 PM by Leprechaun »

Jakethief

  • Guest
Re: Recruit from your Prisoners!
« Reply #2 on: January 15, 2007, 04:02:36 PM »
Wow, that's actually really awesome. If I ever make a mod I will definitely have this in it.

Leprechaun

  • Guest
Re: Recruit from your Prisoners!
« Reply #3 on: January 15, 2007, 04:13:18 PM »
However, I'd advise you to be careful - some part of my code is causing an error, and I haven't ascertained the cause yet. I'm fairly sure it's not this, but I'm not ruling it out. If you get an error when incorporating this code, please give me feedback.


I thought I'd post how it calculates the joining probability while I'm at it.

First it finds the prisoner's faction:
[store_conversation_troop,reg(2)],[store_troop_faction,reg(3),reg(2)]

Then it finds his relation to you:
[store_relation,reg(4),reg(3),"fac_player_faction"]

When you first join a faction your relations improve to three, so I class that as the maximum value to begin with. It then generates a random number between the best likely relations and their actual relations:
[store_random_in_range,reg(5),reg(4),3]

If this number is over or equal to 0, the prisoner will join:
[ge,reg(5),0]
If it's under, he won't:
[lt,reg(5),0]

Obviously, the lower his relations to you, the wider the range for the number to be selected from, so the less chance it has to be above 0, so the less chance he'll join you.
« Last Edit: January 15, 2007, 04:15:47 PM by Leprechaun »

Offline Hellequin

  • Journeyman
  • ***
  • Posts: 254
    • View Profile
Re: Recruit from your Prisoners!
« Reply #4 on: January 19, 2007, 01:20:15 PM »
Um... I'm not sure what (store_random_in_range) would do with an inverted range (store_random_in_range, ":Val", 10, 3), but it's possible that checking overfriendly troops with that script could be the source of your problems.  Try (val_min)ing it down to three before you check?

Leprechaun

  • Guest
Re: Recruit from your Prisoners!
« Reply #5 on: January 20, 2007, 03:51:05 AM »
All it does is make them join you every time. If they're a friendly faction why wouldn't they join up with someone?

If it's an inverted range, all that will happen, surely, is that it'll generate a number between the higher number and the lower number, which will always be over 0 so the troop will always join.

However, that means I need to fix up a new troop tree for deserters with the right faction, to avoid them joining you at once.

It also can't be the cause of the error (I think), because it occurs during game startup, not during the conversation. The conversation itself occurs fine. The error makes me think it may be an error in one of my troops (Winter tipped me of on this) where I have a troop with a skill over 10 in something due to the knows_common being added to something else.

Think I've found it - I altered a hero into a merchant but forgot to remove knows_common so his inventory management was 12.

Nope, not that. Forgot to put a space between comma and face code in three places, that didn't help either.

If it helps, error occurs right at the end of loading setting data as it starts loading textures. Hmm... I wonder. Just had a thought. I'll implement a bypass so any troop with relations over three will just join you, and alter the faction of deserters, but I have an inkling of what also may cause the problem.

atilladahun

  • Guest
Re: Recruit from your Prisoners!
« Reply #6 on: January 27, 2007, 07:48:23 PM »
Hmmm.... for some reason it wont work... i wonder why... it keeps opening a folder that has about 4 files in it plus a bunch of notepad stuff... plz help :(
« Last Edit: January 27, 2007, 07:52:26 PM by atilladahun »

Leprechaun

  • Guest
Re: Recruit from your Prisoners!
« Reply #7 on: January 28, 2007, 10:20:03 AM »
Four folders, and lots of text files? That would be the module, which goes in your modules folder.

juusohuu

  • Guest
Re: Recruit from your Prisoners!
« Reply #8 on: January 29, 2007, 01:31:39 PM »
Four folders, and lots of text files? That would be the module, which goes in your modules folder.
By extracting it to the module folder I get an additional mod to choose from at the start up of M&B. Choosing it I can start a new game (after clicking some error messages), but how can I continue my old games? I have missed something. This mod is a great idea!

Leprechaun

  • Guest
Re: Recruit from your Prisoners!
« Reply #9 on: January 29, 2007, 03:35:24 PM »
There used to be something I could do to allow you to load Native savegames in it, but I can't for the life of me remember what it was. I'm already looking into it, because it's driving me crazy.

Sturmspawn

  • Guest
Re: Recruit from your Prisoners!
« Reply #10 on: January 31, 2007, 11:34:14 AM »
Simplest workaround is to create another subdir under M&BSavedGames using the 'moduleName' that you put the recruit prisoners mod in. Then simply copy your current game into that folder.

BTW - I am still having some perf and grafic issues - I set up parallel modules and savegame dirs, one pure native and one with Recruit Prisoners. For the identical savegame loaded under recruit prisoner, the grafic for StrongBow, etc still pops out of your shoulder like a horn, wheras it doesn't in pure native. I am also getting the same 'delay' issue when firing a bow under the recruit prisoner mods. This is recreatable [as I have done so a few times]. I am guessing that you might have either introduced a subtle error, or unwittingly picked up an old file in the whole complex somewhere. I have not run any file version checks [I threw away all of my dev tools about 7 years ago and I am now merely a consumer].

Leprechaun

  • Guest
Re: Recruit from your Prisoners!
« Reply #11 on: January 31, 2007, 11:53:46 AM »
That's the odd thing though - I built this in the v0.808 python module, without touching any items in the released version, and it was a fresh install of the game, with only the necessary files copied from Native so it actually worked. Most odd. I'll try to fix it in the next version, but to be honest I don't really know where to begin.  ???

EDIT: Hey, custom tag!

Sturmspawn

  • Guest
Re: Recruit from your Prisoners!
« Reply #12 on: January 31, 2007, 11:43:49 PM »
Not to worry - At least I know that my machine is still stable [it's a bit low-end for this game]. I don't recruit that often, so I have Recruit set up as an alternate mod. When I want to recruit, I just copy the native save into the recruit save, do the recruit and copy it back. It's a little inconvenient, but the type of units I recruit [Khergits and Darks] rarely get killed and rarely need replacement thereafter [I think I've actually done recruiting about three times in this current game - don't need to go th the well too often]. As I mentioned in some of my taleworlds posts, this is a wonderful mod. Not that we'd take it for granted, but do you think it will be incorporated ino the base product [with credit where credit's due]?. I'm pretty new to M&B, so I don't have a clue about the culture and community.

Leprechaun

  • Guest
Re: Recruit from your Prisoners!
« Reply #13 on: February 01, 2007, 11:00:15 AM »
If you somehow managed to beg Armagan enough to include it, I'd be happy for it to be included, but the chances of that happening are fairly slim to none. You could ask though, I suppose.

atilladahun

  • Guest
Re: Recruit from your Prisoners!
« Reply #14 on: February 01, 2007, 04:55:57 PM »
Can yuo put this mod on other mods like say... Swadian civil war?