SHARE
TWEET

base_armor.dll

raufdnugroho Aug 12th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "skse/PluginAPI.h"
  2. #include "skse/skse_version.h"
  3. #include "skse/ScaleformCallbacks.h"
  4. #include "skse/ScaleformMovie.h"
  5. #include "skse/ScaleformExtendedData.h"
  6. #include "skse/GameRTTI.h"
  7. #include "skse/GameReferences.h"
  8. #include "skse/GameObjects.h"
  9. #include "skse/GlobalLocks.h"
  10. #include <shlobj.h>
  11.  
  12.  
  13. IDebugLog gLog;
  14.  
  15. PluginHandle    g_pluginHandle = kPluginHandle_Invalid;
  16.  
  17. SKSEScaleformInterface      * g_scaleform = NULL;
  18.  
  19. /**** scaleform functions ****/
  20.  
  21. class SKSEScaleform_RequestBaseArmorRating : public GFxFunctionHandler
  22. {
  23. public:
  24.     virtual void    Invoke(Args * args)
  25.     {
  26.         if (!g_loadGameLock.TryEnter())
  27.             return;
  28.  
  29.         UInt32  formidArg = 0;
  30.         TESForm * formArg = NULL;
  31.  
  32.         if (args->numArgs >= 1) {
  33.             formidArg = (UInt32)args->args[0].GetNumber();
  34.             if (formidArg > 0)
  35.                 formArg = LookupFormByID(formidArg);
  36.         }
  37.  
  38.         args->result->SetNull();
  39.  
  40.         if ((args->result != NULL) && formArg) {
  41.             TESObjectARMO * pArmor = DYNAMIC_CAST(formArg, TESForm, TESObjectARMO);
  42.             if (pArmor){
  43.                 args->result->SetNumber(pArmor->armorValTimes100 / 100);
  44.             }
  45.         }
  46.  
  47.         g_loadGameLock.Leave();
  48.  
  49.     }
  50. };
  51.  
  52. bool RegisterScaleform(GFxMovieView * view, GFxValue * root)
  53. {
  54.     RegisterFunction <SKSEScaleform_RequestBaseArmorRating>(root, view, "RequestBaseArmorRating");
  55.  
  56.     return true;
  57. }
  58.  
  59. extern "C"
  60. {
  61.  
  62. bool SKSEPlugin_Query(const SKSEInterface * skse, PluginInfo * info)
  63. {
  64.     gLog.OpenRelative(CSIDL_MYDOCUMENTS, "\\My Games\\Skyrim\\SKSE\\base_armor_plugin.log");
  65.  
  66.     // populate info structure
  67.     info->infoVersion = PluginInfo::kInfoVersion;
  68.     info->name =        "base armor plugin";
  69.     info->version =     1;
  70.  
  71.     // store plugin handle so we can identify ourselves later
  72.     g_pluginHandle = skse->GetPluginHandle();
  73.  
  74.     if(skse->isEditor)
  75.     {
  76.         _MESSAGE("loaded in editor, marking as incompatible");
  77.  
  78.         return false;
  79.     }
  80.     else if(skse->runtimeVersion != RUNTIME_VERSION_1_9_32_0)
  81.     {
  82.         _MESSAGE("unsupported runtime version %08X", skse->runtimeVersion);
  83.  
  84.         return false;
  85.     }
  86.  
  87.     // get the scaleform interface and query its version
  88.     g_scaleform = (SKSEScaleformInterface *)skse->QueryInterface(kInterface_Scaleform);
  89.     if(!g_scaleform)
  90.     {
  91.         _MESSAGE("couldn't get scaleform interface");
  92.  
  93.         return false;
  94.     }
  95.  
  96.     if(g_scaleform->interfaceVersion < SKSEScaleformInterface::kInterfaceVersion)
  97.     {
  98.         _MESSAGE("scaleform interface too old (%d expected %d)", g_scaleform->interfaceVersion, SKSEScaleformInterface::kInterfaceVersion);
  99.  
  100.         return false;
  101.     }
  102.  
  103.     // ### do not do anything else in this callback
  104.     // ### only fill out PluginInfo and return true/false
  105.  
  106.     // supported runtime version
  107.     return true;
  108. }
  109.  
  110. bool SKSEPlugin_Load(const SKSEInterface * skse)
  111. {
  112.     _MESSAGE("load");
  113.  
  114.     // register scaleform callbacks
  115.     g_scaleform->Register("base_armor", RegisterScaleform);
  116.  
  117.     return true;
  118. }
  119.  
  120. };
RAW Paste Data
Top