Advertisement
Pasterbiner123321

Untitled

May 27th, 2024
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.60 KB | None | 0 0
  1. local RESET_SYS = TalkAction("!reset")
  2.  
  3. local CONFIG = {
  4.     STORAGE_RESETS = 53009, --sprawdz czy wolne
  5.     BACK_TO_LEVEL = 8,
  6.     REDSKULL = true,
  7.     BATTLE = true,
  8.     PZ = false,
  9.     DEFAULT_GAIN_MAX_HEALTH = 0.1,
  10.     DEFAULT_GAIN_MAX_MANA = 0.1,
  11.     STAGES = {
  12.         {resets = 5, level = 10, premium = 14, storage = 101},
  13.         {resets = 10, level = 15, premium = 19, storage = 201},
  14.         {resets = 15, level = 20, premium = 29, storage = 301},
  15.         {resets = 20, level = 30, premium = 39, storage = 401},
  16.         {resets = 30, level = 40, premium = 49, storage = 501},
  17.         {resets = math.huge, level = 40, premium = 50, storage = 601}
  18.     }
  19. }
  20.  
  21. local function getExperienceForLevel(level)
  22.     return ((50 * (level - 1) ^ 3) - (150 * (level - 1) ^ 2) + (400 * (level - 1))) / 3
  23. end
  24.  
  25. local function canResetPlayer(player)
  26.     if CONFIG.REDSKULL and player:getSkull() == SKULL_RED then
  27.         player:sendCancelMessage("You need to be without red skull to reset.")
  28.         return false
  29.     elseif CONFIG.PZ and not getTilePzInfo(player:getPosition()) then
  30.         player:sendCancelMessage("You need to be in protection zone to reset.")
  31.         return false
  32.     elseif CONFIG.BATTLE and player:getCondition(CONDITION_INFIGHT) then
  33.         player:sendCancelMessage("You need to be without battle to reset.")
  34.         return false
  35.     end
  36.     return true
  37. end
  38.  
  39. function RESET_SYS.onSay(player, words, param)
  40.     if not canResetPlayer(player) then
  41.         return false
  42.     end
  43.  
  44.     local playerResets = math.max(0, player:getStorageValue(CONFIG.STORAGE_RESETS))
  45.     local stage = nil
  46.     for _, _stage in pairs(CONFIG.STAGES) do
  47.         if playerResets <= _stage.resets then
  48.             stage = _stage
  49.             break
  50.         end
  51.     end
  52.  
  53.     if not stage then
  54.         print("[Warning - ResetSystem::onSay] Stage not found for player: " .. player:getName())
  55.         return false
  56.     end
  57.  
  58.     local resetLevel = player:isPremium() and stage.premium or stage.level
  59.     local playerLevel = player:getLevel()
  60.     if playerLevel < resetLevel then
  61.         player:sendCancelMessage("You need level " .. resetLevel .. " or more to reset.")
  62.         return false
  63.     end
  64.  
  65.     playerResets = playerResets + 1
  66.     player:setStorageValue(CONFIG.STORAGE_RESETS, playerResets)
  67.     player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(CONFIG.BACK_TO_LEVEL))
  68.    
  69.     local maxHealth = player:getMaxHealth()
  70.     local maxMana = player:getMaxMana()
  71.     local newMaxHealth = stage.gainMaxHealth or (maxHealth * (1 + CONFIG.DEFAULT_GAIN_MAX_HEALTH))
  72.     local newMaxMana = stage.gainMaxMana or (maxMana * (1 + CONFIG.DEFAULT_GAIN_MAX_MANA))
  73.  
  74.     -- Determinar el aumento de HP y MP segรบn la vocaciรณn del jugador
  75.     local vocHealthBonus = 0
  76.     local vocManaBonus = 0
  77.     local playerVocation = player:getVocation():getId()
  78.     if playerVocation == 3 or playerVocation == 4 then -- Paladin or Knight
  79.         vocHealthBonus = 50
  80.         vocManaBonus = 30
  81.     elseif playerVocation == 1 or playerVocation == 2 then -- Sorcerer or Druid
  82.         vocHealthBonus = 30
  83.         vocManaBonus = 50
  84.     end
  85.  
  86.     player:setMaxHealth(maxHealth + newMaxHealth + vocHealthBonus)
  87.     player:setMaxMana(maxMana + newMaxMana + vocManaBonus)
  88.     player:addHealth(newMaxHealth + vocHealthBonus)
  89.     player:addMana(newMaxMana + vocManaBonus)
  90.     player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
  91.     player:sendTextMessage(MESSAGE_INFO_DESCR, "Now you have " .. playerResets .. " " .. (playerResets == 1 and "reset" or "resets") .. ".")
  92.     return false
  93. end
  94.  
  95. RESET_SYS:register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement