• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!
[NPC] Demonguard - Pits of Inferno

[NPC] Demonguard - Pits of Inferno 2024-09-12

No permission to download
Demonguard.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Demonguard" script="Demonguard.lua" walkinterval="0" floorchange="0">
    <health now="100" max="100" />
    <look type="131" head="97" body="94" legs="94" feet="94" addons="3" />
</npc>
Demonguard.lua
LUA:
-- Author: Rodrigo (Nottinghster) - (OTLand, OTFans, XTibia, OTServBR)
-- Country: Brazil
-- From: Tibia World RPG OldSchool

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

local attackedPlayers = {}
local attackInterval = 1000
local lastAttackTime = 0

local fireCondition = Condition(CONDITION_FIRE)
fireCondition:setParameter(CONDITION_PARAM_DELAYED, true)
fireCondition:addDamage(10, 1000, -10)

function onThink()
    npcHandler:onThink()

    local now = os.time() * 1000
    if now - lastAttackTime < attackInterval then
        return
    end
    lastAttackTime = now

    local npc = Npc()
    local npcPos = npc:getPosition()
    local spectators = Game.getSpectators(npcPos, false, true, 5, 5, 5, 5)
    local currentPlayerGuids = {}

    for i = 1, #spectators do
        local player = spectators[i]
        if player:isPlayer() then
            local guid = player:getGuid()
            currentPlayerGuids[guid] = true

            if not attackedPlayers[guid] then
                player:addCondition(fireCondition)
                npcPos:sendMagicEffect(CONST_ME_MAGIC_RED)
                player:getPosition():sendMagicEffect(CONST_ME_HITBYFIRE)
                npc:say("Die, intruder!", TALKTYPE_SAY)
                attackedPlayers[guid] = true
            end
        end
    end

    for guid in pairs(attackedPlayers) do
        if not currentPlayerGuids[guid] then
            attackedPlayers[guid] = nil
        end
    end
end

npcHandler:addModule(FocusModule:new())
Author
Nottinghster
Downloads
2
Views
1,294
First release
Last update

Ratings

0.00 star(s) 0 ratings
Back
Top