• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Player Vs Monster Arena

fatelord

New Member
Joined
Aug 7, 2007
Messages
56
Reaction score
1
Hello to all!
I´ve done something that goes beyond my wildest dreams! (j/k... sleepdrunk here)
All I wanted was an Arena that done the following:
PHP:
1. If player kills the monster, he can step in certain tile and will be teleported out.
2. If the monster is still alive, the tile inside doesnt work.
3. If player dies, the lever outside kills the monster inside.
4. If the player inside kills the monster but dont step on the tile to get out, the lever outside teleport player to outside.
5. If the player AND the monster are still inside(Player still trying to kill the monster and vice-versa), the lever outside doesn't work.
I asked for help and noone helped me! (dramatic) :p
Well.. whatever.. I got bored and could script it o_O (soo many searches... so many sources..)
If you got part of a script you developed in here, tell me and I'll edit later.

First of all, you'll need an Arena! (~doh~)
I´ve done this one:
The arena:
arena1.png

The lever to go in:
arena2.png

The place you get out:
arena3.png

Starting. On actions.xml add:
PHP:
<action actionid="9100" script="arenalever.lua"/>
On movements.xml add
PHP:
<movevent type="StepIn" actionid="9200" event="script" value="arenatile.lua"/>
<movevent type="StepIn" actionid="9201" event="script" value="flee.lua"/>

Whew.. till now its easy..

Now.. to define where the "flee" square leads you (white floor on the black arena? pretty obvious) well create the flee.lua in movements/scripts:
PHP:
function onStepIn(cid, item, pos)

exit = {x=X1, y=Y1, z=Z1}
if isPlayer(cid) then
doTeleportThing(cid,exit,true)
end
end

Code:
X1 = X of destination position for flee square
Y1 = Y of destination position for flee square
Z1 = Z of destination position for flee square

Ok.. now comes the hard part.
On Actions/Scripts, create a file named Arenalever.lua. Use the following:
PHP:
function onUse(cid, item, frompos, item2, pos)
if item.itemid == 1945 then
doTransformItem(item.uid, item.itemid +1)
else
doTransformItem(item.uid, item.itemid -1)
end

exit = {x=X2, y=Y2, z=Z2}
exitcorpse = {x=X3, y=Y3, z=Z3}
local list = {}
local areas = {
	{{x = X4, y = Y4, z = Z4}, {x = X5, y = Y5, z = Z5}}
}
pos1 = {x=X7, y=Y7, z=Z7}
entrance = {x=X6, y=Y6, z=Z6}
tpleft = {x=X4,y=Y4,z=Z4,stackpos=1}
btright = {x=X5,y=Y5,z=5,stackpos=1}

function doCheckArea(t, type, list)
	local result = FALSE
	local list = list or {}
	if not t or not type then	return LUA_ERROR	end
	for _, v in ipairs(t) do
		local frompos, topos = v[1], v[2]
		for x = frompos.x, topos.x do
			for y = frompos.y, topos.y do
				for z = frompos.z, topos.z, (frompos.z <= topos.z and 1 or -1) do
					local pos = {x = x, y = y, z = z}
					local creature = getTopCreature(pos).uid or getTopCreature(pos)
					if creature > 0 then
						local player = (isPlayer(creature) == TRUE)
						if type == "creature" then
							table.insert(list, creature)
							result = TRUE
						elseif type == "monster" then
							if(not player) then
								table.insert(list, creature)
								result = TRUE
							end
						elseif type == "player" then
							if(player) then
								table.insert(list, creature)
								result = TRUE
							end
						end
					end
				end
			end
		end
	end
	return result
end


local function doCleanArea(topLeft1, bottomRight1)

	checking1 = {x=topLeft1.x, y=topLeft1.y, z=topLeft1.z, stackpos=topLeft1.stackpos}

	monsterArena1 = false  

	repeat

	creature1 = getThingfromPos(checking1)


	if creature1.itemid > 0 then


		if isPlayer(creature1.uid) == TRUE then
			monsterArena1 = TRUE
		end

		if isMonster(creature1.uid) == TRUE then
			monsterArena1 = TRUE
		end

		if isCorpse(creature1.uid) == TRUE then
			doTeleportThing(creature1.uid, exitcorpse, TRUE)

		else
			
			doRemoveItem(creature1.uid)
			monsterArena1 = true

		end
	end

	checking1.x=checking1.x+1

	if checking1.x>bottomRight1.x then

		checking1.x=topLeft1.x

		checking1.y=checking1.y+1

	end

	until checking1.y>bottomRight1.y		

