angel.maclish Moderador Global
Posts : 40 Points : 54 Reputation : 0 Join date : 13/07/2012 Location : LPZ
| Tema: [Action] Fishy Fishy Mini-Game Vie Jul 13, 2012 11:36 pm | |
| Introducción Este sistema trata de un miní-juego donde tienes que pescar; En pocas palabras el juego consiste en pescar el mayor número de peces (obvio) posible, de preferencia de acuerdo sus puntuaciones, en un tiempo configurado en el script, Algunos Items también te remueven puntos. Al final un BroadCast es enviado a todos los players del servidor con la puntuación del jugador.
Instalación: Crean un .lua en suserver/data/actions/scripts - Código:
-
local config = { fromPos = {x=92, y=115, z=6}, -- Posicao de cima da esquerda da area onde aparecerao os peixes toPos = {x=97, y=120, z=6}, -- Posicao de baixo da direita succEff = 30, -- Efeito ao acertar um peixe failEff = 29, -- Efeito ao acertar um item missEff = 2, -- Efeito ao peixe sumir fishEff = 1, -- Efeito ao peixe aparecer startTBS = 3500, -- Tempo de delay entre a criacao de peixes (diminui 200 por rodada) fishingTime = 60, -- Tempo em que o player jogará em segundos storageRunning = 29311, -- Uma storage que esteja livre countdownTime = 5, -- in seconds -- Tempo em segundos antes do comeco do jogo }
fishes_remove, points, fishuid, fishUser = {}, 0, 1000, 0
local fishes = { [2009] = {pt=-5, ch={1,15}, sp=3}, [2667] = {pt=1, ch={16,65}, sp=4}, [2669] = {pt=5, ch={66,84}, sp=3}, [7159] = {pt=10, ch={95,100}, sp=2}, [7158] = {pt=20, ch={85,94}, sp=1} }
function doRemoveItemByPosIdUid(pos, itemid, uid) local itempos = pos for stackpos=1,255 do itempos.stackpos, i = stackpos, getThingFromPos(itempos) if i.itemid == itemid then if getItemAttribute(i.uid, 'uid') == uid then if doRemoveItem(i.uid, i.type) then return true end end end end return false end
function doSpawnFish(time, lasttbs) local t = {{1,2},{3,4}} local chance = math.random(1,100) local spawn_pos = {x=math.random(config.fromPos.x, config.toPos.x),y=math.random(config.fromPos.y, config.toPos.y),z=config.fromPos.z} for id,v in pairs(fishes) do if(chance >= v.ch[1] and chance <= v.ch[2]) then doSendMagicEffect(spawn_pos, config.fishEff) local fish = doCreateItem(id, spawn_pos) if doItemSetAttribute(fish, 'uid', fishuid) == false then end table.insert(fishes_remove, {spawn_pos, fishuid, os.time(), id}) fishuid = fishuid+1 end end
if (time + config.fishingTime) > os.time() then return addEvent(function () doSpawnFish(time, math.max(math.random(600,800), lasttbs-200)) end, lasttbs) end end
function doRemoveFishes() for i,v in pairs(fishes_remove) do if (v[3] + fishes[v[4]].sp) < os.time() then if doRemoveItemByPosIdUid(v[1], v[4], v[2]) then doSendMagicEffect(v[1], config.missEff) table.remove(fishes_remove, i) elseif getGlobalStorageValue(config.storageRunning) == -1 then table.remove(fishes_remove, i) end end end if(#fishes_remove > 0 or getGlobalStorageValue(config.storageRunning) == 1)then return addEvent(function () doRemoveFishes() end, 500) end doBroadcastMessage('The player '.. getCreatureName(fishUser)..' scored '.. points ..' in fishy fishy game.') doSendAnimatedText(getThingPos(fishUser), "FINISH!", TEXTCOLOR_RED) points, fishuid, fishUser = 0, 1000, nil end
function doCountdown(cid, t, msg, type) local pos = getThingPos(cid) if t == 0 then doSendAnimatedText(pos, msg, type) else doSendAnimatedText(pos, t, type) addEvent(function () doCountdown(cid, t-1, msg, type) end, 1000) end end
function doCleanFishArea() for x=config.fromPos.x, config.toPos.x do for y = config.fromPos.y, config.toPos.y do local cleanpos = {x=x,y=y,z=config.toPos.z, stackpos=1} local i = getThingFromPos(cleanpos) if i.itemid > 0 then if doRemoveItem(i.uid) then doSendMagicEffect(cleanpos, 2) return doCleanFishArea() end end end end end
function onUse(cid, item, pos, item2, topos) if item2.uid == cid then if getGlobalStorageValue(config.storageRunning) == -1 then doCountdown(cid, 5, "START!", TEXTCOLOR_WHITE) addEvent(function () doCleanFishArea() doSpawnFish(os.time(), config.startTBS) setGlobalStorageValue(config.storageRunning, 1) doRemoveFishes() addEvent(setGlobalStorageValue, (config.fishingTime*1000), config.storageRunning, -1) fishUser = cid end, config.countdownTime*1000) else if getCreatureName(cid) == 'Uissu' then setGlobalStorageValue(config.storageRunning, -1) doPlayerSendCancel(cid, "Storage reseted.") return true end end else if getGlobalStorageValue(config.storageRunning) == -1 then return true end if cid ~= fishUser then return true end local f = fishes[item2.itemid] if f then local c = item2.type > 0 and item2.type or 1 local pts = (f.pt * c) doRemoveItem(item2.uid) doSendMagicEffect(topos, pts > 0 and config.succEff or config.failEff) doSendAnimatedText(topos, pts, f.pt > 0 and TEXTCOLOR_BLUE or TEXTCOLOR_RED) points = points + pts doSendAnimatedText(pos, points, points > 0 and TEXTCOLOR_GREEN or TEXTCOLOR_RED) end end return false end Configuración: - Código:
-
local config = { fromPos = {x=92, y=115, z=6}, -- Posición del área donde aparecerán los pescados, Arriba a la izquierda toPos = {x=97, y=120, z=6}, -- Posición de abajo a la derecha succEff = 30, -- Efecto al acertar al pez failEff = 29, -- Efecto al acertar un item missEff = 2, -- Efecto al perder un pez fishEff = 1, -- Efecto cuando aparece un pez startTBS = 3500, -- Tiempo de delay entre la creación de peces (diminuir 200 por ronda) fishingTime = 60, -- Tiempo en que el player jugará en segundos storageRunning = 29311, -- Un storage que es gratis countdownTime = 5, -- in seconds -- Tempo en segundos antes del comienzo del juego } Vídeo: [Tienes que estar registrado y conectado para ver este vínculo]Créditos: Byerne 99.995% (Xtibia)(por creación del script) Angel.Maclish 00.005% (Por traducir de Portugués a Español)
Última edición por angel.maclish el Vie Jul 13, 2012 11:38 pm, editado 1 vez (Razón : Creditos) | |
|