[Solved] How to specify item modifiers for Companion items?

Users who are viewing this thread

Enofel

Recruit
When choosing which items a custom companion is going to have in troops, how would I make an item be Masterwork or Lordly,

What changes to itm_examplesword, itm_examplehelm would cause them to have modifiers?

Thanks
 
I'm not sure I understood your question correctly, but:

1. All items that you provide your custom companion in module_troops.py cannot have any modifiers.

2. You can give your companion some items via script at the start of the game (script_initialize_npcs seems the most sensible place for this, but any place in script_game_start or it's children scripts will do). Giving items this way at the start of the game is equivalent of giving them to troop in module_troops.py, but in script you can specify item modifiers.
 
To clarify, you are saying that it is not possible for Companions starting equipment to be 'Lordly Great Helm' and 'Masterwork Example Sword' items in the module_troops.py?

Also since the scripts is also .py file, my question still stands, if the name of an item is "itm_Example_Sword", how would I turn it into a Lordly Example Sword in the game?

 
Enofel said:
To clarify, you are saying that it is not possible for Companions starting equipment to be 'Lordly Great Helm' and 'Masterwork Example Sword' items in the module_troops.py?
Yep.

Enofel said:
Also since the scripts is also .py file, my question still stands, if the name of an item is "itm_Example_Sword", how would I turn it into a Lordly Example Sword in the game?
It't not a question of what is a py file. In a script you can add an item to a troop with troop_add_item command, and this command understands item modifiers. So you would write something like:

Code:
(troop_add_item, "trp_example_lord", "itm_example_sword", imod_lordly),

Of course in this case you do not need to give your lord "itm_example_sword" in module_troops.py, he will get it via script instead.
 
You can give items with modifiers to whatever troop you want, but you need to edit the module system compiler.
Here is what you need to do:
1.open process_troops.py
2.search for this piece of code
Code:
for inventory_item in inventory_list:
#      add_tag_use(tag_uses,tag_item,inventory_item)
     file.write("%d 0 "%inventory_item)

3.replace it with this one
Code:
for inventory_item in inventory_list:
#      add_tag_use(tag_uses,tag_item,inventory_item)
      if(type(inventory_item) == types.ListType) or (type(inventory_item) == types.TupleType):
        file.write("%d %d "%(inventory_item[0], inventory_item[1]<<24))
      else:
        file.write("%d 0 "%inventory_item)
4.Done.

Normally, the troop's inventory list would look like this:
Code:
[itm_tutorial_club,itm_leather_jerkin,itm_hide_boots],
An example of an inventory with modifiers would be this:
Code:
[(itm_tutorial_club, imod_cracked), (itm_leather_jerkin, imod_poor), itm_hide_boots],
Instead of (<item_id>, <item_modifier>) you can also use [<item_id>, <item_modifier>].
Note: you can mix between items with modifiers and items without modifiers (notice in the example how the first two items have a modifier, while the third one doesn't).
 
Thanks for the help! Got it working =D

Hmm, seems to be a max of 88 total companions that can be added to the game, sigh and I wrote a java file to spit out thousands of copy pasta companions (at least my comp why give up and die then)

Cheers and thanks again

Edit: @Dragon, you posted that as I was writing this one, I'll definitely try doing that, will save a ton of lines of code in the script init file (along the lines of exactly 616 code lines) for all of the only 88 (grumble) of my copy pasta companions.
 
The_dragon said:
You can give items with modifiers to whatever troop you want, but you need to edit the module system compiler.
Hmm, curious. I have experimented with this part of compiler and it definitely did not work for me. Apparently will have to try again.
 
The_dragon said:
EDIT: I made a mistake in my code; you need to add that red thing
file.write("%d %d "%(inventory_item[0],inventory_item[1]<<24))
Which explains why it didn't work for me - I wasn't aware you have to shift the value.

Nice, definitely going to use this. :smile:
 
Back
Top Bottom