CommonLibSSE icon indicating copy to clipboard operation
CommonLibSSE copied to clipboard

How to call papyrus methods/functions inside c++ plugin?

Open ZikkeyLS opened this issue 2 years ago • 3 comments

I have really limited knowledge about the papyrus VM. My problem is that I don't know how to properly call any papyrus functions or methods (like placeatme).

I tried to execute the DispatchMethodCall, but it just doesn't work in the game. (all arguments are fully filled in) return vm.DispatchMethodCall2((*self)->handle, className, functionName, args, functor);

Can you give an example of how to use any of the papyrus methods through a virtual machine? For example, PlaceAtMe. (I am using latest CommonLibSSE version)

ZikkeyLS avatar Jul 05 '22 15:07 ZikkeyLS

Invoking papyrus methods is very tedious and error prone due to the asynchronous nature of the VM. If you want to invoke a method exposed in a native game script, then I would recommend you disassemble the function in IDA and re-implement the logic by hand. It will be much faster and easier this way.

Ryan-rsm-McKenzie avatar Jul 05 '22 15:07 Ryan-rsm-McKenzie

Any tutorials you would recommend on disassembly and re-implementation? I'm new to SKSE dev but have experience with Papyrus. Seeing how the papyrus functions work would help me learn a lot

JHansen13 avatar Jan 05 '23 23:01 JHansen13

@JHansen13 I can only recommend you to watch source code of SKYMP. (skyrim multiplayer)

ZikkeyLS avatar Jan 08 '23 09:01 ZikkeyLS