Advertisement
Rochet2

Untitled

Mar 27th, 2017
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. local POWER_HAPPINESS = 6
  2. local UNIT_FIELD_BYTES_1 = 0x84 + 0x06
  3. local function GetLoyaltyLevel(pet)
  4.     return GetByteValue(UNIT_FIELD_BYTES_1, 1)
  5. end
  6. local function ModifyPower(unit, power, dVal)
  7.     if dVal == 0 then
  8.         return
  9.     end
  10.     local val = dVal + unit:GetPower(power)
  11.     if val <= 0 then
  12.         unit:SetPower(power, 0)
  13.         return
  14.     end
  15.  
  16.     local maxPower = unit:GetMaxPower(power)
  17.     if val < maxPower then
  18.         unit:SetPower(power, val)
  19.     else
  20.         unit:SetPower(power, maxPower)
  21.     end
  22. end
  23. local function LooseHappiness(pet)
  24.     local curValue = pet:GetPower(POWER_HAPPINESS)
  25.     if curValue <= 0 then
  26.         return
  27.     end
  28.     local addvalue = bit_rshift(140, GetLoyaltyLevel(pet)) * 125
  29.     if pet:IsInCombat() then
  30.         addvalue = math.floor(addvalue * 1.5)
  31.     end
  32.     ModifyPower(pet, POWER_HAPPINESS, -addvalue);
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement