--[[
TEAM #1,
TEAM #2
]]
TEAMS_OUTFITS = {
{ colors = {79, 79, 79, 79}, addons = 3 },
{ colors = {94, 94, 94, 94}, addons = 3 }
}
RUNES = {} --[[##do not touch it!##]]
-- {antibot, normal}
RUNES.UH = {2275, 2273}
RUNES.SD = {2263, 2268}
RUNES.EXPLO = {2312, 2313}
RUNES.HMM = {2314, 2311}
RUNES.GFB = {2307, 2304}
RUNES.PBOMB = {2270, 2286}
RUNES.EBOMB = {2282, 2262}
RUNES.FBOMB = {2306, 2305}
RUNES.MW = {2294, 2293}
GLOBAL_RUNE_TYPE = 2
if ANTIBOT_RUNES then
GLOBAL_RUNE_TYPE = 1
end
ITEMS = {} --[[##do not touch it!##]]
--for empty slot use nil or false
--[[sorcerer]] ITEMS[5] = {
9778, --1 // head // yalahari mask
2200, --2 // necakle // protection amulet
2000, --3 // backpack // red backpack
8890, --4 // armor // robe of the underworld
8922, --5 // right hand // wand of voodoo
8918, --6 // left hand // spellbook of dark mysteries
7730, --7 // legs // blue legs
6132, --8 // feet // soft boots
2214, --9 // ring // ring of healing
nil, --10 // ammo slot // EMPTY
----
--items to a backpack -- {id, inBackpack[, count/subtype]}
----
{RUNES.UH[GLOBAL_RUNE_TYPE], false, 2}, --UH
{RUNES.SD[GLOBAL_RUNE_TYPE], false}, --SD
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{RUNES.HMM[GLOBAL_RUNE_TYPE], false}, --HMM
{2274, false}, --avalanche rune
{RUNES.GFB[GLOBAL_RUNE_TYPE], false}, --GFB
{2261, false}, --destroy field rune
{RUNES.PBOMB[GLOBAL_RUNE_TYPE], false}, --poison bomb rune
{RUNES.FBOMB[GLOBAL_RUNE_TYPE], false}, --firebomb rune
{RUNES.EBOMB[GLOBAL_RUNE_TYPE], false}, --energy bomb rune
{7590, true}, --GMP
{RUNES.MW[GLOBAL_RUNE_TYPE], false} --magic wall rune
}
--[[druid]] ITEMS[6] = {
9778, --1 // head // yalahari mask
2200, --2 // necakle // protection amulet
2002, --3 // backpack // blue backpack
8866, --4 // armor // serpent coat
8910, --5 // right hand // underworld rod
8918, --6 // left hand // spellbook of dark mysteries
7730, --7 // legs // blue legs
6132, --8 // feet // soft boots
2214, --9 // ring // ring of healing
nil, --10 // ammo slot // EMPTY
----
--items to a backpack -- {id, inBackpack[, count/subtype]}
----
{RUNES.UH[GLOBAL_RUNE_TYPE], false, 2}, --UH
{RUNES.SD[GLOBAL_RUNE_TYPE], false}, --SD
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{2274, false}, --avalanche rune
{RUNES.GFB[GLOBAL_RUNE_TYPE], false}, --GFB
{2261, false}, --destroy field rune
{RUNES.PBOMB[GLOBAL_RUNE_TYPE], false}, --poison bomb rune
{RUNES.FBOMB[GLOBAL_RUNE_TYPE], false}, --firebomb rune
{RUNES.EBOMB[GLOBAL_RUNE_TYPE], false}, --energy bomb rune
{7590, true}, --GMP
{RUNES.MW[GLOBAL_RUNE_TYPE], false} --magic wall rune
}
--[[paladin]] ITEMS[7] = {
2493, --1 // head // demon helmet
2200, --2 // necakle // protection amulet
2003, --3 // backpack // grey backpack
8888, --4 // armor // master archer's armor
8850, --5 // right hand // chain bolter
nil, --6 // left hand // EMPTY
9777, --7 // legs // yalahari leg piece
6132, --8 // feet // soft boots
2214, --9 // ring // ring of healing
6529, --10 // ammo slot // infernal bolts
----
--items to a backpack -- {id, inBackpack[, count/subtype]}
----
{RUNES.UH[GLOBAL_RUNE_TYPE], false, 2}, --UH
{RUNES.SD[GLOBAL_RUNE_TYPE], false}, --SD
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{2274, false}, --avalanche rune
{RUNES.GFB[GLOBAL_RUNE_TYPE], false}, --GFB
{2261, false}, --destroy field rune
{RUNES.PBOMB[GLOBAL_RUNE_TYPE], false}, --poison bomb rune
{RUNES.FBOMB[GLOBAL_RUNE_TYPE], false}, --firebomb rune
{RUNES.EBOMB[GLOBAL_RUNE_TYPE], false}, --energy bomb rune
{8472, true}, --GSP
{RUNES.MW[GLOBAL_RUNE_TYPE], false} --magic wall rune
}
--[[knight]] ITEMS[8] = {
2493, --1 // head // demon helmet
2200, --2 // necakle // protection amulet
1999, --3 // backpack // yellow backpack
9776, --4 // armor // yalahari armor
2431, --5 // right hand // stonecutter axe
6433, --6 // left hand // necromancer shield
2470, --7 // legs // golden legs
6132, --8 // feet // soft boots
2214, --9 // ring // ring of healing
nil, --10 // ammo slot // EMPTY
----
--items to a backpack -- {id, inBackpack[, count/subtype]}
----
{RUNES.UH[GLOBAL_RUNE_TYPE], false, 2}, --UH
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{2274, false}, --avalanche rune
{RUNES.GFB[GLOBAL_RUNE_TYPE], false}, --GFB
{2261, false}, --destroy field rune
{RUNES.PBOMB[GLOBAL_RUNE_TYPE], false}, --poison bomb rune
{RUNES.FBOMB[GLOBAL_RUNE_TYPE], false}, --firebomb rune
{RUNES.EBOMB[GLOBAL_RUNE_TYPE], false}, --energy bomb rune
{7591, true}, --GHP
{7620, true} --mana potion
}
ITEMS[1], ITEMS[2], ITEMS[3], ITEMS[4] = ITEMS[5], ITEMS[6], ITEMS[7], ITEMS[8]
ITEMS[0] = ITEMS[1] --prevents debugs
STORAGE = {
PLAYER = {
TEAM_INFO = 40000
},
GLOBAL = {
TEAMS = {40001, 40002},
TEAMS_COUNT = {40011, 40012},
AREA_ID = 40020
}
}
--[[ ##do not change anything below this line!## ]]
BAG_OF_SSA = getBooleanFromString(getConfigValue("addBagOfSSA"))
ANTIBOT_RUNES = getBooleanFromString(getConfigValue("antibotRunes"))
LEVEL_GAIN_FOR_KILL = tonumber(getConfigValue("levelGainForKill"))
ANTI_RELOG_TIME = tonumber(getConfigValue("antiRelogTime"))
DEFAULT_LEVEL = tonumber(getConfigValue("defaultLevel"))
MAXIMUM_LEVEL = tonumber(getConfigValue("maximumLevel"))
INITIALIZED = false
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
map = {
towns = {
{"Fibula", {2, 3}},
{"Venore", {5, 6}},
{"Edron", {8, 9}},
{"Thais", {11, 12}},
{"Coliseum", {22, 23}},
{"Lost Island", {25, 26}},
{"Khalifor", {28, 29}}
},
get = function ()
return getGlobalStorageValue(STORAGE.GLOBAL.AREA_ID)
end,
removeIssue = function ()
if map.get() < 1 or map.get() > #map.towns then
print("map.removeIssue: issue has been removed :: map was ".. map.get())
return setGlobalStorageValue(STORAGE.GLOBAL.AREA_ID, 1)
end
return FALSE
end,
set = function ()
map.removeIssue()
return setGlobalStorageValue(STORAGE.GLOBAL.AREA_ID, (map.get() % #map.towns) + 1)
end
}
playerTeam = {
get = function (cid)
return ((getPlayerStorageValue(cid, STORAGE.PLAYER.TEAM_INFO) == STORAGE.GLOBAL.TEAMS[1]) and 1) or 2
end,
set = function (cid, id)
return setPlayerStorageValue(cid, STORAGE.PLAYER.TEAM_INFO, id)
end
}
teamCount = {
get = function (teamId)
return getGlobalStorageValue(STORAGE.GLOBAL.TEAMS_COUNT[teamId])
end,
add = function (teamId, count)
return setGlobalStorageValue(STORAGE.GLOBAL.TEAMS_COUNT[teamId], teamCount.get(teamId) + count)
end,
rem = function (teamId, count)
return teamCount.add(teamId, -count)
end
}
doPlayerSetTeam = {
login = function (cid)
-- print("getSmallestTeam(): "..getSmallestTeam())
if getPlayerAccess(cid) < 3 then
local time = ANTI_RELOG_TIME or 2000
local team = getSmallestTeam()
playerTeam.set(cid, STORAGE.GLOBAL.TEAMS[team])
-- print(type(TEAMS_OUTFITS[team].colors) .."\n".. type(TEAMS_OUTFITS[team].addons))
doWarCreatureChangeOutfit(cid, TEAMS_OUTFITS[team].colors, TEAMS_OUTFITS[team].addons)
doPlayerSetTown(cid, map.towns[map.get()][2][playerTeam.get(cid)])
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
teamCount.add(team, 1)
doPlayerAddSoul(cid, -getPlayerSoul(cid))
doSendMagicEffect(getCreaturePosition(cid), 37)
end
-- print("Team 1 count: "..teamCount.get(1).."\nTeam 2 count: "..teamCount.get(2))
return TRUE
end,
logout = function (cid)
if getPlayerAccess(cid) < 3 then
local team = playerTeam.get(cid)
-- print("playerTeam.get(cid): "..team)
teamCount.rem(team, 1)
playerTeam.set(cid, FALSE)
-- print("Team 1 count: "..teamCount.get(1).."\nTeam 2 count: "..teamCount.get(2))
end
return TRUE
end
}
function doWarCreatureChangeOutfit(cid, colors, addons)
local outfit = getCreatureOutfit(cid)
if type(colors) == "number" then
colors = {colors, colors, colors, colors}
end
outfit.lookHead, outfit.lookBody, outfit.lookLegs, outfit.lookFeet = unpack(colors)
outfit.addons = addons or 3
doCreatureChangeOutfit(cid, outfit)
return true
end
function doChangeMap(clean, save)
map.set()
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerAccess(pid) < 3 then
local temple = map.towns[map.get()][2][playerTeam.get(cid)]
local oldPosition = getCreaturePosition(pid)
doPlayerSetTown(pid, temple)
doTeleportThing(pid, getTownTemplePosition(temple))
doSendMagicEffect(getCreaturePosition(pid), 37)
doSendMagicEffect(oldPosition, 2)
doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
doCreatureAddMana(pid, (getCreatureMaxMana(pid) - getCreatureMana(pid)))
doRemoveConditions(pid, FALSE)
end
end
if clean then
doCleanMap()
end
if save then
doSaveServer()
end
doBroadcastMessage("Map has been changed. New area is ".. map.towns[map.get()][1] ..".", MESSAGE_STATUS_CONSOLE_BLUE)
print(">> ".. os.date() .." :: Map has been changed. New area is ".. map.towns[map.get()][1] ..".")
return TRUE
end
function getSmallestTeam()
return (teamCount.get(1) > teamCount.get(2) and 2) or 1
end
function doPlayerSetLevel(cid, level)
return doPlayerAddExperience(cid, (getExperienceForLevel(level) - getPlayerExperience(cid)))
end
function doPlayerAddLevel(cid, amount)
return doPlayerAddExperience(cid, getExperienceForLevel(getPlayerLevel(cid) + amount) - getPlayerExperience(cid))
end
function doResetTeams(teams)
for team = 1, #teams do
setGlobalStorageValue(teams[team], 0)
end
return true
end
function doInitializeServer()
doResetTeams(STORAGE.GLOBAL.TEAMS_COUNT)
INIT = true
return print(">> X-Dream War has been initialized <<")
end
if not(INIT) then
addEvent(doInitializeServer, 500)
end
function onKillPlayer(cid, lastHitKiller, mostDamageKiller)
if isPlayer(cid) then
if isPlayer(lastHitKiller) then
doPlayerAddSoul(lastHitKiller, 1)
doSendAnimatedText(getCreaturePosition(lastHitKiller), "FRAG!", 144, lastHitKiller)
if isPlayer(mostDamageKiller) and mostDamageKiller ~= lastHitKiller then
doPlayerAddSoul(mostDamageKiller, 1)
doSendAnimatedText(getCreaturePosition(mostDamageKiller), "FRAG!", 150, mostDamageKiller)
end
if getBooleanFromString(getConfigValue("experienceByKillingPlayers")) and lastHitKiller ~= cid then
if BAG_OF_SSA and lastHitKiller ~= cid then
doPlayerBuyItemContainer(lastHitKiller, 1996, 2197, 1, 0, 5)
if mostDamageKiller ~= lastHitKiller then
doPlayerBuyItemContainer(mostDamageKiller, 1996, 2197, 1, 0, 5)
end
end
local gainLevel = LEVEL_GAIN_FOR_KILL
if tonumber(gainLevel) == nil then
gainLevel = math.floor(getPlayerLevel(cid) * 20000.00) --Aqui você muda a quantidade de experiencia que vai ser adicionado nos Killers
local gold = (math.random (getPlayerLevel(cid)/50, getPlayerLevel(cid)/10))
doPlayerAddItem(mostDamageKiller, 2148, gold)
end
--print("lastHitKiller: ".. lastHitKiller) print("mostDamageKiller: ".. mostDamageKiller) print("cid: ".. cid) print("MAXIMUM_LEVEL:") print(MAXIMUM_LEVEL)
--print("\n\n\n") print(lastHitKiller ~= cid) print(MAXIMUM_LEVEL == nil) print(getPlayerLevel(mostDamageKiller) < MAXIMUM_LEVEL)
if (lastHitKiller ~= cid) and ((MAXIMUM_LEVEL == nil) or (getPlayerLevel(lastHitKiller) < MAXIMUM_LEVEL)) then
doPlayerAddExperience(lastHitKiller, gainLevel)
end
if ((mostDamageKiller ~= lastHitKiller) and (mostDamageKiller ~= cid)) and ((MAXIMUM_LEVEL == nil) or (getPlayerLevel(mostDamageKiller) < MAXIMUM_LEVEL)) then
doPlayerAddExperience(mostDamageKiller, gainLevel)
doPlayerAddItem(mostDamageKiller, 2148, gold)
end
end
end
if tonumber(DEFAULT_LEVEL) ~= nil then
doPlayerSetLevel(cid, DEFAULT_LEVEL)
end
local oldPosition = getCreaturePosition(cid)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
doCreatureAddMana(cid, (getCreatureMaxMana(cid) - getCreatureMana(cid)))
doSendMagicEffect(getCreaturePosition(cid), 37)
doSendMagicEffect(oldPosition, 2)
doRemoveConditions(cid, FALSE)
doPlayerAddSoul(cid, -getPlayerSoul(cid))
return FALSE
end
return TRUE
end
function doPlayerShowFragsCount(cid, thing, position, lookDistance)
if isPlayer(thing.uid) and getPlayerAccess(thing.uid) < 3 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Frags: " .. getPlayerSoul(thing.uid))
end
return TRUE
end
function doPlayerAddEquipment(cid)
if getPlayerAccess(cid) < 3 then
local vocItems = ITEMS[getPlayerVocation(cid)]
for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
local slotItem = getPlayerSlotItem(cid, i)
if slotItem.itemid > 0 then
doRemoveItem(slotItem.uid)
end
if vocItems and vocItems ~= nil and i ~= CONST_SLOT_BACKPACK then
if i == CONST_SLOT_AMMO then
doPlayerAddItem(cid, vocItems, 100)
else
doPlayerAddItem(cid, vocItems)
end
end
end
local backpack = doPlayerAddItem(cid, vocItems[CONST_SLOT_BACKPACK], 1)
for b = 11, #vocItems do
if vocItems and vocItems ~= nil then
if vocItems[2] then
vocItems[3] = vocItems[3] or 1
doPlayerBuyItemContainer(cid, 2000, vocItems[1], 1, 0, vocItems[3])
else
doAddContainerItem(backpack, vocItems[1], vocItems[3])
end
end
end
end
return TRUE
end
function onPlayerAttack(cid, target)
if cid ~= target and isPlayer(cid) and isPlayer(target) and playerTeam.get(cid) == playerTeam.get(target) then
doPlayerSendCancel(cid, "You cannot attack your teammates.")
return FALSE
end
return TRUE
end
TEAM #1,
TEAM #2
]]
TEAMS_OUTFITS = {
{ colors = {79, 79, 79, 79}, addons = 3 },
{ colors = {94, 94, 94, 94}, addons = 3 }
}
RUNES = {} --[[##do not touch it!##]]
-- {antibot, normal}
RUNES.UH = {2275, 2273}
RUNES.SD = {2263, 2268}
RUNES.EXPLO = {2312, 2313}
RUNES.HMM = {2314, 2311}
RUNES.GFB = {2307, 2304}
RUNES.PBOMB = {2270, 2286}
RUNES.EBOMB = {2282, 2262}
RUNES.FBOMB = {2306, 2305}
RUNES.MW = {2294, 2293}
GLOBAL_RUNE_TYPE = 2
if ANTIBOT_RUNES then
GLOBAL_RUNE_TYPE = 1
end
ITEMS = {} --[[##do not touch it!##]]
--for empty slot use nil or false
--[[sorcerer]] ITEMS[5] = {
9778, --1 // head // yalahari mask
2200, --2 // necakle // protection amulet
2000, --3 // backpack // red backpack
8890, --4 // armor // robe of the underworld
8922, --5 // right hand // wand of voodoo
8918, --6 // left hand // spellbook of dark mysteries
7730, --7 // legs // blue legs
6132, --8 // feet // soft boots
2214, --9 // ring // ring of healing
nil, --10 // ammo slot // EMPTY
----
--items to a backpack -- {id, inBackpack[, count/subtype]}
----
{RUNES.UH[GLOBAL_RUNE_TYPE], false, 2}, --UH
{RUNES.SD[GLOBAL_RUNE_TYPE], false}, --SD
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{RUNES.HMM[GLOBAL_RUNE_TYPE], false}, --HMM
{2274, false}, --avalanche rune
{RUNES.GFB[GLOBAL_RUNE_TYPE], false}, --GFB
{2261, false}, --destroy field rune
{RUNES.PBOMB[GLOBAL_RUNE_TYPE], false}, --poison bomb rune
{RUNES.FBOMB[GLOBAL_RUNE_TYPE], false}, --firebomb rune
{RUNES.EBOMB[GLOBAL_RUNE_TYPE], false}, --energy bomb rune
{7590, true}, --GMP
{RUNES.MW[GLOBAL_RUNE_TYPE], false} --magic wall rune
}
--[[druid]] ITEMS[6] = {
9778, --1 // head // yalahari mask
2200, --2 // necakle // protection amulet
2002, --3 // backpack // blue backpack
8866, --4 // armor // serpent coat
8910, --5 // right hand // underworld rod
8918, --6 // left hand // spellbook of dark mysteries
7730, --7 // legs // blue legs
6132, --8 // feet // soft boots
2214, --9 // ring // ring of healing
nil, --10 // ammo slot // EMPTY
----
--items to a backpack -- {id, inBackpack[, count/subtype]}
----
{RUNES.UH[GLOBAL_RUNE_TYPE], false, 2}, --UH
{RUNES.SD[GLOBAL_RUNE_TYPE], false}, --SD
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{2274, false}, --avalanche rune
{RUNES.GFB[GLOBAL_RUNE_TYPE], false}, --GFB
{2261, false}, --destroy field rune
{RUNES.PBOMB[GLOBAL_RUNE_TYPE], false}, --poison bomb rune
{RUNES.FBOMB[GLOBAL_RUNE_TYPE], false}, --firebomb rune
{RUNES.EBOMB[GLOBAL_RUNE_TYPE], false}, --energy bomb rune
{7590, true}, --GMP
{RUNES.MW[GLOBAL_RUNE_TYPE], false} --magic wall rune
}
--[[paladin]] ITEMS[7] = {
2493, --1 // head // demon helmet
2200, --2 // necakle // protection amulet
2003, --3 // backpack // grey backpack
8888, --4 // armor // master archer's armor
8850, --5 // right hand // chain bolter
nil, --6 // left hand // EMPTY
9777, --7 // legs // yalahari leg piece
6132, --8 // feet // soft boots
2214, --9 // ring // ring of healing
6529, --10 // ammo slot // infernal bolts
----
--items to a backpack -- {id, inBackpack[, count/subtype]}
----
{RUNES.UH[GLOBAL_RUNE_TYPE], false, 2}, --UH
{RUNES.SD[GLOBAL_RUNE_TYPE], false}, --SD
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{2274, false}, --avalanche rune
{RUNES.GFB[GLOBAL_RUNE_TYPE], false}, --GFB
{2261, false}, --destroy field rune
{RUNES.PBOMB[GLOBAL_RUNE_TYPE], false}, --poison bomb rune
{RUNES.FBOMB[GLOBAL_RUNE_TYPE], false}, --firebomb rune
{RUNES.EBOMB[GLOBAL_RUNE_TYPE], false}, --energy bomb rune
{8472, true}, --GSP
{RUNES.MW[GLOBAL_RUNE_TYPE], false} --magic wall rune
}
--[[knight]] ITEMS[8] = {
2493, --1 // head // demon helmet
2200, --2 // necakle // protection amulet
1999, --3 // backpack // yellow backpack
9776, --4 // armor // yalahari armor
2431, --5 // right hand // stonecutter axe
6433, --6 // left hand // necromancer shield
2470, --7 // legs // golden legs
6132, --8 // feet // soft boots
2214, --9 // ring // ring of healing
nil, --10 // ammo slot // EMPTY
----
--items to a backpack -- {id, inBackpack[, count/subtype]}
----
{RUNES.UH[GLOBAL_RUNE_TYPE], false, 2}, --UH
{RUNES.EXPLO[GLOBAL_RUNE_TYPE], false}, --EXPLOSION
{2274, false}, --avalanche rune
{RUNES.GFB[GLOBAL_RUNE_TYPE], false}, --GFB
{2261, false}, --destroy field rune
{RUNES.PBOMB[GLOBAL_RUNE_TYPE], false}, --poison bomb rune
{RUNES.FBOMB[GLOBAL_RUNE_TYPE], false}, --firebomb rune
{RUNES.EBOMB[GLOBAL_RUNE_TYPE], false}, --energy bomb rune
{7591, true}, --GHP
{7620, true} --mana potion
}
ITEMS[1], ITEMS[2], ITEMS[3], ITEMS[4] = ITEMS[5], ITEMS[6], ITEMS[7], ITEMS[8]
ITEMS[0] = ITEMS[1] --prevents debugs
STORAGE = {
PLAYER = {
TEAM_INFO = 40000
},
GLOBAL = {
TEAMS = {40001, 40002},
TEAMS_COUNT = {40011, 40012},
AREA_ID = 40020
}
}
--[[ ##do not change anything below this line!## ]]
BAG_OF_SSA = getBooleanFromString(getConfigValue("addBagOfSSA"))
ANTIBOT_RUNES = getBooleanFromString(getConfigValue("antibotRunes"))
LEVEL_GAIN_FOR_KILL = tonumber(getConfigValue("levelGainForKill"))
ANTI_RELOG_TIME = tonumber(getConfigValue("antiRelogTime"))
DEFAULT_LEVEL = tonumber(getConfigValue("defaultLevel"))
MAXIMUM_LEVEL = tonumber(getConfigValue("maximumLevel"))
INITIALIZED = false
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
map = {
towns = {
{"Fibula", {2, 3}},
{"Venore", {5, 6}},
{"Edron", {8, 9}},
{"Thais", {11, 12}},
{"Coliseum", {22, 23}},
{"Lost Island", {25, 26}},
{"Khalifor", {28, 29}}
},
get = function ()
return getGlobalStorageValue(STORAGE.GLOBAL.AREA_ID)
end,
removeIssue = function ()
if map.get() < 1 or map.get() > #map.towns then
print("map.removeIssue: issue has been removed :: map was ".. map.get())
return setGlobalStorageValue(STORAGE.GLOBAL.AREA_ID, 1)
end
return FALSE
end,
set = function ()
map.removeIssue()
return setGlobalStorageValue(STORAGE.GLOBAL.AREA_ID, (map.get() % #map.towns) + 1)
end
}
playerTeam = {
get = function (cid)
return ((getPlayerStorageValue(cid, STORAGE.PLAYER.TEAM_INFO) == STORAGE.GLOBAL.TEAMS[1]) and 1) or 2
end,
set = function (cid, id)
return setPlayerStorageValue(cid, STORAGE.PLAYER.TEAM_INFO, id)
end
}
teamCount = {
get = function (teamId)
return getGlobalStorageValue(STORAGE.GLOBAL.TEAMS_COUNT[teamId])
end,
add = function (teamId, count)
return setGlobalStorageValue(STORAGE.GLOBAL.TEAMS_COUNT[teamId], teamCount.get(teamId) + count)
end,
rem = function (teamId, count)
return teamCount.add(teamId, -count)
end
}
doPlayerSetTeam = {
login = function (cid)
-- print("getSmallestTeam(): "..getSmallestTeam())
if getPlayerAccess(cid) < 3 then
local time = ANTI_RELOG_TIME or 2000
local team = getSmallestTeam()
playerTeam.set(cid, STORAGE.GLOBAL.TEAMS[team])
-- print(type(TEAMS_OUTFITS[team].colors) .."\n".. type(TEAMS_OUTFITS[team].addons))
doWarCreatureChangeOutfit(cid, TEAMS_OUTFITS[team].colors, TEAMS_OUTFITS[team].addons)
doPlayerSetTown(cid, map.towns[map.get()][2][playerTeam.get(cid)])
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
teamCount.add(team, 1)
doPlayerAddSoul(cid, -getPlayerSoul(cid))
doSendMagicEffect(getCreaturePosition(cid), 37)
end
-- print("Team 1 count: "..teamCount.get(1).."\nTeam 2 count: "..teamCount.get(2))
return TRUE
end,
logout = function (cid)
if getPlayerAccess(cid) < 3 then
local team = playerTeam.get(cid)
-- print("playerTeam.get(cid): "..team)
teamCount.rem(team, 1)
playerTeam.set(cid, FALSE)
-- print("Team 1 count: "..teamCount.get(1).."\nTeam 2 count: "..teamCount.get(2))
end
return TRUE
end
}
function doWarCreatureChangeOutfit(cid, colors, addons)
local outfit = getCreatureOutfit(cid)
if type(colors) == "number" then
colors = {colors, colors, colors, colors}
end
outfit.lookHead, outfit.lookBody, outfit.lookLegs, outfit.lookFeet = unpack(colors)
outfit.addons = addons or 3
doCreatureChangeOutfit(cid, outfit)
return true
end
function doChangeMap(clean, save)
map.set()
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerAccess(pid) < 3 then
local temple = map.towns[map.get()][2][playerTeam.get(cid)]
local oldPosition = getCreaturePosition(pid)
doPlayerSetTown(pid, temple)
doTeleportThing(pid, getTownTemplePosition(temple))
doSendMagicEffect(getCreaturePosition(pid), 37)
doSendMagicEffect(oldPosition, 2)
doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
doCreatureAddMana(pid, (getCreatureMaxMana(pid) - getCreatureMana(pid)))
doRemoveConditions(pid, FALSE)
end
end
if clean then
doCleanMap()
end
if save then
doSaveServer()
end
doBroadcastMessage("Map has been changed. New area is ".. map.towns[map.get()][1] ..".", MESSAGE_STATUS_CONSOLE_BLUE)
print(">> ".. os.date() .." :: Map has been changed. New area is ".. map.towns[map.get()][1] ..".")
return TRUE
end
function getSmallestTeam()
return (teamCount.get(1) > teamCount.get(2) and 2) or 1
end
function doPlayerSetLevel(cid, level)
return doPlayerAddExperience(cid, (getExperienceForLevel(level) - getPlayerExperience(cid)))
end
function doPlayerAddLevel(cid, amount)
return doPlayerAddExperience(cid, getExperienceForLevel(getPlayerLevel(cid) + amount) - getPlayerExperience(cid))
end
function doResetTeams(teams)
for team = 1, #teams do
setGlobalStorageValue(teams[team], 0)
end
return true
end
function doInitializeServer()
doResetTeams(STORAGE.GLOBAL.TEAMS_COUNT)
INIT = true
return print(">> X-Dream War has been initialized <<")
end
if not(INIT) then
addEvent(doInitializeServer, 500)
end
function onKillPlayer(cid, lastHitKiller, mostDamageKiller)
if isPlayer(cid) then
if isPlayer(lastHitKiller) then
doPlayerAddSoul(lastHitKiller, 1)
doSendAnimatedText(getCreaturePosition(lastHitKiller), "FRAG!", 144, lastHitKiller)
if isPlayer(mostDamageKiller) and mostDamageKiller ~= lastHitKiller then
doPlayerAddSoul(mostDamageKiller, 1)
doSendAnimatedText(getCreaturePosition(mostDamageKiller), "FRAG!", 150, mostDamageKiller)
end
if getBooleanFromString(getConfigValue("experienceByKillingPlayers")) and lastHitKiller ~= cid then
if BAG_OF_SSA and lastHitKiller ~= cid then
doPlayerBuyItemContainer(lastHitKiller, 1996, 2197, 1, 0, 5)
if mostDamageKiller ~= lastHitKiller then
doPlayerBuyItemContainer(mostDamageKiller, 1996, 2197, 1, 0, 5)
end
end
local gainLevel = LEVEL_GAIN_FOR_KILL
if tonumber(gainLevel) == nil then
gainLevel = math.floor(getPlayerLevel(cid) * 20000.00) --Aqui você muda a quantidade de experiencia que vai ser adicionado nos Killers
local gold = (math.random (getPlayerLevel(cid)/50, getPlayerLevel(cid)/10))
doPlayerAddItem(mostDamageKiller, 2148, gold)
end
--print("lastHitKiller: ".. lastHitKiller) print("mostDamageKiller: ".. mostDamageKiller) print("cid: ".. cid) print("MAXIMUM_LEVEL:") print(MAXIMUM_LEVEL)
--print("\n\n\n") print(lastHitKiller ~= cid) print(MAXIMUM_LEVEL == nil) print(getPlayerLevel(mostDamageKiller) < MAXIMUM_LEVEL)
if (lastHitKiller ~= cid) and ((MAXIMUM_LEVEL == nil) or (getPlayerLevel(lastHitKiller) < MAXIMUM_LEVEL)) then
doPlayerAddExperience(lastHitKiller, gainLevel)
end
if ((mostDamageKiller ~= lastHitKiller) and (mostDamageKiller ~= cid)) and ((MAXIMUM_LEVEL == nil) or (getPlayerLevel(mostDamageKiller) < MAXIMUM_LEVEL)) then
doPlayerAddExperience(mostDamageKiller, gainLevel)
doPlayerAddItem(mostDamageKiller, 2148, gold)
end
end
end
if tonumber(DEFAULT_LEVEL) ~= nil then
doPlayerSetLevel(cid, DEFAULT_LEVEL)
end
local oldPosition = getCreaturePosition(cid)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
doCreatureAddMana(cid, (getCreatureMaxMana(cid) - getCreatureMana(cid)))
doSendMagicEffect(getCreaturePosition(cid), 37)
doSendMagicEffect(oldPosition, 2)
doRemoveConditions(cid, FALSE)
doPlayerAddSoul(cid, -getPlayerSoul(cid))
return FALSE
end
return TRUE
end
function doPlayerShowFragsCount(cid, thing, position, lookDistance)
if isPlayer(thing.uid) and getPlayerAccess(thing.uid) < 3 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Frags: " .. getPlayerSoul(thing.uid))
end
return TRUE
end
function doPlayerAddEquipment(cid)
if getPlayerAccess(cid) < 3 then
local vocItems = ITEMS[getPlayerVocation(cid)]
for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
local slotItem = getPlayerSlotItem(cid, i)
if slotItem.itemid > 0 then
doRemoveItem(slotItem.uid)
end
if vocItems and vocItems ~= nil and i ~= CONST_SLOT_BACKPACK then
if i == CONST_SLOT_AMMO then
doPlayerAddItem(cid, vocItems, 100)
else
doPlayerAddItem(cid, vocItems)
end
end
end
local backpack = doPlayerAddItem(cid, vocItems[CONST_SLOT_BACKPACK], 1)
for b = 11, #vocItems do
if vocItems and vocItems ~= nil then
if vocItems[2] then
vocItems[3] = vocItems[3] or 1
doPlayerBuyItemContainer(cid, 2000, vocItems[1], 1, 0, vocItems[3])
else
doAddContainerItem(backpack, vocItems[1], vocItems[3])
end
end
end
end
return TRUE
end
function onPlayerAttack(cid, target)
if cid ~= target and isPlayer(cid) and isPlayer(target) and playerTeam.get(cid) == playerTeam.get(target) then
doPlayerSendCancel(cid, "You cannot attack your teammates.")
return FALSE
end
return TRUE
end