Advertisement
Guest User

Untitled

a guest
May 30th, 2021
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. -- Scales all reputation changes received from NPC conversation in Enroth
  2. -- Can be saved into a file in Scripts/Global
  3. -- The scaling method is a bit convoluted, but it should work with any
  4. -- scaling factor without losing points to rounding errors.
  5.  
  6. local SCALE_FACTOR = 50
  7.  
  8. vars.EnrothQuestRep = vars.EnrothQuestRep or 0
  9. vars.EnrothRescaledQuestRep = vars.EnrothRescaledQuestRep or 0
  10.  
  11. local function InEnroth()
  12.     return TownPortalControls.GetCurrentSwitch() == 3
  13. end
  14.  
  15. local reputation_before, talking_with_enrothian
  16.  
  17. function events.ShowNPCTopics()
  18.     if talking_with_enrothian or not InEnroth() then
  19.         return
  20.     end
  21.     talking_with_enrothian = true
  22.     reputation_before = NPCFollowers.GetPartyReputation()
  23. end
  24.  
  25. function events.ExitNPC()
  26.     local need_rescaling = talking_with_enrothian
  27.     talking_with_enrothian = false
  28.     if not need_rescaling then
  29.         return
  30.     end
  31.     local rep_change = NPCFollowers.GetPartyReputation() - reputation_before
  32.     vars.EnrothQuestRep = vars.EnrothQuestRep + rep_change
  33.     local new_rescaled = math.round(vars.EnrothQuestRep / SCALE_FACTOR)
  34.     local rescaled_change = new_rescaled - vars.EnrothRescaledQuestRep
  35.     evt.Add("Reputation", rescaled_change - rep_change)
  36.     vars.EnrothRescaledQuestRep = new_rescaled
  37. end
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement