• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[NPC] Attackable NPC's?

Busuwe

New Member
Joined
Oct 12, 2007
Messages
2
Reaction score
0
In an attempt to make a kind of more intelligent and scripted boss monster, I thought I could maybe use npc's for the job.
However, I've yet to find a way to make it so players can attack my npc's. I tried using the following tags in the npc file:
(I am using TFS 0.2.11)
Code:
<flags>
    <flag attackable="1"/>
    <flag pushable="0"/>
</flags>

This made it possible for players to actually attack the npc. However they could not use any runes on the npc, and the melee/distance attacks did not do any damage at all to the npc.

Now I'm asking, is there something I've missed, or is it not possible to have "killable" npc's?
 
His access has to be under 5 or 6 (not 100% sure atm) or he is counted as a gamemaster so you wont be able to atk him.

kind regards, Evil hero
 
My npc has an access of 0.
Here is the npc file:

Code:
<npc name="Bossy" script="data/npc/scripts/Bossy.lua" autowalk="0" attackable="1" floorchange="0" access="0" level="21" maglevel="1">
	<health now="150" max="150"/>
	<look type="142" head="0" body="0" legs="0" feet="0" corpse="2212"/>
	<defenses armor="0" defense="0"/>
    <flags> 
      <flag attackable="1"/> 
      <flag pushable="1"/> 
    </flags>
</npc>
 
Last edited:
Try:

XML:
<npc name="Fight" script="data/npc/scripts/fight.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="0" body="0" legs="0" feet="0" addons="0"/>
<parameters>
<parameter key="message_greet" value="Para batalhar nos diga {aceitar}." />
<parameter key="message_farewell" value="Ate mais." />
<parameter key="message_walkaway" value="Ate mais." />
</parameters>
</npc>

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
local position = getPlayerPosition(cid)
local powerdemonster = "Demon" -------------Coloque aki o poder da creature tera exemplo hit,spells e vida o outfit sera o mesmo do npc------

if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

function doCreatureNpcInTimes()
local npc = "Fight"
local position = {x=1016,y=1019,z=7}
doCreateNpc(npc, position)
return true
end

function doStartDuelNpc()
local npcesta = {x=1016,y=1019,z=7} ---- Coloque aqui a posiçao de onde o npc esta(Não e obrigatorio eu testei mais se existir mais de um npc com este nome e necessario)
local npcname = "Fight"
doRemoveCreature(getCreatureByName(npcesta,npcname))
return true
end
if msgcontains(msg, 'aceitar') then
local playerpos = getPlayerPosition(cid)
local npcl = {lookType = 134} ----Coloque o look type do npc aqui(Super recomendavel)
local tempo = 60
local monster = doCreateMonster("Demon", playerpos)
doSetCreatureOutfit(monster, npcl, -1)
addEvent(doCreatureNpcInTimes, tempo* 10000)
doStartDuelNpc()
else
selfSay('Diga aceitar para batalhar', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top