Skip to content

Comments

Papyrus Refactor#71

Open
infernoplus wants to merge 6 commits intomainfrom
superPapyrusRefactor
Open

Papyrus Refactor#71
infernoplus wants to merge 6 commits intomainfrom
superPapyrusRefactor

Conversation

@infernoplus
Copy link
Owner

Reworking the Papyrus and Dialog compilation process to be staged out and separate from the MSB generation process. This allows me to create flags and variables in a preprocess stage which will make compiling cleaner and more consistent.

InfernoPlus added 5 commits February 10, 2026 19:15
…iables on a per reference/instance basis instead of per record. same goes for subscripts. many papyrus calls now respect target properly now as well including startscript. these fixes bring us much closer to parity with morrowind script execution.
…ild of the game world and played through some of the main quest. Everything seems to be working just fine!
private int nxtGenStateId;

public DialogESD(ESM esm, Layout layout, MainSoundBank sound, ScriptManager scriptManager, Paramanager paramanager, TextManager textManager, ItemManager itemManager, SpeffManager speffManager, Script areaScript, uint id, CharacterContent npcContent, List<NpcManager.TopicData> topicData)
public DialogESD(ESM esm, Layout layout, SoulsFormats.MSBE msb, MainSoundBank sound, ScriptManager scriptManager, Paramanager paramanager, TextManager textManager, ItemManager itemManager, SpeffManager speffManager, Script areaScript, uint id, CharacterContent npcContent, List<NpcManager.TopicData> topicData)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more constructor param, as a treat

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly it didn't have enough already

Copy link
Collaborator

@horfius horfius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main is getting more bloated from this. I really got to take a look at refactoring the structure of that file to break it up a little more. The sections are more clear at least, so it's really just sharing variables and scope that is the challenge.

retFlag = scriptManager.GetFlag(Script.Flag.Designation.Local, varName); // look for it, if we dont find it we create it
if (retFlag == null) { retFlag = scriptManager.common.CreateFlag(Script.Flag.Category.Saved, Script.Flag.Type.Short, Script.Flag.Designation.Local, varName); }
// Find refernce to object that matches the record id of this local var
string recordId = varName.Split(".")[0].Replace("\"", "").Trim();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should assign varName.Split(".") to a local var just to reduce duplication.

interiors = new();

Lort.Log("Generating layout...", Lort.Type.Main);
Lort.NewTask("Generating Layout", 14);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is 14 coming from?

/* Creatures */
foreach (CreatureContent creature in tile.creatures)
{
Override.EnemyRemap remap = Override.GetEnemyRemap(creature.id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to handle null?

MSBE.Part.Asset asset = MakePart.Asset(pickableInfo);
asset.Position = content.relative + Const.MSB_OFFSET;
asset.Rotation = content.rotation;
asset.Scale = new Vector3(content.scale * 0.01f);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should make the 0.01f a named constant.

retFlag = scriptManager.GetFlag(Script.Flag.Designation.Local, varName); // look for it, if we dont find it we create it
if (retFlag == null) { retFlag = scriptManager.common.CreateFlag(Script.Flag.Category.Saved, Script.Flag.Type.Short, Script.Flag.Designation.Local, varName); }
// Find refernce to object that matches the record id of this local var
string recordId = varName.Split(".")[0].Replace("\"", "").Trim();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should move varName.Split to a local var to reduce duplication.


public static void InitializeLocalVariables(ESM esm, ScriptManager scriptManager, BaseScript script, Papyrus papyrus, Content content)
{
void DoStuff(Papyrus p)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit pointless to make this internal function and then have it be the only thing that's called.


pc = 0;

string[] spawnHandlerWithDisableRaw = new string[]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be done like this instead, but I don't know how ParseAddArg handles multiline string.

$"""
SkipIfEventFlag(...)
ChangeCharacterEnableState(...)
...
"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants