• 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!

Creaturescript - monster portal (tweak)

Swiff

Member
Joined
Apr 6, 2009
Messages
366
Reaction score
12
Location
Sweden
I saw Azzkabans post, but it was about a monster having half hp, so I thought instead of bumping it I'll make another.

I just started using this script, it creates a portal for x seconds when I kill a monster.

Lua:
function onKill(cid, target, lastHit)
	local m = {
		["Angry Snowman"] = {
			time = 10, -- Seconds
			to = { x = 1011, y = 347, z = 7 }, -- Where Teleport Goes
			tp = { x = 996, y = 343, z = 6 } -- Where Teleport Creates
		}
	}
	local monster = m[getCreatureName(target)]
		local function deleteTeleport()
			local teleport = getTileItemById(monster.tp, 1387)
			if(teleport.uid > 0) then
				doRemoveItem(teleport.uid)
				doSendMagicEffect(monster.tp, CONST_ME_POFF)
				doSendAnimatedText(monster.tp, "Closed", TEXTCOLOR_RED)
			end
			return true
		end
	if(monster) then
		doCreateTeleport(1387, monster.to, monster.tp)
		addEvent(deleteTeleport, monster.time * 1000)
		doCreatureSay(cid, "You have " .. monster.time .. " seconds to escape!", TALKTYPE_ORANGE_1)
	end
	return true
end

So, what I'm wondering is, can I add more more monsters in this, and just add the event in monstername.xml. I'm thinking of having alot of these quests so, would be cool if I could do something like this:
Lua:
function onKill(cid, target, lastHit)
	local m = {
		["Angry Snowman"] = {
			time = 10, -- Seconds
			to = { x = 1011, y = 347, z = 7 }, -- Where Teleport Goes
			tp = { x = 996, y = 343, z = 6 } -- Where Teleport Creates
		},
                ["Devilatus"] = {
			time = 10, -- Seconds
			to = { x = xxx, y = xxx, z = x }, -- Where Teleport Goes
			tp = { x = xxxx, y = xxx, z = x } -- Where Teleport Creates
		}
	}
	local monster = m[getCreatureName(target)]
		local function deleteTeleport()
			local teleport = getTileItemById(monster.tp, 1387)
			if(teleport.uid > 0) then
				doRemoveItem(teleport.uid)
				doSendMagicEffect(monster.tp, CONST_ME_POFF)
				doSendAnimatedText(monster.tp, "Closed", TEXTCOLOR_RED)
			end
			return true
		end
	if(monster) then
		doCreateTeleport(1387, monster.to, monster.tp)
		addEvent(deleteTeleport, monster.time * 1000)
		doCreatureSay(cid, "You have " .. monster.time .. " seconds to escape!", TALKTYPE_ORANGE_1)
	end
	return true
end

to avoit making a new register in login.lua and a totally new lua creature script (just copy/paste, but still)
I have no idea howto add more monsters, I just.. made an example here because I think it should just be adidng a "," but I have no clue :p
 
Yes, you can use something like this:

Code:
local tpId = 1387
local tps = {
                ["Elvish Minion"] = {pos = {x=970, y=1194, z=9}, toPos = {x=970, y=1194, z=10}, time = 60},
		["Aztroth, Rage Leader"] = {pos = {x=392, y=944, z=11}, toPos = {x=455, y=917, z=11}, time = 60},
		["Toxiros"] = {pos = {x=394, y=919, z=8}, toPos = {x=388, y=914, z=9}, time = 60},
		["Ushuriel"] = {pos = {x=474, y=916, z=2}, toPos = {x=467, y=924, z=1}, time = 60},
}

function removeTp(tp)
        local t = getTileItemById(tp.pos, tpId)
        if t then
                doRemoveItem(t.uid, 1)
                doSendMagicEffect(tp.pos, CONST_ME_POFF)
        end
end

function onDeath(cid)
        local tp = tps[getCreatureName(cid)]
        if tp then
                doCreateTeleport(tpId, tp.toPos, tp.pos)
                doCreatureSay(cid, "Run before the teleport disappears in "..tp.time.." seconds.", TALKTYPE_ORANGE_1)
                addEvent(removeTp, tp.time*1000, tp)
        end
        return TRUE
end
 
Back
Top