Yet more frustration - the torchbearers...
We have some characters who should carry torches when out of doors at night. Currently, no joy...I've tried two approaches to equipping/unequipping the bloody torches. The first was to put this on the NPC's onheartbeat script:
It didn't work, and I assumed the NPCs onheartbeat wasn't getting called. So I tried this on the module's onhearbeat:
And that didn't work either. It turns out that GetItemInSlot() always fails, at least for the slots INVENTORY_SLOT_LEFTHAND and INVENTORY_SLOT_RIGHTHAND... so the first solution is the right solution, if only we could get the equipped item!
We have some characters who should carry torches when out of doors at night. Currently, no joy...I've tried two approaches to equipping/unequipping the bloody torches. The first was to put this on the NPC's onheartbeat script:
Code:
////////////////////////////////////////////////////////////////////////// bv_torchbearer.nss// An spawnin script for torchbearers - if out of doors // at night, carry a torch - if not, don't. Imperfect,// because the torch gets created each time the script// fires, but not subsequently destroyed//// (c) 2008 The Medusa Collective////////////////////////////////////////////////////////////////////////void main(){ string TORCHTAG = "m0_it_torch01"; object equipped = GetItemInSlot( INVENTORY_SLOT_RIGHTHAND); if ( ( GetIsDusk() || GetIsNight()) && GetTag( GetArea(OBJECT_SELF)) == "area_gl24") { if ( GetTag( equipped) != TORCHTAG){ AssignCommand( OBJECT_SELF, ActionEquipItem( CreateItemOnObject( TORCHTAG), INVENTORY_SLOT_RIGHTHAND)); } } else { if ( equipped != OBJECT_INVALID && GetTag( equipped) == TORCHTAG) { AssignCommand( OBJECT_SELF, ActionUnequipItem( equipped)); } }}
Code:
// if oNPC is carrying a torch, unequip itvoid UnequipTorch( string tag) { string TORCHTAG = "m0_it_torch01"; object oNPC = GetNPCByTag( tag); object equipped = GetItemInSlot( INVENTORY_SLOT_LEFTHAND, oNPC); if ( equipped != OBJECT_INVALID) { PrintString( "Unequip torch: npc has a torch"); PrintString( tag); AssignCommand( oNPC, ActionUnequipItem( equipped)); } else { PrintString( "Unequip torch: npc has no torch"); PrintString( tag); if ( equipped != OBJECT_INVALID) { PrintString( GetTag( equipped)); } }}// After the completion of Going Home To Papa, the Reverend, Szczepan and Agnieszka // should unequip their torches. The onheartbeat script is a pretty inefficient way of doing // it, though.void MaybeUnequipTorches() { if ( ! HasJournalEntry( "Plot", "plot/notorches")) { if ( HasJournalEntry("Plot", "plot/ghtp2")) { PrintString( "MaybeUnequipTorches"); UnequipTorch( szczTag); UnequipTorch( revTag); UnequipTorch( agniTag); UnequipTorch( gutkTag); AddJournalEntry( "Plot", "plot/notorches"); } }}


