MA

Genius Movement.

Por MatheusGlad, 08 de fev. de 2012 em Actions e Talkactions

script
15
3.1k
MatheusGladM
08 de fevereiro de 2012 às 23:53



data/movements/scripts/Genius.lua:

CurrentSteps = {}
CurrentSequence = {}

PuzzleGeniusConfig = {
	centerPlayerPos = {x=988,y=985,z=7},
	effectsid = {
			[9562] = {1, 0},
			[9563] = {0, 1},
			[9564] = {-1, 0},
			[9565] = {0, -1}
	},

	appearInterval = 1,
	disapear = 0.6,
	backPos = {x=987,y=982,z=7},

	rewardPos = {x=995,y=988,z=6},
	roundTimes = 100,

}
CurrentSequence = {}

PuzzleGenius = {}


function randomIndexFromTable(tab)
	local tb = {}
	for i,x in pairs(tab) do
			table.insert(tb, i)
	end
	return tb[math.random(1, #tb)]
end

function tileEffect(tileid, pos, int)
local tile = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=0})
doItemSetAttribute(tile.uid, "aid", 6661)
local a = doCreateItem(tileid, pos)
addEvent(function() local tile = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1}).uid doRemoveItem(tile, 1) end, int*1000)
end

function PuzzleGenius:ExecuteSequence(cid)
	if #CurrentSequence >= PuzzleGeniusConfig.roundTimes then
			doTeleportThing(cid, PuzzleGeniusConfig.rewardPos)
			doPlayerSetNoMove(cid, false)
			CurrentSteps = {}
			CurrentSequence = {}
			return true
	end
	table.insert(CurrentSequence, randomIndexFromTable(PuzzleGeniusConfig.effectsid))
	for i,x in ipairs(CurrentSequence) do
			addEvent(tileEffect, PuzzleGeniusConfig.appearInterval*i*1000, x, {x=PuzzleGeniusConfig.centerPlayerPos.x+PuzzleGeniusConfig.effectsid[x][1], y=PuzzleGeniusConfig.centerPlayerPos.y+PuzzleGeniusConfig.effectsid[x][2], z=PuzzleGeniusConfig.centerPlayerPos.z},PuzzleGeniusConfig.disapear)
	end
	addEvent(doPlayerSetNoMove, (PuzzleGeniusConfig.appearInterval*#CurrentSequence+PuzzleGeniusConfig.disapear)*1000, cid, false)
end

function PuzzleGenius:Check(cid, currentSteps)
	if currentSteps[#currentSteps] == CurrentSequence[#currentSteps] then
			return true
	end
	return false
end

function onStepIn(cid, item, pos, fromPos)
if pos.x == PuzzleGeniusConfig.centerPlayerPos.x and pos.y == PuzzleGeniusConfig.centerPlayerPos.y then
	 if #CurrentSequence < 1 then
		 doPlayerSetNoMove(cid, true)
		 return PuzzleGenius:ExecuteSequence(cid)
	 else
		 return false
	 end
end

local coordinates = {pos.x-fromPos.x, pos.y-fromPos.y}
for i,x in pairs(PuzzleGeniusConfig.effectsid) do
	if x[1] == coordinates[1] and x[2] == coordinates[2] then
		table.insert(CurrentSteps, i)
		if PuzzleGenius:Check(cid, CurrentSteps) then
			doCreateItem(i, {x=PuzzleGeniusConfig.centerPlayerPos.x+coordinates[1], y=PuzzleGeniusConfig.centerPlayerPos.y+coordinates[2], z=PuzzleGeniusConfig.centerPlayerPos.z})
		end
	end
end
if PuzzleGenius:Check(cid, CurrentSteps) then
	doTeleportThing(cid, fromPos, true)
	if #CurrentSteps == #CurrentSequence then
		doPlayerSetNoMove(cid, true)
		CurrentSteps = {}
		addEvent(function() PuzzleGenius:ExecuteSequence(cid) end, 500)
	end
else
	doTeleportThing(cid, PuzzleGeniusConfig.backPos)
	CurrentSteps = {}
	CurrentSequence = {}
end
return TRUE
end

function onStepOut(cid, item, pos, fromPos)
local tile = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1})
for i,x in pairs(PuzzleGeniusConfig.effectsid) do
	if i == tile.itemid then
		addEvent(function() local tilee = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1}).uid doRemoveItem(tilee, 1) end, 100)
		break
	end
