GA
action

Ajuda com esse script.

Por gabriel28, 05 de jan. de 2016 em Scripts

resolvido
script
15
2.7k
gabriel28G
06 de janeiro de 2016 às 13:30

Estou com um script (Talkaction) feito por Daniehcv, deste fórum. Ele consiste no seguinte: Permite que vocações summonem quantidades diferentes de monstros.

Está funcionando perfeitamente, o único problema é que summona todos os monstros que eu por, no mesmo level e com usando a mesma quantidade de mana. Queria que alguém ajeitasse isso pra mim, pondo mais ou menos uma tabela onde ficaria o nome dos monstros com seu level e quantidade de mana pra conjuração.

Ex:
{bear, wolf, polar bear: levelmin=20, mana=100},

{dragon, giant spider, orc warlord: levelmin=80, mana 700}

 

E se possível, transformar em magia.

 

Se alguém puder ajudar, agradeço.

Segue o script:

 

 

local mana = 50 --custo de mana
local storage = 79845 --storage para o exhaustion
local tempo = 5 --em segundos

local monsters = {
[1] = {summons = {"rat", "dragon"}, maxSummons = 2, minLevel = 10},
[2] = {summons = {"rat", "dragon"}, maxSummons = 4, minLevel = 10},
[5] = {summons = {"rat", "dragon"}, maxSummons = 4, minLevel = 10},
[6] = {summons = {"rat", "dragon"}, maxSummons = 6, minLevel = 10}
}

function onSay(cid, words, param, channel)
if exhaustion.check(cid, storage) then
doPlayerSendTextMessage(cid, 22, "You are exhausted.")
return true
end
	--Player Status
	local playerpos = getPlayerPosition(cid)

	for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do
		if (param == v)then

			if (monsters[getPlayerVocation(cid)]) and #getCreatureSummons(cid) >= monsters[getPlayerVocation(cid)].maxSummons then
				return doPlayerSendCancel(cid, "Você já tem sumons demais.")
			else
			--Summon
				if getPlayerLevel(cid) < monsters[getPlayerVocation(cid)].minLevel then
					return doPlayerSendCancel(cid, "Level insuficiente.")
				else
					doConvinceCreature(cid, doCreateMonster(param, playerpos))
					doPlayerAddMana(cid, -mana, false)
					exhaustion.set(cid, storage, tempo)
					doSendMagicEffect(playerpos, 2)
				end
			return true
			end
		else
		doPlayerSendCancel(cid, "You can't summon this monster.")
		end
	end
return true
end

 

 


up

rorixR
06 de janeiro de 2016 às 15:30

aqui fera, leve e mana vc modifica la encima

local storage = 79845 --storage para o exhaustion
local tempo = 5 --em segundos

local monsters = {
[1] = {summons = {"rat", "dragon"}, maxSummons = 2, minLevel = 10, mana = 100},
[2] = {summons = {"rat", "dragon"}, maxSummons = 4, minLevel = 10, mana = 100},
[5] = {summons = {"rat", "dragon"}, maxSummons = 4, minLevel = 10, mana = 100},
[6] = {summons = {"rat", "dragon"}, maxSummons = 6, minLevel = 10, mana = 100}
}

function onSay(cid, words, param, channel)
if exhaustion.check(cid, storage) then
doPlayerSendTextMessage(cid, 22, "You are exhausted.")
return true
end
	--Player Status
	local playerpos = getPlayerPosition(cid)

	for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do
		if (param == v)then

			if (monsters[getPlayerVocation(cid)]) and #getCreatureSummons(cid) >= monsters[getPlayerVocation(cid)].maxSummons then
				return doPlayerSendCancel(cid, "Você já tem sumons demais.")
			else
			--Summon
				if getPlayerLevel(cid) < monsters[getPlayerVocation(cid)].minLevel then
					return doPlayerSendCancel(cid, "Level insuficiente.")
				elseif getCreatureMana(cid) < monsters[getPlayerVocation(cid)].mana then
					return doPlayerSendCancel(cid, "Level insuficiente.")
				end
					doConvinceCreature(cid, doCreateMonster(param, playerpos))
					doPlayerAddMana(cid, -mana, false)
					exhaustion.set(cid, storage, tempo)
					doSendMagicEffect(playerpos, 2)
				
			return true
			end
		else
		doPlayerSendCancel(cid, "You can't summon this monster.")
		end
	end
