Este script eu fiz hoje, ele simplesmente é um atirador de minas subterrâneas (você não vê a mina instalada, sprites, etc) e quando alguém pisar no tile com uma mina subterrânea perderá certa quantidade de HP, podendo morrer ou não, depende da configuração e do hit.
Quando instalada a mina, você perderá uma quantia de mana, ela só pode ser instalada em certos tipos de chãos, determinados pela configuração do script, também não pode ser instalada dentro de Protection Zones, nem se você tiver dentro de uma.
Primeiro, adicione a seguinte linhas no seu actions.xml:
<action itemid="7435" script="other/mines.lua" allowfaruse="1"/>
Agora faça um script chamado mines.lua na pasta actions/scripts/other contendo:
local groundsArray = {[351] = 351, [352] = 352, [353] = 353, [354] = 354, [355] = 355}
-- configs
local manaspent = 100
local effecterror = 2
local effectok = 3
local vocationsArray = {[0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8}
-- end configs
function onUse(cid, item, fromPosition, itemEx, toPosition)
topos = toPosition
playerpos = getCreaturePosition(cid)
currentmana = getPlayerMana(cid)
playervoc = getPlayerVocation(cid)
if itemEx.actionid ~= 28900 then
if itemEx.actionid == 0 or itemEx.actionid == 100 and itemEx.actionid ~= 28900 then
if vocationsArray[playervoc] ~= nil then
if getPlayerMana(cid) >= manaspent then
if getTilePzInfo(topos) == FALSE then
if getTilePzInfo(playerpos) == FALSE then
if groundsArray[itemEx.itemid] ~= nil then
doSendMagicEffect(topos,effectok)
doSetItemActionId(itemEx.uid, 28900)
doPlayerAddMana(cid, -manaspent)
else
doPlayerSendTextMessage(cid, 20, "Você só pode implantar bombas em certos chãos.")
doSendMagicEffect(playerpos,effecterror)
end
else
doPlayerSendTextMessage(cid, 20, "Você não pode estar em uma protection zone para implantar bombas.")
doSendMagicEffect(playerpos,effecterror)
end
else
doPlayerSendTextMessage(cid, 20, "Você não pode implantar bombas em áreas de protection zone.")
doSendMagicEffect(playerpos,effecterror)
end
else
doPlayerSendTextMessage(cid, 20, "Você não tem mana suficiente.")
doSendMagicEffect(playerpos,effecterror)
end
else
doPlayerSendTextMessage(cid, 20, "Sua vocação não tem suporte para implantar bombas.")
doSendMagicEffect(playerpos,effecterror)
end
else
doPlayerSendTextMessage(cid, 20, "Você não pode implantar bombas neste SQM.")
doSendMagicEffect(playerpos,effecterror)
end
else
doPlayerSendTextMessage(cid, 20, "Uma bomba já está implantada neste SQM.")
doSendMagicEffect(playerpos,effecterror)
end
end
Configure os tiles que poderão ser implantados as bombas em negrito.
Adicione as seguintes linhas em movements.xml localizado na pasta movements:
<!-- Mine System --><movevent event="StepIn" actionid="28900" script="mineactive.lua"/>
Agora faça um script chamado mineactive.lua em movements/scripts contendo:
function onStepIn(cid, item, position, fromPosition)if isPlayer(cid) then
-- configs
local maykill = 0
local hit = math.random(4000,5000)
local talk = "OUCH!"
local minimumlevel = 20
-- end configs
currenthealth = getCreatureHealth(cid)
if currenthealth <= hit and maykill == 0 then
hit = currenthealth-1
end
playerlevel = getPlayerLevel(cid)
playerpos = getCreaturePosition(cid)
if playerlevel >= minimumlevel then
doCreatureAddHealth(cid, -hit)
doSendAnimatedText(playerpos, talk, 180)
doSendAnimatedText(playerpos, hit, 180)
doSendMagicEffect(playerpos,5)
doSetItemActionId(item.uid, 0)
end
end
end
Para implantar uma bomba, basta dar use with na arma do itemid 7435 e clicar em algum chão que não está restrito pelo script de implantação, ex.: 351, 352, 353, 354, 355; então quando algum player pisar no SQM que seja de level maior que o configurado no script, tomará o dano, podendo morrer ou não.
Screenshoot, tomando dano:
Bom proveito,
Yunie.