code to order items?

Users who are viewing this thread

Sometimes I’d like to buy a particular item with particular stats, let’s say a masterwork arming sword. In order to find it I often have to go through all the shops in the game just to find out that it’s currently not available. It’s quite annoying. Hence the question: does anyone have/know the code that would allow to *order* specific items in-game?
 
I guess my question was unclear. The thing is, I need a code that would allow me, for example, to go to a shop and say “I need a balanced heavy bastard sword, but it’s not in your inventory. Here’s the money, bring me what I need.”

I’m pretty sure I saw a mod that had a similar feature but I don’t remember its name. Besides, I couldn’t find the necessary piece of code in that mod anyway.

Alternatively, if you have another solution that would allow me to spend less time searching for the specific items that I need to equip myself and my companions, please advise.
 
It's only a few nested loops.
Code:
(store_script_param, ":item", 1),
(store_script_param, ":imod", 2),
(assign, ":t_end", towns_end),
(assign, ":encountered", "$g_encountered_party"),
(try_for_range, "$g_encountered_party", towns_begin, ":t_end"),
  (assign, ":s_end", slot_town_elder),
  (try_for_range, ":slot_no", slot_town_weaponsmith, ":s_end"),
    (party_get_slot, ":merchant", "$g_encountered_party", ":slot_no"),
    (gt, ":merchant", 0),
    (troop_get_inventory_capacity, ":cap", ":merchant"),
    (try_for_range, ":i_slot", 10, ":cap"),
      (troop_get_inventory_slot, ":i_item", ":merchant", ":i_slot"),
      (eq, ":i_item", ":item"),
      (troop_get_inventory_slot_modifier, ":i_imod", ":merchant", ":i_slot"),
      (eq, ":i_imod", ":imod"),
      #get value of item
      (store_item_value, ":value", ":item"),
      (call_script, "script_game_get_item_buy_price_factor", ":item"),
      (val_mul, ":value", reg0),
      #do same thing with imod

      #do whatever - add to inventory, deduct gold, or display as a string

      #break loop
      (assign, ":cap", 10),
      (assign, ":s_end", slot_town_weaponsmith),
      (assign, ":t_end", towns_begin),
    (try_end),
  (try_end),
(try_end),
#return original value
(assign, "$g_encountered_party", ":encountered_party"),
 
Somebody,

Thank you very much for your help! I really appreciate it.

Still, being really bad at coding,  :oops: I’m not at all sure I can correctly complete the parts related to the imod, adding to inventory and deducting the gold. And I would really hate to spoil your code with a stupid error. On the other hand, the complete code could be more useful for those forum members who are as incapable of coding as I am but still would like to benefit from this useful feature.

Therefore, if/when you have time, could you please complete your code?
 
I've done a crude version for the original M&B through dialog with the merchants. However, I still can't solve the problem with allowing the correct imod for the item ordered. For example, I can list the good imod for player to choose from, but I don't know how to prevent player from choosing balanced for items that normally can't be balanced without extensively filtering allowed good imod for each item or rearrange items in manageable groups.
 
SPD_Phoenix said:
I've done a crude version for the original M&B through dialog with the merchants. However, I still can't solve the problem with allowing the correct imod for the item ordered. For example, I can list the good imod for player to choose from, but I don't know how to prevent player from choosing balanced for items that normally can't be balanced without extensively filtering allowed good imod for each item or rearrange items in manageable groups.

The best way to do it would be to look at how rubik gets this info at compile-time using Python code for his autoloot code, included in Custom Commander. If you get CC's source, this is done in the file module_my_mod.py Essentially, he uses Python string functions to get the appropriate imod bits for each item and store them in an item slot.
 
Thanks. I'll check it out.

Edit: I checked out the code and it went over my head :(

Anyway, got a different idea based on what I could understand.
 
Back
Top Bottom