Jump to content

Scripting, IsVATSControlsEnabled() Does this funtion simply not work?


Pelgar

Recommended Posts

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

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

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

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

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

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 !bResult

EndFunction

 

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 !bResult

EndFunction

 

If anyone can tell me what's wrong I'd really appreciate it.

Link to comment
Share on other sites

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 Quest


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 !bResult

EndFunction

 

 

Here is the Object script. I know it will need a lot of cleaning up.

 

Scriptname PelgOrg:PelgSwimSuitScript extends ObjectReference

Quest Property pQuest Auto Const
Armor Property thisSwimSuit Auto Const

PelgSwimQuestScript Property SwimQuest Auto Const Mandatory

int CheckWaterID = 1
Location lCur
Actor aOwner
string strCurName
Form [] aryWornItems

Event 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
endif

endEvent

;get slots 0 Hair Top (Hat), 3 Body, 4 Lhand, 5 Rhand, 6-10 under armor, 11-15 armor, 16 headband

Event 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")
EndEvent

Event 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
endIf
endEvent


Event 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...
EndIf
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...