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
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:
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: