Advertisement
expired6978

SKSE Submission

May 5th, 2012
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.55 KB | None | 0 0
  1. /*
  2. ******************************************************************
  3.             PapyrusActor.cpp (Slice - namespace)
  4. ******************************************************************
  5. */
  6.  
  7.  
  8.     // PLB:     Set 'bUseFaceGenPreprocessedHeads:General' to 0
  9.     //      before calling this to ensure it regenerates the head,
  10.     //      this can be done in script. For some reason it
  11.     //      completely disregarded the fact I set the INI at all
  12.     //      when using it here directly, alternatively it might be
  13.     //      a desired result to have only the body update without
  14.     //      completely regenerating the head. I believe increasing
  15.     //      weight would cause the head to not match the body
  16.     //      and 'gaps' may occur, so only decreasing would be
  17.     //      recommended. If the face is regenerated all actors
  18.     //      except for the player will lose their face tint.
  19.     //
  20.     void QueueNiNodeUpdate(Actor* thisActor)
  21.     {
  22.         Character * pChar = DYNAMIC_CAST(thisActor, Actor, Character);
  23.         if(pChar) {
  24.             CALL_MEMBER_FN(pChar, QueueNiNodeUpdate)(true);
  25.         }
  26.     }
  27.  
  28. /*
  29. ******************************************************************
  30.             PapyrusActor.cpp (Slice - RegisterFunctions)
  31. ******************************************************************
  32. */
  33.  
  34.     registry->RegisterFunction(
  35.         new NativeFunction0 <Actor, void>("QueueNiNodeUpdate", "Actor", papyrusActor::QueueNiNodeUpdate, registry));
  36.  
  37.  
  38.  
  39. /*
  40. ******************************************************************
  41.             PapyrusUtility.cpp (Full File)
  42. ******************************************************************
  43. */
  44.  
  45. #include "PapyrusUtility.h"
  46.  
  47. #include "GameForms.h"
  48. #include "GameObjects.h"
  49. #include "GameReferences.h"
  50. #include "GameExtraData.h"
  51. #include "GameRTTI.h"
  52. #include "GameSettings.h"
  53.  
  54. #include "PapyrusVM.h"
  55. #include "PapyrusNativeFunctions.h"
  56.  
  57. namespace papyrusUtility
  58. {
  59.     // This was taken from Hooks_Scaleform.cpp, maybe move this to somewhere it can be mutually defined
  60.     static Setting * GetINISetting(const char * name)
  61.     {
  62.         Setting * setting = (*g_iniSettingCollection)->Get(name);
  63.         if(!setting)
  64.             setting = (*g_iniPrefSettingCollection)->Get(name);
  65.  
  66.         return setting;
  67.     }
  68.  
  69.     float GetINIFloat(StaticFunctionTag* base, BSFixedString ini)
  70.     {
  71.         Setting * setting = GetINISetting(ini.data);
  72.         if(!setting || setting->GetType() != Setting::kType_Float)
  73.             return 0.0;
  74.  
  75.         return setting->data.f32;
  76.     }
  77.  
  78.     UInt32 GetINIInt(StaticFunctionTag* base, BSFixedString ini)
  79.     {
  80.         Setting * setting = GetINISetting(ini.data);
  81.         if(!setting || setting->GetType() != Setting::kType_Integer)
  82.             return 0;
  83.  
  84.         return setting->data.s32;
  85.     }
  86.  
  87.     bool GetINIBool(StaticFunctionTag* base, BSFixedString ini)
  88.     {
  89.         Setting * setting = GetINISetting(ini.data);
  90.         if(!setting || setting->GetType() != Setting::kType_Bool)
  91.             return false;
  92.  
  93.         return setting->data.u8 >= 1 ? true : false;
  94.     }
  95.  
  96.     BSFixedString GetINIString(StaticFunctionTag* base, BSFixedString ini)
  97.     {
  98.         Setting * setting = GetINISetting(ini.data);
  99.         if(!setting || setting->GetType() != Setting::kType_String)
  100.             return NULL;
  101.  
  102.         return setting->data.s;
  103.     }
  104. }
  105.  
  106. void papyrusUtility::RegisterFuncs(VMClassRegistry* registry)
  107. {
  108.     // PLB: Not really sure why these weren't in vanilla...
  109.     registry->RegisterFunction(
  110.         new NativeFunction1 <StaticFunctionTag, float, BSFixedString>("GetINIFloat", "Utility", papyrusUtility::GetINIFloat, registry));
  111.  
  112.     registry->RegisterFunction(
  113.         new NativeFunction1 <StaticFunctionTag, UInt32, BSFixedString>("GetINIInt", "Utility", papyrusUtility::GetINIInt, registry));
  114.  
  115.     registry->RegisterFunction(
  116.         new NativeFunction1 <StaticFunctionTag, bool, BSFixedString>("GetINIBool", "Utility", papyrusUtility::GetINIBool, registry));
  117.  
  118.     registry->RegisterFunction(
  119.         new NativeFunction1 <StaticFunctionTag, BSFixedString, BSFixedString>("GetINIString", "Utility", papyrusUtility::GetINIString, registry));
  120. }
  121.  
  122. /*
  123. ******************************************************************
  124.         PapyrusUtility.h (Full File)
  125. ******************************************************************
  126. */
  127.  
  128. #pragma once
  129. #include "GameTypes.h"
  130.  
  131. struct StaticFunctionTag;
  132. class Setting;
  133.  
  134. class VMClassRegistry;
  135.  
  136. namespace papyrusUtility
  137. {
  138.     void RegisterFuncs(VMClassRegistry* registry);
  139.  
  140.     static Setting * GetINISetting(const char * name);
  141.     float GetINIFloat(StaticFunctionTag* base, BSFixedString ini);
  142.     UInt32 GetINIInt(StaticFunctionTag* base, BSFixedString ini);
  143.     bool GetINIBool(StaticFunctionTag* base, BSFixedString ini);
  144.     BSFixedString GetINIString(StaticFunctionTag* base, BSFixedString ini);
  145. }
  146.  
  147. /*
  148. ******************************************************************
  149.         GameReferences.h (Slice)
  150. ******************************************************************
  151. */
  152. // 1B0
  153. // Character + 98 = process?
  154. class Character : public Actor
  155. {
  156.     enum { kTypeID = kFormType_Character };
  157.  
  158. public:
  159.     MEMBER_FN_PREFIX(Character);
  160.     DEFINE_MEMBER_FN(QueueNiNodeUpdate, void, 0x00727D80, bool); // PLB: shadeMe found this one, I just hooked it up to Papyrus
  161. };
  162.  
  163.  
  164. /*
  165. ******************************************************************
  166.         Script Use Sample
  167. ******************************************************************
  168. */
  169.  
  170.     akTarget.GetActorBase().SetFacePreset(0, 3) ; Change a face preset, I think this is the nose
  171.     akTarget.GetActorBase().SetWeight(0) ; Set the actors weight to zero
  172.     string facegen = "bUseFaceGenPreprocessedHeads:General"
  173.     bool value = Utility.GetINIBool(facegen) ; Retrieve the value of this setting
  174.     Utility.SetINIBool(facegen, false) ; Set it to zero
  175.     akTarget.QueueNiNodeUpdate() ; Invoke a node update
  176.     Utility.SetINIBool(facegen, value) ; Restore the previous value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement