Ryan-rsm-McKenzie / CommonLibSSE

A reverse engineered library for hacking Skyrim Special Edition
MIT License
202 stars 152 forks source link

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

Open ZikkeyLS opened 2 years ago

ZikkeyLS commented 2 years ago

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)

Ryan-rsm-McKenzie commented 2 years ago

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.

JHansen13 commented 1 year ago

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

ZikkeyLS commented 1 year ago

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