Oskar
Forum friend
- Dołączył
- Styczeń 24, 2009
- Posty
- 2256
- Liczba reakcji
- 331
By udowodni?, cho? nie musia?em tego robi?, ?e nie sk?pi? swoich skrypt?w i udost?pniam je tylko za po?rednictwem wymiany, tj. pieni?dze za skrypt, postanowi?em doda?, w?a?nie tutaj, na to forum, skrypt na Hunting Room Aren?.
~~Hunting Room Arena~~
[0] = {0, -1}, - to pozycja sk?d b?dzie pobiera? rodzaj potworka do danego teleportu, w praktyce ma to si? tak, ?e skrypt pobiera pozycj? teleportu i do jego pozycji 'x' dodaje 0, za? do pozycji 'y' dodaje -1. Czyli w ko?cowym rozrachunku wygl?da to tak: [0] = {pozycjaX, pozycjaY}
monsters = {'medusa', ... ,'green djinn'}, - to potwory, kt?re zostan? zaakceptowane pod to actionid. To znaczy, ?e nie b?dzie akceptowa? teleport?w, przy kt?rych stoi potw?r, kt?rego nie ma na tej li?cie.
centerRoomPositions = {{x=1730,y=1333,z=7}, ... ,{x=1808,y=1403,z=7}}, - pozycje ?rodk?w (!) pomieszcze?, kt?re b?d? naszymi hunting roomami. Wypisujemy tutaj wszystkie pokoje, kt?re b?d? 'obs?ugiwa?' dany gatunek potwor?w. W praktyce ma to si? tak, ?e (badaj?c ten przypadek) mamy grup? potwor?w typowo ziemnych i bagiennych, wi?c pozycje prowadz? do pomieszcze? o takiej tematyce. Czyli bagiennej i zwi?zanej z ziemi?.
tps={}, - w sumie niepotrzebne, wi?c nie rusza?
expTime = 10, - czas po jakim wyrzuci nas z rooma, w minutach
roomSize = {6,6}, - wielko?? pokoj?w, wa?ne jest by wszystkie by?y tej samej wielko?ci. Liczby oznaczaj? ca?kowit? szeroko?? pomieszczenia oraz wysoko?? dzielone przez dwa. Czyli maj?c pomieszczenie 10x10sqm wpiszemy w tym miejscu {5,5}
id={2157,1}, - wymagania by m?c wej?? do hunting rooma, mo?na wpisywa? dowoln? ilo?? item?w zachowuj?c odpowiedni spos?b wype?niania tej tabelki: {itemId1, count1, itemId2, count2, ... , itemIdx, countx}
count = {1,3} - ilo?? tworzonych potwor?w {od, do}
Wszystkim teleportom wewn?trz pokoj?w, czyli tym wychodz?cym, ustawiamy actionid 8002, tak samo kratkom wzywaj?cym nowe potwory, r?wnie? actionid 8002. W ka?dym pokoju to samo!!
Zdj?cie:
Tak ma wygl?da? room z teleportami, g?rne teleporty, gdzie potw?r stoi o jedn? kratk? ponad teleportem maj? mie? actionid 8000 (wszystkie!), za? te na dole, gdzie potw?r stoi pod teleportem actionid 8001.
Zdj?cie:
Jak wida? wyj?ciowy teleport ma mie? AID 8002, dok?adnie tak samo jak kratka, dzi?ki kt?rej wezwiemy nowe potwory na aren?.
~~Hunting Room Arena~~
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Hunting Room Arena" version="1.4" author="Oskar" contact="http://tibia.net.pl/members/oskar.html" enabled="no">
<config name="huntingRoom_conf"><![CDATA[
specialTiles = {5023, 473} --teleportId and tileId, ma to zapobiegac postawianiu potworka na teleporcie czy danej kratce
ignoreAcces = 5
huntingConfig = {
range = 4, --zasieg od centrum pokoju w kazda ze stron gdzie spawnowac bedzie potwory/gracza
storage = 1234, --storage zapisujace czas
czas = 4, --ilosc sekund potrzebnych do ponownego wejscia do roomu
[8000] = {[0] = {0, -1},
[1] = {monsters = {'medusa','hydra','bog raider','serpent spawn','wyvern','plague bearer','plaguesmith','defiler','giant spider','green djinn'},
centerRoomPositions = {{x=1730,y=1333,z=7},{x=1755,y=1333,z=7},{x=1783,y=1333,z=7},{x=1808,y=1333,z=7},
{x=1730,y=1354,z=7},{x=1755,y=1354,z=7},{x=1783,y=1354,z=7},{x=1808,y=1354,z=7},
{x=1730,y=1382,z=7},{x=1755,y=1382,z=7},{x=1783,y=1382,z=7},{x=1808,y=1382,z=7},
{x=1730,y=1403,z=7},{x=1755,y=1403,z=7},{x=1783,y=1403,z=7},{x=1808,y=1403,z=7}},
tps={}, expTime = 10, roomSize = {6,6},
id={2157,1}, count = {1,3}
},
[2] = {monsters = {'dragon','dragon lord','diabolic imp','infernalist','demon','hellhound','spark of the phoenix','fire devil','hellfire fighter','fire elemental','fury','draken elite','draken warmaster','draken spellweaver'},
centerRoomPositions = {{x=1631,y=1336,z=7},{x=1654,y=1336,z=7},{x=1681,y=1336,z=7},{x=1704,y=1336,z=7},
{x=1631,y=1354,z=7},{x=1654,y=1354,z=7},{x=1681,y=1354,z=7},{x=1704,y=1354,z=7},
{x=1631,y=1382,z=7},{x=1654,y=1382,z=7},{x=1681,y=1382,z=7},{x=1704,y=1382,z=7},
{x=1631,y=1400,z=7},{x=1654,y=1400,z=7},{x=1681,y=1400,z=7},{x=1704,y=1400,z=7}},
tps={}, expTime = 10, roomSize = {6,6},
id={2157,1}, count = {1,3}
},
},
[8001] = {[0] = {0, 1},
[1] = {monsters = {'grim reaper','nightmare','fallen island warlock','the chosen one','banshee','necromancer','behemoth','undead dragon'},
centerRoomPositions = {{x=1629,y=1303,z=7},{x=1648,y=1301,z=7},{x=1671,y=1303,z=7},{x=1690,y=1301,z=7},
{x=1713,y=1303,z=7},{x=1732,y=1301,z=7},{x=1755,y=1303,z=7},{x=1774,y=1301,z=7},
{x=1797,y=1303,z=7},{x=1816,y=1301,z=7},{x=1840,y=1303,z=7},{x=1859,y=1301,z=7}},
tps={}, expTime = 10, roomSize = {6,6},
id={2157,1}, count = {1,3}
},
[2] = {monsters = {'brimstone bug','juggernaut','bonelord','earth destroyer','lizard legionnaire'},
centerRoomPositions = {{x=1631,y=1336,z=7},{x=1654,y=1336,z=7},{x=1681,y=1336,z=7},{x=1704,y=1336,z=7},
{x=1631,y=1354,z=7},{x=1654,y=1354,z=7},{x=1681,y=1354,z=7},{x=1704,y=1354,z=7},
{x=1631,y=1382,z=7},{x=1654,y=1382,z=7},{x=1681,y=1382,z=7},{x=1704,y=1382,z=7},
{x=1631,y=1400,z=7},{x=1654,y=1400,z=7},{x=1681,y=1400,z=7},{x=1704,y=1400,z=7}},
tps={}, expTime = 10, roomSize = {6,6},
id={2157,1}, count = {1,3}
},
--[[[3] = {monsters = {'frost dragon','crystal spider','ice witch','ice golem','sea serpent'},
centerRoomPositions = {{x=1730,y=1333,z=7},{x=1755,y=1333,z=7},{x=1783,y=1333,z=7},{x=1808,y=1333,z=7},
{x=1730,y=1354,z=7},{x=1755,y=1354,z=7},{x=1783,y=1354,z=7},{x=1808,y=1354,z=7},
{x=1730,y=1382,z=7},{x=1755,y=1382,z=7},{x=1783,y=1382,z=7},{x=1808,y=1382,z=7},
{x=1730,y=1403,z=7},{x=1755,y=1403,z=7},{x=1783,y=1403,z=7},{x=1808,y=1403,z=7}},
tps={}, expTime = 10, roomSize = {6,6},
id={2157,1}, count = {1,3}
},--]]
--[[[4] = {monsters = {'spark of energy nothingness','ancient scarab','warlock','betrayed wraith','zaoan samurai','black knight'},
centerRoomPositions = {{x=1631,y=1336,z=7},{x=1654,y=1336,z=7},{x=1681,y=1336,z=7},{x=1704,y=1336,z=7},
{x=1631,y=1354,z=7},{x=1654,y=1354,z=7},{x=1681,y=1354,z=7},{x=1704,y=1354,z=7},
{x=1631,y=1382,z=7},{x=1654,y=1382,z=7},{x=1681,y=1382,z=7},{x=1704,y=1382,z=7},
{x=1631,y=1400,z=7},{x=1654,y=1400,z=7},{x=1681,y=1400,z=7},{x=1704,y=1400,z=7}},
tps={}, expTime = 10, roomSize = {6,6},
id={2157,1}, count = {1,3}
},--]]
}
}
playerRoomType = {
['monster'] = {},
['position'] = {}
}
function isWalkable(pos, creature, proj, pz)
if getTileThingByPos({x=pos.x,y=pos.y,z=pos.z,stackpos=0}).itemid == 0 then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
pos.stackpos = i
local tile = getTileThingByPos(pos)
if tile.itemid ~= 0 and not isCreature(tile.uid) then
if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
return false
end
end
end
return true
end
function checkTileFromPos(pos)
for i = 1, #specialTiles do
if getTileItemById(pos, i).uid > 0 then
return false end
end
return true
end
function checkPositions(fromPos, toPos, nb)
local pos = {x=math.random(fromPos.x,toPos.x), y=math.random(fromPos.y,toPos.y), z=math.random(fromPos.z,toPos.z)}
if isWalkable(pos, true, true, true) and checkTileFromPos(pos) then
return pos
end
return (nb < 200 and checkPositions(fromPos, toPos, nb+1) or false)
end
function doCreateRoomMonsters(roomType, monster, centerRoomPos, fromPos)
for i = 1, math.random(roomType.count[1], roomType.count[2]) do
local toPos = checkPositions({x=centerRoomPos.x-huntingConfig.range,y=centerRoomPos.y-huntingConfig.range,z=centerRoomPos.z}, {x=centerRoomPos.x+huntingConfig.range,y=centerRoomPos.y+huntingConfig.range,z=centerRoomPos.z}, 0)
local monster = doCreateMonster(monster, toPos, false)
doSendDistanceShoot(fromPos, getThingPos(monster), CONST_ANI_SUDDENDEATH)
doSendMagicEffect(getThingPos(monster), CONST_ME_MORTAREA)
end
return true
end
local _f = doTeleportThing
function doTeleportThing(cid, newpos, ignoreBlocking)
return (ignoreBlocking or isWalkable(newpos, true, true, false) or false) and _f(cid, newpos, true, true)
end
function doCleanRoom(centerRoomPosition, roomSize)
if getSpectators(centerRoomPosition, roomSize[1], roomSize[2]) then
for _, pid in pairs(getSpectators(centerRoomPosition, roomSize[1], roomSize[2])) do
if isMonster(pid) then
doRemoveThing(pid)
end
end
end
return true
end
function checkFreeRoom(cid, roomType, searchOwn)
local player
for _, pos in pairs(roomType.centerRoomPositions) do
player = false
if getSpectators(pos, roomType.roomSize[1], roomType.roomSize[2]) then
for _, pid in pairs(getSpectators(pos, roomType.roomSize[1], roomType.roomSize[2])) do
if isPlayer(pid) and getPlayerAccess(pid) < ignoreAcces then
if searchOwn then
if getCreatureName(cid):lower() == getCreatureName(pid):lower() and cid == pid then
return pos
end
else
player = true
break
end
end
end
end
if not(player and searchOwn) then
return doCleanRoom(pos, roomType.roomSize) and pos
end
end
if player then
return doCreatureSay(cid, 'Somebody are in the room!', TALKTYPE_ORANGE_1) and false
end
return false
end
function checkRoomType(aid, monster)
for k = (aid or 8000), (aid or 8001) do
for i = 1, #huntingConfig[k] do
if isInArray(huntingConfig[k][i].monsters, monster) then
return huntingConfig[k][i]
end
end
end
return false
end
]]></config>
<moveevent type="stepIn" name="huntingRoomStepIn" fromaid="8000" toaid="8074" event="script"><![CDATA[
domodlib('huntingRoom_conf')
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if isPlayer(cid) then
if item.itemid == 1387 and huntingConfig[item.actionid] then
if os.time() < getCreatureStorage(cid, huntingConfig.storage) then
return doTeleportThing(cid, fromPosition, true) and doCreatureSay(cid, 'You cannot enter on arena in '..getCreatureStorage(cid, huntingConfig.storage) - os.time()..' seconds yet.', TALKTYPE_ORANGE_1)
end
local pos = getThingPos(item.uid)
local monster = getTopCreature({x=pos.x+huntingConfig[item.actionid][0][1],y=pos.y+huntingConfig[item.actionid][0][2],z=pos.z}).uid
if not isCreature(monster) then
return print('ERROR: [Not found monster near teleport].')
end
local roomType = checkRoomType(item.actionid, getCreatureName(monster):lower())
if not roomType then
return print('ERROR: [Untypical \'roomType\' value. Probably invalid monster type on position near teleport].')
end
local newPos, message, itemCount = checkFreeRoom(cid, roomType), '', 0
if not newPos then
print('ERROR: [Untypical \'newPos\' value].')
return doTeleportThing(cid, fromPosition, true)
end
if type(roomType.id) == 'table' and #roomType.id > 1 then
for i = 1, #roomType.id/2 do
itemCount = itemCount + (getPlayerItemCount(cid, roomType.id[i*2-1]) >= roomType.id[i*2] and 1 or 0)
message = message .. roomType.id[i*2]..'x '..getItemNameById(roomType.id[i*2-1]) .. (roomType.id[i*2] > 1 and 's' or '') .. (i < #roomType.id/2 and ', ' or '.')
end
end
if itemCount ~= #roomType.id/2 then
return doTeleportThing(cid, fromPosition, true) and doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Requied items which need to enter to room is '..message)
end
for i = 1, #roomType.id/2 do
doPlayerRemoveItem(cid, roomType.id[i*2-1], roomType.id[i*2])
end
playerRoomType['monster'][cid] = getCreatureName(monster):lower()
playerRoomType['position'][cid] = {x=fromPosition.x + (roomType.tps[1] == 'x' and roomType.tps[2] or 0),y=fromPosition.y + (roomType.tps[1] == 'y' and roomType.tps[2] or 0),z=fromPosition.z}
doCreatureSetStorage(cid, huntingConfig.storage, os.time() + huntingConfig.czas)
doCreatureSetStorage(cid, huntingConfig.storage+1, os.time() + roomType.expTime * 60)
doCreateRoomMonsters(roomType, getCreatureName(monster):lower(), newPos, getThingPos(item.uid))
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE, 'For '..roomType.expTime..' minutes you kick from hunting room.')
doTeleportThing(cid, checkPositions({x=(newPos.x-huntingConfig.range),y=(newPos.y-huntingConfig.range),z=newPos.z}, {x=(newPos.x+huntingConfig.range),y=(newPos.y+huntingConfig.range),z=newPos.z}, 0), true)
return addEvent(function()
if isPlayer(cid) and playerRoomType['position'][cid] and os.time() == getCreatureStorage(cid, huntingConfig.storage+1) then
doTeleportThing(cid, playerRoomType['position'][cid], true)
playerRoomType['position'][cid] = 0
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE, 'Your time is over.')
doCreatureSetStorage(cid, huntingConfig.storage+1, 0)
return doCreatureSetStorage(cid, huntingConfig.storage, os.time() + huntingConfig.czas)
end end,
roomType.expTime * 60 * 1000,
cid, huntingConfig)
elseif item.itemid == 5023 and playerRoomType['position'][cid] and item.actionid == 8002 then
doTeleportThing(cid, playerRoomType['position'][cid], true)
playerRoomType['position'][cid] = 0
doCreatureSetStorage(cid, huntingConfig.storage+1, 0)
return doCreatureSetStorage(cid, huntingConfig.storage, os.time() + huntingConfig.czas)
end
if os.time() < getCreatureStorage(cid, huntingConfig.storage) then
return doPlayerSendCancel(cid, 'You cannot summon new creature still '..getCreatureStorage(cid,huntingConfig.storage)-os.time()..' seconds.')
end
local roomType = checkRoomType(false, playerRoomType['monster'][cid])
if not roomType then
return print('ERROR: [Untypical \'roomType\' value. Probably invalid monster type on position near teleport.].')
end
local newPos = checkFreeRoom(cid, roomType, true)
if type(newPos) == 'table' then
if getSpectators(newPos, roomType.roomSize[1], roomType.roomSize[2]) then
for _, pid in ipairs(getSpectators(newPos, roomType.roomSize[1], roomType.roomSize[2])) do
if isMonster(pid) and getCreatureName(pid):lower() == playerRoomType['monster'][cid] then
return doPlayerSendCancel(cid, 'You must kill all of the monsters ('..getCreatureName(pid)..') if you want create new monsters.')
end
end
end
doCreateRoomMonsters(roomType, playerRoomType['monster'][cid], newPos, getThingPos(item.uid))
return doCreatureSetStorage(cid, huntingConfig.storage, os.time() + huntingConfig.czas)
else
return print('ERROR: [Untypical \'newPos\' value].')
end
end
return true
end
]]></moveevent>
</mod>
Liczba w nawiasach kwadratowych '[ ]' to actionid teleportu prowadz?cego do pokoi z potworkami (szersze wyja?nienie ni?ej)[8000] = {[0] = {0, -1},
[1] = {monsters = {'medusa','hydra','bog raider','serpent spawn','wyvern','plague bearer','plaguesmith','defiler','giant spider','green djinn'},
centerRoomPositions = {{x=1730,y=1333,z=7},{x=1755,y=1333,z=7},{x=1783,y=1333,z=7},{x=1808,y=1333,z=7},
{x=1730,y=1354,z=7},{x=1755,y=1354,z=7},{x=1783,y=1354,z=7},{x=1808,y=1354,z=7},
{x=1730,y=1382,z=7},{x=1755,y=1382,z=7},{x=1783,y=1382,z=7},{x=1808,y=1382,z=7},
{x=1730,y=1403,z=7},{x=1755,y=1403,z=7},{x=1783,y=1403,z=7},{x=1808,y=1403,z=7}},
tps={}, expTime = 10, roomSize = {6,6},
id={2157,1}, count = {1,3}
},
[0] = {0, -1}, - to pozycja sk?d b?dzie pobiera? rodzaj potworka do danego teleportu, w praktyce ma to si? tak, ?e skrypt pobiera pozycj? teleportu i do jego pozycji 'x' dodaje 0, za? do pozycji 'y' dodaje -1. Czyli w ko?cowym rozrachunku wygl?da to tak: [0] = {pozycjaX, pozycjaY}
monsters = {'medusa', ... ,'green djinn'}, - to potwory, kt?re zostan? zaakceptowane pod to actionid. To znaczy, ?e nie b?dzie akceptowa? teleport?w, przy kt?rych stoi potw?r, kt?rego nie ma na tej li?cie.
centerRoomPositions = {{x=1730,y=1333,z=7}, ... ,{x=1808,y=1403,z=7}}, - pozycje ?rodk?w (!) pomieszcze?, kt?re b?d? naszymi hunting roomami. Wypisujemy tutaj wszystkie pokoje, kt?re b?d? 'obs?ugiwa?' dany gatunek potwor?w. W praktyce ma to si? tak, ?e (badaj?c ten przypadek) mamy grup? potwor?w typowo ziemnych i bagiennych, wi?c pozycje prowadz? do pomieszcze? o takiej tematyce. Czyli bagiennej i zwi?zanej z ziemi?.
tps={}, - w sumie niepotrzebne, wi?c nie rusza?
expTime = 10, - czas po jakim wyrzuci nas z rooma, w minutach
roomSize = {6,6}, - wielko?? pokoj?w, wa?ne jest by wszystkie by?y tej samej wielko?ci. Liczby oznaczaj? ca?kowit? szeroko?? pomieszczenia oraz wysoko?? dzielone przez dwa. Czyli maj?c pomieszczenie 10x10sqm wpiszemy w tym miejscu {5,5}
id={2157,1}, - wymagania by m?c wej?? do hunting rooma, mo?na wpisywa? dowoln? ilo?? item?w zachowuj?c odpowiedni spos?b wype?niania tej tabelki: {itemId1, count1, itemId2, count2, ... , itemIdx, countx}
count = {1,3} - ilo?? tworzonych potwor?w {od, do}
Wszystkim teleportom wewn?trz pokoj?w, czyli tym wychodz?cym, ustawiamy actionid 8002, tak samo kratkom wzywaj?cym nowe potwory, r?wnie? actionid 8002. W ka?dym pokoju to samo!!
Zdj?cie:

Tak ma wygl?da? room z teleportami, g?rne teleporty, gdzie potw?r stoi o jedn? kratk? ponad teleportem maj? mie? actionid 8000 (wszystkie!), za? te na dole, gdzie potw?r stoi pod teleportem actionid 8001.
Zdj?cie:

Jak wida? wyj?ciowy teleport ma mie? AID 8002, dok?adnie tak samo jak kratka, dzi?ki kt?rej wezwiemy nowe potwory na aren?.