Unknown Soldier
Mapping a map
- Joined
- Oct 30, 2010
- Messages
- 293
- Solutions
- 11
- Reaction score
- 664
Hi everyone,
I am struggling with bugged ring of ending script.
When you put the ring on, everything goes fine, you will get the ring, or you will die, 50/50.
But the problem starts, when you pull off the ring during the event of messages... There are two variants when the ring is taken off from the ring slot:
- the event continues, you can still die when you are unlucky (but you can keep the unstable ring of ending)
- when you are lucky, you will clone the ring - so you will have one succesful ring in ring slot (ID 22516) and one unstable ring of ending (ID 22543) which you had in the beginning.
So I am searching for solution which will stop the event when you put the ring off, and simultaneously will stop the function preventing from logging off duiring the event.
Alternative solution would be making the unstable ring of ending impossible to take off, when you put it on. It will disappear when you die, or transform to succesful ring when you are lucky.
I have tried to put stopEvent in function onDeEquip(cid, item, slot), but didn't work.
Thanks in advance.
movements.xml
ringofending.lua
creaturescripts/logout.lua
I am struggling with bugged ring of ending script.
When you put the ring on, everything goes fine, you will get the ring, or you will die, 50/50.
But the problem starts, when you pull off the ring during the event of messages... There are two variants when the ring is taken off from the ring slot:
- the event continues, you can still die when you are unlucky (but you can keep the unstable ring of ending)
- when you are lucky, you will clone the ring - so you will have one succesful ring in ring slot (ID 22516) and one unstable ring of ending (ID 22543) which you had in the beginning.
So I am searching for solution which will stop the event when you put the ring off, and simultaneously will stop the function preventing from logging off duiring the event.
Alternative solution would be making the unstable ring of ending impossible to take off, when you put it on. It will disappear when you die, or transform to succesful ring when you are lucky.
I have tried to put stopEvent in function onDeEquip(cid, item, slot), but didn't work.
Thanks in advance.
movements.xml
Lua:
<movevent event="Equip" itemid="22543" slot="ring" function="onEquipItem" script="ringofending.lua"/>
<movevent event="DeEquip" itemid="22543" slot="ring" function="onDeEquipItem" script="ringofending.lua"/>
ringofending.lua
Lua:
local storage = 480658
local storage2 = 480663
local messages = {
{m = "The ring feels quite heavy now. Nothing else happens.", e = CONST_ME_MAGIC_GREEN},
{m = "The ring feels even heavier. You feel slightly stronger, however.", e = CONST_ME_MAGIC_GREEN},
{m = "You feel better, more energetic than ever before. The ring seems to wrap itself tighter around your finger."},
{m = "The ring now cuts your flesh. However, you feel fast as lightning and strong as a dragon, fires seem to burn within you."},
{m = "You feel as if you could touch the stars and see beyond even the dimmest of them. The ring hurts you now.", e = CONST_ME_MAGIC_GREEN},
{m = "The ring now seems to be as hot as fire while at the same time cold as ice. Put it off or it will seriously hurt you."},
{m = "Pain is no word for what you feel anymore. If you do not put the ring off it MAY kill you. Chances are 50/50.", e = CONST_ME_FIREWORK_YELLOW},
{m = "Your pain transports you in a different world, you are alone there. Filled with anguish. You may live or it MAY KILL YOU."},
{m = "You became pain itself. You are mere seconds away from death. If you do not PUT OFF THE RING. You MAY actually DIE.", e = CONST_ME_MORTAREA}
}
local function endRing(cid)
if not isPlayer(cid) then
return true
end
if getPlayerStorageValue(cid, storage) == 0 then
return true
end
local chance = math.random(1, 2)
if chance == 1 then
doPlayerRemoveItem(cid, 22543, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "The ring closes. It feels cool now. With the ring restored, you have returned.")
local itemUID = doCreateItemEx(22516, 1)
local item = Item(itemUID)
item:setAttribute(ITEM_ATTRIBUTE_TEXT,"This eternal ring was forged in the pain of " .. getCreatureName(cid) .. " and hardened by his/her endurance.")
doPlayerAddItemEx(cid, itemUID, true)
setPlayerStorageValue(cid, storage2, getPlayerStorageValue(cid, storage2) - 1)
else
doCreatureAddHealth(cid, -getCreatureHealth(cid))
doPlayerRemoveItem(cid, 22543, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "A bright explosion bursts from inside the ring. You die.")
setPlayerStorageValue(cid, storage2, getPlayerStorageValue(cid, storage2) - 1)
end
return true
end
function onEquip(cid, item, slot)
if getPlayerStorageValue(cid, storage) == 1 then
return true
else
setPlayerStorageValue(cid, storage, 1)
setPlayerStorageValue(cid, storage2, 1)
end
local time = 0
for m = 1, #messages do
addEvent(doPlayerSendTextMessage, time, cid.uid, MESSAGE_EVENT_ADVANCE, messages[m].m)
if messages[m].e then
addEvent(doSendMagicEffect, time, getPlayerPosition(cid.uid), messages[m].e)
end
time = time + 10000
end
addEvent(endRing, #messages * 10000, cid.uid)
return true
end
function onDeEquip(cid, item, slot)
if getPlayerStorageValue(cid, storage) == 0 then
return true
else
setPlayerStorageValue(cid, storage, 0)
end
return true
end
creaturescripts/logout.lua
Lua:
function onLogout(cid)
if (Player(cid):getStorageValue(480663) == 1) then
doPlayerSendCancel(cid, "You can not log out during these effects.")
return false
end
return true
end