AN

[Encerrado] NPC HALLOWEEN TFS 0.4

Por Animal Pak, 30 de out. de 2015 em Tópicos Sem Resposta

6
951
Animal PakA
01 de novembro de 2015 às 13:34

Boa tarde, alguém conseguiria fazer esse npc funcionar no tfs 0.4:

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)

local condition = createConditionObject(CONDITION_OUTFIT)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3 * 24 * 3600 * 1000) -- here time in miliseconds, default 3 days
addOutfitCondition(condition, 0, 857, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 853, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 852, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 851, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 843, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 837, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 833, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 785, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 720, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 659, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 597, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 549, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 544, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 523, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 510, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 878, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 877, 0, 0, 0, 0)
addOutfitCondition(condition, 0, 890, 0, 0, 0, 0)
setCombatCondition(combat, condition)

local area = createCombatArea( { {1,1,1,1,1}, {1,1,1,1,1}, {1,1,3,1,1}, {1,1,1,1,1}, {1,1,1,1,1} } )
setCombatArea(combat, area)

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Say halloween.")

function halloweenNPC(cid, message, keywords, parameters, node)
doCombat(getNpcCid(), combat, numberToVariant(getNpcCid()))
npcHandler:say('You are Dead, Suprise!', cid)
return true
end
keywordHandler:addKeyword({'halloween'}, halloweenNPC, {})
npcHandler:addModule(FocusModule:new())

OBS: NÃO CONSIGO CRIAR TÓPICO NA ÁREA CORRETA SUPORTE DE SCRIPTING!

 


@up

MasterDinoM
01 de novembro de 2015 às 14:26

addOutfitCondition(condition, 0, 857, 0, 0, 0, 0) ????? Isso não existe.

 

Explica melhor o que é que o npc ira fazer exatamente?

Animal PakA
01 de novembro de 2015 às 14:49

Bom Master, nesse caso é um npc especial para o halloween, eu gostaria que quando o jogador falasse com ele halloween o jogador ganhasse uma entre algumas outfits aleatórias.

MasterDinoM
01 de novembro de 2015 às 15:01

 

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Say {halloween}.")

local outfits = {857,853,852,851,843,837,833,785,720,659,597,549,544,523,510,878,877,890}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)

function onTargetCreature(cid, target)
	doSetCreatureOutfit(target, math.random(#outfits), 3 * 24 * 3600 * 1000)
end
setCombatCallBack(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

setCombatArea(combat, createCombatArea({
	{1,1,1,1,1},
	{1,1,1,1,1},
	{1,1,3,1,1},
	{1,1,1,1,1},
	{1,1,1,1,1}
}))

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
	if(msg:lower() == "halloween") then
		doCombat(getNpcId(), combat, positionToVariant(getThingPos(getNpcId())))
		npcHandler:say('You are Dead, Suprise!', talkUser)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

 

Não testado.

Animal PakA
01 de novembro de 2015 às 15:12

 

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Say {halloween}.")

local outfits = {857,853,852,851,843,837,833,785,720,659,597,549,544,523,510,878,877,890}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)

function onTargetCreature(cid, target)
	doSetCreatureOutfit(target, math.random(#outfits), 3 * 24 * 3600 * 1000)
end
setCombatCallBack(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

setCombatArea(combat, createCombatArea({
	{1,1,1,1,1},
	{1,1,1,1,1},
	{1,1,3,1,1},
	{1,1,1,1,1},
	{1,1,1,1,1}
}))

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
	if(msg:lower() == "halloween") then
		doCombat(getNpcId(), combat, positionToVariant(getThingPos(getNpcId())))
		npcHandler:say('You are Dead, Suprise!', talkUser)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

 

Não testado.

 

Obrigado, mais deu erro na linha 18 SetCombatCallBack a nill value

Editado Novembro 1 por Animal Pak

2 anos depois...
StigalS
21 de abril de 2018 às 03:31
A questão neste tópico de suporte foi encerrada por falta de respostas. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta.

+ Caso a dúvida não tenha sido resolvida você poderá criar outro tópico solicitando ajuda.
* Lembre-se que é permitido dar UP no tópico a cada 24 horas para assim o destacar e manter movimentado.