Jump to content

Script help needed


Recommended Posts

19 minutes ago, aurreth said:

I saw a mod maybe a week ago (?) that starts a brand new game as NG+ level one.  Maybe not so much a mod as several bat files and instructions on how to use them.  That might help you.

Sounds like that mod just starts a alternate unity quest, rather then reducing the players current level.

Link to comment
Share on other sites

I only looked at the native CreateStarbornGame() once but for me it seemed like this function actually creates an almost enterly new game for NG+ instead of "resetting" it. A very few ActorValues (held in a FormList but I don't remember its name) and the player's base attributes are copied over. There's an antient native command "ResetWorld" that's supposed to reset a save game but it's broken. On each new NG+ playthrough an ActorValue is incremented for quests, dialogues conditions, some random events and such. CreateStarbornGame() is only called somewhere in the last main quest (maybe MQ302 Stage 1000?) so one can set this quest stage to create NG+ saves at any level.

Edited by LarannKiar
Link to comment
Share on other sites

Quote

it seemed like this function actually creates an almost enterly new game for NG+ instead of "resetting" it.

That's exactly what it does.  It carries over player appearance, perks, and a few actor values, and wipes the rest to start over.

Quote

CreateStarbornGame() is only called somewhere in the last main quest (maybe MQ302 Stage 1000?) so one can set this quest stage to create NG+ saves at any level.

I think it's 2000.  setstage 0024EF9C 2000 triggers an immediate jump through Unity, playing the animation, credits, and starting a new game.  I also have in my notes that setstage 0024EF9C 1 will quickstart a new game from level 1, but I haven't tried that.

Link to comment
Share on other sites

On 2/5/2024 at 5:57 AM, senterpat said:

SFSE dependency is not an issue for me at all. Most of my mods end up requiring them anyways, and all mods require them right now 😛 If you could make such an event that would be neato bandito and make my life easier for sure.

I didn't have too much time to mess with it yesterday. But I'm off work today and have some time to test around with it.

 

AttachPapyrusScript does work in Starfield, I had to use it for another mod already using bat commands.

 

edit:

This is unrelated, but you may know better than most. Is there any way to reset the players level to 1? If possible it seems it would require script extension, as all my research and attempts seem to point to it being impossible.

All right, if you're still interested, I made a simplified version of PapyrusCallbacks. The bigger version I use contains many unrelated / undecoded structs so I just left OnWorkshopObjectPlacedEx and OnSaveLoadEvent in the plugin.

It works like this:

   - ..\Data\SFSE\Plugins\PapyrusCallbacks\ folder may contain an INI file matching your mod's name, i.e., MyMod.esm then MyMod.ini.

   - default INI contains this:

[Papyrus]
sScriptName=testScript
[Callbacks]
bOnWorkshopObjectPlaced=1
bOnSaveLoadEvent=1

   - if you don't want to receive a callback, set its INI setting to 0 or just remove the line. INI settings are loaded to the memory ("reevaluated") every time a save game is loaded.

   - replace "testScript" with the name of your script.

   - default testScript contains this:

Function OnSaveLoadEvent() Global
	Debug.MessageBox("OnSaveLoadEvent : testScript")
EndFunction

Function OnWorkshopObjectPlacedEx(ObjectReference itemRef, ObjectReference workshopRef) Global
	Debug.MessageBox("OnWorkshopObjectPlacedEx : testScript: itemRef = " + Utility.IntToHex(itemRef.GetFormID()) + " workshopRef = " + Utility.IntToHex(workshopRef.GetFormID()))
EndFunction

   - callback function names can't be changed but the parameters' can.

   - the script that receives the callbacks doesn't need to be registered, the SFSE plugins calls the global functions when it receives the events from the game code as long as their INI settings are set.

Edited by LarannKiar
Link to comment
Share on other sites

Awesome I'll test this as soon as I get a chance, your the man 😄

 

Also thanks for the step by step instructions, you made my life much easier 😄

 

edit: Got it working like a charm, took me a minute because I didn't realize Starfield and SKSE had been updated last week.

One question tho, without registering the script, how can I tell the script which alias to fill?

 

Edited by senterpat
Link to comment
Share on other sites

You can use GetFormFromFile to get the quest and its alias into the Global function. I haven't tried to compile it but it should work:

Scriptname testScript



Function OnWorkshopObjectPlacedEx(ObjectReference itemRef, ObjectReference workshopRef) Global
	Debug.Notification("OnWorkshopObjectPlacedEx : testScript: itemRef = " + Utility.IntToHex(itemRef.GetFormID()) + " workshopRef = " + Utility.IntToHex(workshopRef.GetFormID()))

	ReferenceAlias targetAlias = Utility.CallGlobalFunction("testScript", "GetTargetAlias", None) as ReferenceAlias        ; replace testScript with your script's name

	If !targetAlias
		Debug.MessageBox("Error: targetAlias couldn't be found. Either the mod that contains the quest is not installed and/or wrong FormID/AliasID was specified for the Quest/Alias.")
		Return None
	EndIf

	targetAlias.ForceRefTo(itemRef)

EndFunction

ReferenceAlias Function GetTargetAlias()
	Return (Game.GetFormFromFile(0x123456, "YourModName.esm") as Quest).GetAlias(999) as ReferenceAlias		; replace 0x123456 with the FormID of the quest that holds the alias and 999 with the AliasID, and YourModName.esm with your mod's name
EndFunction

 

Edited by LarannKiar
Link to comment
Share on other sites

😕 I have been trying to get this to work for the past couple of days, convinced I just don't know how to use quest aliases, so I was trying to figure out what combination of tags I needed to get it to work, but after adding a debug message to GetTargetAliasFunction(), I'm not sure it's a quest alias issue as the message doesn't pop up before the error message, although I know next to nothing about creating custom events and functions, so it could just be that I'm a fool 😛 

I've double and triple-checked all the instructions you placed are followed correctly, I can send you the mod with folder structure if you think that's where the issue may lie

Edited by senterpat
Link to comment
Share on other sites

  • 1 month later...

Did you register the event on the current Workshop (Outpost) object? Also OnWorkshopObjectPlaced takes one ObjRef argument, not two.

Fallout 4 reference
"OnWorkshopObjectPlaced(ObjectReference akReference)"
OnWorkshopObjectPlaced - ObjectReference - the Fallout4 CreationKit Wiki (uesp.net)

From decompiled SF script
"Event OnWorkshopObjectPlaced(ObjectReference akReference)"

Link to comment
Share on other sites

  • Recently Browsing   0 members

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