stonefisher Posted July 10, 2017 Share Posted July 10, 2017 @FiftyTifty True I could use bools now that i have seen a script with them yesterday. I presume thats alot faster. I just have to make it set the bools on equip and on leaving the armour workbench. Link to comment Share on other sites More sharing options...
FiftyTifty Posted July 10, 2017 Share Posted July 10, 2017 @FiftyTifty True I could use bools now that i have seen a script with them yesterday. I presume thats a lot faster. I just have to make it set the bools on equip and on leaving the armour workbench. Scriptname CGXAM_GhostGoggles extends ObjectReference Armor Property CGXAM_CourserGhostX92Goggles Auto Keyword property CGXAMGhostX92GogglesDown auto Keyword property CGXAMGhostX92GogglesUp auto Keyword property CGXAMGhostX92GogglesPulsingDown auto Keyword property CGXAMGhostX92GogglesPulsingUp auto Keyword property CGXAMGhostX92GogglesAnimated auto Keyword property CGXAMWearingGhostX92Goggles auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesDown Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesUp Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingDown Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingUp Auto bool Property bGogglesAnimated Auto bool Property bGogglesUp Auto bool Property bGogglesPulsingUp Auto bool Property bGogglesDown Auto bool Property bGogglesPulsingDown Auto bool Property bWeaponDrawn Auto Actor Property ActorRef Auto Actor Property PlayerRef Auto Event OnEquipped(Actor akActor) ActorRef = akActor bool bGogglesAnimated = ActorRef.wornhaskeyword(CGXAMGhostX92GogglesAnimated) bool bGogglesUp = ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp) bool bGogglesPulsingUp = ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp) bool bGogglesDown = ActorRef.wornhaskeyword(CGXAMGhostX92GogglesDown) bool bGogglesPulsingDown = ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingDown) bool bWeaponDrawn = ActorRef.IsWeaponDrawn() If bGogglesAnimated RegisterForAnimationEvent(ActorRef, "WeaponDraw") RegisterForAnimationEvent(ActorRef, "WeaponSheathe") if bWeaponDrawn If bGogglesUp AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) ElseIf bGogglesPulsingUp AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) EndIf ElseIf bWeaponDrawn == false If bGogglesDown AttachMod(CGXAM_mod_CourserGhostX92GogglesUp) ElseIf bGogglesPulsingDown AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) EndIf EndIf EndIf EndEvent Event OnAnimationEvent(ObjectReference akSource, string asEventName) If bGogglesAnimated If (akSource == ActorRef) && (asEventName == "WeaponDraw") If bGogglesUp AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) ElseIf bGogglesPulsingUp AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) EndIf ElseIf (akSource == ActorRef) && (asEventName == "WeaponSheathe") If bGogglesDown AttachMod(CGXAM_mod_CourserGhostX92GogglesUp) ElseIf bGogglesPulsingDown AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp) EndIf EndIf EndIf endEvent Event OnUnequipped(Actor akActor) if akActor == ActorRef If ActorRef.wornhaskeyword(CGXAMWearingGhostX92Goggles == false UnregisterForAnimationEvent(PlayerRef, "WeaponDraw") UnregisterForAnimationEvent(PlayerRef, "WeaponSheathe") EndIf EndIf EndEvent Link to comment Share on other sites More sharing options...
stonefisher Posted July 10, 2017 Share Posted July 10, 2017 @fiftytifty interesting demonstration of using the bool's. I presume checking a bool is alot lot more cpu friendly than running a function. I compressed my script as much as possible down below and ran it and turns out that the changing mods really do unequip and reequip the item it is on, just really fast. So your script would be running the on equip event and on animation event at the same time running the functions everytime. But thanks for the demonstration, I will redo mine with an on first equip bool and an on exiting workbench section to run the function calls in. Scriptname CGXAM_GhostGoggles extends ObjectReference Keyword property CGXAMGhostX92GogglesDown auto Keyword property CGXAMGhostX92GogglesUp auto Keyword property CGXAMGhostX92GogglesPulsingDown auto Keyword property CGXAMGhostX92GogglesPulsingUp auto Keyword property CGXAMGhostX92GogglesAnimated auto Keyword property CGXAMWearingGhostX92Goggles auto ;Keyword property CGXAMGhostX92GogglesAutoNightVisionOff auto Keyword property CGXAMGhostX92GogglesAutoNightVisionOn auto Keyword property CGXAMX92GogglesNightVisionOff auto Keyword property CGXAMX92GogglesNightVisionOn auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesDown Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesUp Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingDown Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingUp Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesNVOff Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesNVOn Auto Actor Property ActorRef Auto Float Property LLNumber Auto GlobalVariable Property CGXAM_LightLevelNumber Auto Event OnEquipped(Actor akActor) Debug.Notification("OnEquippedAAA") ActorRef = akActor If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesAnimated)) StartTimer(0.01) EndIf EndEvent Event OnTimer(int aiTimerID) If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesAnimated)) If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesAutoNightVisionOn)) LLNumber = CGXAM_LightLevelNumber.GetValue() If ((ActorRef.GetLightLevel()) <= (LLNumber)) If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp)) AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp)) AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) EndIf If (ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOff)) AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOn) EndIf Else If (ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOn)) AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff) EndIf if (ActorRef.IsWeaponDrawn() == true) If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp)) AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp)) AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) EndIf Else If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesDown)) AttachMod(CGXAM_mod_CourserGhostX92GogglesUp) ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingDown)) AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp) EndIf EndIf EndIf Else If (ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOn)) AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff) EndIf if (ActorRef.IsWeaponDrawn() == true) If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesUp)) AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingUp)) AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) EndIf Else If (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesDown)) AttachMod(CGXAM_mod_CourserGhostX92GogglesUp) ElseIF (ActorRef.wornhaskeyword(CGXAMGhostX92GogglesPulsingDown)) AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp) EndIf EndIf EndIf StartTimer(0.5) EndIf EndEvent Event OnUnequipped(Actor akActor) Debug.Notification("OnUnequippedZZZ") If !(ActorRef.wornhaskeyword(CGXAMWearingGhostX92Goggles)) CancelTimer() EndIf EndEvent Link to comment Share on other sites More sharing options...
FiftyTifty Posted July 10, 2017 Share Posted July 10, 2017 The functions return bools to begin with. The problem lies in that you're repeatedly calling the same functions, when you have previously gotten their result. Call the functions once, put them into a bool, and then use the bools in the if checks. The script I posted is the exact same one you posted on the previous page, but optimized with bools and PlayerRef instead of Game.GetPlayer() Link to comment Share on other sites More sharing options...
stonefisher Posted July 11, 2017 Share Posted July 11, 2017 (edited) Well heres my script with bools. :smile: It feels more complicated to me nut it compiled fine and now to test it. Scriptname CGXAM_GhostGoggles extends ObjectReference ;Armor Property CGXAM_CourserGhostX92Goggles Auto ;Keyword property CGXAMX92GogglesDown auto Keyword property CGXAMX92GogglesUp auto ;Keyword property CGXAMX92GogglesPulsingDown auto Keyword property CGXAMX92GogglesPulsingUp auto Keyword property CGXAMX92GogglesAnimated auto Keyword property CGXAMWearingGhostX92Goggles auto ;Keyword property CGXAMX92GogglesAutoNightVisionOff auto Keyword property CGXAMX92GogglesAutoNightVisionOn auto ;Keyword property CGXAMX92GogglesNightVisionOff auto Keyword property CGXAMX92GogglesNightVisionOn auto Keyword property workbencharmor auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesDown Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesUp Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingDown Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingUp Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesNVOff Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesNVOn Auto GlobalVariable Property CGXAM_LightLevelNumber Auto bool Property bGogglesAnimated = False Auto bool Property bAutoNightVisionOn Auto bool Property bNightVisionOn Auto bool Property bGogglesUp Auto bool Property bGogglesPulsingUp Auto ;bool Property bGogglesDown Auto ;bool Property bGogglesPulsingDown Auto bool Property bFunctionsRan = False Auto Actor Property ActorRef Auto Float Property LLNumber Auto Event OnEquipped(Actor akActor) Debug.Notification("OnEquipped proof") ActorRef = akActor If ActorRef == Game.GetPlayer() RegisterForMenuOpenCloseEvent("ExamineConfirmMenu") EndIf If bFunctionsRan == False StartTimer(0.01, 1) EndIf If bGogglesAnimated == True StartTimer(0.01) EndIf EndEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) Debug.Notification("OnMenuOpenCloseEvent") if abOpening == False CancelTimer() Debug.Notification("Menu send to timer 1") bFunctionsRan = False StartTimer(0.01, 1) EndIf endEvent Event OnTimer(int aiTimerID) If aiTimerID == 1 If bFunctionsRan == False bGogglesAnimated = ActorRef.wornhaskeyword(CGXAMX92GogglesAnimated) bAutoNightVisionOn = ActorRef.wornhaskeyword(CGXAMX92GogglesAutoNightVisionOn) bNightVisionOn = ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOn) bGogglesUp = ActorRef.wornhaskeyword(CGXAMX92GogglesUp) bGogglesPulsingUp = ActorRef.wornhaskeyword(CGXAMX92GogglesPulsingUp) ; bGogglesDown = ActorRef.wornhaskeyword(CGXAMX92GogglesDown) ; bGogglesPulsingDown = ActorRef.wornhaskeyword(CGXAMX92GogglesPulsingDown) If bGogglesAnimated == True bFunctionsRan = True StartTimer(0.01) Else Endif Debug.Notification("bFunctionsRan") EndIf EndIf If aiTimerID == 0 If bAutoNightVisionOn LLNumber = CGXAM_LightLevelNumber.GetValue() If ((ActorRef.GetLightLevel()) <= (LLNumber)) If bGogglesUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) bGogglesUp = False ElseIF bGogglesPulsingUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) bGogglesPulsingUp = False EndIf If bNightVisionOn == False AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOn) bNightVisionOn = True EndIf Else If bNightVisionOn == True AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff) bNightVisionOn = False EndIf if (ActorRef.IsWeaponDrawn() == true) If bGogglesUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) bGogglesUp = False ElseIF bGogglesPulsingUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) bGogglesPulsingUp = False EndIf Else If bGogglesUp == False AttachMod(CGXAM_mod_CourserGhostX92GogglesUp) bGogglesUp = True ElseIF bGogglesPulsingUp == False AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp) bGogglesPulsingUp = True EndIf EndIf EndIf Else If bNightVisionOn == True AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff) bNightVisionOn = False EndIf if (ActorRef.IsWeaponDrawn() == true) If bGogglesUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) bGogglesUp = False ElseIF bGogglesPulsingUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) bGogglesPulsingUp = False EndIf Else If bGogglesUp == False AttachMod(CGXAM_mod_CourserGhostX92GogglesUp) bGogglesUp = True ElseIF bGogglesPulsingUp == False AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp) bGogglesPulsingUp = True EndIf EndIf EndIf StartTimer(0.5) EndIf EndEvent Event OnUnequipped(Actor akActor) Debug.Notification("OnUnequippedZZZ") If !(ActorRef.wornhaskeyword(CGXAMWearingGhostX92Goggles)) CancelTimer() bFunctionsRan = False UnregisterForMenuOpenCloseEvent("ExamineConfirmMenu") Debug.Notification("CancelTimer") EndIf EndEvent Edited July 11, 2017 by stonefisher Link to comment Share on other sites More sharing options...
stonefisher Posted July 11, 2017 Share Posted July 11, 2017 (edited) Well the script worked but due to my bad use of bools kept reverting to steady light when set to pulsing light. Well heres the same script with a few extra bools to ensure it always sticks to the right one. Also I have made it if you are outside in rain or worse the goggles come down. Scriptname CGXAM_GhostGoggles extends ObjectReference Keyword property CGXAMX92GogglesUp auto Keyword property CGXAMX92GogglesDown auto Keyword property CGXAMX92GogglesPulsingUp auto Keyword property CGXAMX92GogglesPulsingDown auto Keyword property CGXAMX92GogglesAnimated auto Keyword property CGXAMWearingGhostX92Goggles auto Keyword property CGXAMX92GogglesAutoNightVisionOn auto Keyword property CGXAMX92GogglesNightVisionOn auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesDown Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesUp Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingDown Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesPulsingUp Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesNVOff Auto ObjectMod Property CGXAM_mod_CourserGhostX92GogglesNVOn Auto GlobalVariable Property CGXAM_LightLevelNumber Auto bool Property bGogglesAnimated = False Auto bool Property bAutoNightVisionOn Auto bool Property bNightVisionOn Auto bool Property bGogglesUp Auto bool Property bGogglesPulsingUp Auto bool Property bGogglesDown Auto bool Property bGogglesPulsingDown Auto bool Property bFunctionsRan = False Auto Actor Property ActorRef Auto Float Property LLNumber Auto Event OnEquipped(Actor akActor) Debug.Notification("OnEquipped proof") ActorRef = akActor If ActorRef == Game.GetPlayer() RegisterForMenuOpenCloseEvent("ExamineConfirmMenu") EndIf If bFunctionsRan == False StartTimer(0.01, 1) EndIf If bGogglesAnimated == True StartTimer(0.01) EndIf EndEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) Debug.Notification("OnMenuOpenCloseEvent") if abOpening == False CancelTimer() Debug.Notification("Menu send to timer 1") bFunctionsRan = False StartTimer(0.01, 1) EndIf endEvent Event OnTimer(int aiTimerID) If aiTimerID == 1 CancelTimer() If bFunctionsRan == False bGogglesAnimated = ActorRef.wornhaskeyword(CGXAMX92GogglesAnimated) bAutoNightVisionOn = ActorRef.wornhaskeyword(CGXAMX92GogglesAutoNightVisionOn) bNightVisionOn = ActorRef.wornhaskeyword(CGXAMX92GogglesNightVisionOn) bGogglesDown = ActorRef.wornhaskeyword(CGXAMX92GogglesDown) bGogglesUp = ActorRef.wornhaskeyword(CGXAMX92GogglesUp) bGogglesPulsingDown = ActorRef.wornhaskeyword(CGXAMX92GogglesPulsingDown) bGogglesPulsingUp = ActorRef.wornhaskeyword(CGXAMX92GogglesPulsingUp) If bGogglesAnimated == True bFunctionsRan = True StartTimer(0.01) StartTimer(60, 1) Else Endif Debug.Notification("bFunctionsRan") EndIf EndIf If aiTimerID == 0 ;Debug.Notification("PULSE") If bAutoNightVisionOn LLNumber = CGXAM_LightLevelNumber.GetValue() If ((ActorRef.GetLightLevel()) <= (LLNumber)) Debug.Notification("night vision on") If bGogglesUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) bGogglesUp = False bGogglesDown = True ElseIF bGogglesPulsingUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) bGogglesPulsingUp = False bGogglesPulsingDown = True EndIf If bNightVisionOn == False AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOn) bNightVisionOn = True EndIf Else If bNightVisionOn == True AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff) bNightVisionOn = False EndIf If (ActorRef.IsInInterior() == False && (Weather.GetCurrentWeather()).GetClassification() >= 2) Debug.Notification("Bad weather outdoors on") If bGogglesUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) bGogglesUp = False bGogglesDown = True ElseIF bGogglesPulsingUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) bGogglesPulsingUp = False bGogglesPulsingDown = True EndIf Else if (ActorRef.IsWeaponDrawn() == true) Debug.Notification("IsWeaponDrawn") If bGogglesUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) bGogglesUp = False bGogglesDown = True ElseIF bGogglesPulsingUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) bGogglesPulsingUp = False bGogglesPulsingDown = True EndIf Else Debug.Notification("IsWeaponsheathed") If bGogglesDown == True AttachMod(CGXAM_mod_CourserGhostX92GogglesUp) bGogglesDown = False bGogglesUp = True ElseIF bGogglesPulsingDown == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp) bGogglesPulsingDown = False bGogglesPulsingUp = True EndIf EndIf EndIf EndIf Else If bNightVisionOn == True AttachMod(CGXAM_mod_CourserGhostX92GogglesNVOff) bNightVisionOn = False EndIf If (ActorRef.IsInInterior() == False && (Weather.GetCurrentWeather()).GetClassification() >= 2) Debug.Notification("Bad weather outdoors on") If bGogglesUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) bGogglesUp = False bGogglesDown = True ElseIF bGogglesPulsingUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) bGogglesPulsingUp = False bGogglesPulsingDown = True EndIf Else if (ActorRef.IsWeaponDrawn() == true) Debug.Notification("IsWeaponDrawn") If bGogglesUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesDown) bGogglesUp = False bGogglesDown = True ElseIF bGogglesPulsingUp == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingDown) bGogglesPulsingUp = False bGogglesPulsingDown = True EndIf Else Debug.Notification("IsWeaponsheathed") If bGogglesDown == True AttachMod(CGXAM_mod_CourserGhostX92GogglesUp) bGogglesDown = False bGogglesUp = True ElseIF bGogglesPulsingDown == True AttachMod(CGXAM_mod_CourserGhostX92GogglesPulsingUp) bGogglesPulsingDown = False bGogglesPulsingUp = True EndIf EndIf EndIf EndIf StartTimer(0.5) EndIf EndEvent Event OnUnequipped(Actor akActor) Debug.Notification("OnUnequippedZZZ") Utility.wait(2) If !(ActorRef.wornhaskeyword(CGXAMWearingGhostX92Goggles)) CancelTimer() CancelTimer(1) bFunctionsRan = False UnregisterForMenuOpenCloseEvent("ExamineConfirmMenu") Debug.Notification("CancelTimer") EndIf EndEvent Edited July 11, 2017 by stonefisher Link to comment Share on other sites More sharing options...
stonefisher Posted July 11, 2017 Share Posted July 11, 2017 (edited) It compiles and seems to work according to the debug messagers, but the ,odels are not going up for some reason. I get night vision so I know the mods are switching. OOps i should go check with the animation mod removed, maybe its the armour addon index's that are broken. Edit: I should have done a fresh mod run. now it works perfectly Edited July 11, 2017 by stonefisher Link to comment Share on other sites More sharing options...
Recommended Posts