Author Topic: Autoloot Source Code with Merging Instructions for other mods  (Read 6499 times)

0 Members and 1 Guest are viewing this topic.

fisheye

  • Back in Black
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Autoloot Source Code with Merging Instructions for other mods
« on: November 17, 2008, 06:43:32 PM »
NOTE: This version is no longer supported, the upgraded version by rubik is highly recommended:
http://forums.taleworlds.net/index.php/topic,60097.0.html


http://www.mbrepository.com/modules/PDdownloads/singlefile.php?cid=1&lid=951

Band of Warriors has some code where you can click one button and have all your heroes upgrade their gear from your loot pool. This is the new and improved code for it. It is a straight cut-and-paste into your mod source, very easy, no customization required.

List of changes (you only need to add code in 11 places):

module_constants:
* Some new constants, mostly slot definitions. Make sure these do not clash with your slot definitions

module_dialogs:
* A "start" option for talking to your heroes, this has to be near the top of the dialogs file.
* A chunk of item management conversation for selecting hero upgrade options, this has to be in "member_talk"
* A small conditional making sure you cannot separate a party member while talking to them inside the camp

module_game_menus:
* An additional option to access loot management from the camp menu
* "mnu_total_victory": Instead of just displaying the loot screen (change_screen_loot), we display a loot management menu instead
* Autoloot menus are at the bottom, you can put them anywhere.

module_items:
* An "itm_items_end" item at the end of the list to mark the end of the list

module_scripts:
* A call to "script_init_item_difficulties" at the top in "game_start"
* The autoloot scripts are at the bottom of the file, you can put them anywhere

module_strings:
* Some new strings, you can put them anywhere

process_items.py: (NOTE! this is process_items.py, the actual PYTHON processing code)
* A small snippet of code to be placed inside the "for item in items:" loop. Most modders don't change the process_xxx files so you can just copy this file.


That's all!

Note: the current version only supports items with a STR requirement of 5-14. So if you got an item of strength requirement 15, it won't work correctly (you just have to add in an additional line of code for each of these high-requirement items).

« Last Edit: March 23, 2009, 02:14:42 PM by fisheye »

fisheye

  • Back in Black
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #1 on: November 19, 2008, 08:07:42 PM »
Updated to fix issue where items with requirement 0 and the heavy or masterwork modifier are perceived to have difficulty 1 and 4 respectively instead of 0.

sirgrigor

  • Sergeant at Arms
  • *
  • Calradia at War
    • View Profile
    • Calradia at War Mod
  • Faction: Neutral
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #2 on: November 20, 2008, 01:43:33 AM »
Updated to fix issue where items with requirement 0 and the heavy or masterwork modifier are perceived to have difficulty 1 and 4 respectively instead of 0.

Great code fisheye, I might include this in future versions of my mod if it is ok with you.

s/g

fisheye

  • Back in Black
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #3 on: November 20, 2008, 03:05:43 AM »
The more the merrier! No need to ask permission, that's what I posted the code for.

Sinan

  • Regular
  • *
  • Master of the Khergit Guards
    • View Profile
  • Faction: Khergit
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #4 on: November 20, 2008, 10:24:55 AM »
Hi guys, could someone please tell me what to do with the files in the rar package. Thx for posting this. I've done some tweaks to the game, but only in the text files, plus added unique armory (items). I have no idea how to merge this with my game. Many thanks.

fisheye

  • Back in Black
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #5 on: November 20, 2008, 02:59:40 PM »
Search for the tag "autoloot", find the chunk of code, cut and paste in the correct location in your own code.

It is impossible to get more specific than that, sorry.

My feeling is that you need at least a nonzero level of skill in modding to incorporate this, so you will have to learn the module system to really make use of this. This is a modder's resource, not a magelord tweak.

Sinan

  • Regular
  • *
  • Master of the Khergit Guards
    • View Profile
  • Faction: Khergit
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #6 on: November 20, 2008, 05:20:13 PM »
Ok, thanks.

HardCode

  • Sergeant Knight at Arms
  • *
  • Return of Rosario Dawson
    • View Profile
  • Faction: Bandit
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #7 on: November 22, 2008, 03:42:58 AM »
I didn't download the most recent version with the "Masterwork Hunting Bow" fix yet, but I've noticed that bastard swords aren't considered one-handed as before. Is this by design, or in the newest release, or needs looking at?
"You can please some of the people some of the time, but you can ban all of the people all of the time too" - Archonsod


fisheye

  • Back in Black
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #8 on: November 22, 2008, 05:15:01 PM »
What's the itp_xxx on the bastardsword? That's what it is classified as, because that's what item_get_type returns. There's no workaround on this issue for this version. That's the price to pay for making the code vastly simpler for other modders to incorporate.

