Jump to content

[Script] I can't move or see any material requirements for constructable objects around if added via AddForm()


Magicockerel

Recommended Posts

I've been working on recreating and expanding upon an existing mod of mine using scripts. This involves adding turret NPCs to formlists (and subsequently to the workshop menu) via the AddForm() function, which seems to work fine. The formlists are linked to a constructable object, where the appropriate material requirements have been set up. The issue is that in-game the material requirements aren't shown unless the player doesn't meet the material requirements, and I'm unable to pick up or interact the turrets once they've been constructed.

Doing some Googling has revealed that there was a vanilla bug with the generators (and potentially other constructable objects) in the past where the same thing happened, but I can't find what the fix was. A solution would be greatly appreciated.

If you're looking at the functionality of the mod itself, it's intended to recreate what the existing mod accomplishes with several different versions and a FOMOD installer. The final version will include a holotape that allows the global variables to be configured, but I haven't gotten that far yet. I wanted to deal with this issue first. I'll also be changing the existing features as it appears that Bethesda have removed the random element themselves, which pretty much leaves me playing with the requirements (as they've messed with them as well) and showing all available turrets.

Here's a dropbox link to the full mod, including the source, so that you can view this through the CK. All mod-specific forms have the prefix "NMRTM".

Alternatively, here's a text dump of the source:

 

Scriptname NMRTM_QUST_Primary_Script extends Quest

;=====================================================
;									EVENTS
;=====================================================

Event OnInit()
	Debug.Notification("Hello world!")
	
	Self.RegisterForRemoteEvent(PlayerRef, "OnPlayerLoadGame")
	Self.RegisterForRemoteEvent(PlayerRef, "OnLocationChange")
	
	Maintenance()
	AddTurretsToWorkshopMenu()
EndEvent

Event Actor.OnPlayerLoadGame(Actor akSender)
	Debug.Notification("The game has been loaded.")
	
	Maintenance()
	AddTurretsToWorkshopMenu()
EndEvent

Event Actor.OnLocationChange(Actor akSender, Location akOldLoc, Location akNewLoc)
	If (akSender == PlayerRef)
		Debug.Notification("The player has changed location.")
		
		AddTurretsToWorkshopMenu()
	EndIf
EndEvent

;=======================================================================================
;																FUNCTIONS
;=======================================================================================

Function AddTurretsToWorkshopMenu()
	Int EncounterZoneCheck = NMRTM_GLOB_EncounterZoneCheck.GetValue() As Int
	Int LevelRequirementCheck = NMRTM_GLOB_LevelRequirementCheck.GetValue() As Int
	
	Int TurretLevel
	
	Int EncounterZoneLevel = PlayerRef.CalculateEncounterLevel()
	Int PlayerLevel = PlayerRef.GetLevel()
	
	If (EncounterZoneCheck == 0 && LevelRequirementCheck == 0)
		TurretLevel = -1
	ElseIf (EncounterZoneCheck == 1 && LevelRequirementCheck == 0)
		TurretLevel = EncounterZoneLevel
	ElseIf (EncounterZoneCheck == 1 && LevelRequirementCheck == 1)
		TurretLevel = EncounterZoneLevel
	ElseIf (EncounterZoneCheck == 0 && LevelRequirementCheck == 1)
		TurretLevel = PlayerLevel
	Else
		Debug.MessageBox("An error has occurred while determining the turrets level.")
	EndIf
	
	Int TurretDisplayMode = NMRTM_GLOB_TurretDisplayMode.GetValue() As Int
	
	;NMRTM_FLST_TurretTripodList.Revert()
	;NMRTM_FLST_TurretTripodMountedList.Revert()
	
	If (TurretDisplayMode == 1) ; Display only the highest mark turret available
		If (TurretLevel < 16)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkI)
			
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkI)
		ElseIf (TurretLevel >= 16 && TurretLevel < 28)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkIII)
			
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkIII)
		ElseIf (TurretLevel >= 28 && TurretLevel < 40)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkV)
			
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkV)
		ElseIf (TurretLevel >= 40 || TurretLevel < 0)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkVII)
			
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkVII)
		Else
			Debug.MessageBox("An error has occurred while adding turrets to the workshop menu.")
		EndIf
	ElseIf (TurretDisplayMode == 2) ; Display all available mark turrets
		If (TurretLevel < 16)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkI)
			
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkI)
		ElseIf (TurretLevel >= 16 && TurretLevel < 28)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkI)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkIII)
			
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkI)
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkIII)
		ElseIf (TurretLevel >= 28 && TurretLevel < 40)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkI)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkIII)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkV)
			
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkI)
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkIII)
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkV)
		ElseIf (TurretLevel >= 40 || TurretLevel < 0)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkI)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkIII)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkV)
			NMRTM_FLST_TurretTripodList.AddForm(NMRTM_NPC_TurretTripodMkVII)
			
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkI)
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkIII)
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkV)
			NMRTM_FLST_TurretTripodMountedList.AddForm(NMRTM_NPC_TurretTripodMountedMkVII)
		Else
			Debug.MessageBox("An error has occurred while adding turrets to the workshop menu.")
		EndIf
	Else
		Debug.MessageBox("An error has occurred while ascertaining the turret display mode.")
	EndIf
	
	;Debug.MessageBox("Level Summary: \n TurretLevel = " + TurretLevel + "\n EncounterZoneLevel = " + EncounterZoneLevel + "\n PlayerLevel = " + PlayerLevel)
EndFunction

Function Maintenance()
	If (Game.IsPluginInstalled("NoMoreRandomTurretMks.esp") == true || Game.IsPluginInstalled("NoMoreRandomTurretMksAIO.esp") == true)
		Debug.MessageBox("You currently have version 2.3.0 or earlier installed. \n Please uninstall this earlier version before continuing your game. \n The game is now closing to desktop.")
		Debug.QuitGame()
	EndIf
	
	
EndFunction

;=============================================
;								PROPERTIES
;=============================================

Actor Property PlayerRef Auto Const

ActorBase Property NMRTM_NPC_TurretTripodMkI Auto Const
ActorBase Property NMRTM_NPC_TurretTripodMkIII Auto Const
ActorBase Property NMRTM_NPC_TurretTripodMkV Auto Const
ActorBase Property NMRTM_NPC_TurretTripodMkVII Auto Const

ActorBase Property NMRTM_NPC_TurretTripodMountedMkI Auto Const
ActorBase Property NMRTM_NPC_TurretTripodMountedMkIII Auto Const
ActorBase Property NMRTM_NPC_TurretTripodMountedMkV Auto Const
ActorBase Property NMRTM_NPC_TurretTripodMountedMkVII Auto Const

GlobalVariable Property NMRTM_GLOB_EncounterZoneCheck Auto Const
GlobalVariable Property NMRTM_GLOB_LevelRequirementCheck Auto Const
GlobalVariable Property NMRTM_GLOB_TurretDisplayMode Auto Const

FormList Property NMRTM_FLST_TurretTripodList Auto Const
FormList Property NMRTM_FLST_TurretTripodMountedList Auto Const

Quest Property NMRTM_QUST_Primary Auto Const

 



Of course, any help is appreciated :happy:

Edit: The title was intended to be "[script] I can't move or see any material requirements for constructable objects if they're added via AddForm()", pretty sure I can't change it now. Please let me know if I can.

 

Edit 2: I changed the code format to something not awful.

Edited by KernalsEgg
Link to comment
Share on other sites

  • Recently Browsing   0 members

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