Advertisement
Putnam

itemsyndrome hook writing attempt

Sep 2nd, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. //I HAVE NO IDEA WHAT I'M DOING.
  2.  
  3. #include "Core.h"
  4. #include "Console.h"
  5. #include "Export.h"
  6. #include "PluginManager.h"
  7. #include "modules/Items.h"
  8. #include <VTableInterpose.h>
  9. #include "df/general_ref.h" //no idea if this is right
  10.  
  11. using namespace DFHack;
  12. using namespace df::enums;
  13.  
  14. using df::global::world;
  15.  
  16. static command_result tweak(color_ostream &out, vector <string> & parameters);
  17.  
  18. DFHACK_PLUGIN("itemsyndrome_hooks");
  19.  
  20. DEFINE_LUA_EVENT_1(onItemEquipped,unitID)
  21.  
  22. DFHACK_PLUGIN_LUA_EVENTS {
  23.     DFHACK_LUA_EVENT(itemEquipped),
  24.     DFHACK_LUA_END
  25. };
  26.  
  27. struct itemsyndrome_hook : df::general_ref_unit_holderst{
  28.     typedef df::general_ref_unit_holderst interpose_base;
  29.     DEFINE_VMETHOD_INTERPOSE(void,getUnit,(int16_t unitID)) //no idea if this argument thing will work at all, no idea where the plugins get them :X Sometimes I just can't find things...
  30.     {
  31.         CoreSuspendClaimer suspend;
  32.         color_ostream_proxy out(Core::getInstance().getConsole());
  33.         bool call_native=true;
  34.         onItemEquipped(out,this,unitID);
  35.         if(call_native)
  36.             INTERPOSE_NEXT(itemEquipped)(unitID);
  37.         itemEquipped(out,this);
  38.     }
  39. };
  40. IMPLEMENT_VMETHOD_INTERPOSE(itemsyndrome_hook, getUnit);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement