Ir para conteúdo

Arena Svargrond


Posts Recomendados

Vou postar aqui o script da Arena Svargrond, algumas partes do script foram baseadas no script do Gesior.

 

XML do NPC:

<npc name="Halvar" script="data/npc/scripts/arena.lua" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="129" head="114" body="119" legs="114" feet="114" corpse="2212"/>
</npc>

O looktype não está muito certo, se você tiver o certo poste que eu substituo...

 

Script do NPC:

(crie com o nome de arena.lua)

local focuses = {}
local function isFocused(cid)
for i, v in pairs(focuses) do
	if(v == cid) then
		return true
	end
end
return false
end

local function addFocus(cid)
if(not isFocused(cid)) then
	table.insert(focuses, cid)
end
end
local function removeFocus(cid)
for i, v in pairs(focuses) do
	if(v == cid) then
		table.remove(focuses, i)
		break
	end
end
end
local function lookAtFocus()
for i, v in pairs(focuses) do
	if(isPlayer(v)) then
		doNpcSetCreatureFocus(v)
		return
	end
end
doNpcSetCreatureFocus(0)
end


local function getPlayerMoney(cid)
return ((getPlayerItemCount(cid, 2160) * 10000) +
(getPlayerItemCount(cid, 2152) * 100) +
getPlayerItemCount(cid, 2148))
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
if(isFocused(cid)) then
	selfSay("Hmph!")
	removeFocus(cid)
end
end

talkstate = 0
function onCreatureSay(cid, type, msg)
if((msg == "hi") and not (isFocused(cid))) then
	addFocus(cid)
	selfSay("Welcome, ".. getCreatureName(cid) ..". Do you wanna fight at the Arena?", cid)
	talkstate = 1
elseif isFocused(cid) and talkstate == 1 and msg == "yes" then
	completed = getPlayerStorageValue(cid, arenaconf.storages.level_completed)
	current = getPlayerStorageValue(cid, arenaconf.storages.level)
	money = getPlayerMoney(cid)
	if getGlobalStorageValue(arenaconf.storages.busy) == -1 then
		if completed == -1 and current == -1 then
			if money >= arenaconf.cost[1] then
				setPlayerStorageValue(cid, arenaconf.storages.level, 1)
				setPlayerStorageValue(cid, arenaconf.storages.room, 1)
				current = 1
				doPlayerRemoveMoney(cid, arenaconf.cost[1])
				selfSay("You will fight at Greenshore level, good luck!", cid)
			else
				selfSay("You don't have enough money, you need ".. arenaconf.cost[1] .."gp to fight.", cid)
			end
		elseif current == -1  and completed ~= -1 and completed ~= 3 then
			if money >= arenaconf.cost[completed+1] then
				setPlayerStorageValue(cid, arenaconf.storages.level, completed+1)
				setPlayerStorageValue(cid, arenaconf.storages.room, 1)
				current = completed+1
				doPlayerRemoveMoney(cid, arenaconf.cost[current])
				selfSay("You will fight at ".. arenaconf.levelname[current] .." level, good luck!", cid)
			else
				selfSay("You don't have enough money, you need ".. arenaconf.cost[completed+1] .."gp to fight.", cid)
			end
		elseif completed == 3 then
			selfSay("You already did every arena level.", cid)
		end
	else
		selfSay("Sorry but there is another adventurer fighting right now.", cid)
	end
end
end

function onPlayerCloseChannel(cid)
if(isFocused(cid)) then
	selfSay("Hmph!")
	removeFocus(cid)
end
end

function onThink()
for i, focus in pairs(focuses) do
	if(not isCreature(focus)) then
		removeFocus(focus)
	else
		local distance = getDistanceTo(focus) or -1
		if((distance > 4) or (distance == -1)) then
			selfSay("Hmph!")
			removeFocus(focus)
		end
	end
end
lookAtFocus()
end

 

no movements.xml adicione:

<movevent type="StepIn" actionid="42321" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42300" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42301" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42302" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42303" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42304" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42305" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42306" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42307" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42308" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42309" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42310" event="script" value="arena teleports.lua"/>
<movevent type="StepIn" actionid="42360" event="script" value="arena globet.lua"/>
<movevent type="StepOut" actionid="42360" event="script" value="arena globet.lua"/>
<movevent type="StepIn" actionid="42370" event="script" value="arena globet.lua"/>
<movevent type="StepOut" actionid="42370" event="script" value="arena globet.lua"/>
<movevent type="StepIn" actionid="42380" event="script" value="arena globet.lua"/>
<movevent type="StepOut" actionid="42380" event="script" value="arena globet.lua"/>

 

crie um arquivo chamado "arena teleports.lua" e adicione:

function onStepIn(cid, item, position, fromPosition)
room = getPlayerStorageValue(cid, arenaconf.storages.room)
level = getPlayerStorageValue(cid, arenaconf.storages.level)
if item.actionid == 42321 then
	setPlayerStorageValue(cid, arenaconf.storages.room, -1)
	setPlayerStorageValue(cid, arenaconf.storages.level, -1)
	setGlobalStorageValue(arenaconf.storages.busy, -1)
	if getCreatureByName(arenaconf.boss[level][room]) ~= nil then
		doRemoveCreature(getCreatureByName(arenaconf.boss[level][room]), false)
	end
	doTeleportThing(cid,  arenaconf.position["kick"])
elseif room == 10 and isCreature(getCreatureByName(arenaconf.boss[level][10])) == false then
	setPlayerStorageValue(cid, arenaconf.storages.room, -1)
	setPlayerStorageValue(cid, arenaconf.storages.level_completed, level)
	setPlayerStorageValue(cid, arenaconf.storages.level, -1)
	setGlobalStorageValue(arenaconf.storages.busy, -1)
	doTeleportThing(cid,  arenaconf.position["rewards"])
elseif room < 10 and item.actionid ~= 42300 and isCreature(getCreatureByName(arenaconf.boss[level][room])) == false then
	setPlayerStorageValue(cid, arenaconf.storages.room, room+1)
	room = room+1
	setGlobalStorageValue(arenaconf.storages.busy, 1)
	local pos = arenaconf.position[room]
	doCreateMonster(arenaconf.boss[level][room], pos)
	doTeleportThing(cid, {x = (pos.x+1), y = pos.y, z = pos.z})
elseif item.actionid == 42300 then
	local pos = arenaconf.position[room]
	doCreateMonster(arenaconf.boss[level][room], pos)
	doTeleportThing(cid, {x = (pos.x+1), y = pos.y, z = pos.z})
end
return true
end

Crie um arquivo chamado "arena globet.lua" e adicione:

STORAGE_GLOBET = {arenaconf.storage_init+6, arenaconf.storage_init+7, arenaconf.storage_init+8}
function onStepIn(cid, item, position, fromPosition)
local gobletPos = getThingPos(item.uid)
level = getPlayerStorageValue(cid, arenaconf.storages.level_completed)
glob = getPlayerStorageValue(cid, STORAGE_GLOBET[level])
if item.actionid == 42360 and glob == -1 then
	if level == 1 then
		setPlayerStorageValue(cid, STORAGE_GLOBET[1], 1)
		local goblet = doCreateItemEx(5807, 1)
		doItemSetAttribute(goblet, "description", "It is given to the courageous victor of the barbarian arena greenhorn difficulty.\nAwarded to " .. getCreatureName(cid) .. ".")
		doTileAddItemEx({x=gobletPos.x,y=gobletPos.y-1,z=gobletPos.z}, goblet)
	end
elseif item.actionid == 42370 and glob == -1 then
	if level == 2 then
		setPlayerStorageValue(cid, STORAGE_GLOBET[2], 1)
		local goblet = doCreateItemEx(5806, 1)
		doItemSetAttribute(goblet, "description", "It is given to the courageous victor of the barbarian arena scrapper difficulty.\nAwarded to " .. getCreatureName(cid) .. ".")
		doTileAddItemEx({x=gobletPos.x,y=gobletPos.y-1,z=gobletPos.z}, goblet)
	end
elseif item.actionid == 42380 and glob == -1 then
	if level == 3 then
		setPlayerStorageValue(cid, STORAGE_GLOBET[3], 1)
		local goblet = doCreateItemEx(5805, 1)
		doItemSetAttribute(goblet, "description", "It is given to the courageous victor of the barbarian arena warlord difficulty.\nAwarded to " .. getCreatureName(cid) .. ".")
		doTileAddItemEx({x=gobletPos.x,y=gobletPos.y-1,z=gobletPos.z}, goblet)
	end
end
doTransformItem(item.uid, item.itemid - 1)
return TRUE
end

function onStepOut(cid, item, pos)
doTransformItem(item.uid, item.itemid + 1)
return TRUE
end

Vá no actions.xml e adicione:

<action actionid="42357" event="script" value="global/arena doors.lua"/>
<action actionid="42366" event="script" value="global/arena doors.lua"/>
<action actionid="42376" event="script" value="global/arena doors.lua"/>
<action actionid="42386" event="script" value="global/arena doors.lua"/>
<action actionid="42361" event="script" value="global/arena presentbox.lua"/>
<action actionid="42362" event="script" value="global/arena sword.lua"/>
<action actionid="42363" event="script" value="global/arena axe.lua"/>
<action actionid="42364" event="script" value="global/arena club.lua"/>
<action actionid="42365" event="script" value="global/arena backpack.lua"/>
<action actionid="42371" event="script" value="global/arena presentbox.lua"/>
<action actionid="42372" event="script" value="global/arena sword.lua"/>
<action actionid="42373" event="script" value="global/arena axe.lua"/>
<action actionid="42374" event="script" value="global/arena club.lua"/>
<action actionid="42375" event="script" value="global/arena backpack.lua"/>
<action actionid="42381" event="script" value="global/arena presentbox.lua"/>
<action actionid="42382" event="script" value="global/arena sword.lua"/>
<action actionid="42383" event="script" value="global/arena axe.lua"/>
<action actionid="42384" event="script" value="global/arena club.lua"/>
<action actionid="42385" event="script" value="global/arena backpack.lua"/>

Crie um arquivo chamado "arena doors.lua" e adicione nele:

function onUse(cid, item, fromPosition, itemEx, toPosition)
   local cidPosition = getCreaturePosition(cid)
   if item.actionid ~= 42357 then
       if (item.actionid == 42366 and getPlayerStorageValue(cid, arenaconf.storages.level_completed) == 1) or (item.actionid == 42376 and getPlayerStorageValue(cid, arenaconf.storages.level_completed) == 2) or (item.actionid == 42386 and getPlayerStorageValue(cid, arenaconf.storages.level_completed) == 3) then
           if cidPosition.x < toPosition.x then
               doTeleportThing(cid, {x=toPosition.x+1,y=toPosition.y,z=toPosition.z}, TRUE)
           else
               doTeleportThing(cid, {x=toPosition.x-1,y=toPosition.y,z=toPosition.z}, TRUE)
           end
           return TRUE
       else
           doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not enter room.")
           return TRUE
       end
   elseif (item.actionid == 42357 and getPlayerStorageValue(cid, arenaconf.storages.level) ~= -1 and getGlobalStorageValue(arenaconf.storages.busy) == -1) then
       setGlobalStorageValue(arenaconf.storages.busy, 1)
       if cidPosition.x < toPosition.x then
           doTeleportThing(cid, {x=toPosition.x+1,y=toPosition.y,z=toPosition.z}, TRUE)
       else
           doTeleportThing(cid, {x=toPosition.x-1,y=toPosition.y,z=toPosition.z}, TRUE)
       end
       return TRUE
   else
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must pay first.")
       return TRUE
   end
   return FALSE
end

Crie um arquivo chamdo "arena sword.lua" e adicione:

