XJDHDR Posted September 30, 2019 Share Posted September 30, 2019 The various "EquipItem" commands have a second parameter which blocks unequipping that item if that parameter is 1. I want to know how I can figure out if an item the player is wearing has had that block applied. The only thing I've found so far is this note on the CS Wiki's pages for the various EquipItem commands:EquipItem will not work if there is already an item in that slot that has been equipped with the NoUnequipFlag set. This can be useful for determining whether or not that flag has been set. This is the script I currently have to try detect this (lines 22 - 31 are the ones where I'm trying to test):ScriptName XjPostLoadGameEventFunctionScript Short bUnusedGameLoadedSuccessfully ; We already filtered our event to only run on successful loads Array_Var arrEquippedItemArray Long lCurrentEquippedItemSlotMask Ref rCurrentRefreshTarget Ref rZero Short bNoUnequipItemFlagSet Begin _Function{bUnusedGameLoadedSuccessfully} ; Compiler override needs to be enabled. "0" in rZero is treated as literal filter otherwise instead of ignored. Let rZero := 0 ; Need to assign 0 to ref variable. Script doesn't compile otherwise: https://forums.nexusmods.com/index.php?/topic/1031654-blockhead/page-103#entry73732678 ' RegisterEquipmentOverrideHandler XjEquipmentManagementScript rZero rZero CustomRace rZero ; Add code to re-equip everything the player is wearing PlayerRef.AddItemNS XjTestNoUnequipFlagItem 1 ForEach arrEquippedItemArray <- PlayerRef.GetEquippedItems Let rCurrentRefreshTarget := arrEquippedItemArray->value Let lCurrentEquippedItemSlotMask := GetBipedSlotMask rCurrentRefreshTarget SetBipedSlotMask lCurrentEquippedItemSlotMask XjTestNoUnequipFlagItem PlayerRef.EquipItem XjTestNoUnequipFlagItem If PlayerRef.GetEquipmentSlotMask lCurrentEquippedItemSlotMask == rCurrentRefreshTarget Let bNoUnequipItemFlagSet := 1 PlayerRef.UnequipItemSilent rCurrentRefreshTarget Else Let bNoUnequipItemFlagSet := 0 PlayerRef.UnequipItemSilent XjTestNoUnequipFlagItem EndIf If XjInitQuest.bDontRunEquipItemBlock == 0 PlayerRef.EquipItem2NS rCurrentRefreshTarget bNoUnequipItemFlagSet Else PlayerRef.EquipItemSilent rCurrentRefreshTarget bNoUnequipItemFlagSet EndIf Loop Let arrEquippedItemArray := ar_Null PlayerRef.RemoveItemNS XjTestNoUnequipFlagItem 1 End This script doesn't work, however. When I load my test save, all the items I have equipped had the "no unequip" flag enabled. This means that bNoUnequipItemFlagSet was set to 1, which means that rCurrentRefreshTarget was still equipped after I equipped XjTestNoUnequipFlagItem. And no, the test save character was not wearing anything that was force equipped. Link to comment Share on other sites More sharing options...
Recommended Posts