Prevent unequipping an item?

Users who are viewing this thread

Keedo420

Knight at Arms
I was just wondering if anyone knew of a way to prevent the player from unequipping an item? I think this would be a good idea for creating cursed items that can only be removed by completing a certain quest. I'd also like to make it so that certain helmets couldn't be unequipped (such as helmets designed to give the appearance of non-human race). Making troops with these kinds of helmets is easy enough, but if I wanted the player to start as one of these races, or have a companion that is one of these races, I would want to prevent the helmet from being removed by the player or by events such as when the player is captured and some of his items are lost.
 
I know how to prevent an item getting looted.  This is from "loot_player_items" in module scripts.  I simply defined a list of items as a constant.  Then I added that constant to the code block.
("loot_player_items",
    [
      (store_script_param, ":enemy_party_no", 1),
     
      (troop_get_inventory_capacity, ":inv_cap", "trp_player"),
      (try_for_range, ":i_slot", 0, ":inv_cap"),
        (troop_get_inventory_slot, ":item_id", "trp_player", ":i_slot"),
        (ge, ":item_id", 0),
        (troop_get_inventory_slot_modifier, ":item_modifier", "trp_player", ":i_slot"),
        (try_begin),
          (is_between, ":item_id", gutts_begin, gutts_end),
          (assign, ":randomness", 0),
        (else_try),
          (is_between, ":item_id", trade_goods_begin, trade_goods_end),
          (assign, ":randomness", 20),
By assigning :randomness to 0 for the items listed as between gutts_begin and gutts_end they will never be looted by enemy parties. 
 
Thanks for the info. Now I just have to figure out if it's possible to prevent a player from unequipping an item.
 
Keedo420 said:
Thanks for the info. Now I just have to figure out if it's possible to prevent a player from unequipping an item.

On the flip side of that, I'm trying to see if I can force an agent to unequip an item (or force them to equip another).  Would help with my broken lance code....
 
So, bringing this topic back even though it's a few years old, since it requests the exact same thing I'm after, and it didn't receive an answer.

I'm making a mini-mod, featuring a few new companions and some custom items for them - starting out at the easier end of the modding scale.

However, I want to make some equipment that is

1) not sold by merchants (itp_merchandise I guess?)
and
2) not unequipable - if I give my new NPC a "family heirloom sword", I don't want the player to be able to take it (unless they do something to deserve the weapon, anyhow...but that's another can of worms)

and finally, is there a list of what the itp_ flags all mean somewhere? I mean most of them are sort-of-descriptive in the name they have, but I though maybe someone had a list somewhere.
 