return true
end
gabriel28G
06 de janeiro de 2016 às 20:36

O problema que tem nesse jeito, é que ambos, rat e dragon, serão sumonados no level 10 e gastando 100 de mana.

Gostaria que fosse dessa forma como exemplifiquei: {bear, wolf, polar bear: levelmin=20, mana=100},

{dragon, giant spider, orc warlord: levelmin=80, mana 700}

Nessa forma, os mosnstros ficam meio que divididos em categorias, dai dá pra controlar o level que cada um poderá ser sumonado, sacou?

CaronteC
06 de janeiro de 2016 às 21:56


local storage = 79845 --storage para o exhaustion

local tempo = 5 --em segundos

 

local monsters = {

[1] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 2 },

[2] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4 },

[5] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4 },

[6] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 6 },

}

 

function onSay(cid, words, param, channel)

if exhaustion.check(cid, storage) then

doPlayerSendTextMessage(cid, 22, "You are exhausted.")

return true

end

--Player Status

local playerpos = getPlayerPosition(cid)

param = string.lower(param)

for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do

if (param == k)then

 

if (monsters[getPlayerVocation(cid)]) and #getCreatureSummons(cid) >= monsters[getPlayerVocation(cid)].maxSummons then

return doPlayerSendCancel(cid, "Você já tem sumons demais.")

else

--Summon

if getPlayerLevel(cid) < v.level then

return doPlayerSendCancel(cid, "Level insuficiente.")

elseif getCreatureMana(cid) < k.mana then

return doPlayerSendCancel(cid, "Mana insuficiente.")

end

doConvinceCreature(cid, doCreateMonster(param, playerpos))

doPlayerAddMana(cid, -k.mana, false)

exhaustion.set(cid, storage, tempo)

doSendMagicEffect(playerpos, 2)

 

return true

end

else

doPlayerSendCancel(cid, "You can't summon this monster.")

end

end

return true

end

 

Editado Janeiro 6 por Caronte

gabriel28G
06 de janeiro de 2016 às 22:21
local storage = 79845 --storage para o exhaustion
local tempo = 5 --em segundos

local monsters = {
[1] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 2  },
[2] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[5] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[6] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 6  },
}

function onSay(cid, words, param, channel)
if exhaustion.check(cid, storage) then
doPlayerSendTextMessage(cid, 22, "You are exhausted.")
return true
end
	--Player Status
	local playerpos = getPlayerPosition(cid)

	for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do
		if (param == k)then

			if (monsters[getPlayerVocation(cid)]) and #getCreatureSummons(cid) >= monsters[getPlayerVocation(cid)].maxSummons then
				return doPlayerSendCancel(cid, "Você já tem sumons demais.")
			else
			--Summon
				if getPlayerLevel(cid) < v.level then
					return doPlayerSendCancel(cid, "Level insuficiente.")
				elseif getCreatureMana(cid) < k.mana then
					return doPlayerSendCancel(cid, "Mana insuficiente.")
				end
					doConvinceCreature(cid, doCreateMonster(param, playerpos))
					doPlayerAddMana(cid, -k.mana, false)
					exhaustion.set(cid, storage, tempo)
					doSendMagicEffect(playerpos, 2)
				
			return true
			end
		else
		doPlayerSendCancel(cid, "You can't summon this monster.")
		end
	end
return true
end

 

Dai posso acrescentar mais monstros seguindo a lógica?

CaronteC
06 de janeiro de 2016 às 22:28

 

 

