skyrim-multiplayer / skymp

Multiplayer Mod & TypeScript SDK for Skyrim Special Edition
Other
217 stars 75 forks source link

Add ESPM API to SkyrimPlatform #326

Closed CarlosLeyvaAyala closed 2 years ago

CarlosLeyvaAyala commented 2 years ago

I want to make a petition for Skyrim Platform to expose more information from Skyrim objects and classes.

Context

As a mod author, there are three things that have made me consider learning how to do SKSE dlls:

  1. Papyrus slow speed.
  2. Papyrus language limitations.
  3. SKSE itself carrying WAY more information than it actually makes available to Papyrus users.

Issues 1 and 2 were already solved by your hard and awesome work, but issue 3 still persists.

For example, after delving into the source code of PapyrusUtil, MiscUtil, lines 91-93, I noticed they got the EditorID for an Actor Race by getting that value directly from data that SKSE already knows... data none of the *.psc files that come with it make available to us.

Since Skyrim Platform translates to Typescript only the functions that were exposed by the *.psc files that come with SKSE, we modders are still limited on what information we can work with.

Benefits

I believe making all that information available to Skyrim Platform programmers will completely close the gap between C++ and SP plugins.

For outsiders the SkyMP team (like me), and people who find the prospect of doing C++ dlls daunting (like me), right now SP is just "a way better and way faster Papyrus". \ But we all know it's MUCH more that; it's a real game changer that has the potential to completely transform the Skyrim modding scene forever.

Giving us modders more information to work with will get us all closer to that day way faster.

Possible downsides

I'm aware giving us total freedom to change whatever we want has the potential to introduce new and really hard to track bugs. It's no coincidence only people that actually know what they're doing are the only ones making C++ dlls.

Still, just giving us read only access to all this information would make totally feasible mods that weren't possible before.

Possible ways to expose them

I think one of the easiest ways for us to use it could be by adding functions to existing class declarations. For example, using the EditorId example, we could have something like this:

export declare class Race extends Form{
    ...
    getEditorId(): string;
}

It was brought to my attention that it's possible to load values directly from the esp. I think it would be still useful to extend the class declarations themselves, so we can get that information from the esp or whatever place that info is.

  const race = Race.From(GetFromFromFile("file", formId))
  const race2 = Race.From(GetFormFromEsp("file", formId))   // SP's own esp parser

  // Either way, we got the same value
  printConsole(race.getEditorid())
  printConsole(race2.getEditorid())
Pospelove commented 2 years ago

no activity, closing for now