end
return TRUE
end



tags movements.xml:

<movevent type="StepIn" actionid="6661" event="script" value="Genius.lua"/>
<movevent type="StepOut" actionid="6661" event="script" value="Genius.lua"/>



Mapa:

1in0c2.png

A - Action ID 6661.
B - Teleport que teleporta para A, centerPlayerPos no script.

As pedras ou qlqr outro item que voce quizer botar sao obrigatorias para nao ocorrerem bugs,

E os sqm dentro das pedras devem ter a caracteristica de nao poder logar.

Script antigo... whatever postei nada pra fazer.

Editado Fevereiro 8 por MatheusMkalo

AnneMottaA
08 de fevereiro de 2012 às 23:55

oque isso faz exatamente ? =.=

 

 

@ edited

 

opa agora tem video rs

Editado Fevereiro 9 por AnneMotta

HisashiitYamagutiH
09 de fevereiro de 2012 às 00:03

Matheus dando uma aula de como ser mito no jogo, xD.

 

Falando sério:

Muito legal a sua contribuição para o xtibia, logo logo estarei testando aqui...

Ainda mais tem vídeo, isso é uma coisa inovadora nos scripts, pois poucos postados aqui no xtibia tem isso.

bepokemonB
09 de fevereiro de 2012 às 00:21

@Matheus

Isso vai para o Concurso #SDS?

MatheusGladM
09 de fevereiro de 2012 às 01:06

Sim

VodkartV
09 de fevereiro de 2012 às 16:28

nossa mkalo sempre inovando com suas idéias geniais uhauahauua

sempre gostei desse jogo,o código está muito bem formatado,parabéns amigo!

com certeza vc terá meu voto no concurso ._.

sucesso parceiro,fica com deus

 

REP+

noobinhuN
09 de fevereiro de 2012 às 23:45

ola moco

 

parabens pelo codigo ok

 

e o vodkart ainda acessa aqui, parabens tb cara

 

obg

MatheusGladM
10 de fevereiro de 2012 às 11:40

O que fazes aki andy gostoso.

 

Concertou o pc que tem windows ja?

3 meses depois...
MapperWolfM
02 de maio de 2012 às 19:42

Muito bom cara. Sem comentarios ! ;p sempre inovador...

2 meses depois...
pkemommP
11 de julho de 2012 às 12:47

Cara, inceramente, eu não consegui compreender como faço para eu colocar pra funcionar... Eu coloquei os scripts recomendados por vc.

 

CurrentSteps = {}

CurrentSequence = {}

PuzzleGeniusConfig = {

centerPlayerPos = {x=988,y=985,z=7},

effectsid = {

[9562] = {1, 0},

[9563] = {0, 1},

[9564] = {-1, 0},

[9565] = {0, -1}

},

appearInterval = 1,

disapear = 0.6,

backPos = {x=987,y=982,z=7},

rewardPos = {x=995,y=988,z=6},

roundTimes = 100,

}

CurrentSequence = {}

PuzzleGenius = {}

 

function randomIndexFromTable(tab)

local tb = {}

for i,x in pairs(tab) do

table.insert(tb, i)

end

return tb[math.random(1, #tb)]

end

function tileEffect(tileid, pos, int)

local tile = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=0})

doItemSetAttribute(tile.uid, "aid", 6661)

local a = doCreateItem(tileid, pos)

addEvent(function() local tile = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1}).uid doRemoveItem(tile, 1) end, int*1000)

end

function PuzzleGenius:ExecuteSequence(cid)

if #CurrentSequence >= PuzzleGeniusConfig.roundTimes then

doTeleportThing(cid, PuzzleGeniusConfig.rewardPos)

doPlayerSetNoMove(cid, false)

CurrentSteps = {}

