Hide helmet and/or weapons


#1

Hi all. I got this situation of a hangout in my campaign where many cutscenes happen. I found out that showing helmets and weapons in an area where the party goes to rest is kinda silly so I chose to remove them upon entering. This causes the problem that when the player exits the area and picks a party has to re-equip helmets and weapons to all companions. Is there a function which just hides these items instead of unequipping them? Many games (like Dragon Age) have done such a thing but I cannot find any stock function that does that in NWN2. Any clues?


#2

to get this you have to write your own function. fortunately you’re already half there. now you have to store a variable somewhere (the item, the character, etc.) which either stores the character last equipping that item, or the item last equipped.

beware that if you forcefully unequip an item beneficial effects, like extra spell slots due to increased intelligence ability, will be reset. that could lead to the problem that the player won’t notice and will be really annoyed later, especially if this always happens when entering an area.

personally i would not implement such a feature.


#3

I don’t think there is anything that makes helm/weapons visually disappear via script. An unequip/reequip script is probably the way to go. Unfortunately, I couldn’t get the Remember/RestoreEquippedItem functions to work like it’s supposed to, so I wrote my own script that does exactly what you’re looking for. Try this:

/*
	Unequips hands and helm at start of convo.
	Reequips hands and helm at end of convo.
	Place this script on the very first node of the convo.
	Also place this on the end dialog nodes OR in both the End/Abort Conversation handlers.
*/

#include "ginc_item"

void main()
{
	object oPC = GetPCSpeaker();
	object oItem;
	
	object oFM = GetFirstFactionMember(oPC, FALSE);

	if (!GetLocalInt(OBJECT_SELF, "unequipped"))
	{
		SetLocalInt(OBJECT_SELF, "unequipped", TRUE);

		while (GetIsObjectValid(oFM))
		{
			oItem = GetItemInSlot(INVENTORY_SLOT_HEAD, oFM);
			if (GetIsObjectValid(oItem)) SetLocalObject(oFM, "head", oItem);
	
			oItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oFM);
			if (GetIsObjectValid(oItem)) SetLocalObject(oFM, "left", oItem);
	
			oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oFM);
			if (GetIsObjectValid(oItem)) SetLocalObject(oFM, "right", oItem);

			UnequipSlot(oFM, INVENTORY_SLOT_HEAD);
			UnequipSlot(oFM, INVENTORY_SLOT_LEFTHAND);
			UnequipSlot(oFM, INVENTORY_SLOT_RIGHTHAND);
			
			oFM = GetNextFactionMember(oPC, FALSE);
		}
	}

	else
	{
		SetLocalInt(OBJECT_SELF, "unequipped", FALSE);
		
		while (GetIsObjectValid(oFM))
		{
			oItem = GetLocalObject(oFM, "head");
			if (GetIsObjectValid(oItem)) AssignCommand(oFM, ActionEquipItem(oItem, INVENTORY_SLOT_HEAD));

			oItem = GetLocalObject(oFM, "right");
			if (GetIsObjectValid(oItem)) AssignCommand(oFM, ActionEquipItem(oItem, INVENTORY_SLOT_RIGHTHAND));			
			
			oItem = GetLocalObject(oFM, "left");
			if (GetIsObjectValid(oItem)) AssignCommand(oFM, ActionEquipItem(oItem, INVENTORY_SLOT_LEFTHAND));
			
			oFM = GetNextFactionMember(oPC, FALSE);
		}
	}
}

I have tested this with party members and it works nicely with controlled companions, too.


#4

you could try this hardcoded funct:

// TWH - OEI 5/25/2006
// Returns TRUE if it found an object to set weapon visibilty on
// oObject is the object to set weapon visibility on
// nVisibile 0 for invisibile, 1 for visible, and 4 is default engine action
// nType is: 0 - weapon, 1 - helm, 2 - both
int SetWeaponVisibility( object oObject, int nVisibile, int nType=0 );

 

Aqvilinus and i recently fixed the functions that remove/restore equipment in ‘ginc_item’ for Nwn2Fixes

but Removing a wizard’s +4 Circlet of Intelligence is basically an offensive act.


#5

SetWeaponVisibility does indeed make whatever is in the left/right hand become invisible. Although the function description states that it can work with helms, unfortunately, it does not appear to work with them.

Needs confirmation.


#6

there could be a ‘fancy’ way to do this …

store each item’s model-part numbers, then set the item’s current model-parts to invisible parts (if they exist for each item-type + model-part), and restore the original parts later

(but i suspect that the functions for this, iirc, that were written for Nwn1 just ain’t gonna work in 2)


#7

the thing with the helm slot is that it replaces the hair mesh. even an invisible item would mess up the appearance.


#8

Good ideas here. I guess the equip/unequip version of travus is the easiest to try (since he tested it and it works). Thanks a lot :).