Pelgar Posted January 5, 2018 Share Posted January 5, 2018 I have a follower equipping a swimsuit when the player swims. I'm now trying to get her to change back into armor when out of water. If isSwimming is still around in FO4 I can't find it. I've tried all of the Is???controlsEnabled functions, (isSneakingEnabled, isVatsControlEnabled, IsFightingControlEnabled). All of these functions return true even using a timer and checking after player has been in the water for 20 or 30 seconds. Does anyone know how to get these functions to work or have any idea how to detect when player or npc is no longer swimming? Link to comment Share on other sites More sharing options...
Reneer Posted January 5, 2018 Share Posted January 5, 2018 What InputLayer are you calling these functions on? Link to comment Share on other sites More sharing options...
Pelgar Posted January 5, 2018 Author Share Posted January 5, 2018 Hi Reneer, Thanks for the reply! These are the Game version functions, not the inputlayer functions. I would try the inputlayer functions but I can't figure out how to point at an input layer. Link to comment Share on other sites More sharing options...
Reneer Posted January 5, 2018 Share Posted January 5, 2018 This is just a guess, but probably those Game functions are being overridden by an InputLayer. To create a new InputLayer (and check for status) you just do this: InputEnableLayer myLayer = InputEnableLayer.Create() bool cansneak = myLayer.IsSneakingEnabled() myLayer.Disable() Link to comment Share on other sites More sharing options...
Pelgar Posted January 5, 2018 Author Share Posted January 5, 2018 Thanks again Reneer! I did try creating an InputLayer and using those functions but the results were always enabled. I guessed that you had to point at the layer that actually disabled them.I'm really rusty at scripting, been awhile. I'm going to copy paste your example and see what happens. Thanks again. Link to comment Share on other sites More sharing options...
Pelgar Posted January 5, 2018 Author Share Posted January 5, 2018 I tested the code and even when player is underwater it reports that sneaking is enabled! Just in case someone else wants to try the code, the InputEnableLayer does not have a Disable function, I changed it to Delete and it would compile.I'm going to try the other InputLayer controls that are disabled when swimming hopefully at least one of them will work. I'm trying this in an object script, is that possibly a problem. Does it require a quest, actor or other script type? Link to comment Share on other sites More sharing options...
Pelgar Posted January 6, 2018 Author Share Posted January 6, 2018 I've tried all of the InputEnableLayer and Game isFight IsSneak IsVats enabled functions in both an object script and a quest script. They always report that these controls are enabled! Here is a copy of the Quest script using the Game functions: bool Function isPlayerSwimming( ) bool bResult = false bResult = Game.IsVATSControlsEnabled() if bResult bResult = Game.IsFightingControlsEnabled() endif if bResult bResult = Game.IsSneakingControlsEnabled() endif return !bResultEndFunction Here is the InputLayer version bool Function isPlayerSwimming( ) bool bResult = false InputEnableLayer myLayer = InputEnableLayer.Create() bResult = myLayer.IsVATSEnabled() if bResult bResult = myLayer.IsFightingEnabled() endif if bResult bResult = myLayer.IsSneakingEnabled() endif myLayer.Delete() return !bResultEndFunction If anyone can tell me what's wrong I'd really appreciate it. Link to comment Share on other sites More sharing options...
Reneer Posted January 6, 2018 Share Posted January 6, 2018 Are those the entire scripts? You'll want to post everything to get a bit more help. Link to comment Share on other sites More sharing options...
Pelgar Posted January 6, 2018 Author Share Posted January 6, 2018 Yes that is nearly the entire script, well the quest script anyway. I'm calling the isPlayerSwimming function from my object script. I'll post the entire Quest script here and the entire object script below it. Scriptname PelgOrg:PelgSwimQuestScript extends Questbool Function isPlayerSwimming( ) bool bResult = false InputEnableLayer myLayer = InputEnableLayer.Create() bResult = myLayer.IsVATSEnabled() if bResult bResult = myLayer.IsFightingEnabled() endif if bResult bResult = myLayer.IsSneakingEnabled() endif myLayer.Delete() return !bResultEndFunction Here is the Object script. I know it will need a lot of cleaning up. Scriptname PelgOrg:PelgSwimSuitScript extends ObjectReferenceQuest Property pQuest Auto ConstArmor Property thisSwimSuit Auto ConstPelgSwimQuestScript Property SwimQuest Auto Const Mandatoryint CheckWaterID = 1Location lCurActor aOwnerstring strCurNameForm [] aryWornItemsEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) Actor aCur = akNewContainer as Actor lCur = aCur.GetCurrentLocation() if (aCur.getrace().GetName() == "Human" && aCur.IsPlayerTeammate()) Actor aPrev = akOldContainer as Actor int iSex = aCur.GetLeveledActorBase().GetSex() strCurName = aCur.GetLeveledActorBase().GetName() if (iSex == 1) ;;if female if (aPrev == Game.GetPlayer()) debug.MessageBox("You gave " + strCurName + " a swimsuit. Location = " + lCur.GetName()) else debug.MessageBox(strCurName + " picked up a swimsuit") endif aOwner = aCur RegisterForRemoteEvent(Game.GetPlayer(), "OnPlayerSwimming") ;used by the Affinity Event system endIf endifendEvent;get slots 0 Hair Top (Hat), 3 Body, 4 Lhand, 5 Rhand, 6-10 under armor, 11-15 armor, 16 headbandEvent Actor.OnPlayerSwimming(Actor akSender) aryWornItems = New Form[0] string strWorn = strCurName + " is wearing " int iIndex = 0 int iAryIdx = 0 while (iIndex < 15) if (iIndex !=1 && iIndex !=2 && aOwner.GetWornItem(iIndex).Item) aryWornItems.add( aOwner.GetWornItem(iIndex).Item) strWorn += aOwner.GetWornItem(iIndex).ModelName +", " iAryIdx += 1 endif iIndex += 1 EndWhile Debug.MessageBox(strWorn) iAryIdx = 0 int iAryMax = aryWornItems.Length While (iAryIdx < iAryMax) aOwner.UnequipItem(aryWornItems[iAryIdx]) iAryIdx += 1 EndWhile aOwner.Equipitem(thisSwimSuit); RegisterForAnimationEvent(aOwner, "SwimStop"); If (!RegisterForAnimationEvent(aOwner, "SwimStop")); Debug.MessageBox("Failed to register for SwimStop event!"); EndIf; If (!RegisterForAnimationEvent(aOwner, "MTSwimStop")); Debug.MessageBox("Failed to register for MTSwimStop event!"); EndIf StartTimer(5, CheckWaterID); Debug.MessageBox("Player is swimming")EndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName) if (akSource == aOwner) Debug.Notification("An anim event fired on NPC") if (asEventName == "SwimStop") Debug.MessageBox("Anim Event: SwimStop fired on Owner!") elseif (asEventName == "MTSwimStop") Debug.MessageBox("Anim Event: MTSwimStop fired on Owner!") endif endIfendEventEvent OnTimer(int aiTimerID) If aiTimerID == CheckWaterID ; The five second timer we started just expired; InputEnableLayer myLayer = InputEnableLayer.Create(); bool cansneak = myLayer.IsVATSEnabled(); if cansneak; Debug.MessageBox("Player can use VATS"); else; Debug.MessageBox("VATS Disabled"); endif; myLayer.Delete() bool bSwimming bSwimming = SwimQuest.isPlayerSwimming() if bSwimming Debug.MessageBox("Player is swimming") else Debug.MessageBox("Player is not swimming") endif StartTimer(5, CheckWaterID) ; If we wanted to have the timer start over, we could now do StartTimer again... EndIfEndEvent Link to comment Share on other sites More sharing options...
Recommended Posts