Ir para conteúdo

Featured Replies

Postado

Estou sem tempo no momento de fazer mas vou te dar uma idéia:
Você encontra no fórum um NPC que faz quase isso, ele ataca players PK, basta modificá-lo para verificar storage ao invés de PK.

Bom resolvi tentar mesmo com pouco tempo, lembrando que não testei apenas peguei de um post de NPC que atacava PK e modifiquei pra atacar storage, se der erros não-referentes a minhas modificações talvez eu não possa dar suporte.
Em data/npc/lib, crie um arquivo chamado guard.lua e adicione o conteúdo abaixo, configurandoo em 'storage' a sua storage, 'valorStorage' o valor de storage do player que o NPC deve atacar, 'min' o mínimo que o NPC vai hitar e 'max' o máximo que o NPC vai hitar.

Spoiler

Guard = {
    config = {              
        attackspeed = 1000,
        storage = STORAGE,
        valorStorage = VALOR,
    },
    combat = {type = COMBAT_PHYSICALDAMAGE, min = 100, max = 200}
}

function Guard:new()
        local ret = {}
        setmetatable({}, {__index = self.combat})
        setmetatable(ret, {__index = self})
        return ret
end

function Guard:reset()
    self.config = Guard.config
    self.target = 0
    selfFollow(0)
    doTeleportThing(self.id, self.position)
end

function Guard:updateTarget()
    if self.target ~= 0 then
        return
    end
    local creatures = getSpectators(getThingPosition(self.id), self.range, self.range, false)
    for i = 1, #creatures do
        local target = creatures
        if isPlayer(target) and getPlayerStorageValue(target, self.config.storage) == self.config.valorStorage then
            if not getTilePzInfo(getThingPosition(target)) then
                if selfFollow(target) then
                    selfSay("I don't tolerate people like you, ".. getCreatureName(target))
                    self.target = target
                    self:attack()
                    break
                end
            end
        else
            self:reset()
        end
    end
end

function Guard:attack()
    if self.target == 0 then
        self:reset()
        return
    end
    self.time = self.time or os.clock()
    if self.time < os.clock() then
        if getDistanceBetween(getThingPosition(self.id), getThingPosition(self.target)) == 1 then
            doTargetCombatHealth(self.id, self.target, self.combat.type, -self.combat.min, -self.combat.max, CONST_ME_DRAWBLOOD)
        end
        self.time = self.time + (self.config.attackspeed/1000)
    end
end

 

Agora em data/npc/scripts, crie um arquivo chamado guard.lua e adicione o conteúdo abaixo:

Spoiler

local guard = Guard:new()
function onCreatureAppear(cid)
    if cid == getNpcId() then
        guard.id = getNpcId()
        guard.target = 0
        guard.position = getNpcPos()
    end
end

function onCreatureDisappear(cid)
    if cid == guard.target then
        guard:reset()
    end
end

function onCreatureSay(cid, type, msg)
    return false
end

function onThink()
    guard:updateTarget()
    if guard.target ~= 0 then
        if isPlayer(guard.target) then
            guard:attack()
        else
            guard:reset()
        end
    else
        guard:reset()
    end
end

 

E em data/npc/ crie um arquivo chamado guard.xml e adicione o conteúdo abaixo:

Spoiler

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Guard" script="guard.lua" walkinterval="0" speed="200" floorchange="0">
    <health now="100" max="100"/>
    <look type="134" head="57" body="59" legs="40" feet="76" addons="0"/>
    <parameters/>
</npc>

 

 

Se ajudei por favor dee REP+
 

Créditos pelo postador do script original link > @Garou

Te ajudei? Clique em  Gostei ! 

²²²d¬¬b²²²

 

 

"She's got a smile that it seems to me...."  ♪♪

Postado
51 minutos atrás, doido disse:

Amigo ele so vai atacar quem nao tiver a storage entendeu seu o player tiver a storage ele nao vai atacar ta dessa forma?

e tem que dar para matar ele tbm

 

Infelizmente não sei se é possível fazer isso com monstro para poder mata-lo..... Se é possível foge de minhas capacidades :(
Mas eu tentei...

Te ajudei? Clique em  Gostei ! 

²²²d¬¬b²²²

 

 

"She's got a smile that it seems to me...."  ♪♪

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo