Postado Março 7, 2019 6 anos Galera, tenho um script que é de annihilator modificado, com opção de sumonar monstros em uma determinada área, porem eu gostaria de aprimorar ele, na parte de sumonar monstros na area determinada que o script entendesse que se tiver alguma coisa que empeça o local do respawn (parede, pedra, água e etc...) não desse erro e deixa-se de sumonar e sim sumonar em outro sqm que esta livre. Ou seja, sumonar naquela área porem ignorar os sqms bloqueados Citar local room = { -- room with demons fromX = 3966, fromY = 2914, fromZ = 7, toX = 3982, toY = 2930, toZ = 7 } local monster_pos = { [1] = {pos = {3970, 2918, 7}, monster = "Demon"} } local monster_area = { area = { topLeftPos = {x = 3974, y = 2922, z = 7}, bottomRightPos = {x = 3980, y = 2928, z = 7}, }, monsters = { {name = "Fire Elemental", count = 5}, {name = "Hellfire Fighter", count = 2}, } } local players_pos = { {x = 4128, y = 3000, z = 6, stackpos = 253}, {x = 4129, y = 3000, z = 6, stackpos = 253} } local new_player_pos = { {x = 3973, y = 2921, z = 7}, {x = 3974, y = 2921, z = 7} } local playersOnly = "no" local questLevel = 10 function onUse(cid, item, fromPosition, itemEx, toPosition) local all_ready, monsters, player, level = 0, 0, {}, 0 if item.itemid == 1945 then for i = 1, #players_pos do table.insert(player, 0) end for i = 1, #players_pos do player = getThingfromPos(players_pos) if player.itemid > 0 then if string.lower(playersOnly) == "yes" then if isPlayer(player.uid) == TRUE then all_ready = all_ready+1 else monsters = monsters+1 end else all_ready = all_ready+1 end end end if all_ready == #players_pos then for i = 1, #players_pos do player = getThingfromPos(players_pos) if isPlayer(player.uid) == TRUE then if getPlayerLevel(player.uid) >= questLevel then level = level+1 end else level = level+1 end end if level == #players_pos then if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then for _, area in pairs(monster_pos) do doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]}) end for i = 1, #monster_area.monsters do local PosX = math.random(monster_area.area.topLeftPos.x, monster_area.area.bottomRightPos.x) local PosY = math.random(monster_area.area.topLeftPos.y, monster_area.area.bottomRightPos.y) local PosZ = monster_area.area.topLeftPos.z local position = {x = PosX, y = PosY, z = PosZ} for k = 1, monster_area.monsters.count do doSummonCreature(monster_area.monsters.name, position, false, true) end end for i = 1, #players_pos do doSendMagicEffect(players_pos, CONST_ME_POFF) doTeleportThing(player.uid, new_player_pos, FALSE) doSendMagicEffect(new_player_pos, CONST_ME_ENERGYAREA) doTransformItem(item.uid,1946) end else doPlayerSendTextMessage(cid,19,"Only players can do this quest.") end else doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.") end else doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." players to do this quest.") end elseif item.itemid == 1946 then local player_room = 0 for x = room.fromX, room.toX do for y = room.fromY, room.toY do for z = room.fromZ, room.toZ do local pos = {x=x, y=y, z=z,stackpos = 253} local thing = getThingfromPos(pos) if thing.itemid > 0 then if isPlayer(thing.uid) == TRUE then player_room = player_room+1 end end end end end if player_room >= 1 then doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.") elseif player_room == 0 then for x = room.fromX, room.toX do for y = room.fromY, room.toY do for z = room.fromZ, room.toZ do local pos = {x=x, y=y, z=z,stackpos = 253} local thing = getThingfromPos(pos) if thing.itemid > 0 then doRemoveCreature(thing.uid) end end end end doTransformItem(item.uid,1945) end end return TRUE end
Postado Março 7, 2019 6 anos Citar local room = { -- room with demons fromX = 3966, fromY = 2914, fromZ = 7, toX = 3982, toY = 2930, toZ = 7 } local monster_pos = { [1] = {pos = {3970, 2918, 7}, monster = "Demon"} } local monster_area = { area = { topLeftPos = {x = 3974, y = 2922, z = 7}, bottomRightPos = {x = 3980, y = 2928, z = 7}, }, monsters = { {name = "Fire Elemental", count = 5}, {name = "Hellfire Fighter", count = 2}, } } local players_pos = { {x = 4128, y = 3000, z = 6, stackpos = 253}, {x = 4129, y = 3000, z = 6, stackpos = 253} } local new_player_pos = { {x = 3973, y = 2921, z = 7}, {x = 3974, y = 2921, z = 7} } local posss = { {x = 3974, y = 2921, z = 7} } local playersOnly = "no" local questLevel = 10 function onUse(cid, item, fromPosition, itemEx, toPosition) local all_ready, monsters, player, level = 0, 0, {}, 0 if item.itemid == 1945 then for i = 1, #players_pos do table.insert(player, 0) end for i = 1, #players_pos do player = getThingfromPos(players_pos) if player.itemid > 0 then if string.lower(playersOnly) == "yes" then if isPlayer(player.uid) == TRUE then all_ready = all_ready+1 else monsters = monsters+1 end else all_ready = all_ready+1 end end end if all_ready == #players_pos then for i = 1, #players_pos do player = getThingfromPos(players_pos) if isPlayer(player.uid) == TRUE then if getPlayerLevel(player.uid) >= questLevel then level = level+1 end else level = level+1 end end if level == #players_pos then if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then for _, area in pairs(monster_pos) do doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]}) end for i = 1, #monster_area.monsters do local PosX = math.random(monster_area.area.topLeftPos.x, monster_area.area.bottomRightPos.x) local PosY = math.random(monster_area.area.topLeftPos.y, monster_area.area.bottomRightPos.y) local PosZ = monster_area.area.topLeftPos.z local position = {x = PosX, y = PosY, z = PosZ} for k = 1, monster_area.monsters.count do doSummonCreature(monster_area.monsters.name, position, false, true) else doSummonCreature(monster_area.monsters.name, posss, false, true) end end for i = 1, #players_pos do doSendMagicEffect(players_pos, CONST_ME_POFF) doTeleportThing(player.uid, new_player_pos, FALSE) doSendMagicEffect(new_player_pos, CONST_ME_ENERGYAREA) doTransformItem(item.uid,1946) end else doPlayerSendTextMessage(cid,19,"Only players can do this quest.") end else doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.") end else doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." players to do this quest.") end elseif item.itemid == 1946 then local player_room = 0 for x = room.fromX, room.toX do for y = room.fromY, room.toY do for z = room.fromZ, room.toZ do local pos = {x=x, y=y, z=z,stackpos = 253} local thing = getThingfromPos(pos) if thing.itemid > 0 then if isPlayer(thing.uid) == TRUE then player_room = player_room+1 end end end end end if player_room >= 1 then doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.") elseif player_room == 0 then for x = room.fromX, room.toX do for y = room.fromY, room.toY do for z = room.fromZ, room.toZ do local pos = {x=x, y=y, z=z,stackpos = 253} local thing = getThingfromPos(pos) if thing.itemid > 0 then doRemoveCreature(thing.uid) end end end end doTransformItem(item.uid,1945) end end return TRUE end
Postado Março 7, 2019 6 anos Autor Em 07/03/2019 em 23:40, Adventure disse: Ainda não foi isso, mas estou tentando aqui. Valeu a atenção =)))
Postado Março 8, 2019 6 anos Testa ai. Mostrar conteúdo oculto local room = { -- room with demons fromX = 3966, fromY = 2914, fromZ = 7, toX = 3982, toY = 2930, toZ = 7 } local monster_pos = { [1] = {pos = {3970, 2918, 7}, monster = "Demon"} } local monster_area = { area = { topLeftPos = {x = 3974, y = 2922, z = 7}, bottomRightPos = {x = 3980, y = 2928, z = 7}, }, monsters = { {name = "Fire Elemental", count = 5}, {name = "Hellfire Fighter", count = 2}, } } local players_pos = { {x = 4128, y = 3000, z = 6, stackpos = 253}, {x = 4129, y = 3000, z = 6, stackpos = 253} } local new_player_pos = { {x = 3973, y = 2921, z = 7}, {x = 3974, y = 2921, z = 7} } local playersOnly = "no" local questLevel = 10 function onUse(cid, item, fromPosition, itemEx, toPosition) local all_ready, monsters, player, level = 0, 0, {}, 0 if item.itemid == 1945 then for i = 1, #players_pos do table.insert(player, 0) end for i = 1, #players_pos do player = getThingfromPos(players_pos) if player.itemid > 0 then if string.lower(playersOnly) == "yes" then if isPlayer(player.uid) == TRUE then all_ready = all_ready+1 else monsters = monsters+1 end else all_ready = all_ready+1 end end end if all_ready == #players_pos then for i = 1, #players_pos do player = getThingfromPos(players_pos) if isPlayer(player.uid) == TRUE then if getPlayerLevel(player.uid) >= questLevel then level = level+1 end else level = level+1 end end if level == #players_pos then if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then for _, area in pairs(monster_pos) do doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]}) end for i = 1, #monster_area.monsters do local PosX = math.random(monster_area.area.topLeftPos.x, monster_area.area.bottomRightPos.x) local PosY = math.random(monster_area.area.topLeftPos.y, monster_area.area.bottomRightPos.y) local PosZ = monster_area.area.topLeftPos.z local position = {x = PosX, y = PosY, z = PosZ} while not isWalkable(position, true) do position = {x = math.random(monster_area.area.topLeftPos.x, monster_area.area.bottomRightPos.x), y = math.random(monster_area.area.topLeftPos.y, monster_area.area.bottomRightPos.y)} end for k = 1, monster_area.monsters.count do doSummonCreature(monster_area.monsters.name, position, false, true) end end for i = 1, #players_pos do doSendMagicEffect(players_pos, CONST_ME_POFF) doTeleportThing(player.uid, new_player_pos, FALSE) doSendMagicEffect(new_player_pos, CONST_ME_ENERGYAREA) doTransformItem(item.uid,1946) end else doPlayerSendTextMessage(cid,19,"Only players can do this quest.") end else doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.") end else doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." players to do this quest.") end elseif item.itemid == 1946 then local player_room = 0 for x = room.fromX, room.toX do for y = room.fromY, room.toY do for z = room.fromZ, room.toZ do local pos = {x=x, y=y, z=z,stackpos = 253} local thing = getThingfromPos(pos) if thing.itemid > 0 then if isPlayer(thing.uid) == TRUE then player_room = player_room+1 end end end end end if player_room >= 1 then doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.") elseif player_room == 0 then for x = room.fromX, room.toX do for y = room.fromY, room.toY do for z = room.fromZ, room.toZ do local pos = {x=x, y=y, z=z,stackpos = 253} local thing = getThingfromPos(pos) if thing.itemid > 0 then doRemoveCreature(thing.uid) end end end end doTransformItem(item.uid,1945) end end return TRUE end Nós somos aquilo que fazemos repetidamente. Excelência, não é um modo de agir, mas um hábito. Aristóteles
Postado Março 8, 2019 6 anos @Zabim Ta aqui uma function que, com base na fromPos e na toPos, insere num array todas as posições que são andáveis. function getWalkablesPositions(fromPos, toPos) local walks_pos = {} for z = fromPos.z, toPos.z do for y = fromPos.y, toPos.y do for x = fromPos.x, toPos.x do local pos = {x = x, y = y, z = z} if isWalkable(pos) then table.insert(walk_pos, pos) end end end end return walks_pos end Não se esqueça de adicionar na sua LIB a function isWalkable(pos) Depois disso, é só fazer um math.random dentro do array retornado pela função na função que cria o monstro.
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.