Dai posso acrescentar mais monstros seguindo a lógica?

 

Sim, só copiar a tabela do monstro, e colocar no final, com uma vírgula separando:

{["rat"] = {level = 10, mana = 20},

é só colocar dentro da tabela summons.

 

 

vou editar um negócio no meu post, é que o script só vai funcionar se o parametro estiver em minúsculo.

quando eu editar você substitui lá.

gabriel28G
07 de janeiro de 2016 às 00:00

 

 

Sim, só copiar a tabela do monstro, e colocar no final, com uma vírgula separando:

{["rat"] = {level = 10, mana = 20},

é só colocar dentro da tabela summons.

 

 

vou editar um negócio no meu post, é que o script só vai funcionar se o parametro estiver em minúsculo.

quando eu editar você substitui lá.

 

 

Vou testar o script pra ver se ta funfando bem. Mesmo assim, muito obrigado pela ajuda.

Ta dando nenhum erro, porem não está sumonando nada.

up

DanihcvD
07 de janeiro de 2016 às 03:50

Tenta agr:

local storage = 79845 --storage para o exhaustion
local tempo = 5 --em segundos

local monsters = {
[1] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 2  },
[2] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[5] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[6] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 6  },
}

function onSay(cid, words, param, channel)
if exhaustion.check(cid, storage) then
doPlayerSendTextMessage(cid, 22, "You are exhausted.")
return true
end
	--Player Status
	local playerpos = getPlayerPosition(cid)

	for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do
		if (param == v)then

			if (monsters[getPlayerVocation(cid)]) and #getCreatureSummons(cid) >= monsters[getPlayerVocation(cid)].maxSummons then
				return doPlayerSendCancel(cid, "Você já tem sumons demais.")
			else
			--Summon
				if getPlayerLevel(cid) < monster[getPlayerVocation(cid)].summons[param].level then
					return doPlayerSendCancel(cid, "Level insuficiente.")
				elseif getCreatureMana(cid) < monster[getPlayerVocation(cid)].summons[param].mana then
					return doPlayerSendCancel(cid, "Mana insuficiente.")
				end
					doConvinceCreature(cid, doCreateMonster(param, playerpos))
					doPlayerAddMana(cid, -monster[getPlayerVocation(cid)].summons[param].mana, false)
					exhaustion.set(cid, storage, tempo)
					doSendMagicEffect(playerpos, 2)
				
			return true
			end
		else
		doPlayerSendCancel(cid, "You can't summon this monster.")
		end
	end
return true
end
gabriel28G
07 de janeiro de 2016 às 04:53

 

Tenta agr:

local storage = 79845 --storage para o exhaustion
local tempo = 5 --em segundos

local monsters = {
[1] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 2  },
[2] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[5] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[6] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 6  },
}

function onSay(cid, words, param, channel)
if exhaustion.check(cid, storage) then
doPlayerSendTextMessage(cid, 22, "You are exhausted.")
return true
end
	--Player Status
	local playerpos = getPlayerPosition(cid)

	for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do
		if (param == v)then

			if (monsters[getPlayerVocation(cid)]) and #getCreatureSummons(cid) >= monsters[getPlayerVocation(cid)].maxSummons then
				return doPlayerSendCancel(cid, "Você já tem sumons demais.")
			else
			--Summon
				if getPlayerLevel(cid) < monster[getPlayerVocation(cid)].summons[param].level then
					return doPlayerSendCancel(cid, "Level insuficiente.")
				elseif getCreatureMana(cid) < monster[getPlayerVocation(cid)].summons[param].mana then
					return doPlayerSendCancel(cid, "Mana insuficiente.")
				end
					doConvinceCreature(cid, doCreateMonster(param, playerpos))
					doPlayerAddMana(cid, -monster[getPlayerVocation(cid)].summons[param].mana, false)
					exhaustion.set(cid, storage, tempo)
					doSendMagicEffect(playerpos, 2)
				
			return true
			end
		else
		doPlayerSendCancel(cid, "You can't summon this monster.")
		end
	end