HardCode

  • Sergeant Knight at Arms
  • *
  • Return of Rosario Dawson
    • View Profile
  • Faction: Bandit
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #9 on: November 23, 2008, 02:24:23 AM »
Ah, okay. It's itp_type_two_handed_wpn. So it won't equip unless telling the Hero to equip two-handed weapons. I wonder what would happen if declaring a new itp_ and using the logical OR operators that Fugiwara was happy to see in the mod system now. Maybe it could be worked out to check something declared with "itp_type_two_handed_wpn|itp_my_new_bastard_sword_type".
"You can please some of the people some of the time, but you can ban all of the people all of the time too" - Archonsod


Zathan

  • Sergeant Knight
  • *
  • Devil's plaything
    • View Profile
  • Faction: Swadian
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #10 on: November 24, 2008, 08:23:39 PM »
Thanks for porting the autoloot code!

I have a problem though:

New items I've added disappear through autolooting. They are removed from the party inventory, but none of
the heroes use them. Any idea why?


HardCode

  • Sergeant Knight at Arms
  • *
  • Return of Rosario Dawson
    • View Profile
  • Faction: Bandit
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #11 on: November 24, 2008, 09:48:38 PM »
Did you initialize them if they have minimum requirements (like Strength or Power Draw)? There is a place in module_scripts that initializes items with requirements.
"You can please some of the people some of the time, but you can ban all of the people all of the time too" - Archonsod


Zathan

  • Sergeant Knight
  • *
  • Devil's plaything
    • View Profile
  • Faction: Swadian
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #12 on: November 24, 2008, 10:15:08 PM »
I did nothing but add the source in.
What do you mean by initialize? I see that the top of the autoloot-code in module_scripts deals with difficulty, but why would added items be treated any different than native items with a strenght requirement?

fisheye

  • Back in Black
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #13 on: November 24, 2008, 10:34:48 PM »
Could you post an example, e.g. the item listing

["zathan_sword", etc etc]

and the how it is problematic, e.g.

Borcha discards zathan's sword but picks up the dagger, so zathan's sword is left in the loot pile.

PS did you add them after "itm_items_end" in module_items.py? That item is the end marker and MUST be at the end.

Zathan

  • Sergeant Knight
  • *
  • Devil's plaything
    • View Profile
  • Faction: Swadian
Re: Autoloot Source Code with Merging Instructions for other mods
« Reply #14 on: November 25, 2008, 09:17:07 AM »
Below is the end of my module_items file.
These helmets do show up as loot after battle. But when giving the heroes the chance to autoloot, the helmets disappear from the loot but isn't being used by the heroes.
So in essence, after the autloot, these helmets are gone - they somehow vanish in the process as it were. :lol:
I've gone through  your code fisheye, but can't find anything that would exclude new items.
Is there an ID_items cap involved?

Thanks for your help. :)

#FROM COMMUNITYHELMS

["crown_great_helmet", "Crown Great Helmet", [("crown_helm",0)], itp_merchandise| itp_type_head_armor|itp_covers_head,0,
 4250 , weight(3)|abundance(10)|head_armor(60)|body_armor(0)|leg_armor(0)|difficulty(10) ,imodbits_plate ],
["flat_topped_helmet_faceplate", "Flat Topped Helmet", [("faceplate",0)], itp_merchandise| itp_type_head_armor,0,
 569 , weight(2.5)|abundance(100)|head_armor(46)|body_armor(0)|leg_armor(0)|difficulty(8) ,imodbits_plate ],
["flat_topped_helmet_b", "Flat Topped Helmet", [("flattop",0)], itp_merchandise| itp_type_head_armor   ,0,
 411 , weight(2)|abundance(100)|head_armor(40)|body_armor(0)|leg_armor(0)|difficulty(8) ,imodbits_plate ],