[list type=decimal]
[*]Correct
[*]Make a new dialog after do_member_trade and compare $g_talk_troop to your character, see if the item isn't equipped, and transfer it from the player's inventory (troop_remove/add_item).
[/list]
header_items contain all the flags. Look at the Native items for their functionality (yes, they're mostly self-explanatory).
 
Somebody said:
[list type=decimal]
[*]Correct
[*]Make a new dialog after do_member_trade and compare $g_talk_troop to your character, see if the item isn't equipped, and transfer it from the player's inventory (troop_remove/add_item).
[/list]
header_items contain all the flags. Look at the Native items for their functionality (yes, they're mostly self-explanatory).

Thanks,

what I'm doing is in module_dialogs.py, right after
Code:
[anyone|plyr,"supported_pretender_talk", [],
   "Let us keep going, {reg65?my lady:sir}.", "close_window",[]],
I add this:
Code:
[trp_npc17,"do_member_trade", [ #only npc 17
	#(store_conversation_troop,"$g_talk_troop"),
	(eq,1,1), #I know this isn't needed but it's easier to switch on/off quickly
	(neg|troop_has_item_equipped,trp_npc17,itm_special_sword), #only if the player has the special sword (thief!!)
	], "I see you've been admiring my sword. I would like it back now though.", "member_talk",[]],

And this almost works - but not quite. If I enter the equipment screen for NPC 17 and steal the sword, it'll return me to the normal conversation as if I didn't take it. Then if I re-enter the equipment screen, and exit, it'll (correctly) accuse me of stealing the sword. Conversely, if I return the sword, it'll still accuse me of having stolen it the first time around.
 
code][anyone|plyr,"supported_pretender_talk", [],
  "Let us keep going, {reg65?my lady:sir}.", "close_window",[]],[/code][/spoiler] I add this:
Code:
[trp_npc17,"do_member_trade", [ #only npc 17
	#(store_conversation_troop,"$g_talk_troop"),
	(eq,1,1), #I know this isn't needed but it's easier to switch on/off quickly
	(neg|troop_has_item_equipped,trp_npc17,itm_special_sword), #only if the player has the special sword (thief!!)
	], "I see you've been admiring my sword. I would like it back now though.", "member_talk",[]],

And this almost works - but not quite. If I enter the equipment screen for NPC 17 and steal the sword, it'll return me to the normal conversation as if I didn't take it. Then if I re-enter the equipment screen, and exit, it'll (correctly) accuse me of stealing the sword. Conversely, if I return the sword, it'll still accuse me of having stolen it the first time around.
[/quote]


I don't think this is actually the problem, but
(neg|troop_has_item_equipped,trp_npc17,itm_special_sword),
really defines when the NPC has NOT got the sword, and not if the player DOES have the sword.

How about if you run the check
trp_has_itm on the player, and if it is 'true' then you can remove it from the player, and give it to the NPC.

(I'll try to remember to look up the exact operations when I am back at my python computer)
 
Thanks for looking into it - now, what I can find by going through header_operations.py are "player_has_item", and the one I've used, troop_has_item_equipped. Using "troop_has_item_equipped" will only work on the NPC, since there's no guarantee the player has the sword equipped (in fact, after "stealing" it, it will by definition be in his inventory).

I've tried using "player_has_item" and it gives the same result as before - it only "updates" after doing something else, and then re-entering/exiting the NPC equipment screen.

edit: I suppose I can try a "double check", to see if the NPC hasn't got the sword AND the player does have it, but I doubt it'll make a difference.
edit2: Nope, it didn't. But then, I wasn't really expecting it to. So this is still a mystery (at least to me !)
 
You need to make another dialog that fires after do_member_trade - since change_screen fires in the consequence, it will check the original state before you do anything in the inventory and then jump to the next dialog state in the background.
Code:
  [anyone,"do_member_trade", [], "Anything else?", "member_trash_talk",[]],
  [trp_npc_17, [(neg|troop_has_item_equipped,"trp_npc17","itm_special_sword"),],
  "I see you've been admiring my sword. I would like it back now though.", "member_talk",[]],
  [anyone|auto_proceed, [], "{!}Whatever", "member_talk",[]],
 
It's a bit embarrasing, but I still can't get it to work properly. Currently I have

Code:
	[trp_npc17,"member_talk",[(neg|troop_has_item_equipped,"trp_npc17","itm_special_sword"),],
	  "I see you've been admiring my sword. I would like it back now though.", "member_talk",[]],
	[anyone,"do_member_trade", [], "Anything else okay?", "member_trash_talk",[]],
  
  [anyone|auto_proceed,"member_trash_talk",[], "{!}Whatever", "member_talk",[]],

and it sends me into an infinte loop of "let me see your equipment -> it's all here - > "let me see your equipment" UNLESS I take the sword away, then I (correctly) get the "I'd like it back now" dialog, and exit out. However that's only when talking to NPC17 - if I talk to someone else, I'm locked inside that infinite loop (since they don't care that I have the sword).
 
 
I'm guessing you could  check if the item is equipped. Then make a dialog for the companion that says "I'm sorry sir/madam, but what sword are you talking about?" when they don't have it equipped.
 
Back
Top Bottom