return true
end

 

Sem nenhum erro, mas continua sem conjurar nada, tentei ajeitar botando 'minLevel' e nada também. Tá complicado mesmo. =/

CaronteC
07 de janeiro de 2016 às 14:15


local storage = 79845 --storage para o exhaustion

local tempo = 5 --em segundos

 

local monsters = {

[1] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 2 },

[2] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4 },

[5] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4 },

[6] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 6 },

}

 

function onSay(cid, words, param, channel)

if exhaustion.check(cid, storage) then

doPlayerSendTextMessage(cid, 22, "You are exhausted.")

return true

end

 

--Player Status

local playerpos = getPlayerPosition(cid)

param = string.lower(param)

local loop = 0

 

function checkSummon()

for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do

if param == k then

return true

end

end

return false

end

 

if not checkSummon() then

doPlayerSendCancel(cid, "You can't summon this monster.")

return true

end

 

for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do

loop = loop + 1

if (param == k) then

if (monsters[getPlayerVocation(cid)]) and #getCreatureSummons(cid) >= monsters[getPlayerVocation(cid)].maxSummons then

return doPlayerSendCancel(cid, "Você já tem sumons demais.")

else

--Summon

if getPlayerLevel(cid) < v.level then

return doPlayerSendCancel(cid, "Level insuficiente.")

elseif getCreatureMana(cid) < v.mana then

return doPlayerSendCancel(cid, "Mana insuficiente.")

end

doConvinceCreature(cid, doCreateMonster(param, playerpos))

doPlayerAddMana(cid, -v.mana, false)

exhaustion.set(cid, storage, tempo)

doSendMagicEffect(playerpos, 2)

return true

end

end

end

return true

end

 

DanihcvD
07 de janeiro de 2016 às 17:50

Caso o do caronte não dê certo, tenta assim:

local storage = 79845 --storage para o exhaustion
local tempo = 5 --em segundos

local monsters = {
[1] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 2  },
[2] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[5] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[6] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 6  },
}

function onSay(cid, words, param, channel)
if exhaustion.check(cid, storage) then
doPlayerSendTextMessage(cid, 22, "You are exhausted.")
return true
end
	--Player Status
	local playerpos = getPlayerPosition(cid)

	for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do
		if (param == v)then

			if (monsters[getPlayerVocation(cid)]) and #getCreatureSummons(cid) >= monsters[getPlayerVocation(cid)].maxSummons then
				return doPlayerSendCancel(cid, "Você já tem sumons demais.")
			else
			--Summon
				if getPlayerLevel(cid) < monster[getPlayerVocation(cid)].summons[param].level then
					return doPlayerSendCancel(cid, "Level insuficiente.")
				elseif getCreatureMana(cid) < monster[getPlayerVocation(cid)].summons[param].mana then
					return doPlayerSendCancel(cid, "Mana insuficiente.")
				elseif getPlayerLevel(cid) >= monster[getPlayerVocation(cid)].summons[param].level and getCreatureMana(cid) >= monster[getPlayerVocation(cid)].summons[param].mana then
					doConvinceCreature(cid, doCreateMonster(param, playerpos))
					doPlayerAddMana(cid, -monster[getPlayerVocation(cid)].summons[param].mana, false)
					exhaustion.set(cid, storage, tempo)
					doSendMagicEffect(playerpos, 2)
				
				return true
				end
			end
		else
		doPlayerSendCancel(cid, "You can't summon this monster.")
		end
	end
return true
end
gabriel28G
07 de janeiro de 2016 às 20:58

Nem o seu, nem o do Caronte funcionou, continua com o mesmo problema, sem erros no console, porém não sumona nada. Creio que o problema esteja na tabela em si, mas não entendo isso. Pelo visto, meu server vai ficar sem isso e terei que remudar a jogabilidade dos Druids. Ou consiga, se alguém souber alterar o código que tenho, mudando-o para funcionar no TFS 0.4 rev.3884.

