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

Lua Monster arena editing

aalqaq2

Trying to help, but I'm not too good at it.
Joined
Apr 10, 2017
Messages
112
Solutions
3
Reaction score
8
I want to add a few changes to this Monster Arena script. I can't remember who its by or I'd give them proper credit. I've made a few changes to it. I would like to add an entry fee, allow 4 summons per person to fight at the same time, and prevent multi-clients in this arena. Any help would be appreciated. Oh, I also need to remove the loot and loot message from the monsters when they die.


Lua:
MonsterArena = {

    fromPosition = { Position(32571,32321,7), Position(32573,32321,7) }, -- Location of entry tiles

    toPosition = { Position(32569,32312,7), Position(32571,32312,7) }, -- Location of arena entry


    spawnPosition = { Position(32569,32315,7), Position(32571,32310,7) }, -- Location of arena spawn


    area = {

       from = Position(32564,32307,7),

       to = Position(32576,32317,7)

    }, -- Arena size


    --exitPositon = Position(32570,32294,7), -- Location of exit tiles


    blockItemId = 3402,-- Blocking storage


    --Only convincable / summonable monsters

    monsters = {'Dwarf Guard', 'Orc Leader', 'Demon Skeleton', 'Orc Berserker', 'Gozzler', 'Quara Constrictor Scout', 'Assassin', 'Monk', 'Gargoyle', 'Tortoise','Minotaur Guard', 'Barbarian Bloodwalker', 'Dworc Voodoomaster', 'Tarantula', 'Stone Golem', 'Terramite', 'Lizard Templar', 'Elephant',},


    event = 'MonsterArenaDeath', -- Name of event

    reward = {itemId = 2160, count = 1}, -- Item reward id and count

    players = {}

}


--Check if player is in arena

function MonsterArena.hasPlayer(player)

    local position = player:getPosition() -- Assigning player position to variable

    return position.x <= MonsterArena.area.to.x and position.y <= MonsterArena.area.to.y and position.z == MonsterArena.area.from.z -- Make sure player is in arena

end


--Check if arena is occupied

function MonsterArena.isOccupied()

    for _, pid in ipairs(MonsterArena.players) do

       local player = Player(pid)

       if player and MonsterArena.hasPlayer(player) then

           return true

       end

    end


    return false

end


--Clean the arena

function MonsterArena.clean()

    for i = 1, #MonsterArena.players do

       MonsterArena.players[I] = nil

    end

end


-- When lever is used

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if item.itemid ~= 1945 then

       item:transform(1946) --Transform lever (flip position)

       return true

    end


    if MonsterArena.isOccupied() then

       player:sendCancelMessage('The arena is currently occupied. Please wait...') -- Send cancel message if arena is occupied

       return true

    end


    local players = {}


    for _, fromPosition in ipairs(MonsterArena.fromPosition) do

       local creature = Tile(fromPosition):getTopCreature()


       if not creature or not creature:isPlayer() then -- Check for two players entering

           player:sendCancelMessage('You need another player to enter the monster arena.')

           return true

       end


       table.insert(players,creature)

    end -- for


    MonsterArena.clean() -- Clean the arena


    local summons = {}


    MonsterArena.clean() -- Clean the arena


    for i, player in ipairs(players) do

       player:teleportTo(MonsterArena.toPosition[I]) -- Player enter arena

       MonsterArena.fromPosition[I]:sendMagicEffect(CONST_ME_POFF)

       MonsterArena.toPosition[I]:sendMagicEffect(CONST_ME_TELEPORT)


       local monsterName = MonsterArena.monsters[math.random(#MonsterArena.monsters)] --Get random monster

       local monster = Game.createMonster(monsterName, MonsterArena.spawnPosition[I], true) --Create the monster


       monster:setMaster(player) -- Set player as summoner

       monster:registerEvent(MonsterArena.event)

       table.insert(summons, monster)


       -----

       -- local monsterName1 = MonsterArena.monsters[math.random(#MonsterArena.monsters)] --Get random monster

       -- local monster1 = Game.createMonster(monsterName1, MonsterArena.spawnPosition[I], true) --Create the monster


       -- monster1:setMaster(player) -- Set player as summoner

       -- monster1:registerEvent(MonsterArena.event)

       -- table.insert(summons, monster1)


       -- local monsterName2 = MonsterArena.monsters[math.random(#MonsterArena.monsters)] --Get random monster

       -- local monster2 = Game.createMonster(monsterName2, MonsterArena.spawnPosition[I], true) --Create the monster


       -- monster2:setMaster(player) -- Set player as summoner

       -- monster2:registerEvent(MonsterArena.event)

       -- table.insert(summons, monster2)


       -- local monsterName3 = MonsterArena.monsters[math.random(#MonsterArena.monsters)] --Get random monster

       -- local monster3 = Game.createMonster(monsterName3, MonsterArena.spawnPosition[I], true) --Create the monster


       -- monster3:setMaster(player) -- Set player as summoner

       -- monster3:registerEvent(MonsterArena.event)

       -- table.insert(summons, monster3)


       -----


       Game.createItem(MonsterArena.blockItemId, 1, MonsterArena.spawnPosition[I]) -- Prevent additional players from entering the arena


       player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('A %s if fighting for you this round!', monsterName)) -- Inform player of monster assigned

       table.insert(MonsterArena.players, player.uid)

    end -- for


    --monster[1]:setTarget(summons[2]) -- Player 1 attack Player 2 (monster)

    --monster[2]:setTarget(summons[1]) -- Player 2 attack Player 1 (monster)

    players[1]:setTarget(summons[2]) -- Player 1 attack Player 2 (monster)

    players[2]:setTarget(summons[1]) -- Player 2 attack Player 1 (monster)


    item:transform(1945) -- Reset lever

    return true

end -- onUse


-- function onStepIn(cid, item, position, fromPosition)

    -- local list = {}

    -- local ips = {}

    -- local players = getPlayersOnline()


    -- for i, pid in ipairs(players) do

       -- local ip = getPlayerIp(pid)

       -- local tmp = table.find(ips, ip)


       -- if(tmp ~= nil) then

           -- if(table.countElements(list, ip) == 0) then

               -- list[players[tmp]] = ip

           -- end

           -- list[pid] = ip

       -- end

    

       -- table.insert(ips, ip)

    -- end


    -- if(table.maxn(list) > 0) then

       -- for pid, ip in pairs(list) do

           -- if getPlayerIp(cid) == ip then

               -- doTeleportThing(cid,fromPosition,true)

               -- doPlayerPopupFYI(cid, 'Alert: Events allow one player per IP  \nDuplicate IP found for: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'. Please close multi-client.')

               -- return true

           -- end

       -- end

    -- end

    -- return true

-- end
 
Back
Top