--------------------------------
--[[ HardSham' room. ]]--
--[[ Version 1.9.1 Beta. ]]--
--[[ Developped by TheLeetCoder. ]]--
--------------------------------
--// by TheLeetCoder \\--
mapXML1 = ''
mapXML2 = ''
mapXML4 = ''
--// by Toonney \\--
mapXML3 = ''
maps = { mapXML1, mapXML2, mapXML3, mapXML4 }
difficultLevel = {}
itemUsages = {}
currentSham = ""
currentMap = ""
lastSham = ""
maxSummon = 5
roundNumber = 0
freeRound = false
tfm.exec.newGame(maps[math.random(#maps)])
tfm.exec.disableAllShamanSkills(true)
tfm.exec.disableAutoNewGame(true)
for playerName in pairs(tfm.get.room.playerList) do
difficultLevel[playerName] = 0
itemUsages[playerName] = 0
ui.addTextArea(100, "
« Bienvenue dans le salon #hardcham. »
Tapez !diff [level] afin de régler la difficulté.
", playerName, 250, 21, 300)
if tfm.get.room.playerList[playerName].isShaman then
currentSham = playerName
end
end
function eventNewPlayer(playerName) -- Nouveau joueur entre.
ui.addTextArea(100, "« Bienvenue dans le salon #hardcham. »
Tapez !diff [level] afin de régler la difficulté.
", playerName, 250, 21, 300)
end
function eventNewGame() -- Démarrage d'une nouvelle partie.
if roundNumber == 5 then
ui.removeTextArea(100, nil)
ui.addTextArea(115, "Le chamane à le droit à une partie sans limites !", nil, 250, 21, 320)
freeRound = true
roundNumber = 0
elseif roundNumber ~= 5 then
roundNumber = roundNumber + 1
freeRound = false
for playerName in pairs(tfm.get.room.playerList) do
ui.addTextArea(100, "Une nouvelle partie va commencer.
Tapez !diff [level] afin de régler la difficulté.
", playerName, 250, 21, 300)
itemUsages[playerName] = 0
lastSham = currentSham
ui.removeTextArea(103, playerName)
ui.removeTextArea(104, playerName)
ui.removeTextArea(115, playerName)
if tfm.get.room.playerList[playerName].isShaman then
currentSham = playerName
if difficultLevel[currentSham] > 3 then
itemUsages[currentSham] = (maxSummon - 1)
elseif difficultLevel[currentSham] > 6 then
itemUsages[currentSham] = (maxSummon - 2)
elseif difficultLevel[currentSham] > 9 then
itemUsages[currentSham] = (maxSummon - 3)
end
end
end
end
ui.removeTextArea(102, lastSham)
end
function eventLoop(timer, remaining)
if freeRound == true then
ui.addTextArea(101, "FEEL FREE *-* !!!", playerName, 5, 21, 150)
else
ui.addTextArea(101, "Invocations restantes: "..(maxSummon - itemUsages[currentSham]), playerName, 5, 21, 150)
end
if remaining<=0 then
nextMap = maps[math.random(#maps)]
if nextMap ~= currentMap then
tfm.exec.newGame(nextMap)
currentMap = nextMap
else
nextMap = maps[math.random(#maps)]
tfm.exec.newGame(nextMap)
currentMap = nextMap
end
end
end
function eventChatCommand(playerName, command) -- Commandes.
if command:sub(0, 4) == "diff" then
if tonumber(command:sub(6)) < 0 or tonumber(command:sub(6)) > 10 then
ui.addTextArea(104, "« Format invalide. Format : !diff [level] (entre 0 et 10). »
", playerName, 250, 21, 300)
else
difficultLevel[playerName] = tonumber(command:sub(6))
end
elseif command == "mort" or command == "kill" or command == "die" then
tfm.exec.killPlayer(playerName)
end
end
function eventSummoningEnd(playerName, type, x, y, angle, xspeed, yspeed, object)
if freeRound == true then
ui.addTextArea(101, "FEEL FREE *-* !!!", playerName, 5, 21, 150)
else
if maxSummon - itemUsages[playerName] == 0 then
for playerName in pairs(tfm.get.room.playerList) do
if tfm.get.room.playerList[playerName].isShaman then
ui.removeTextArea(100, playerName)
ui.addTextArea(102, "« Vous-avez utilisé tout vos objets. Dommage. »
", playerName, 250, 21, 300)
else
ui.removeTextArea(100, nil)
ui.addTextArea(103, "« Votre chamane a utilisé tout ses objets. Il ne peut plus invoquer. »
", nil, 250, 21, 350)
end
end
tfm.exec.removeObject(object.id)
elseif object.id == 0 then
-- Nothing.
else
itemUsages[playerName] = itemUsages[playerName] + 1
end
end
end
function eventPlayerWon(playerName)
if tfm.get.room.playerList[playerName].isShaman then
nextMap = maps[math.random(#maps)]
if nextMap ~= currentMap then
tfm.exec.newGame(nextMap)
currentMap = nextMap
else
nextMap = maps[math.random(#maps)]
tfm.exec.newGame(nextMap)
currentMap = nextMap
end
end
end
function eventPlayerDied()
local i=0
for n,player in pairs(tfm.get.room.playerList) do
if not player.isDead then
i=i+1
end
end
if i==0 then
tfm.exec.newGame(maps[math.random(#maps)])
end
end