O código foi feito pro TFS 0.4.5972. Se alguém souber modificar, o código estará aqui em baixo:

 

 

 

1. spells.cpp

Find:

    if (player->getSummonCount() >= 2) {
       player->sendCancel("You cannot summon more creatures.");
       g_game.addMagicEffect(player->getPosition(), NM_ME_POFF);
       return false;
     }

Replace it with:

    if (player->getSummonCount() >= player->getMaxSummons()) {
       player->sendCancel("You cannot summon more creatures.");
       g_game.addMagicEffect(player->getPosition(), NM_ME_POFF);
       return false;
     }
---------------------------------------------------------------------------------

2. vocations.h

Find:

uint32_t getCapGain() const {
     return gainCap;
}

After it paste:

uint32_t getMaxSummons() const {
     return maxSummons;
}

Find:

uint32_t gainCap;

After it paste:

uint32_t maxSummons;
---------------------------------------------------------------------------------

3. vocations.cpp

Find:

          if (readXMLInteger(p, "gaincap", intVal)) {
             voc->gainCap = intVal;
           }

After it paste:

if(readXMLInteger(p, "maxsummons", intVal)) {
     voc->maxSummons = intVal;
}
Find:

gainCap = 5;

After it paste:

maxSummons = 2;
---------------------------------------------------------------------------------

4. player.h

Find:

    Vocation* getVocation() const {
       return vocation;
     }

After it paste:

uint32_t getMaxSummons() const {
     return vocation->getMaxSummons();
}

 

 

Editado Janeiro 7 por gabrielvs

CaronteC
10 de janeiro de 2016 às 01:54
Melhor resposta

Cara, tá pegando perfeitamente aqui no meu TFS 0.4

local storage = 79845 --storage para o exhaustion
local tempo = 5 --em segundos

local monsters = {
[1] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 2  },
[2] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[5] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 4  },
[6] = {summons = {["rat"] = {level = 10, mana = 20}, ["dragon"] = {level = 100, mana = 200} }, maxSummons = 6  },
}

function onSay(cid, words, param, channel)
if exhaustion.check(cid, storage) then
doPlayerSendTextMessage(cid, 22, "You are exhausted.")
return true
end

	--Player Status
	local playerpos = getPlayerPosition(cid)
    param = string.lower(param)
	
	function checkSummon()
		for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do
			if param == k then
				return true
			end
		end
		return false
	end
	
	if not checkSummon() then
		doPlayerSendCancel(cid, "You can't summon this monster.")
		return true
	end 
	
	for k, v in pairs(monsters[getPlayerVocation(cid)].summons) do
		if (param == k) then
			if (monsters[getPlayerVocation(cid)]) and #getCreatureSummons(cid) >= monsters[getPlayerVocation(cid)].maxSummons then
				return doPlayerSendCancel(cid, "Você já tem sumons demais.")
			else
			--Summon
				if getPlayerLevel(cid) < v.level then
					return doPlayerSendCancel(cid, "Level insuficiente.")
				elseif getCreatureMana(cid) < v.mana then
					return doPlayerSendCancel(cid, "Mana insuficiente.")
				end
					doConvinceCreature(cid, doCreateMonster(param, playerpos))
					doPlayerAddMana(cid, -v.mana, false)
					exhaustion.set(cid, storage, tempo)
					doSendMagicEffect(playerpos, 2)
				return true
			end
		end
	end
	return true
end
gabriel28G
13 de janeiro de 2016 às 20:13

Foi, você me ajudou no outro fórum, se é o mesmo script que você já pois aqui, não sei oq danado eu tava fazendo de errado. hahaha
Valeu cara.

DanihcvD
15 de janeiro de 2016 às 00:37

Tópico movido para dúvidas / pedidos resolvidos.