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

CreatureEvent [0.4] Monster Arena [Minigame by Summ]

Summ

(\/)(;,,;)(\/) Y not?
Staff member
Global Moderator
Joined
Oct 15, 2008
Messages
4,152
Solutions
12
Reaction score
1,107
Location
Germany :O
Orc_Berserker.gif
Monster Arena Player vs. Player

Description:
You need 2 people for this minigame. You stand on the tiles and pull the lever.
Inside the arena each player will get a random summon and has to attack the enemies summon with his. The player whose summon kills the other first wins and gets rewarded.

Contains:
~Action
~Creatureevent
~Movement
~Map

Download Map:
Speedyshare: http://speedy*****malware.localhost/uX5T5/mArena.otbm
6FiHS.png


Scripts:

Actions/actions.xml:
Code:
<action actionid="1750" event="script" value="monsterArena.lua"/>

Actions/scripts/monsterArena.lua:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1946 then
        return false
    end

    local p = {getThingFromPos(ma_config.fromPos[1]).uid, getThingFromPos(ma_config.fromPos[2]).uid}
    if not(isInArray(p, cid)) then
        return true
    end

    if not(p[1] > 0 and p[2] > 0) then
        return doPlayerSendCancel(cid, "You need an other player for this game.")
    end

    local monsters, players = areaCreatures(ma_config.area)
    if #players > 0 then
        return arraySendCancel(p, "The arena is currently in use.")
    elseif #monsters > 0 then
        for _, mid in pairs(monsters) do
            doRemoveThing(mid)
        end
    end

    doRemoveFieldsInArea(ma_config.area)
    for i = 1, 2 do
        doSendMagicEffect(getThingPos(p[i]), CONST_ME_POFF)
        doTeleportThing(p[i], ma_config.toPos[i])
        doSendMagicEffect(getThingPos(p[i]), CONST_ME_TELEPORT)

        local summon = doCreateMonster(ma_config.monsters[math.random(#ma_config.monsters)], getPositionByDirection(ma_config.toPos[i], ma_config.spawnDir[_], 1))
        doConvinceCreature(p[i], summon, true)
        registerCreatureEvent(summon, "MonsterArenaDeath")
    end

    return false
end

Movements/movements.xml:
Code:
<movevent type="StepOut" actionid="1751" event="script" value="monsterArena.lua"/>
<movevent type="StepIn" actionid="1751" event="script" value="monsterArena.lua"/>

Movements/scripts/monsterArena.lua:
Code:
function onStepOut(cid, item, position, fromPosition)
    if not(isMonster(cid)) then
        return true
    end

    doCreateItem(ma_config.blockID, position)
    return true
end

function onStepIn(cid, item, position, fromPosition)
    if not(isMonster(cid)) then
        doTeleportThing(cid, fromPosition, true)
    end
    return true
end

Creaturescripts/creaturescripts.xml:
Code:
<event type="death" name="MonsterArenaDeath" event="script" value="monsterArena.lua"/>

Creaturescripts/scripts/monsterArena.lua:
Code:
function onDeath(cid, corpse, deathList)
    local master = getCreatureMaster(cid)
   
    local m, p = areaCreatures(ma_config.area)
    if master == cid or not(isInArray(p, master)) then
        return true
    end
   
    for _, mid in pairs(m) do
        doRemoveCreature(mid)
    end
   
    for _, pid in pairs(p) do
        if pid == master then
            doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "Your monster lost the fight!")
        else
            doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "Your monster won the fight! You are rewarded.")
            doPlayerAddItem(pid, ma_config.reward[1], ma_config.reward[2])
        end
        doSendMagicEffect(getThingPos(pid), CONST_ME_POFF)
        doTeleportThing(pid, ma_config.exitPos)
        doSendMagicEffect(getThingPos(pid), CONST_ME_TELEPORT)
    end

    for _, pos in pairs(ma_config.toPos) do
        local thing = getTileItemById(getPositionByDirection(pos, ma_config.spawnDir[_], 1), ma_config.blockID)
        if thing.uid > 0 then
            doRemoveItem(thing.uid)
        end
    end
   
    return true
end

Create a new lib file and add this (example: "libs/750-monsterArena.lua"):
Code:
ma_config = {
        fromPos = {{x=919,y=919,z=7,stackpos=253}, {x=921,y=919,z=7,stackpos=253}},
        toPos = {{x=918,y=910,z=7}, {x=920,y=910,z=7}},
        spawnDir = {2, 0},
        area = {
            {x=913, y=905, z=7},
            {x=925, y=915, z=7}
        },
        monsters = {"Rat", "Demon Skeleton", "Ghoul", "Skeleton", "Fire Elemental", "Orc Berserker"},
        blockID = 3402,
        exitPos = getTownTemplePosition(1),
        reward = {2160, 1}
    }
   
function areaCreatures(area)
    local monsters, players = {}, {}
    for x = area[1].x, area[2].x do
        for y = area[1].y, area[2].y do
            local tmp = getThingFromPos({x=x, y=y, z=area[1].z, stackpos=253})
            if tmp.uid > 0 then
                if isPlayer(tmp.uid) then
                    table.insert(players, tmp.uid)
                elseif isMonster(tmp.uid) then
                    table.insert(monsters, tmp.uid)
                end
            end
        end
    end
    return monsters, players
end
   
function arraySendCancel(arr, msg)
    for _, pid in pairs(arr) do
        doPlayerSendCancel(pid, msg)
    end
    return true
end

UNREMOVABLE_FIELDS = {1497, 1498, 1499, 1505, 1506, 1507, 1508, 7465, 7466, 7467, 7468, 7469, 7470, 7471, 7472, 7473, 11094, 11095}
function doRemoveFieldsInArea(area)
    for x = area[1].x, area[2].x do
        for y = area[1].y, area[2].y do
            local field = getTileItemByType({x=x, y=y, z=area[1].z}, ITEM_TYPE_MAGICFIELD)
            if(field.uid > 0 and not isInArray(UNREMOVABLE_FIELDS, field.itemid)) then
                doRemoveItem(field.uid)
            end
        end
    end
    return true
end

Config:
7dvZK.jpg


fromPos = {{x=919,y=919,z=7,stackpos=253}, {x=921,y=919,z=7,stackpos=253}},
> The two tiles where the players need to stand when pulling the lever. Marked in GREEN

toPos = {{x=918,y=910,z=7}, {x=920,y=910,z=7}},
> The two positions inside the arena. Marked with PURPLE

spawnDir = {2, 0},
> The direction from toPos to the tile where the monster spawn (ORANGE). Ignore if using my map

area = {
{x=913, y=905, z=7},
{x=925, y=915, z=7}},
> Marked in the image with RED

monsters = {"Rat", "Demon Skeleton", "Ghoul", "Skeleton", "Fire Elemental", "Orc Berserker"},
> List of Monsters from which the script randomly chooses Monsters need to be convincable

blockID = 3402,
> Can basically be ignored if using my map

exitPos = getTownTemplePosition(1),
> Where the player gets teleported after the event

reward = {2160, 1}
> Itemid, Count => So it will reward the winner with 1 Crystal Coin

Action IDs:
Ignore if using my map
Lever: Actionid 1750
Tile marked with ORANGE: 1751
 
Last edited:
looks sick
btw, map pos
{x = 1025, y = 1024, z = 3}
 
Summon are not convinceable, continues to be a monster and trying to attack the player.

TFS 0.4

My monster..
Code:
?xml version="1.0" encoding="UTF-8"?>
<monster name="Demon Skeleton" nameDescription="a demon skeleton" race="undead" experience="240" speed="230" manacost="620">
	<health now="400" max="400"/>
	<look type="37" corpse="5963"/>
	<targetchange interval="5000" chance="8"/>
	<strategy attack="100" defense="0"/>
	<flags>
		<flag summonable="1"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="1"/>
		<flag convinceable="1"/>
		<flag pushable="0"/>
		<flag canpushitems="1"/>
		<flag canpushcreatures="1"/>
		<flag targetdistance="1"/>
		<flag staticattack="90"/>
		<flag runonhealth="0"/>
	</flags>

Edit:
Alter
doConvinceCreature(p, summon, true)
to
doConvinceCreature(p, summon)
and it works in 0.4

Now i have problem to remevo wall in creaturescript.. it do not remove the wall for the next battle.
 
Last edited:
The script refuses to send back the players, can't find whats wrong so far.
 
Last edited:
[Error - Action Interface]
Data/Action/other/MonsterArena.lua:On use
Description:
<luadoconvincecreature> Creature Not found
 
The download link is only for premium users!
Can someone rehost it for free please?
 
They have to our their summon wont target the other one.
 
I can't believe I haven't seen this before!! Could you rehost the map? <3

Red
 
Neither do I have the scripts nor the map on my disk xD
No clue where they are.. I got stuff from 4 years ago but this is missing..
 
A problem... The system isnt sumonning the monsters...
Help...
semttulonyg.png
 

Attachments

Post your setup of the script (config)
 
Back
Top