end



local function doRemoveMonster(topLeft, bottomRight) -- remove monsters and items and players ;)


	checking = {x=topLeft.x, y=topLeft.y, z=topLeft.z, stackpos=topLeft.stackpos}

	playerArena = false 

	monsterArena = false  
	
	counter = 0

	repeat

	creature = getThingfromPos(checking)

	if creature.itemid > 0 then



		if isPlayer(creature.uid) == TRUE then
			doTeleportThing(creature.uid, exit, TRUE)
			playerArena = true
		end

		if isMonster(creature.uid) == TRUE then

			doRemoveCreature(creature.uid)

			monsterArena = true

		end
			


	end

	checking.x=checking.x+1

	if checking.x>bottomRight.x then

		checking.x=topLeft.x

		checking.y=checking.y+1

	end

	until checking.y>bottomRight.y		

end





	
	if doCheckArea(areas, "player", list) == TRUE then
		if doCheckArea(areas, "monster", list) == TRUE then
			local test = getCreaturePosition(cid)
			doSendAnimatedText(test, 'I am noob', TEXTCOLOR_GOLD)
		else
			doRemoveMonster(tpleft, btright)
			doCleanArea(tpleft, btright)
			
		end		
	elseif doCheckArea(areas, "monster", list) == TRUE then
		doRemoveMonster(tpleft, btright)
		doCleanArea(tpleft, btright)
		
	else