["mail_coif_b", "Mail Coif", [("full_mail_coif",0)], itp_merchandise| itp_type_head_armor   ,0,
 156 , weight(1.50)|abundance(100)|head_armor(29)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_armor ],
 ["ghulam_helmet", "Ghulam Helmet", [("ghulam_helm2",0)], itp_merchandise| itp_type_head_armor   ,0,
 555 , weight(2.0)|abundance(100)|head_armor(43)|body_armor(0)|leg_armor(0)|difficulty(9) ,imodbits_plate ],
 ["nordic_helmet_b", "Nordic Helmet", [("helmet_w_eyeguard_new_alt",0)], itp_merchandise| itp_type_head_armor   ,0,
 450 , weight(2.25)|abundance(100)|head_armor(42)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["kettle_hat_paddedcoif", "Kettle Hat", [("kettlehat_paddedcoif",0)], itp_merchandise| itp_type_head_armor,0,
 109 , weight(1.5)|abundance(100)|head_armor(25)|body_armor(0)|leg_armor(0)|difficulty(6) ,imodbits_plate ],
 ["kettle_hat_b", "Kettle Hat", [("kettlehelm",0)], itp_merchandise| itp_type_head_armor,0,
 167 , weight(1.5)|abundance(100)|head_armor(30)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["great_helmet_b", "Great Helmet", [("maciejowskihelm",0)], itp_merchandise| itp_type_head_armor|itp_covers_head,0,
 1180 , weight(3)|abundance(100)|head_armor(54)|body_armor(0)|leg_armor(0)|difficulty(10) ,imodbits_plate ],
 ["mamluk_helmet", "Mamluk Helmet", [("mamluk_helm",0)], itp_merchandise| itp_type_head_armor   ,0,
 755 , weight(2.5)|abundance(100)|head_armor(44)|body_armor(0)|leg_armor(0)|difficulty(9) ,imodbits_plate ],
 ["mamluk_helmet_b", "Mamluk Helmet", [("metropolian_helm",0)], itp_merchandise| itp_type_head_armor   ,0,
 755 , weight(2.5)|abundance(100)|head_armor(44)|body_armor(0)|leg_armor(0)|difficulty(9) ,imodbits_plate ],
 ["nasal_helmet_b", "Nasal Helmet", [("nasal_helmet_new",0)], itp_merchandise| itp_type_head_armor   ,0,
 66 , weight(1)|abundance(100)|head_armor(21)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["nasal_helmet_c", "Nasal Helmet", [("nasal_helmet_new_alt",0)], itp_merchandise| itp_type_head_armor   ,0,
 83 , weight(1.25)|abundance(100)|head_armor(23)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["nasal_helmet_d", "Nasal Helmet", [("nasalhelm_coif",0)], itp_merchandise| itp_type_head_armor   ,0,
 83 , weight(1.25)|abundance(100)|head_armor(27)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["nordic_helmet_c", "Nordic Helmet", [("nordhelm_coif",0)], itp_merchandise| itp_type_head_armor   ,0,
 480 , weight(2)|abundance(100)|head_armor(43)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["guard_helmet_b", "Guard Helmet", [("normanhelmwithcoif",0)], itp_merchandise| itp_type_head_armor   ,0,
 555 , weight(2.5)|abundance(100)|head_armor(47)|body_armor(0)|leg_armor(0)|difficulty(9) ,imodbits_plate ],
 ["bascinet_b", "Bascinet", [("realbascinetb",0)], itp_merchandise| itp_type_head_armor   ,0,
 555 , weight(2.5)|abundance(100)|head_armor(45)|body_armor(0)|leg_armor(0)|difficulty(9) ,imodbits_plate ],
 ["bascinet_c", "Bascinet", [("realbascinetc",0)], itp_merchandise| itp_type_head_armor   ,0,
 555 , weight(2.5)|abundance(100)|head_armor(45)|body_armor(0)|leg_armor(0)|difficulty(9) ,imodbits_plate ],
 ["skullcap_with_coif", "Skullcap with Coif", [("skullcap_coif",0)], itp_merchandise| itp_type_head_armor   ,0,
 258 , weight(1.75)|abundance(100)|head_armor(36)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["suttonhoo_helm", "Sutton Hoo Helmet", [("suttonhoo",0)], itp_merchandise| itp_type_head_armor   ,0,
 555 , weight(2.5)|abundance(100)|head_armor(44)|body_armor(0)|leg_armor(0)|difficulty(9) ,imodbits_plate ],
 ["valsgarde_helmet", "Valsgarde Helmet", [("valsgarde",0)], itp_merchandise| itp_type_head_armor   ,0,
 631 , weight(2.25)|abundance(100)|head_armor(48)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["vendel_helmet", "Vendel Helmet", [("vendel",0)], itp_merchandise| itp_type_head_armor   ,0,
 570 , weight(2)|abundance(100)|head_armor(45)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["manhunter_helmet", "Manhunter Helmet", [("orcmaskcheeks",0)], itp_merchandise| itp_type_head_armor   ,0,
 277 , weight(2)|abundance(100)|head_armor(37)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],
 ["manhunter_helmet_b", "Manhunter Helmet", [("orcromanhelm",0)], itp_merchandise| itp_type_head_armor   ,0,
 237 , weight(1.75)|abundance(100)|head_armor(34)|body_armor(0)|leg_armor(0)|difficulty(7) ,imodbits_plate ],

######################################################################################
# Autoloot: Need this dummy item here to mark end of file
######################################################################################
 ["items_end","INVALID ITEM", [("practice_sword",0)], itp_type_one_handed_wpn|itp_primary|itp_secondary, itc_longsword, 3,weight(1.5)|spd_rtng(103)|weapon_length(90)|swing_damage(16,blunt)|thrust_damage(10,blunt),imodbits_none],

 
]