dofile("war_config.lua")
local creatureevent = CreatureEvent("onLogin")-- header
function onLogin(player)
local vocation = player:getVocation():getId()
local promotion = player:getVocation():getPromotion()
local function getVocationName(player)
if vocation == 0 then
return "Newbie"
end
if vocation == 1 then
return "Sorcerer"
end
if vocation == 2 then
return "Druid"
end
if vocation == 3 then
return "Paladin"
end
if vocation == 4 then
return "Knight"
end
if vocation == 5 then
return "Master Sorcerer"
end
if vocation == 6 then
return "Elder Druid"
end
if vocation == 7 then
return "Royal Paladin"
end
if vocation == 8 then
return "Elite Knight"
end
return "Unknown"
end
local function getExpForLevel(level)
level = level - 1
return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
end
local function getMinimumLevel(skill)
if skill == "LEVEL" then
if player:getStorageValue(minimumLevelUp1Stor) == 1 then
return minimumLevelUp1
else
return minimumLevel
end
end
if vocation == 1 or vocation == 5 then
if skill == SKILL_CLUB or skill == SKILL_SWORD or skill == SKILL_AXE or skill == SKILL_DISTANCE then
return 10
end
if skill == SKILL_SHIELD then
if player:getStorageValue(sorcererShieldUp1Stor) == 1 then
return sorcererShieldUp1
else
return sorcererShield
end
end
if skill == "MAGIC" then
if player:getStorageValue(sorcererMagicUp1Stor) == 1 then
return sorcererMagicUp1
else
return sorcererMagic
end
end
end
if vocation == 2 or vocation == 6 then
if skill == SKILL_CLUB or skill == SKILL_SWORD or skill == SKILL_AXE or skill == SKILL_DISTANCE then
return 10
end
if skill == SKILL_SHIELD then
if player:getStorageValue(druidShieldUp1Stor) == 1 then
return druidShieldUp1
else
return druidShield
end
end
if skill == "MAGIC" then
if player:getStorageValue(druidMagicUp1Stor) == 1 then
return druidMagicUp1
else
return druidMagic
end
end
end
if vocation == 3 or vocation == 7 then
if skill == SKILL_CLUB or skill == SKILL_SWORD or skill == SKILL_AXE then
return 10
end
if skill == SKILL_DISTANCE then
if player:getStorageValue(paladinDistanceUp1Stor) == 1 then
return paladinDistanceUp1
else
return paladinDistance
end
end
if skill == SKILL_SHIELD then
if player:getStorageValue(paladinShieldUp1Stor) == 1 then
return paladinShieldUp1
else
return paladinShield
end
end
if skill == "MAGIC" then
if player:getStorageValue(paladinMagicUp1Stor) == 1 then
return paladinMagicUp1
else
return paladinMagic
end
end
end
if vocation == 4 or vocation == 8 then
if skill == SKILL_DISTANCE then
return 10
end
if skill == SKILL_CLUB or skill == SKILL_SWORD or skill == SKILL_AXE then
if player:getStorageValue(knightMeleeUp1Stor) == 1 then
return knightMeleeUp1
else
return knightMelee
end
end
if skill == SKILL_SHIELD then
if player:getStorageValue(knightShieldUp1Stor) == 1 then
return knightShieldUp1
else
return knightShield
end
end
if skill == "MAGIC" then
if player:getStorageValue(knightMagicUp1Stor) == 1 then
return knightMagicUp1
else
return knightMagic
end
end
end
end
local function getRemainingDoubleFragReward(player)
if player:getStorageValue(doubleFragRewardStor) >= 1 then
return player:getStorageValue(doubleFragRewardStor)
else
return 0
end
end
local function getRemainingExtraExp(player)
if player:getStorageValue(extraExpStor) >= 1 then
return player:getStorageValue(extraExpStor)
else
return 0
end
end
local temple = getGlobalStorageValue(currentMap)
player:teleportTo(mapPositions[temple])
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, everyLoginMessage)
if player:getLastLoginSaved() <= 0 then
if player:getGroup():getId() < 2 then
player:setStorageValue(fragStor, 0)
player:setStorageValue(deathStor, 0)
player:setStorageValue(doubleFragRewardStor, bonusFragReward)
player:setStorageValue(extraExpStor, bonusExpReward)
player:addExperience(getExpForLevel(startLevel) - player:getExperience())
end
if string.lower(promoteOnLogin) ~= "no" then
if player:getGroup():getId() < 2 then
player:setVocation(promotion)
end
end
if string.lower(giveFirstItems) ~= "no" then
if player:getGroup():getId() < 2 then
for _, v in ipairs(commonItems) do
player:addItem(v.itemid, v.count or 1)
end
local giveItems = firstItems[vocation]
if giveItems ~= nil then
for _, v in ipairs(giveItems) do
player:addItem(v.itemid, v.count or 1)
end
end
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have recieved your first items!")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, newPlayerMessage)
end
end
end
if string.lower(enableMinimumLevel) ~= "no" then
if player:getLevel() < getMinimumLevel("LEVEL") then
if player:getGroup():getId() < 2 then
player:addExperience(getExpForLevel(getMinimumLevel("LEVEL")) - player:getExperience())
end
end
end
if string.lower(fullBlessOnLogin) ~= "no" then
if player:getGroup():getId() < 2 then
player:addPremiumDays(1)
player:addBlessing(1)
player:addBlessing(2)
player:addBlessing(3)
player:addBlessing(4)
player:addBlessing(5)
end
end
if string.lower(displayStatsOnLogin) ~= "no" then
if player:getGroup():getId() < 2 then
player:popupFYI("" .. player:getName() .. " the " .. getVocationName(player) .. " " ..
"\nKills: " .. player:getStorageValue(fragStor) .. " | Deaths: " .. player:getStorageValue(deathStor) .. " " ..
"\n " ..
"\nCharacter Stat: Current Level | (Minimum Level) " ..
"\n " ..
"\nExperience Level: " .. player:getLevel() .. " | (" .. getMinimumLevel("LEVEL") .. ") " ..
"\nMagic Level: " .. player:getMagicLevel() .. " | (" .. getMinimumLevel("MAGIC") .. ") " ..
"\nClub Fighting: " .. player:getSkillLevel(SKILL_CLUB) .. " | (" .. getMinimumLevel(SKILL_CLUB) .. ") " ..
"\nSword Fighting: " .. player:getSkillLevel(SKILL_SWORD) .. " | (" .. getMinimumLevel(SKILL_SWORD) .. ") " ..
"\nAxe Fighting: " .. player:getSkillLevel(SKILL_AXE) .. " | (" .. getMinimumLevel(SKILL_AXE) .. ") " ..
"\nDistance Fighting: " .. player:getSkillLevel(SKILL_DISTANCE) .. " | (" .. getMinimumLevel(SKILL_DISTANCE) .. ") " ..
"\nShielding: " .. player:getSkillLevel(SKILL_SHIELD) .. " | (" .. getMinimumLevel(SKILL_SHIELD) .. ") " ..
"\n " ..
"\nBONUS FRAGS REMAINING: " ..
"\nDouble GOLD: " .. getRemainingDoubleFragReward(player) .. " " ..
"\nExtra EXP: " .. getRemainingExtraExp(player) .. " " ..
"\n " ..
"\nPurchase upgrades on the website! " ..
"\n ")
end
end
if string.lower(enableMinimumSkills) ~= "no" then
if player:getGroup():getId() < 2 then
if vocation == 1 or vocation == 5 then
while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
end
while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
end
end
if vocation == 2 or vocation == 6 then
while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
end
while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
end
end
if vocation == 3 or vocation == 7 then
while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
end
while player:getSkillLevel(SKILL_DISTANCE) < getMinimumLevel(SKILL_DISTANCE) do
player:addSkillTries(SKILL_DISTANCE, player:getVocation():getRequiredSkillTries(SKILL_DISTANCE, player:getSkillLevel(SKILL_DISTANCE) + 1) - player:getSkillTries(SKILL_DISTANCE))
end
while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
end
end
if vocation == 4 or vocation == 8 then
while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
end
while player:getSkillLevel(SKILL_SWORD) < getMinimumLevel(SKILL_SWORD) do
player:addSkillTries(SKILL_SWORD, player:getVocation():getRequiredSkillTries(SKILL_SWORD, player:getSkillLevel(SKILL_SWORD) + 1) - player:getSkillTries(SKILL_SWORD))
end
while player:getSkillLevel(SKILL_AXE) < getMinimumLevel(SKILL_AXE) do
player:addSkillTries(SKILL_AXE, player:getVocation():getRequiredSkillTries(SKILL_AXE, player:getSkillLevel(SKILL_AXE) + 1) - player:getSkillTries(SKILL_AXE))
end
while player:getSkillLevel(SKILL_CLUB) < getMinimumLevel(SKILL_CLUB) do
player:addSkillTries(SKILL_CLUB, player:getVocation():getRequiredSkillTries(SKILL_CLUB, player:getSkillLevel(SKILL_CLUB) + 1) - player:getSkillTries(SKILL_CLUB))
end
while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
end
end
end
end
if string.lower(enableStartSkills) ~= "no" then
if player:getGroup():getId() < 2 then
if vocation == "sorcerer" or vocation == "master sorcerer" then
while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
end
while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
end
end
if vocation == "druid" or vocation == "elder druid" then
while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
end
while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
end
end
if vocation == "paladin" or vocation == "royal paladin" then
while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
end
while player:getSkillLevel(SKILL_DISTANCE) < getMinimumLevel(SKILL_DISTANCE) do
player:addSkillTries(SKILL_DISTANCE, player:getVocation():getRequiredSkillTries(SKILL_DISTANCE, player:getSkillLevel(SKILL_DISTANCE) + 1) - player:getSkillTries(SKILL_DISTANCE))
end
while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
end
end
if vocation == "knight" or vocation == "elite knight" then
while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
end
while player:getSkillLevel(SKILL_SWORD) < getMinimumLevel(SKILL_SWORD) do
player:addSkillTries(SKILL_SWORD, player:getVocation():getRequiredSkillTries(SKILL_SWORD, player:getSkillLevel(SKILL_SWORD) + 1) - player:getSkillTries(SKILL_SWORD))
end
while player:getSkillLevel(SKILL_AXE) < getMinimumLevel(SKILL_AXE) do
player:addSkillTries(SKILL_AXE, player:getVocation():getRequiredSkillTries(SKILL_AXE, player:getSkillLevel(SKILL_AXE) + 1) - player:getSkillTries(SKILL_AXE))
end
while player:getSkillLevel(SKILL_CLUB) < getMinimumLevel(SKILL_CLUB) do
player:addSkillTries(SKILL_CLUB, player:getVocation():getRequiredSkillTries(SKILL_CLUB, player:getSkillLevel(SKILL_CLUB) + 1) - player:getSkillTries(SKILL_CLUB))
end
while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
end
end
end
end
creatureevent:register() -- footer/end
local creatureevent2 = CreatureEvent("register onLogin") -- header 2
function creatureevent2.onLogin(player)
player:registerEvent("PrepareDeath")
player:registerEvent("DeathStats")
return true
end
creatureevent2:register() -- footer/end