Advertisement
expired6978

EquipManager

Jan 5th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. typedef BGSEquipSlot * (* _GetEitherHandSlot)();
  2. _GetEitherHandSlot GetEitherHandSlot = (_GetEitherHandSlot)0x0054BD70;
  3.  
  4. typedef BGSEquipSlot * (* _GetRightHandSlot)();
  5. _GetRightHandSlot GetRightHandSlot = (_GetRightHandSlot)0x0054BD40;
  6.  
  7. typedef BGSEquipSlot * (* _GetLeftHandSlot)();
  8. _GetLeftHandSlot GetLeftHandSlot = (_GetLeftHandSlot)0x0049D0D0;
  9.  
  10. typedef UInt8 (__stdcall * _HasItemInHand)(Character * actor, TESForm * baseForm, BGSEquipSlot * equipSlot);
  11. _HasItemInHand HasItemInHand = (_HasItemInHand)0x006EDC60;
  12.  
  13. typedef BGSEquipType * (* _GetEquipType)(TESForm * baseForm);
  14. _GetEquipType GetEquipType = (_GetEquipType)0x0044AE60;
  15.  
  16. class EquipManager
  17. {
  18. public:
  19.     virtual ~EquipManager();
  20.  
  21.     MEMBER_FN_PREFIX(EquipManager);
  22.     DEFINE_MEMBER_FN(doEquipItem, void, 0x006EEEB0, Character * actor, TESForm * baseForm, BaseExtraList * extraData, UInt32 unkFlag1, BGSEquipSlot * equipSlot, UInt8 bEquipSound, UInt8 bNoRemove, UInt8 bShowMsg, UInt8 unkFlag3);
  23.  
  24.     static EquipManager *   GetSingleton(void)
  25.     {
  26.         return *((EquipManager **)0x012E51AC);
  27.     }
  28. };
  29.  
  30.  
  31. // Papyrus EquipItem 8DCCA0
  32. // Inventory EquipItem 6EF2F0
  33.  
  34. // Has3D (TESForm::Unk_27)
  35.  
  36.  
  37. BGSEquipSlot * equipSlot = NULL;
  38. BGSEquipSlot * destinationSlot = GetLeftHandSlot();
  39. TESForm * ironMace = LookupFormByID(0x13982);
  40. BGSEquipType * equipType = GetEquipType(ironMace);
  41. if(equipType) {
  42.     equipSlot = equipType->GetEquipSlot();
  43. }
  44.  
  45. bool has3D = ironMace->Has3D();
  46. UInt8 hasEquip = HasItemInHand(actor, ironMace, equipSlot);
  47. bool eitherHand = (equipSlot == GetEitherHandSlot());
  48.  
  49. // Conditions to check:
  50. // - Form isn't None
  51. // - Form has 3D
  52. // - Form is in Container
  53. // - If player has this exact item equip already, skip enchant
  54.  
  55. if(has3D)
  56.     CALL_MEMBER_FN(EquipManager::GetSingleton(), doEquipItem)(actor, ironMace, NULL, 1, destinationSlot, 0, 0, 0, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement