Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RESET_SYS = TalkAction("!reset")
- local CONFIG = {
- STORAGE_RESETS = 53009, --sprawdz czy wolne
- BACK_TO_LEVEL = 8,
- REDSKULL = true,
- BATTLE = true,
- PZ = false,
- DEFAULT_GAIN_MAX_HEALTH = 0.1,
- DEFAULT_GAIN_MAX_MANA = 0.1,
- STAGES = {
- {resets = 5, level = 10, premium = 14, storage = 101},
- {resets = 10, level = 15, premium = 19, storage = 201},
- {resets = 15, level = 20, premium = 29, storage = 301},
- {resets = 20, level = 30, premium = 39, storage = 401},
- {resets = 30, level = 40, premium = 49, storage = 501},
- {resets = math.huge, level = 40, premium = 50, storage = 601}
- }
- }
- local function getExperienceForLevel(level)
- return ((50 * (level - 1) ^ 3) - (150 * (level - 1) ^ 2) + (400 * (level - 1))) / 3
- end
- local function canResetPlayer(player)
- if CONFIG.REDSKULL and player:getSkull() == SKULL_RED then
- player:sendCancelMessage("You need to be without red skull to reset.")
- return false
- elseif CONFIG.PZ and not getTilePzInfo(player:getPosition()) then
- player:sendCancelMessage("You need to be in protection zone to reset.")
- return false
- elseif CONFIG.BATTLE and player:getCondition(CONDITION_INFIGHT) then
- player:sendCancelMessage("You need to be without battle to reset.")
- return false
- end
- return true
- end
- function RESET_SYS.onSay(player, words, param)
- if not canResetPlayer(player) then
- return false
- end
- local playerResets = math.max(0, player:getStorageValue(CONFIG.STORAGE_RESETS))
- local stage = nil
- for _, _stage in pairs(CONFIG.STAGES) do
- if playerResets <= _stage.resets then
- stage = _stage
- break
- end
- end
- if not stage then
- print("[Warning - ResetSystem::onSay] Stage not found for player: " .. player:getName())
- return false
- end
- local resetLevel = player:isPremium() and stage.premium or stage.level
- local playerLevel = player:getLevel()
- if playerLevel < resetLevel then
- player:sendCancelMessage("You need level " .. resetLevel .. " or more to reset.")
- return false
- end
- playerResets = playerResets + 1
- player:setStorageValue(CONFIG.STORAGE_RESETS, playerResets)
- player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(CONFIG.BACK_TO_LEVEL))
- local maxHealth = player:getMaxHealth()
- local maxMana = player:getMaxMana()
- local newMaxHealth = stage.gainMaxHealth or (maxHealth * (1 + CONFIG.DEFAULT_GAIN_MAX_HEALTH))
- local newMaxMana = stage.gainMaxMana or (maxMana * (1 + CONFIG.DEFAULT_GAIN_MAX_MANA))
- -- Determinar el aumento de HP y MP segรบn la vocaciรณn del jugador
- local vocHealthBonus = 0
- local vocManaBonus = 0
- local playerVocation = player:getVocation():getId()
- if playerVocation == 3 or playerVocation == 4 then -- Paladin or Knight
- vocHealthBonus = 50
- vocManaBonus = 30
- elseif playerVocation == 1 or playerVocation == 2 then -- Sorcerer or Druid
- vocHealthBonus = 30
- vocManaBonus = 50
- end
- player:setMaxHealth(maxHealth + newMaxHealth + vocHealthBonus)
- player:setMaxMana(maxMana + newMaxMana + vocManaBonus)
- player:addHealth(newMaxHealth + vocHealthBonus)
- player:addMana(newMaxMana + vocManaBonus)
- player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
- player:sendTextMessage(MESSAGE_INFO_DESCR, "Now you have " .. playerResets .. " " .. (playerResets == 1 and "reset" or "resets") .. ".")
- return false
- end
- RESET_SYS:register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement