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?
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.
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.
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.
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.
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)
the thing with the helm slot is that it replaces the hair mesh. even an invisible item would mess up the appearance.
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 :).
It just occurred to me that when we enter the hangout the companions have already left the party. So the loop as written won’t do any good. Is there any way to loop through all creatures in the area? It’s only the companions there anyway.
Try this as an action script for each actor in the dialog. Set the sTag parameter using the companion’s tag or leave blank for the PC.
// ga_hands_helm
/*
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.
sTag = Tag of companion. Leave blank for PC.
*/
#include "ginc_item"
void main(string sTag)
{
object oFM = GetObjectByTag(sTag);
object oItem;
if (sTag == "") oFM = GetFirstPC(FALSE);
if (!GetLocalInt(oFM, "unequipped"))
{
SetLocalInt(oFM, "unequipped", TRUE);
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);
}
else
{
SetLocalInt(oFM, "unequipped", FALSE);
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));
}
}
Or just use this script that covers everyone on the map.
/*
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()
{
int n;
object oItem;
object oCreature = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, CREATURE_ALIVE_TRUE, GetFirstPC(FALSE), n);
while (GetIsObjectValid(oCreature))
{
if (!GetLocalInt(oCreature, "unequipped"))
{
SetLocalInt(oCreature, "unequipped", TRUE);
oItem = GetItemInSlot(INVENTORY_SLOT_HEAD, oCreature);
if (GetIsObjectValid(oItem)) SetLocalObject(oCreature, "head", oItem);
oItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oCreature);
if (GetIsObjectValid(oItem)) SetLocalObject(oCreature, "left", oItem);
oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oCreature);
if (GetIsObjectValid(oItem)) SetLocalObject(oCreature, "right", oItem);
UnequipSlot(oCreature, INVENTORY_SLOT_HEAD);
UnequipSlot(oCreature, INVENTORY_SLOT_LEFTHAND);
UnequipSlot(oCreature, INVENTORY_SLOT_RIGHTHAND);
}
else
{
SetLocalInt(oCreature, "unequipped", FALSE);
oItem = GetLocalObject(oCreature, "head");
if (GetIsObjectValid(oItem)) AssignCommand(oCreature, ActionEquipItem(oItem, INVENTORY_SLOT_HEAD));
oItem = GetLocalObject(oCreature, "right");
if (GetIsObjectValid(oItem)) AssignCommand(oCreature, ActionEquipItem(oItem, INVENTORY_SLOT_RIGHTHAND));
oItem = GetLocalObject(oCreature, "left");
if (GetIsObjectValid(oItem)) AssignCommand(oCreature, ActionEquipItem(oItem, INVENTORY_SLOT_LEFTHAND));
}
n++;
oCreature = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, CREATURE_ALIVE_TRUE, OBJECT_SELF, n);
}
}
This works so well :). Thanks again Travus.