Forums
Games
Cyberpunk 2077 Thronebreaker: The Witcher Tales GWENT®: The Witcher Card Game The Witcher 3: Wild Hunt The Witcher 2: Assassins of Kings The Witcher The Witcher Adventure Game
Jobs Store Support Log in Register
Forums - CD PROJEKT RED
Menu
Forums - CD PROJEKT RED
  • Hot Topics
  • NEWS
  • GENERAL
    THE WITCHER ADVENTURE GAME
  • STORY
    THE WITCHER THE WITCHER 2 THE WITCHER 3 THE WITCHER TALES
  • GAMEPLAY
    THE WITCHER THE WITCHER 2 THE WITCHER 3 MODS (THE WITCHER) MODS (THE WITCHER 2) MODS (THE WITCHER 3)
  • TECHNICAL
    THE WITCHER THE WITCHER 2 (PC) THE WITCHER 2 (XBOX) THE WITCHER 3 (PC) THE WITCHER 3 (PLAYSTATION) THE WITCHER 3 (XBOX) THE WITCHER 3 (SWITCH)
  • COMMUNITY
    FAN ART (THE WITCHER UNIVERSE) FAN ART (CYBERPUNK UNIVERSE) OTHER GAMES
  • RED Tracker
    The Witcher Series Cyberpunk GWENT
THE WITCHER
THE WITCHER 2
THE WITCHER 3
MODS (THE WITCHER)
MODS (THE WITCHER 2)
MODS (THE WITCHER 3)
Menu

Register

Yet more frustration - the torchbearers...

+
U

username_2075278

Senior user
#1
Aug 10, 2008
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:
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));		}	}}
It didn't work, and I assumed the NPCs onheartbeat wasn't getting called. So I tried this on the module's onhearbeat:
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");		}	}}
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!
 
G

Gamewidow

Forum veteran
#2
Aug 11, 2008
This seems to work alright, but it never fires at the correct time when i use it as a daily script ...what am i missing ? I have another script (very similar) to re-equip the torch.
Code:
void main(){	object oReverend = GetObjectByTag( "bv_npct_reverend");	object oRevtorch = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oReverend);  //unequip if valid  if (GetIsObjectValid(oRevtorch)) {   AssignCommand(oReverend, ActionUnequipItem(oRevtorch));  } }
 
G

Gamewidow

Forum veteran
#3
Aug 12, 2008
problem fixed for our module anyway ... but by brute force. here's the code:
Code:
void main(){	int nHour = GetTimeHour();	if(nHour > 05 && nHour < 19) {		object oTorch = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, OBJECT_SELF);		//unequip if valid		if (GetIsObjectValid(oTorch)) {			AssignCommand(OBJECT_SELF, ActionUnequipItem(oTorch));		}	} else {		object oItem = GetFirstItemInInventory(OBJECT_SELF);		object oTorch = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, OBJECT_SELF);		if (GetIsObjectValid(oTorch)) {			return;		}		while (oItem != OBJECT_INVALID) {			if (GetTag(oItem) == "it_torch_001") {				AssignCommand(OBJECT_SELF, ActionEquipItem(oItem, INVENTORY_SLOT_LEFTHAND));				break;			} else				oItem = GetNextItemInInventory(OBJECT_SELF);		}	}}
i run this from the onHeartbeat field, so it could quite likely be more efficient, but it works. So if anyone can suggest a way to make it more elegant, great :)
 
Share:
Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email Link
  • English
    English Polski (Polish) Deutsch (German) Русский (Russian) Français (French) Português brasileiro (Brazilian Portuguese) Italiano (Italian) 日本語 (Japanese) Español (Spanish)

STAY CONNECTED

Facebook Twitter YouTube
CDProjekt RED Mature 17+
  • Contact administration
  • User agreement
  • Privacy policy
  • Cookie policy
  • Press Center
© 2018 CD PROJEKT S.A. ALL RIGHTS RESERVED

The Witcher® is a trademark of CD PROJEKT S. A. The Witcher game © CD PROJEKT S. A. All rights reserved. The Witcher game is based on the prose of Andrzej Sapkowski. All other copyrights and trademarks are the property of their respective owners.

Forum software by XenForo® © 2010-2020 XenForo Ltd.