STORAGE_CHEST = {arenaconf.storage_init+3, arenaconf.storage_init+4, arenaconf.storage_init+5}
function onUse(cid, item, fromPosition, itemEx, toPosition)
level = getPlayerStorageValue(cid, arenaconf.storages.level_completed)
if getPlayerStorageValue(cid, STORAGE_CHEST[level]) == -1 then
	setPlayerStorageValue(cid, STORAGE_CHEST[level], 1)
	doPlayerAddItem(cid, getItemIdByName(arenaconf.reward["sword"][level]))
	return true
end
return true
end

Crie um arquivo com o nome de "arena axe.lua" e adicione:

STORAGE_CHEST = {arenaconf.storage_init+3, arenaconf.storage_init+4, arenaconf.storage_init+5}
function onUse(cid, item, fromPosition, itemEx, toPosition)
level = getPlayerStorageValue(cid, arenaconf.storages.level_completed)
if getPlayerStorageValue(cid, STORAGE_CHEST[level]) == -1 then
	setPlayerStorageValue(cid, STORAGE_CHEST[level], 1)
	doPlayerAddItem(cid, getItemIdByName(arenaconf.reward["axe"][level]))
	return true
end
return true
end

Crie um arquivo chamado "arena club.lua" e coloque nele:

STORAGE_CHEST = {arenaconf.storage_init+3, arenaconf.storage_init+4, arenaconf.storage_init+5}
function onUse(cid, item, fromPosition, itemEx, toPosition)
level = getPlayerStorageValue(cid, arenaconf.storages.level_completed)
if getPlayerStorageValue(cid, STORAGE_CHEST[level]) == -1 then
	setPlayerStorageValue(cid, STORAGE_CHEST[level], 1)
	doPlayerAddItem(cid, getItemIdByName(arenaconf.reward["club"][level]))
	return true
end
return true
end

Crie um arquivo chamado "arena presentbox.lua" e coloque isso nele:

STORAGE_CHEST = {arenaconf.storage_init+3, arenaconf.storage_init+4, arenaconf.storage_init+5}
function onUse(cid, item, fromPosition, itemEx, toPosition)
level = getPlayerStorageValue(cid, arenaconf.storages.level_completed)
if getPlayerStorageValue(cid, STORAGE_CHEST[level]) == -1 then
	setPlayerStorageValue(cid, STORAGE_CHEST[level], 1)
	pb = doPlayerAddItem(cid, 1990)
	for t = 1,#arenaconf.reward["presentbox"][level] do
		doAddContainerItem(pb, getItemIdByName(arenaconf.reward["presentbox"][level][t][1]), arenaconf.reward["presentbox"][level][t][2])
	end
	return true
end
return true
end

Crie um arquivo chamdo "arena backpack.lua" e coloque isso nele:

STORAGE_CHEST = {arenaconf.storage_init+3, arenaconf.storage_init+4, arenaconf.storage_init+5}
function onUse(cid, item, fromPosition, itemEx, toPosition)
level = getPlayerStorageValue(cid, arenaconf.storages.level_completed)
if getPlayerStorageValue(cid, STORAGE_CHEST[level]) == -1 then
	setPlayerStorageValue(cid, STORAGE_CHEST[level], 1)
	bp = doPlayerAddItem(cid, 7342)
	for t = 1,#arenaconf.reward["backpack"][level] do
		doAddContainerItem(bp, getItemIdByName(arenaconf.reward["backpack"][level][t][1]), arenaconf.reward["backpack"][level][t][2])
	end
	return true
end
return true
end

 

Agora neste código é que você configurará informações como a posição das salas dos bixos, a sala de recompensas, pra onde o player será kicado quando desistir e todo o resto:

arenaconf = {}
arenaconf.storage_init = 60000
arenaconf.storages = {}
arenaconf.storages.busy = arenaconf.storage_init -- global storage
arenaconf.storages.level = arenaconf.storage_init
arenaconf.storages.level_completed = arenaconf.storage_init+1
arenaconf.storages.room = arenaconf.storage_init+2
arenaconf.cost = {1000, 5000, 10000}
arenaconf.levelname = {"Greenshore", "Scrapper", "Warlord"}
arenaconf.boss = {}
arenaconf.boss[1] = {"Achad", "Axeitus Headbanger", "Bloodpaw", "Bovinus", "Colerian the Barbarian", "Cursed Gladiator", "Frostfur", "Orcus the Cruel", "Rocky", "The Hairy One"}
arenaconf.boss[2] = {"Avalanche", "Drasilia", "Grimgor Guteater", "Kreebosh the Exile", "Slim", "Spirit of Earth", "Spirit of Fire", "Spirit of Water", "The Dark Sorcerer", "The Hag"}
arenaconf.boss[3] = {"Darakan the Executioner", "Deathbringer", "Fallen Mooh'Tah Master Ghar", "Gnorre Chyllson", "Norgle Glacierbeard", "Svoren the Mad", "The Masked Marauder", "The Obliverator", "The Pit Lord", "Webster"}
arenaconf.position = {}
arenaconf.position[1] = {x = 1059, y = 1067, z = 7}
arenaconf.position[2] = {x = 1044, y = 1067, z = 7}
arenaconf.position[3] = {x = 1030, y = 1067, z = 7}
arenaconf.position[4] = {x = 1016, y = 1067, z = 7}
arenaconf.position[5] = {x = 1053, y = 1051, z = 7}
arenaconf.position[6] = {x = 1038, y = 1051, z = 7}
arenaconf.position[7] = {x = 1023, y = 1051, z = 7}
arenaconf.position[8] = {x = 1045, y = 1039, z = 7}
arenaconf.position[9] = {x = 1030, y = 1039, z = 7}
arenaconf.position[10] = {x = 1037, y = 1025, z = 7}
arenaconf.position["kick"] = {x = 32222, y = 31094, z = 7}
arenaconf.position["rewards"] = {x = 1071, y = 1049, z = 6}
arenaconf.reward = {}
arenaconf.reward["presentbox"] = {}
arenaconf.reward["presentbox"][1] = {{"Piggy Bank", 1}, {"Surprise Bag", 1}, {"Bar of Chocolate", 1}, {"Candy", 10}, {"Ice Cream", 1}}
arenaconf.reward["presentbox"][2] = {{"Baby Seal Doll", 1}, {"Bar of Chocolate", 1}, {"Ice Cream", 1}, {"Candy", 10}}
arenaconf.reward["presentbox"][3] = {{"Panda Teddy", 1}, {"Bar of Chocolate", 1}, {"Ice Cream", 1}, {"Candy", 10}}
arenaconf.reward["backpack"] = {}
arenaconf.reward["backpack"][1]   = {{"Sniper Arrow", 100}, {"Onyx Arrow", 100}}
arenaconf.reward["backpack"][2]   = {{"great fireball rune", 50}, {"heavy magic missile rune", 50}, {"Power Bolt", 200}, {"Onyx Arrow", 100}}
arenaconf.reward["backpack"][3]   = {{"Infernal Bolt", 100}, {"Mastermind Potion", 1}, {"Bullseye Potion", 1}, {"Sudden Death Rune", 50}, {"Ultimate Healing Rune", 50}}
arenaconf.reward["axe"] = {"Headchopper", "Heroic Axe", "Royal Axe"}
arenaconf.reward["sword"] = {"Blacksteel Sword", "Mystic Blade", "Justice Seeker"}
arenaconf.reward["club"] = {"Orcish Maul", "Cranial Basher", "Blessed Sceptre"}

Esse código você colocará dentro da pasta lib com o nome de arena.lua, depois disso você tem que pegar um código qualquer desta pasta e adicionar isso no começo ou no final:

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

 

Clique aqui para baixar o mapa com os actionids já configurados

 

edit: tinha um pequeno problema com o arquivo arena doors.lua que já foi resolvido

Editado por Eventide
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...