CurrentSequence = {}

return true

end

table.insert(CurrentSequence, randomIndexFromTable(PuzzleGeniusConfig.effectsid))

for i,x in ipairs(CurrentSequence) do

addEvent(tileEffect, PuzzleGeniusConfig.appearInterval*i*1000, x, {x=PuzzleGeniusConfig.centerPlayerPos.x+PuzzleGeniusConfig.effectsid[x][1], y=PuzzleGeniusConfig.centerPlayerPos.y+PuzzleGeniusConfig.effectsid[x][2], z=PuzzleGeniusConfig.centerPlayerPos.z},PuzzleGeniusConfig.disapear)

end

addEvent(doPlayerSetNoMove, (PuzzleGeniusConfig.appearInterval*#CurrentSequence+PuzzleGeniusConfig.disapear)*1000, cid, false)

end

function PuzzleGenius:Check(cid, currentSteps)

if currentSteps[#currentSteps] == CurrentSequence[#currentSteps] then

return true

end

return false

end

function onStepIn(cid, item, pos, fromPos)

if pos.x == PuzzleGeniusConfig.centerPlayerPos.x and pos.y == PuzzleGeniusConfig.centerPlayerPos.y then

if #CurrentSequence < 1 then

doPlayerSetNoMove(cid, true)

return PuzzleGenius:ExecuteSequence(cid)

else

return false

end

end

local coordinates = {pos.x-fromPos.x, pos.y-fromPos.y}

for i,x in pairs(PuzzleGeniusConfig.effectsid) do

if x[1] == coordinates[1] and x[2] == coordinates[2] then

table.insert(CurrentSteps, i)

if PuzzleGenius:Check(cid, CurrentSteps) then

doCreateItem(i, {x=PuzzleGeniusConfig.centerPlayerPos.x+coordinates[1], y=PuzzleGeniusConfig.centerPlayerPos.y+coordinates[2], z=PuzzleGeniusConfig.centerPlayerPos.z})

end

end

end

if PuzzleGenius:Check(cid, CurrentSteps) then

doTeleportThing(cid, fromPos, true)

if #CurrentSteps == #CurrentSequence then

doPlayerSetNoMove(cid, true)

CurrentSteps = {}

addEvent(function() PuzzleGenius:ExecuteSequence(cid) end, 500)

end

else

doTeleportThing(cid, PuzzleGeniusConfig.backPos)

CurrentSteps = {}

CurrentSequence = {}

end

return TRUE

end

function onStepOut(cid, item, pos, fromPos)

local tile = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1})

for i,x in pairs(PuzzleGeniusConfig.effectsid) do

if i == tile.itemid then

addEvent(function() local tilee = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1}).uid doRemoveItem(tilee, 1) end, 100)

break

end

end

return TRUE

end

 

 

 

Entao, adicionei a Tag :

 

<movevent type="StepIn" actionid="6661" event="script" value="Genius.lua">

<movevent type="StepOut" actionid="6661" event="script" value="Genius.lua">

 

 

Pois entao adicionei no meu servidor e coloquei no mapa :

 

 

>semttuloxzz.png</noscript>

 

 

Ai eu modifiquei ele para :

 

 

CurrentSteps = {}

CurrentSequence = {}

PuzzleGeniusConfig = {

centerPlayerPos = {x=10181,y=10004,z=12},

effectsid = {

[9562] = {1, 0},

[9563] = {0, 1},

[9564] = {-1, 0},

[9565] = {0, -1}

},

appearInterval = 1,

disapear = 0.6,

backPos = {x=10182,y=10000,z=12},

rewardPos = {x=10181,y=10004,z=12},

roundTimes = 100,

}

CurrentSequence = {}

PuzzleGenius = {}

 

function randomIndexFromTable(tab)

local tb = {}

for i,x in pairs(tab) do

table.insert(tb, i)

end

return tb[math.random(1, #tb)]

end

function tileEffect(tileid, pos, int)

local tile = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=0})

doItemSetAttribute(tile.uid, "aid", 6661)

local a = doCreateItem(tileid, pos)

addEvent(function() local tile = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1}).uid doRemoveItem(tile, 1) end, int*1000)

end

function PuzzleGenius:ExecuteSequence(cid)

if #CurrentSequence >= PuzzleGeniusConfig.roundTimes then

doTeleportThing(cid, PuzzleGeniusConfig.rewardPos)

doPlayerSetNoMove(cid, false)

CurrentSteps = {}

CurrentSequence = {}

return true

end

table.insert(CurrentSequence, randomIndexFromTable(PuzzleGeniusConfig.effectsid))

for i,x in ipairs(CurrentSequence) do

addEvent(tileEffect, PuzzleGeniusConfig.appearInterval*i*1000, x, {x=PuzzleGeniusConfig.centerPlayerPos.x

+PuzzleGeniusConfig.effectsid[x][1], y=PuzzleGeniusConfig.centerPlayerPos.y+PuzzleGeniusConfig.effectsid[x][2],

z=PuzzleGeniusConfig.centerPlayerPos.z},PuzzleGeniusConfig.disapear)

end

addEvent(doPlayerSetNoMove, (PuzzleGeniusConfig.appearInterval*#CurrentSequence+PuzzleGeniusConfig.disapear)*1000, cid, false)

end

function PuzzleGenius:Check(cid, currentSteps)

if currentSteps[#currentSteps] == CurrentSequence[#currentSteps] then

return true

end

return false

end

function onStepIn(cid, item, pos, fromPos)

if pos.x == PuzzleGeniusConfig.centerPlayerPos.x and pos.y == PuzzleGeniusConfig.centerPlayerPos.y then

if #CurrentSequence < 1 then

doPlayerSetNoMove(cid, true)

return PuzzleGenius:ExecuteSequence(cid)

else

return false

end

end

local coordinates = {pos.x-fromPos.x, pos.y-fromPos.y}

for i,x in pairs(PuzzleGeniusConfig.effectsid) do

if x[1] == coordinates[1] and x[2] == coordinates[2] then

table.insert(CurrentSteps, i)

if PuzzleGenius:Check(cid, CurrentSteps) then

doCreateItem(i, {x=PuzzleGeniusConfig.centerPlayerPos.x+coordinates[1], y=PuzzleGeniusConfig.centerPlayerPos.y

+coordinates[2], z=PuzzleGeniusConfig.centerPlayerPos.z})

end

end

end

if PuzzleGenius:Check(cid, CurrentSteps) then

doTeleportThing(cid, fromPos, true)

if #CurrentSteps == #CurrentSequence then

doPlayerSetNoMove(cid, true)

CurrentSteps = {}

addEvent(function() PuzzleGenius:ExecuteSequence(cid) end, 500)

end

else

doTeleportThing(cid, PuzzleGeniusConfig.backPos)

CurrentSteps = {}

CurrentSequence = {}

end

return TRUE

end

function onStepOut(cid, item, pos, fromPos)

local tile = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1})

for i,x in pairs(PuzzleGeniusConfig.effectsid) do

if i == tile.itemid then

addEvent(function() local tilee = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1}).uid doRemoveItem(tilee, 1) end, 100)

break

end

end

return TRUE

end

 

 

Oq edito ? Oque eu modifico ? Me ajuda Por Favor.

Editado Julho 11 por pkemomm

3 semanas depois...
qweqweQ
30 de julho de 2012 às 22:57

removido.

Editado Setembro 15 por Demonbholder

1 mês depois...
25 de agosto de 2012 às 14:31

Putz esse cara aki /\ kk

victormatosV
25 de agosto de 2012 às 17:03

esse script não faz nada de mais.

1 mês depois...
grokuG
15 de setembro de 2012 às 17:34

Crendeuspai adoro esse tipo de joguinho que tem que memorizar ee.eeeeee

3 anos depois...
4sharedddd4
04 de janeiro de 2016 às 03:30

sei que já faz tempo o post, desculpe. achei muito interessante... como faço para ele realizar tal ação depois de "x" rodadas, tipo doTelepor... depois q ele acertou 6 vezes, alguém pode ajudar?