Ir para conteúdo
Entre para seguir isso  
Nord

Nord War V2.5 (Times, Frags+Level...)

Recommended Posts

Nord    2
Nord

Nome

Nord War V2.5

 

Autor: Nord

Testado em: TFS 0.3.4 patch 2 p/ Tibia 8.5

OBS: Dou minha permissão para postar em qualquer lugar até sem meus créditos.

 

Após muita inatividade, preguiça, calotagem e tudo mais vim dar um presentinho de Natal para todos.

 

O que é um war system?

Um war system da um upgrade no servidor fazendo que os players não precisem relogar quando morrem, há contagem de quantas pessoas você matou e isso faz ganhar pontos, há um ganho de level quando morre, há balanceamento de time automático, isso faz com que um time não tenha muitas pessoas e outro poucas e para completar um sistema de troca de mapa automática.

 

Lembrando que o meu war system não é o mesmo que o do X-Dream War, eu refiz ele pra ficar mais leve e menor.

 

----Instalando----

Em data\lib crie um arquivo war.lua com o seguinte código:

--//Nord's War System V2.5
LEVEL = {START = 150, GAIN = 2}

TEAMS = {
[1] = {
COUNT = function()
	return getGlobalStorageValue(101021)
end,
COLOR = {0, 88, 95, 0}, EFFECT = 47},
[2] = {
COUNT = function()
	return getGlobalStorageValue(101022)
end,
COLOR = {0, 94, 132, 114}, EFFECT = 48}
}

TOWNS = {
{"Thais", {1, 2}},
{"Edron", {3, 4}},
{"Venore", {5, 6}},
{"Carlin", {7, 8}},
{"Darashia", {9, 10}}
}

maleOutfits = {128, 129, 130, 131, 132, 133, 134, 143, 144, 145, 146, 151, 152, 153, 154, 251, 268, 273, 278, 289, 325, 253, 254, 255}
femaleOutfits = {136, 137, 138, 139, 140, 141, 142, 147, 148, 149, 150, 155, 156, 157, 158, 252, 269, 270, 279, 288, 324, 264}

setGlobalStorageValue(101010, 1)

function doPlayerSetLevel(cid, level)
doPlayerAddExperience(cid, getExperienceForLevel(level) - getPlayerExperience(cid))
end

function doPlayerAddLevel(cid, amount)
local level = getPlayerLevel(cid)
if level < 250 then
	doPlayerAddExperience(cid, getExperienceForLevel(level + amount) - getPlayerExperience(cid))
end
end

team = {
get = function(id)
	if id == 0 then
		return (TEAMS[1].COUNT() < TEAMS[2].COUNT()+math.random(0, 1) and 1 or 2)
	else
		return (TEAMS[1].COLOR[4] == getCreatureOutfit(id).lookFeet and 1 or 2)
	end
end,
add = function(id, n)
	if n == 0 then
		setGlobalStorageValue(101021, 0)
		setGlobalStorageValue(101022, 0)
	else
		setGlobalStorageValue(101020+id, TEAMS[id].COUNT() + n)
	end
	return TRUE
end
}

team.add(0, 0)

event = {
login = function(cid)
	if getPlayerGroupId(cid) <= 1 then
		local teamid = team.get(0)
		if teamid > 0 then
			team.add(teamid, 1)
			local NOW = getGlobalStorageValue(101010)
			local color = TEAMS[teamid].COLOR
			doCreatureChangeOutfit(cid, {lookType = getPlayerSex(cid) == 1 and maleOutfits[math.random(#maleOutfits)] or femaleOutfits[math.random(#femaleOutfits)], lookHead = color[1], lookBody = color[2], lookLegs = color[3], lookFeet = color[4], lookAddons = math.random(3)})
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
			doCreatureAddMana(cid, getCreatureMaxMana(cid))
			doPlayerSetTown(cid, TOWNS[NOW][2][teamid])
			doTeleportThing(cid, getTownTemplePosition(TOWNS[NOW][2][teamid]), FALSE)
			doPlayerAddSoul(cid, -getPlayerSoul(cid))
			doSendMagicEffect(getCreaturePosition(cid), TEAMS[teamid].EFFECT)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Map: ".. TOWNS[NOW][1] .."\nTeam: ".. tostring(teamid) .." (".. TEAMS[1].COUNT() ..",".. TEAMS[2].COUNT() ..")\n \nChecking...\nIP: ".. doConvertIntegerToIp(getPlayerIp(cid)) .."\nMC Safe: ON\nMC Status: Clean")
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[X-Dream]+[Nord War]: Para mais informações /info")
			if getPlayerStorageValue(cid, 20000) == -1 then
				setPlayerStorageValue(cid, 20000, os.time(t))
			end
		end
	end
	return TRUE
end,
logout = function(cid)
	if getPlayerGroupId(cid) <= 1 then
		team.add(team.get(cid), -1)
	end
	return TRUE
end,
look = function(cid, thing)
	if not isPlayer(thing.uid) or getPlayerGroupId(thing.uid) > 1 then
		return TRUE
	end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ""..getPlayerName(thing.uid).." ("..getPlayerVocationName(thing.uid)..")\n[Lv: "..getPlayerLevel(thing.uid).."][Frags: "..getPlayerSoul(thing.uid).."]")
end,
combat = function(cid, target)
	if cid == target or getCreatureOutfit(cid).lookFeet == getCreatureOutfit(target).lookFeet then
		return FALSE
	end
	return TRUE
end,
kill = function(cid, lastHitKiller, mostDamageKiller)
	if isPlayer(cid) then
		if isPlayer(lastHitKiller) then
			doPlayerAddSoul(lastHitKiller, 1)
			doPlayerAddLevel(lastHitKiller, LEVEL.GAIN)
			doPlayerSendTextMessage(lastHitKiller, MESSAGE_INFO_DESCR, 'Kill [+'..LEVEL.GAIN..' levels]')
			if isPlayer(mostDamageKiller) and mostDamageKiller ~= lastHitKiller then
				doPlayerAddSoul(lastHitKiller, 1)
				doPlayerSendTextMessage(mostDamageKiller, MESSAGE_INFO_DESCR, 'Kill [+'..LEVEL.GAIN..' levels]')
				doPlayerAddLevel(mostDamageKiller, LEVEL.GAIN)
			end
		end
		if LEVEL.START ~= nil then
			doPlayerSetLevel(cid, LEVEL.START)
		end
		local oldPosition = getCreaturePosition(cid)
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
		doCreatureAddMana(cid, getCreatureMaxMana(cid))
		doSendMagicEffect(getCreaturePosition(cid), TEAMS[team.get(cid)].EFFECT)
		doSendMagicEffect(oldPosition, 65)
		doRemoveConditions(cid, FALSE)
		doPlayerAddSoul(cid, -getPlayerSoul(cid))
		return FALSE
	end
	return TRUE
end,
map = function(clean, save)
	NOW = getGlobalStorageValue(101010) >= #TOWNS and 1 or getGlobalStorageValue(101010) + 1
	setGlobalStorageValue(101010, NOW)
	doBroadcastMessage("Map changed\n[".. TOWNS[NOW][1] .."]\nNext map in 30 minutes.", MESSAGE_INFO_DESCR)
	team.add(0, 0)
	for _, cid in ipairs(getPlayersOnline()) do
		if getPlayerGroupId(cid) <= 1 then
			local teamid = team.get(cid)
			team.add(teamid, 1)
			doPlayerSetTown(cid, TOWNS[NOW][2][teamid])
			doTeleportThing(cid, getTownTemplePosition(TOWNS[NOW][2][teamid]), FALSE)
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
			doCreatureAddMana(cid, getCreatureMaxMana(cid))
			doRemoveConditions(cid, FALSE)
			doPlayerAddSoul(cid, -getPlayerSoul(cid))
		end
	end
	if clean == TRUE then
		doCleanMap()
	end
	if save == TRUE then
		doSaveServer()
	end
end
}

Procure em data\lib o arquivo data.lua e no final do arquivo pule uma linha e adicione isto:

dofile(getDataDir() .. "lib/war.lua")

Agora em data\creaturescripts\scripts crie de novo um arquivo war.lua, mas desta vez com este código:

function onLogin(cid)
registerCreatureEvent(cid, "WarLook")
registerCreatureEvent(cid, "WarKill")
registerCreatureEvent(cid, "WarLogout")
registerCreatureEvent(cid, "WarCombat")
return event.login(cid)
end

function onLogout(cid)
return event.logout(cid)
end

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
return event.kill(cid, lastHitKiller, mostDamageKiller)
end

function onLook(cid, thing, position, lookDistance)
return event.look(cid, thing)
end

function onCombat(cid, target)
return event.combat(cid, target)
end

Em data\creaturescripts abra o arquivo creaturescripts.xml e adicione isto:

	<event type="preparedeath" name="WarKill" event="script" value="war.lua"/>
<event type="login" name="WarLogin" event="script" value="war.lua"/>
<event type="logout" name="WarLogout" event="script" value="war.lua"/>
<event type="look" name="WarLook" event="script" value="war.lua"/>
<event type="combat" name="WarCombat" event="script" value="war.lua"/>

Em data\globalevents\scripts crie um arquivo map.lua com este código:

function onThink1()
broadcastMessage("Map change in 1 second.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(event.map, 1000, TRUE, TRUE)
return TRUE
end

function onThink2()
broadcastMessage("Map change in 2 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink1, 1000)
return TRUE
end

function onThink3()
broadcastMessage("Map change in 3 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink2, 1000)
return TRUE
end

function onThink4()
broadcastMessage("Map change in 4 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink3, 1000)
return TRUE
end

function onThink5()
broadcastMessage("Map change in 5 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink4, 1000)
return TRUE
end

function onThink6()
broadcastMessage("Map change in 6 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink5, 1000)
return TRUE
end

function onThink7()
broadcastMessage("Map change in 7 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink6, 1000)
return TRUE
end

function onThink8()
broadcastMessage("Map change in 8 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink7, 1000)
return TRUE
end

function onThink9()
broadcastMessage("Map change in 9 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink8, 1000)
return TRUE
end

function onThink10()
broadcastMessage("Map change in 10 seconds.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink9, 1000)
return TRUE
end

function onThink11()
broadcastMessage("Map will change in 1 minute.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink10, 50000)
return TRUE
end

function onThink(interval, lastExecution)
broadcastMessage("Map will change in 5 minutes.", MESSAGE_STATUS_CONSOLE_BLUE)
addEvent(onThink11, 240000)
end

Em data\globalevents abra o arquivo globalevents.xml e coloque isto:

	<globalevent name="map" interval="1500" event="script" value="map.lua"/>

Tudo pronto, só configurar :D

 

----Configurando----

No arquivo data\lib\war.lua que há as configurações, vejamos então:

  • LEVEL = {START = 150, GAIN = 2}
    START é o level em que qualquer jogador irá começar, neste caso 150.
    GAIN é quantos levels o player ganha por matar um adversário.
     
  • TEAMS = {
    [1] = {
    COUNT = function()
    return getGlobalStorageValue(101021)
    end,
    COLOR = {0, 88, 95, 0}, EFFECT = 47},
    [2] = {
    COUNT = function()
    return getGlobalStorageValue(101022)
    end,
    COLOR = {0, 94, 132, 114}, EFFECT = 48}
    }
    Apenas o que está em vermelho é importante
    COLOR defini as cores de cada time conforme este esquema: {CorDaCabeça, CorDoCorpo, CorDaPerna, CorDoPé}, no caso o corpo do time 1 vai ser azul porque 88 corresponde ao azul.
    EFFECT defini o Nº do efeito quando o player loga (aquela bolinha azul estilo teleport), se eu quiser que o time 2 faça um efeito de chamas em vés de 48 eu colocaria 36.
     
  • TOWNS = {
    {"Thais", {1, 2}},
    {"Edron", {3, 4}},
    {"Venore", {5, 6}},
    {"Carlin", {7, 8}},
    {"Darashia", {9, 10}}
    }
    Esta é a configuração da troca dos mapas.
    Entre "aspas" é o nome da cidade.
    Dentro das chaves os números 1 e 2 corresponde ao TownId dos times, explicando melhor... Quando você configura o mapa existe a ferramenta Edit Towns, nela você configura a posição dos templos, se por exemplo o templo/town de Nº 7 é em Port Hope e eu quero que lá comece o time 1 e no templo/town de Nº 9 é próximo de Port Hope e eu quero que lá comece o time 2 na configuração ficaria assim: {"Port Hope", {7, 9}}
     
    No config.lua certifique-se de que essas duas opções estejam como as abaixo:
  • allowChangeColors = "no"
  • noDamageToSameLookfeet = "yes"

 

Ow, TIO! Eu quero usar só uma cidade, tem algum problema?

Nenhum! Como ele não tem mapa para trocar os players voltaram para o mesmo templo na troca de mapa, mas isso é bom! Sabe quando enche de gente na frente do templo? Pode ser uma boa ajuda.

Mas TIO! Eu não quero nem que volte pro templo, como faço?

Não adicione o global event que eu passei lá pra cima /\

TIUUÔ! Eu to dando look e fica aquela coisa estranha: Nord (Sorcerer) [Lv:150][Frags:0], da pra deixa como tava antes?

Vai no creaturescripts.xml e tire isto: "<event type="look" name="WarLook" event="script" value="war.lua"/>"

 

As outfits (lookType), são escolhidas automaticamente, incluindo as outfits de barbarian (male/female).

 

Qualquer dúvida postem no tópico (talvez eu responda, tenho muita ausência), mas por PM nem pensar.

 

Bom divertimento e FELIZ NATAL, O NATAL É DE JESUUUS! :yes:

OBS: Natal já passou /\, FELIZ ANO NOVO!

Editado por Nord

Compartilhar este post


Link para o post
Gpwjhlkdcf    21
Gpwjhlkdcf

Feliz ano novo para você também. Ótimo script, obrigado.

Aprovado e Movido.

Compartilhar este post


Link para o post
Iago Felipe    5
Iago Felipe

Nóssa, é o melhor, mais leve, mais útil e com mais conteúdo e custo beneficio script que eu ja vi (custo beneficio é só pra enfeita).

 

Na boa é um ótimo script, obrigado por trazer cara parabéns, vc vai ganhar mtos tankis D: tenkis (Thanks).

Compartilhar este post


Link para o post
Dosman    0
Dosman

Muito bom !

Dificil encontrar algo asim !

 

Abraços.

Compartilhar este post


Link para o post
Nord    2
Nord

Ow, vlw mesmo pelos 2 comentários (muito animadores), eu pensei que ouviria reclamações por ser muito grande.

O que vcs acham de na nova versão caber 4 times?

Exemplo:

o time azul e o vermelho ficam no mapa de Thais enquanto...

o time verde e o preto ficam no mapa de Venore

Isso seria bom no caso de super lotação.

Editado por Nord

Compartilhar este post


Link para o post
MatheusGrilo    0
MatheusGrilo

Um dos melhores scripts de war q ja vi

Vlw cara

Compartilhar este post


Link para o post
ushoriuma    0
ushoriuma

nord S2(zuei)

o script n é bom nem ótimo

é perfect!

parabéns!

Compartilhar este post


Link para o post
Pandá s2    0
Pandá s2

Vlw kara Pelo TOPICO...

 

está bem criativo a war

Compartilhar este post


Link para o post
pejuge2    1
pejuge2

Ainda não testei, mas acredito que o global event fique melhor assim:

function onThink(interval, lastExecution)
   broadcastMessage("Map will change in 5 minutes.", MESSAGE_STATUS_CONSOLE_BLUE)
   addEvent(onThink2, 240000, 60000, 50000)
end

function onThink2(time, next)
   broadcastMessage("Map change in "..time / 1000 .." second(s).", MESSAGE_STATUS_CONSOLE_BLUE)
   nothing = time - next == 0 and addEvent(event.map, 1000, TRUE, TRUE) or addEvent(onThink2, time - next, time - next, 1000)
   return TRUE                                                                                                       
end

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×