Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1.     const char* AnimEvent = NULL;
  2.     void DecideAnimReplace(int a1){
  3.         if (!s_Idles || a1 == 0)
  4.             return;
  5.         AnimEvent = NULL;
  6.         int obj = Lib::SafeRead32(a1 + 4);
  7.         if (obj == 0)
  8.             return;
  9.         UInt64 key = Forms::GetFormKey((TESForm*)obj);
  10.         if (key == 0)
  11.             return;
  12.  
  13.         // Look for a replacer
  14.         std::string AnimEventName((const char*)Lib::SafeRead32(a1 + 0x14));
  15.         TESForm* FormRef = GetSingleton()->GetValue(key, AnimEventName, NULL);
  16.         if (!FormRef)
  17.             FormRef = GetSingleton()->GetValue(0, AnimEventName, NULL);
  18.         if (!FormRef)
  19.             return;
  20.  
  21.         // Get the Idle object to use
  22.         TESIdleForm* IdleRef = NULL;
  23.         if (FormRef && FormRef->formType == kFormType_Idle)
  24.             IdleRef = DYNAMIC_CAST(FormRef, TESForm, TESIdleForm);
  25.         if (!IdleRef)
  26.             return;
  27.  
  28.         // Override
  29.         //_MESSAGE(IdleRef->animationEvent.data);
  30.         SafeWrite32(a1 + 0x24, (UInt32)IdleRef);
  31.         AnimEvent = IdleRef->animationEvent.data;
  32.         SafeWrite32(a1 + 0x14, (UInt32)AnimEvent);
  33.         /*
  34.         Normal a1                               Modified a1
  35.         +0      vtable
  36.         +4      actor
  37.         +8      0
  38.         +C      BGSAction (e.g. ActionIdle)             ?BGSAction(Idle)
  39.         +10     2
  40.         +14     AnimationEventName*                     AnimationEventName *
  41.         +18     AnimationParams?
  42.         +1C     0
  43.         +20     0
  44.         +24     TESIdleForm*
  45.         +28     0
  46.         +2C     1
  47.         +30     Return address of function?
  48.         +34     0
  49.         +38     40h
  50.         +3C     0
  51.         +40     1   Animation handler?
  52.         +44     0
  53.         +48     0
  54.         +4C     Unk*
  55.         +50     Script* <- dynamically allocated
  56.         +54     0
  57.         +58     Animation event NOT POINTER <- this is not the case when BGSAction is not idle
  58.         +...    0
  59.         */
  60.     }
  61.  
  62.     int animJNEBack = 0x6F0305;
  63.     int animJEBack = 0x6F0312;
  64.     void InitPlugin() {
  65.        
  66.         void * animCodeStart;
  67.         _asm
  68.         {
  69.             mov animCodeStart, offset animStart
  70.             jmp animEnd
  71.         animStart :
  72.             push eax
  73.             push ecx
  74.             push edx
  75.             push esi
  76.             call DecideAnimReplace
  77.             add esp, 4
  78.             pop edx
  79.             pop ecx
  80.             pop eax
  81.  
  82.             test byte ptr[esi + 0x2C], 1
  83.             je animJEJump
  84.             jmp animJNEBack
  85.         animJEJump :
  86.             jmp animJEBack
  87.         animEnd :
  88.         }
  89.  
  90.         WriteRelJump(0x6F02FF, (UInt32)animCodeStart);
  91.        
  92.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement