Jump to content

Stop options message/menu showing when exiting power armor.


Recommended Posts

Hi everyone, i have an outfit that has an options message/menu pop up every time it is equipped, which is great, but when i exit power armor the options message pops up (because i think the game is technically re-equipping the player armors etc when exiting power armor)

 

I have tried picking up various Events like "Event Actor.OnGetUp()", "Event OnExitFurniture()", but i cant get any of them working, it might have something to do with the way im trying to use "Bool InPipboy = True/False" rather than the events themselves, but im really unsure.

 

So i thought that the best way to do things would be to have the options message/menu only able to show when in the pipboy screen to avoid this and other unforseen events that will enevitably cause the player to re-equip armors etc.

 

This is what i have so far...

Scriptname SM_Equip extends ObjectReference


Message Property OptionsMESG Auto

ObjectMod Property Mod_1 Auto
ObjectMod Property Mod_2 Auto
ObjectMod Property Mod_3 Auto
ObjectMod Property Mod_4 Auto

Quest Property MQ101 Auto

Bool CurrentlyAttachingMod = False
Bool NewGameStarted = True
Bool InPipboy = False

;_____________________________________________________________________

Event OnInit()

		RegisterForMenuOpenCloseEvent("PipboyMenu") 


	If MQ101.GetStageDone(20)
		NewGameStarted = False
	Else
		RegisterForRemoteEvent(MQ101, "OnStageSet")
	EndIf
EndEvent

Event Quest.OnStageSet(Quest akQuest, Int auiStageID, Int auiItemID)
	If akQuest == MQ101 && auiStageID == 20
		NewGameStarted = False
		UnregisterForRemoteEvent(MQ101, "OnStageSet")
	EndIf
EndEvent

;____________________________________________________________________

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
    if (asMenuName== "PipboyMenu")
        if (abOpening)
	    InPipboy = True
        Else
	    InPipboy = False
   	endif
    EndIf
endEvent
;____________________________________________________________________


Event OnEquipped(Actor Owner)
	If !NewGameStarted ;Check if the mirror scene of the beginning is already done.
		If Owner == Game.GetPlayer() && !CurrentlyAttachingMod && InPipboy
			CurrentlyAttachingMod = True
			Int iButton = OptionsMESG.Show() ; Shows your menu.
			If iButton == 0  ; Open
				AttachMod(Mod_1)
				Debug.Notification("Mod 1 equipped")
			ElseIf iButton == 1  ; Closed
				AttachMod(Mod_2)
				Debug.Notification("Mod 2 equipped")
			ElseIf iButton == 2 ; Unzipped
				AttachMod(Mod_3)		
				Debug.Notification("Mod 3 equipped")
			ElseIf iButton == 3 ; Tied
				AttachMod(Mod_4)
				Debug.Notification("Mod 4 equipped")
			ElseIf iButton == 4 ; Cancel
				Debug.Notification("Style unchanged")
			EndIf
			CurrentlyAttachingMod = False

			RegisterForMenuOpenCloseEvent("PipboyMenu") 

		EndIf
	EndIf
EndEvent

But it doesnt do anything, infact it just breaks the whole script and no options message/menu shows up at all, it doesnt matter if the pipboy is open or not - nothing.

 

if i change -

If Owner == Game.GetPlayer() && !CurrentlyAttachingMod && InPipboy

to -

If Owner == Game.GetPlayer() && !CurrentlyAttachingMod && !InPipboy

Then the options message/menu will show up agin like normal, but it will still show the message/menu when exiting the power armor :(

 

Would anyone be kind enough to show me the error of my ways and point me in the right direction here?

Link to comment
Share on other sites

The code is ok, but the problem is that the outfit is actually being equipped after closing the Pipboy.

On the other hand, this gives me an idea to improve the script:

Scriptname SM_Equip extends ObjectReference Const

Message Property OptionsMESG Auto Mandatory Const

ObjectMod Property Mod_1 Auto Mandatory Const
ObjectMod Property Mod_2 Auto Mandatory Const
ObjectMod Property Mod_3 Auto Mandatory Const
ObjectMod Property Mod_4 Auto Mandatory Const

Int Property myTimerID = 33 Auto Const

Event OnInit()
	RegisterForMenuOpenCloseEvent("PipboyMenu")
EndEvent

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
	If asMenuName == "PipboyMenu"
		If abOpening
			RegisterForRemoteEvent(Game.GetPlayer(), "OnItemEquipped")
		Else
			StartTimer(1.0, myTimerID)
		EndIf
	EndIf
EndEvent

Event Actor.OnItemEquipped(Actor akActor, Form akBaseObject, ObjectReference akReference)
	If akReference == Self
		CancelTimer(myTimerID)
		UnregisterForRemoteEvent(akActor, "OnItemEquipped")
		Int iButton = OptionsMESG.Show() ; Shows your menu.
		If iButton == 0  ; Open
			AttachMod(Mod_1)
			Debug.Notification("Mod 1 equipped")
		ElseIf iButton == 1  ; Closed
			AttachMod(Mod_2)
			Debug.Notification("Mod 2 equipped")
		ElseIf iButton == 2 ; Unzipped
			AttachMod(Mod_3)		
			Debug.Notification("Mod 3 equipped")
		ElseIf iButton == 3 ; Tied
			AttachMod(Mod_4)
			Debug.Notification("Mod 4 equipped")
		ElseIf iButton == 4 ; Cancel
			Debug.Notification("Style unchanged")
		EndIf
	EndIf
EndEvent

Event OnTimer(Int aiTimerID)
	UnregisterForRemoteEvent(Game.GetPlayer(), "OnItemEquipped")
EndEvent

Edited by DieFeM
Link to comment
Share on other sites

Ahhh, that makes sense - outfits being actually equipped after closing the pipboy, no wonder my script didnt work haha :smile:

oh and really cool, i didnt know you could register for OnItemEquipped like that, but that also makes a boat load of sense :smile: thanks again DieFeM!!!

 

Unfortunately i cant make your new script work mate :/ no options message/menu pops up when equipping the outfit.

hahaha i guess it did effectively stop the message showing when exiting power armor though hahaha

Edited by SandMouseAnarchy
Link to comment
Share on other sites

So i couldnt see a problem with your script mate, but then it is a little over my head - i presume your script is saying that the options message can only show if the onitemequipped event happens - which is registered when entering the pipboy, in that way when exiting power armor there is no onitemequipped event happening, it seems logical, but hell if i know why its not showing the menu at all :/

 

So, because i had no idea what to edit on your script, i went back to my previous version, and in now knowing that outfits are actually equipped after leaving the pipboy i set this up -

;____________________________________________________________________

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
	 if (asMenuName== "PipboyMenu")
       	 if (abOpening)
			InPipboy = True
        	Else
			 InPipboy = True
				Utility.Wait (5)
	 		   InPipboy = False
   		endif
	EndIf
endEvent
;____________________________________________________________________

But still no luck. Infact it didnt show the message/menu until i changed the "!InPipboy" / "InPipboy" bit again, and then it did show the menu when equipping but it still showed the menu when exiting power armor.

im still racking my brain for other ways to stop the message showing when exiting the power armor...

Edited by SandMouseAnarchy
Link to comment
Share on other sites

I'm not sure when the OnInit fires, I've added a messagebox to the oninit event and it doesn't seems to trigger at any moment, so I decided to test it in a quest instead.

I don't have the suit mods, so I've tested with a Debug.MessageBox() instead, but it works fine, so there we go:

 

I've created a new quest (note that you must give an ID to the quest and click OK before adding a script), and added a new script named SM_VaultSuitScript.

Then I've created a new FormList, I named it SM_VaultSuitList, and added all the vault suits of the game to the list (I don't know if your mods are compatible with all vault suits, but I guess yes)

Then I've used a modified version of the script and it works just fine, so I guess this script should work for you:

Scriptname SM_VaultSuitScript extends Quest Const

Message Property OptionsMESG Auto Mandatory Const

FormList Property SM_VaultSuitList Auto Mandatory Const

ObjectMod Property Mod_1 Auto Mandatory Const
ObjectMod Property Mod_2 Auto Mandatory Const
ObjectMod Property Mod_3 Auto Mandatory Const
ObjectMod Property Mod_4 Auto Mandatory Const

Event OnQuestInit()
	RegisterForMenuOpenCloseEvent("PipboyMenu")
EndEvent

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
	If asMenuName == "PipboyMenu"
		Actor Player = Game.GetPlayer()
		If abOpening
			RegisterForRemoteEvent(Player, "OnItemEquipped")
		Else
			UnregisterForRemoteEvent(Player, "OnItemEquipped")
		EndIf
	EndIf
EndEvent

Event Actor.OnItemEquipped(Actor akActor, Form akBaseObject, ObjectReference akReference)
	If SM_VaultSuitList.Find(akBaseObject) >= 0
		UnregisterForRemoteEvent(akActor, "OnItemEquipped")
		Int iButton = OptionsMESG.Show() ; Shows your menu.
		If iButton == 0  ; Open
			akReference.AttachMod(Mod_1)
			Debug.Notification("Mod 1 equipped")
		ElseIf iButton == 1  ; Closed
			akReference.AttachMod(Mod_2)
			Debug.Notification("Mod 2 equipped")
		ElseIf iButton == 2 ; Unzipped
			akReference.AttachMod(Mod_3)		
			Debug.Notification("Mod 3 equipped")
		ElseIf iButton == 3 ; Tied
			akReference.AttachMod(Mod_4)
			Debug.Notification("Mod 4 equipped")
		ElseIf iButton == 4 ; Cancel
			Debug.Notification("Style unchanged")
		EndIf
		RegisterForRemoteEvent(akActor, "OnItemEquipped")
	EndIf
EndEvent

Note that this event is received as soon as you equip the vaultsuit in the pipboy (when the pipboy is still open) so I don't know if it could be an issue when it comes to attach mods on the vault suit.

Edited by DieFeM
Link to comment
Share on other sites

Hey again mate, damn that is one elegant solution! i like the idea of having a quest script and formlist instead of actually putting individual scripts inside the vanilla armor records :smile: i just tested the script and set up the quest ((i tried ticking "start game enabled" and unticked "run once"))((also, i didnt set any alias's, im not sure if that matters though ^.^))

 

So, the message/menu definately shows up now when equipping the outfit in the pipboy (but its double firing for some reason) and unfortunately the menu still pops up when exiting power armor, and im not really sure why...

 

Im thinking about adding back the "bool CurrentlyAttachingMod" sections from your earlier versions to see if that stops the double firing.

 

So, because this is getting pretty technical, ive made a Zip for you set up like a mod so you can play around with the same files im using if you would like :smile: ((everything edited can be found in CK with the search "_SM_" :smile:

 

 

Heres the file mate = http://www.filedropper.com/smvaultsui111Test

 

its still a bit rough around the edges, but its mainly a proof of concept with the vault suit just being the first outfit ive tried this on to test if its possible. :smile:

Edited by SandMouseAnarchy
Link to comment
Share on other sites

Well, I don't know if you removed the script from the vault suit before testing the script in the quest, or if you didn't loaded a "clean save" before testing it, but It seems to work fine for me, for the properties I've used an array of ObjectMod instead of 4 ObjectMod properties, but the script is almost the same, check it out.

I've also used xEdit to remove the record for the vanilla vault suit, so none of the records in your esp modifies vanilla records.

 

https://drive.google.com/file/d/19NJECNyHCuj9MXoi2enlWMFt1B_ky-xu/view

 

PS: It doesn't seem to change anything but I guess it's because the Object mods have no nif configured yet.

Link to comment
Share on other sites

Well, I have bad news for you... its not going to work with the quest script.

I checked the logs for papyrus and I found this:

 

error: Cannot call AttachMod() on a None object, aborting function call

 

 

This means that akReference doesn't store a reference. This happens because the vaultsuit is not persistant, from the wiki:

  • akReference: The reference that the actor just equipped - if the reference is persistant. Otherwise, None.

So we will need back to the previous method.

Edited by DieFeM
Link to comment
Share on other sites

Oh no, that's bad news, a quest script would have been beautiful, ah well I guess scripts on the outfits themselves is the way to go then, thankyou for checking your log :) I haven't checked my log, I'll start doing that from now on ;)

 

Ah totally embarrassed, no I didn't start a new game to test the scripts, well occasionally I'm starting new games to test other mods I'm working on (and use that save for other soft testing from then on) but I had thought that scripts were OK to edit without needing to start a new game, but I guess that isn't the case at all. I'll start new games from now on too :) I did remove the scripts from the outfits before testing the quest script though :)

 

I'm not sure what you mean about the object mods not having nifs configured yet though, because the object mods on the vault suit are just armor index modifiers with the nifs "closed/tied/unzipped" being in the vanilla armor record?

 

 

Ah man, DieFeM - thankyou very much mate! I definitely wouldn't have been able to get this far (any time soon atleast haha) without your help! When I release the mod, I'm going to write a thankyou credit for you so large it's going to be ridiculous! Haha

 

 

Back to business - I think I should re-check the last version you posted (non quest version) on a new game, because I'm not sure I started a new game to test that one, and you had tested it with messages instead of OMods, so maybe that one was a winner afterall. It does look like it should work(?)

Edited by SandMouseAnarchy
Link to comment
Share on other sites

There's no need to start a new game, but at least a game save where the mod that you are testing has not been loaded yet.

 

On the other hand I'm also trying some crazy things with the script, I let you know if I get it working properly.

 

Edit: I don't know anything about creating object mods nor outfits... I'm completely neglecting on this matter.

Edited by DieFeM
Link to comment
Share on other sites

  • Recently Browsing   0 members

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