KicklerOfButts Posted 19 hours ago Posted 19 hours ago TLDR: I need a script that hooks into any time the engine calls the OnObjectEquipped event so I can call a function when it does, but I'm not really a programmer so I don't know how. Best I've managed was a papyrus script that still required the script to be connected to the actor either directly or through a ReferenceAlias, and I need it to be able to fire without having to attach a copy of the script to every actor in the game. It's my understanding that SKSE allows for engine independent scripts to run?
traison Posted 19 hours ago Posted 19 hours ago 10 minutes ago, KicklerOfButts said: I need a script that hooks into any time the engine calls the OnObjectEquipped event so I can call a function when it does, but I'm not really a programmer so I don't know how. I don't see why the game engine would send out OnObjectEquipped events to object references that have no Papyrus script attached to them. It may not even be sending them to scripts that aren't specifically listening for this event. I would look for some other more generic hook point to do this. 12 minutes ago, KicklerOfButts said: It's my understanding that SKSE allows for engine independent scripts to run? CommonLibSSE would be better for that. With any luck it migth already contain something you can hook into, or contain a pointer that's conveniently nearby.
KicklerOfButts Posted 18 hours ago Author Posted 18 hours ago (edited) 20 minutes ago, traison said: I don't see why the game engine would send out OnObjectEquipped events to object references that have no Papyrus script attached to them. It may not even be sending them to scripts that aren't specifically listening for this event. I would look for some other more generic hook point to do this. It was my understanding that whenever a character equips an item, that is an OnObjectEquipped event getting fired but only scripts registered to receive it will receive it. I was hoping to be able to read the event without going through a papyrus script, since that requires attaching a script to every actor that I want to "monitor" and papyrus is a performance bottleneck, but it sounds like there's no event getting fired at all unless a script registers to call for it? 20 minutes ago, traison said: CommonLibSSE would be better for that. With any luck it migth already contain something you can hook into, or contain a pointer that's conveniently nearby. I'll have to look into it EDIT: Quote CommonLib is incompatible with SKSE Welp rip that idea Edited 18 hours ago by KicklerOfButts
traison Posted 18 hours ago Posted 18 hours ago (edited) 10 minutes ago, KicklerOfButts said: ...but it sounds like there's no event getting fired at all unless a script registers to call for it? At this point I would assume that this is a posibility. In a game with hundereds of actors, most of which aren't even in the currently active game world, I wouldn't send out events unless I had to - I'd cull out the unloaded actors and those that do not need the event at all. Did Bethesda think like me? Maybe. Edit: This is easy to test, no? Attach a script that listens for OnObjectEquipped to someone in Solitude using a spell. Have that spell change their equipment in OnUpdate and trigger that OnUpdate when you yourself are in Whiterun. If OnObjectEquipped gets called, you probably could tap into it from a dll and get the results you want. Edited 18 hours ago by traison
KicklerOfButts Posted 18 hours ago Author Posted 18 hours ago (edited) 49 minutes ago, traison said: If OnObjectEquipped gets called, you probably could tap into it from a dll and get the results you want. How would one script a dll to do that? I have no experience with dll scripting, what language is it in and is there an API? I should be able to test it directly with the dll by the sounds of it, I don't have papyrus scripting set up so I'd rather avoid dipping into it if possible. EDIT: So I'm shopping around for DLL compilers and everyone and their mother is saying you need specifically Visual Studio 2022 but that version requires an ongoing subscription to Visual Studio. Any alternatives? I ain't paying microslop money just so I can mod skyrim. Edited 17 hours ago by KicklerOfButts
traison Posted 17 hours ago Posted 17 hours ago (edited) 1 hour ago, KicklerOfButts said: How would one script a dll to do that? Script languages are not compiled, programming languages are compiled. You program and compile a dll. 1 hour ago, KicklerOfButts said: ...what language is it in and is there an API? Any programming language that compiles down to pure machine code. C++ is the safe bet. The "API" is created by you, unless someone has already done it for you and packed it into SKSE/CommonLibSSE. 1 hour ago, KicklerOfButts said: I'm shopping around for DLL compilers and everyone and their mother is saying you need specifically Visual Studio 2022... VS 2026 now, but either works. Most of the existing dlls are most likely written for the toolchain in VS 2022 so that's the minimum; v140 or v142, I forget. 1 hour ago, KicklerOfButts said: ...but that version requires an ongoing subscription to Visual Studio. No it doesn't. It's called community edition. 1 hour ago, KicklerOfButts said: Any alternatives? MinGW, gcc (maybe), vscode (using the c++ compiling plugin which is most likely the same thing that's in vs), ... 1 hour ago, KicklerOfButts said: I should be able to test it directly with the dll by the sounds of it, I don't have papyrus scripting set up so I'd rather avoid dipping into it if possible. If Papyrus scripting is a problem, you're looking at years of work to get into making a dll. Lets say the function you're looking to tap into is not already discovered and made ready for hooking by something like CommonLibSSE, then you'll have to find it yourself in a debugger. I personally use x64dbg, and the disassembler I probably can't name here. Edit: For perspective, Papyrus is a bit like python or javascript, i.e. the most simplest of languages. Assembly, which is what you'd see in a debugger or disassembler, is (excluding the meme languages) the most difficult it will ever get. Edited 16 hours ago by traison
traison Posted 16 hours ago Posted 16 hours ago Had a poke around in CBPC's source code as I recalled it had an event handler to catch TESEquipEvent events so that it can alter physics when armor is worn. This is probably what you're looking for. It's in scan.cpp around line 996. Note that my code here is modified so the line number is probably not exact. It does a check for an actor field called loadedState a few lines later kind of suggesting these events are sent out to everyone: loaded and unloaded. While this is built on SKSE, and TESEquipEvent is a concept of SKSE (based on the vanilla game no doubt) I imagine CommonLibSSE is going to have something similar.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now