doTeleportThing(cid,entrance,true)
local mobs = {
    "MOBNAME1",
    "MOBNAME2",
    "MOBNAME3"
}
local random = math.random(1, #mobs)

doSummonCreature(mobs[random], pos1)


	end
	

end
Where:
Code:
X2 = X of destination position for when player gets out.
Y2 = Y of destination position for when player gets out.
Z2 = Z of destination position for when player gets out.
Code:
X3 = X of destination position for corpses inside arena.
Y3 = Y of destination position for corpses inside arena
Z3 = Z of destination position for corpses inside arena
Code:
X4 = X of top left square of arena
Y4 = Y of top left square of arena
Z4 = Z of top left square of arena
PS: Notice that you need to put that on 2 diferent places. One is for the cleaning of the arena(remove fields and blood marks) and other is for the check monsters in area.
Same on:
Code:
X5 = X of bottom right square of arena
Y5 = Y of bottom right square of arena
Z5 = Z of bottom right square of arena

More to change...
Code:
X6 = X of destination position for when player gets in.
Y6 = Y of destination position for when player gets in.
Z6 = Z of destination position for when player gets in.
Code:
X7 = X of destination position for summoned monster.
Y7 = Y of destination position for summoned monster.
Z7 = Z of destination position for summoned monster.
Code:
MOBNAME1 = Name of one of the monsters that can be summoned inside the arena.
MOBNAME2 = Name of one of the monsters that can be summoned inside the arena.
MOBNAME3 = Name of one of the monsters that can be summoned inside the arena.
The mobs you can add as much as you want. I use this one:
PHP:
"Acid Blob",
"Crazed Beggar",
"Damaged worker golem",
"Death Blob",
"Gang member",
"Gladiator",
"Gozzler",
"Haunted treeling",
"Hellspawn",
"Infernalist",
"Mad scientist",
"Mercury Blob",
"Mutated Rat",
"Mutated Human",
"Mutated Bat",
"Mutated tiger",
"Nightmare Scion",
"Nightstalker",
"Undead gladiator",
"Vampire Bride",
"War Golem",
"Werewolf",
"Worker golem",
"Zombie",
"Bones",
"Fluffy",
"Grynch Clan Goblin",
"Hacker",
"Minishabaal",
"Primitive",
"Tibia Bug",
"Undead Minion",
"Amazon",
"Valkyrie",
"Xenia",
"Carrion Worm",
"Rotworm",
"Rotworm Queen",
"Kongra",
"Hairman the Huge",
"Merlkin",
"Sibang",
"Crystal Spider",
"Giant Spider",
"Poison Spider",
"Scorpion",
"Spider",
"Tarantula",
"The old widow",
"Achad",
"Axeitus Headbanger",
"Bloodpaw",
"Bovinus",
"Colerian The Barbarian",
"Cursed Gladiator",
"Frostfur",
"Orcus the Cruel",
"Rocky",
"The Hairy One",
"Avalanche",
"Drasilla",
"Grimgor Guteater",
"Kreebosh the Exile",
"Slim",
"Spirit of Earth",
"Spirit of Fire",
"Spirit of Water",
"The Dark Dancer",
"The Hag",
"Darakan the Executioner",
"Deathbringer",
"Fallen Mooh'tah Master Ghar",
"Gnorre Chyllson",
"Norgle Glacierbeard",
"Svoren the Mad",
"The Masked Marauder",
"The Obliverator",
"The Pit Lord",
"Webster",
"Barbarian Bloodwalker",
"Barbarian Brutetamer",
"Barbarian Headsplitter",
"Barbarian Skullhunter",
"Barbaria",
"Bear",
"Panda",
"Polar Bear",
"Braindeath",
"Beholder",
"Elder Beholder",
"Gazer",
"The evil eye",
"eye of the seven",
"Carniphila",
"Spit Nettle",
"The Abomination",
"Son of Verminor",
"Son of Verminor summon",
"Slime Summon",
"Slime",
"Bog Raider",
"Tiquandas Revenge",
"Chicken",
"Dire Penguin",
"Flamingo",
"Parrot",
"Penguin",
"Seagull",
"Terror Bird",
"Bazir",
"Infernatil",
"Zoralurk",
"Apocalypse",
"Ghazbaran",
"Morgaroth",
"Orshabaal",
"Dog",
"Hellhound",
"War wolf",
"Winter wolf",
"Wolf",
"Chakoya toolshaper",
"Chakoya tribewarden",
"Chakoya windcaller",
"Blood Crab",
"Crab",
"Ice Golem",
"Yeti",
"Acolyte of the Cult",
"Adept of the Cult",
"Enlightened of the Cult",
"Novice of the Cult",
"Grandfather Tridian",
"Ungreez",
"Dark Torturer",
"Demon",
"Destroyer",
"Diabolic Imp",
"Fire Devil",
"Fury",
"Hand of Cursed Fate",
"Juggernaut",
"Nightmare",
"Plaguesmith",
"Blue Djinn",
"Efreet",
"Green Djinn",
"Marid",
"Frost Dragon",
"Wyrm",
"Sea Serpent",
"Dragon Lord",
"Dragon",
"Hydra",
"Dragon Hatchling",
"Dragon Lord Hatchling",
"Frost Dragon Hatchling",
"Demodras",
"Dwarf Geomancer",
"Dwarf Guard",
"Dwarf Soldier",
"Dwarf",
"Foreman kneebiter",
"Mad Technomancer",
"Dworc fleshhunter",
"Dworc venomsniper",
"Dworc voodoomaster",
"Elephant",
"Mammoth",
"Elf Arcanist",
"Elf Scout",
"Elf",
"Dharalion",
"Charged Energy Elemental",
"Energy Elemental",
"Massive Energy Elemental",
"Overcharged Energy Elemental",
"Energy Overlord",
"Cat",
"Lion",
"Tiger",
"Azure Frog",
"Coral Frog",
"Crimson Frog",
"Green Frog",
"Orchid Frog",
"Toad",
"Jagged Earth Elemental",
"Muddy Earth Elemental",
"Earth Elemental",
"Massive Earth Elemental",
"Earth Overlord",
"Gargoyle",
"Stone Golem",
"Grorlam",
"ghost",
"phantasm summon",
"phantasm",
"pirate ghost",
"spectre",
"Frost Giant",
"Frost Giantess",
"Cyclops Smith",
"Cyclops Drone",
"Behemoth",
"Cyclops",
"Stonecracker",
"Slick Water Elemental",
"Roaring Water Elemental",
"Ice Overlord",
"Water Elemental",
"Massive Water Elemental",
"Ancient Scarab",
"Blue Butterfly",
"Bug",
"Centipede",
"Cockroach",
"Exp Bug",
"Larva",
"Pink Butterfly",
"Red Butterfly",
"Scarab",
"Wasp",
"Yellow Butterfly",
"Lizard Sentinel",
"Lizard Snakecharmer",
"Lizard Templar",
"High templar cobrass",
"minotaur archer",
"minotaur guard",
"minotaur mage",
"minotaur",
"Apprentice Sheng",
"The horned fox",
"General murius",
"Squirrel",
"Goblin Demon",
"Badger",
"Bat",
"Deer",
"Halloween Hare",
"Hyaena",
"Pig",
"Rabbit",
"Silver Rabbit",
"Skunk",
"Wisp",
"Dark Monk",
"Monk",
"Training Monk",
"tha exp carrier",
"Fernfang",
"Necromancer",
"Priestess",
"Necropharus",
"Orc Berserker",
"Orc Leader",
"Orc Rider",
"Orc Shaman",
"Orc Spearman",
"Orc Warlord",
"Orc Warrior",
"Orc",
"Warlord Ruzad",
"Goblin Leader",
"Goblin Scavenger",
"Goblin",
"Goblin Assassin",
"Assassin",
"Bandit",
"Black Knight",
"Hero",
"Hunter",
"Nomad",
"Smuggler",
"Stalker",
"Poacher",
"Wild Warrior",
"Man in the cave",
"Rukor Zad",
"Smuggler Baron Silvertoe",
"Ashmunrah",
"Dipthrah",
"Mahrdis",
"Morguthis",
"Omruc",
"Rahemos",
"Thalas",
"Vashresamun",
"Brutus Bloodbeard",
"Lethal Lissy",
"Deadeye Devious",
"Ron the Ripper",
"Pirate Buccaneer",
"Pirate Corsair",
"Pirate Cutthroat",
"Pirate Marauder",
"The plasmother",
"Dracola",
"The Handmaiden",
"Mr. Punish",
"The Countess Sorrow",
"The Imperor",
"Massacre",
"Fire Overlord",
"Massive Fire Elemental",
"Blistering Fire Elemental",
"Blazing Fire Elemental",
"Fire Elemental",
"Hellfire Fighter",
"Quara Constrictor Scout",
"Quara Hydromancer Scout",
"Quara Mantassin Scout",
"Quara Pincher Scout",
"Quara Predator Scout",
"Quara Constrictor",
"Quara Hydromancer",
"Quara Mantassin",
"Quara Pincher",
"Quara Predator",
"Thul",
"Cave Rat",
"Rat",
"Munster",
"Cobra",
"Crocodile",
"Serpent Spawn",
"Snake",
"Wyvern",
"Black Sheep",
"Sheep",
"Mimic",
"Betrayed Wraith",
"BoneBeast",
"Demon Skeleton",
"Lost Soul",
"Pirate Skeleton",
"Skeleton",
"Skeleton Warrior",
"Pythius the rotten",
"Undead Dragon",
"Dark apprentice",
"Dark Magician",
"Ice Witch",
"Ferumbras",
"Warlock",
"Witch",
"Zarabustor",
"Yakchal",
"Annihilon",
"Hellgorak",
"Latrivan",
"Madareth",
"Zugurosh",
"Ushuriel",
"Golgordan",
"Thornback Tortoise",
"Tortoise",
"Tortoise",
"Deathslicer",
"Flamethrower",
"Magicthrower",
"Plaguethrower",
"Poisonthrower",
"Shredderthrower",
"Troll Champion",
"Frost Troll",
"Island Troll",
"Swamp Troll",
"Troll",
"Big Boss Trolliver",
"Banshee",
"Blightwalker",
"Crypt Shambler",
"Ghoul",
"Lich",
"Mummy",
"Vampire",
"Grim Reaper",
"The count",
"The reaper",
"Gravelord Oshuran",
"Arachir the ancient one",
"Diblis the fair",
"Sir valorcrest",
"Zevelon Duskbringer"
Yea.. big list. It includes every monster on my monster.xml. Did on excel tho.. If anyone got TONS of custom monsters that you wanted to be here and you are too lazy to type, pm me and i´ll explain how to do or maybe even do it to you, dpending on how sexy your sister is :D


Uff.. thats done for the lever!. OMG.. nooo.. there's still the tile! (FUUUUUUUUUUUU)

Basically, its not that hard. You'll remove that change item type from the actions scripts, change the onuse to onstep and voila! its done
Put this on movements/scripts named "arenatile.lua" (Copy and paste boys 'n girls :p)
PHP:
function onStepIn(cid, item, pos)

exit = {x=X2, y=Y2, z=Z2}
exitcorpse = {x=X3, y=Y3, z=Z3}
local list = {}
local areas = {
	{{x = X4, y = Y4, z = Z4}, {x = X5, y = Y5, z = Z5}}
}
pos1 = {x=X7, y=Y7, z=Z7}
entrance = {x=X6, y=Y6, z=Z6}
tpleft = {x=X4,y=Y4,z=Z4,stackpos=1}
btright = {x=X5,y=Y5,z=5,stackpos=1}

function doCheckArea(t, type, list)
	local result = FALSE
	local list = list or {}
	if not t or not type then	return LUA_ERROR	end
	for _, v in ipairs(t) do
		local frompos, topos = v[1], v[2]
		for x = frompos.x, topos.x do
			for y = frompos.y, topos.y do
				for z = frompos.z, topos.z, (frompos.z <= topos.z and 1 or -1) do
					local pos = {x = x, y = y, z = z}
					local creature = getTopCreature(pos).uid or getTopCreature(pos)
					if creature > 0 then
						local player = (isPlayer(creature) == TRUE)
						if type == "creature" then
							table.insert(list, creature)
							result = TRUE
						elseif type == "monster" then
							if(not player) then
								table.insert(list, creature)
								result = TRUE
							end
						elseif type == "player" then
							if(player) then
								table.insert(list, creature)
								result = TRUE
							end
						end
					end
				end
			end
		end
	end
	return result
end


local function doCleanArea(topLeft1, bottomRight1)

	checking1 = {x=topLeft1.x, y=topLeft1.y, z=topLeft1.z, stackpos=topLeft1.stackpos}

	monsterArena1 = false  

	repeat

	creature1 = getThingfromPos(checking1)


	if creature1.itemid > 0 then


		if isPlayer(creature1.uid) == TRUE then
			monsterArena1 = TRUE
		end

		if isMonster(creature1.uid) == TRUE then
			monsterArena1 = TRUE
		end

		if isCorpse(creature1.uid) == TRUE then
			doTeleportThing(creature1.uid, exitcorpse, TRUE)

		else
			
			doRemoveItem(creature1.uid)
			monsterArena1 = true

		end
	end

	checking1.x=checking1.x+1

	if checking1.x>bottomRight1.x then

		checking1.x=topLeft1.x

		checking1.y=checking1.y+1

	end

	until checking1.y>bottomRight1.y		

end



local function doRemoveMonster(topLeft, bottomRight) -- remove monsters and items and players ;)


	checking = {x=topLeft.x, y=topLeft.y, z=topLeft.z, stackpos=topLeft.stackpos}

	playerArena = false 

	monsterArena = false  
	
	counter = 0

	repeat

	creature = getThingfromPos(checking)

	if creature.itemid > 0 then



		if isPlayer(creature.uid) == TRUE then
			doTeleportThing(creature.uid, exit, TRUE)
			playerArena = true
		end

		if isMonster(creature.uid) == TRUE then

			doRemoveCreature(creature.uid)

			monsterArena = true

		end
			


	end

	checking.x=checking.x+1

	if checking.x>bottomRight.x then

		checking.x=topLeft.x

		checking.y=checking.y+1

	end

	until checking.y>bottomRight.y		

end





	
	if doCheckArea(areas, "player", list) == TRUE then
		if doCheckArea(areas, "monster", list) == TRUE then
			local test = getCreaturePosition(cid)
			doSendAnimatedText(test, 'I am noob', TEXTCOLOR_GOLD)
		else
			doRemoveMonster(tpleft, btright)
			doCleanArea(tpleft, btright)
			
		end		
	elseif doCheckArea(areas, "monster", list) == TRUE then
		doRemoveMonster(tpleft, btright)
		doCleanArea(tpleft, btright)
	end
	

end
Where:
Code:
X2 = X of destination position for when player gets out.
Y2 = Y of destination position for when player gets out.
Z2 = Z of destination position for when player gets out.
Code:
X3 = X of destination position for corpses inside arena.
Y3 = Y of destination position for corpses inside arena
Z3 = Z of destination position for corpses inside arena
Code:
X4 = X of top left square of arena
Y4 = Y of top left square of arena
Z4 = Z of top left square of arena
PS: Notice that you need to put that on 2 diferent places. One is for the cleaning of the arena(remove fields and blood marks) and other is for the check monsters in area.
Same on:
Code:
X5 = X of bottom right square of arena
Y5 = Y of bottom right square of arena
Z5 = Z of bottom right square of arena

More to change...
Code:
X6 = X of destination position for when player gets in.
Y6 = Y of destination position for when player gets in.
Z6 = Z of destination position for when player gets in.
Code:
X7 = X of destination position for summoned monster.
Y7 = Y of destination position for summoned monster.
Z7 = Z of destination position for summoned monster.


And its done!

Tested on TFS 0.3.4 with that fix was posted in otfans.
When player leaves arena, it's get cleaned from fields and some corpses are teleported out. I think it dont get all corpses cause of that stackpos, and I kinda dont bother too :p


Well.. if it works for you can you pretty please say thanks or 'YA AR NUBISH! GIVE FRE ITAMS OR ME LOG MAI MOD ADN BAXS YA' :p


PS: Flee square is needed for me, cause I like to show my players its total random, so sometimes it spawns traps inside :p
 
Hey. just wondering. Anyone tested this here? I want to know if its working properly on other ots. It do work on mine but I just want to be sure..
 
Back
Top