Aller au contenu

Photo

Limiting companion inventory/equipment


  • Veuillez vous connecter pour répondre
10 réponses à ce sujet

#1
kamal_

kamal_
  • Members
  • 5 240 messages

I would like to control inventory for companions. Namely, I want to be able to limit the size of the inventory (say x slots instead of the nwn2 default four pages of inventory), and prevent a companion from carrying some item types (for example, talking rabbit companions can't carry full plate). Lastly, I want to control equipment ("I refuse to give up my family heirloom sword!"), blocking unequipping from a given item slot and blocking equipping items to a given slot (for instance the Headless Horseman can't wear a helm because he has no head!).

 

I've done some searching, but teh googles is failing me though. I bet all this has already been done by someone and the answer is out there. Rather than reinventing the wheel, I figured I ask the community.



#2
Tchos

Tchos
  • Members
  • 5 042 messages

Well, the heirloom sword thing, as many characters had in Baldur's Gate, is easily done with tag-based unacquire and unequip scripts for the special items, which reacquire or reequip the items and show an appropriate message.  I've done for several items.

 

Blocking a slot from being equipped by anything may require a different solution.



#3
andysks

andysks
  • Members
  • 1 645 messages

Somebody gave me this a while ago. I think it was PJ.

 

They did it in a module with M.Reader... I think, and this script is a copy of that. The companion will even strike a convo if you try to remove his heirloom. 
 
void main()
{
    // * This code runs when the item is unequipped
    object oPC      = GetPCItemLastUnequippedBy();
    object oItem    = GetPCItemLastUnequipped();

 	//Your code goes here
	
	//Companion's name is Cyril, but armor Ceryl. Just a typo. Shouldn't mess things up, since it's
	//just a tag.
	//If you try and take his armor, he won't like it.
	//NOTE!!! 
	//See if you can divert it, for later if PC find a better piece?
	
	
{
object oArmor = GetObjectByTag("ceryl_armor");
object oCyril = GetObjectByTag("cyril");
object oPC = GetFirstPC();
AssignCommand(oCyril,ActionEquipItem(oArmor,INVENTORY_SLOT_CHEST));
AssignCommand(oPC,ActionStartConversation(oCyril,"cyril_armor_convo",FALSE,FALSE,TRUE));
}

}

ps. The convo doesn't happen on my companion, but that's another bug I just postpone to address. Rest work. He won't unequip it.



#4
Dann-J

Dann-J
  • Members
  • 3 161 messages

The strength score of the average talking rabbit should discourage anyone from putting fullplate in its inventory. :)

 

You could put a certain number of plotted and cursed null items into a companion's inventory to reduce the number of slots available. The icon for the wenderkazoo should do the trick.

 

Here's the sort of tag-based OnUnequipped script you might use for an heirloom weapon. I don't know what might happen if the AI tried to switch weapons - an infinite loop of equip/unequip perhaps?

//i_itemtag_ue
#include "ginc_item"

void main()
{
object oPC = GetPCItemLastUnequippedBy();
object oItem = GetPCItemLastUnequipped();
int iSlot = GetSlotOfEquippedItem(oItem, oPC);
AssignCommand(oPC, ClearAllActions(TRUE));
DelayCommand(0.1, AssignCommand(oPC, ActionEquipItem(oItem, iSlot)));
}


#5
GCoyote

GCoyote
  • Members
  • 341 messages
How did they do the cursed domino ask in MoW? It could be unequiped but not removed from the PC.

#6
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
Items flagged cursed cannot be dropped, but they can be unequipped.
  • GCoyote aime ceci

#7
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
For the headless horseman I would give him a cursed helm that has no beneficial prperties or weight, that is uneqippable using a script and set him to not show his helm if you cannot make it invisible in some way.

#8
rjshae

rjshae
  • Members
  • 4 485 messages

I think a cursed item has to have a price of zero or be a plot item to prevent it from being sold.


  • GCoyote aime ceci

#9
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages

I think a cursed item has to have a price of zero or be a plot item to prevent it from being sold.


We've done this dance before.

What we resolved then is cursed means undroppable but not unsellable or unequipable. To make something unsellable make it a plot item or worth 0. To make it unequipable you need a tag based script.

Regards



#10
rjshae

rjshae
  • Members
  • 4 485 messages

It might be interesting to see if a new item property can be inserted that restricts usage to a character with a specific feat, then create a set of Heritage background feats that you can assign to your companions. That way you can always limit the usage to just one character.


  • GCoyote aime ceci

#11
Dann-J

Dann-J
  • Members
  • 3 161 messages

It's easy enough to hack into the module OnEquip script. They did that extensively with the official campaigns, inserting checks for companions that can't equip a lot of items (blade golem, okku, one-of-many). You could put in a check that looks for a local string variable on an item, and if it exists then only allow a party member with a tag that matches that string variable to equip it. Otherwise, immediately unequip it.

 

I've edited the module OnEquip script to include checks for things like ability scores, gender, and deity. I've never actually used any of those checks - they were more of a proof-of-concept experiment. The downside is that the item icons don't turn red in the inventory, so you have to explain the limitations of the items in their descriptions. An appropriate message when they get unequipped automatically ("you must have a strength score of at least xx to equip this item") also helps.