• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

CreatureEvent [TFS 1.2] Revive system + resurrection spell by Zbizu

Status
Not open for further replies.
@Jeffro
auto resurrection will make you lose all your revive items so if you are trapped you're going to lose all of them and die anyway
unless you add tp to temple also
I see what you are saying. I have implemented a 24 hour exhaustion since I posted that. Plus, wasn't intended for function but study purposes as-well as yours. Thank you for your wisdom.
 
Last edited:
Guys, I tried everything in this topic make monsters stop to attack dead players but nothing works.....
Please I really need a help here, I only know the basic for scripting...
Can someone give me a hand?
Thanks!!!
 
Guys, I tried everything in this topic make monsters stop to attack dead players but nothing works.....
Please I really need a help here, I only know the basic for scripting...
Can someone give me a hand?
Thanks!!!

Try this.

Code:
<group id="0" name="player_dead" flags="8796093047055" access="0" maxdepotitems="0" maxvipentries="0" />
 
@strutZ I tried, and didn't work...
The monsters keep attaking me, and I can trap him with my dead body.
Anything to fix this?
 
Server Crashes, when i "suicide" to a fire field / or any field damage.
any clues?
 
Im sorry to revive an old thread but as it is stickied someone else might get the same issue as i did...

If you guys are having trouble with otclient not accepting your choice to revive just change " self:setHiddenHealth(true)" in "toggleDeath()" function to false,
for some weird reason that was the problem and well thats it
 
Possible to make so other players can walk thru the dead body?
 
based on @Colors revive system

F8XBPaw.jpg


6JozE6f.jpg


QG9cjNK.jpg


groups.xml:
Code:
    <group id="0" name="player_dead" flags="13194139558159" access="0" maxdepotitems="0" maxvipentries="0" />

creaturescripts.xml:
Code:
<event type="preparedeath" name="modalDeath" script="modaldeath.lua"/>
    <event type="modalwindow" name="deathMW" script="modaldeath.lua"/>
    <event type="login" name="loginDeath" script="modaldeath.lua"/>

modaldeath.lua:
Code:
-- revive system by zbizu
-- config
    local deathStorage = 250120
    local counterStorage = 250121 -- res expiration timestamp
    local deathGroupId = 0
    local reviveStone = 2674 -- red apple, change it
    local resTime = 30 * 60 -- 30 minutes
    local showCountdown = true -- shows timer above dead player
-- end of config

local condition = Condition(CONDITION_OUTFIT)
condition:setTicks(-1)

function Player:setHealth(value)
    if not self:isPlayer() then return false end
    self:addHealth(value - self:getHealth())
return true
end

function Player:setMana(value)
    if not self:isPlayer() then return false end
    self:addMana(value - self:getMana(), false)
return true
end


function buildModalWindow(cid)
    local player = Player(cid)
    local resitem = player:getItemCount(reviveStone)
   
    local modal = ModalWindow(999, "You are dead", "Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto the world in exchange for a small sacrifice. " .. (resitem > 0 and "\n\n" .. ItemType(reviveStone):getName() .. " x" .. resitem or "") .. "\n\nIf you choose to return, logout or your time run\nout, death penatly will be applied.")

    modal:addButton(1, "Return")
    modal:setDefaultEnterButton(1)
    modal:addButton(2, "Wait")
    modal:setDefaultEscapeButton(2)

    if resitem > 0 then
        modal:addButton(3, "Use Item")
    end

    return modal:sendToPlayer(player)
end

function Player:isDead()
    return self:getGroup():getId() == deathGroupId
end

function Player:die()
    self:toggleDeath()
    self:setStorageValue(counterStorage, -1)
    self:setStorageValue(deathStorage, 1)
    self:addHealth(-(self:getMaxHealth()))
    return true
end

function sendDeathWindowOnMove(cid, lockPos)
    local player = Player(cid)
    if not player then return false end
    if not player:isDead() then
        return false
    end
   
    if os.time() > player:getStorageValue(counterStorage) then
        player:die()
        return true
    end
   
    addEvent(sendDeathWindowOnMove, 100, cid, lockPos)
   
    if player:getPosition() ~= lockPos then
        player:teleportTo(lockPos)
        buildModalWindow(cid)
    end
   
    return true
end

function sendReviveCountdown(cid)
    if not showCountdown then return false end
    local player = Player(cid)
    if not player then return false end
    if not player:isDead() then
        return false
    end
   
    local timeleft = os.date("!%X",player:getStorageValue(counterStorage) - os.time()):split(":")
   
   
    player:say(timeleft[2] .. ":" .. timeleft[3], TALKTYPE_MONSTER_SAY)
    addEvent(sendReviveCountdown, 1000, cid)
    return true
end

function Player:toggleDeath(countdown)
    if self:isDead() then
        self:setGroup(Group(1))
        self:setHiddenHealth(false)
        self:setHealth(math.ceil(self:getMaxHealth() * 0.3))
        self:setMana(math.ceil(self:getMaxMana() * 0.3))
        self:removeCondition(CONDITION_OUTFIT)
        return true
    end
   
    if countdown then
        self:setStorageValue(counterStorage, os.time() + countdown)
    end
   
    self:setGroup(Group(deathGroupId))
    self:setHiddenHealth(true)
    buildModalWindow(self:getId())
   
    local pos = self:getPosition()
    sendDeathWindowOnMove(self:getId(), pos)
    sendReviveCountdown(self:getId())
   
    local npos = Position(pos.x + 1, pos.y, pos.z)
    if not Tile(npos) then
        Game.createTile(npos)
    end
   
    self:teleportTo(npos, true)
    return true
end

function onLogin(player)
    player:registerEvent("modalDeath")
    player:registerEvent("deathMW")
    player:registerEvent("loginDeath")

    if player:isDead() then
        if player:getStorageValue(counterStorage) == -1 then
            player:toggleDeath()
            return true
        end
       
        if os.time() > player:getStorageValue(counterStorage) then
            player:die()
            return true
        end
       
        player:setHiddenHealth(true)
        sendDeathWindowOnMove(player:getId(), player:getPosition())
        sendReviveCountdown(player:getId())
    end

    return true
end

function onPrepareDeath(creature, killer)
-- pvp kills may act weird
    if not creature:isPlayer() then
        return true
    end
   
    if creature:getStorageValue(deathStorage) == 1 then
        creature:setStorageValue(deathStorage, -1)
        return true
    end
   
    creature:toggleDeath(resTime)
    condition:setOutfit(creature:getSex() == PLAYERSEX_FEMALE and 3065 or 3058)
    creature:addCondition(condition)
    return false
end

function onModalWindow(player, modalWindowId, buttonId, choiceId)
    if modalWindowId ~= 999 then
        return false
    end
   
    if not player:isDead() then
        return false
    end
   
    if buttonId == 1 then
        player:die()
        return true
    elseif buttonId == 2 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You decided to wait for a healer. Move in any direction to send revival window again.")
        return true
    elseif buttonId == 3 then
        if player:getItemCount(reviveStone) == 0 then
            player:sendCancelMessage("You don't have any item to revive yourself.")
            return true
        end
       
        player:getItemById(reviveStone, true):remove(1)
        player:toggleDeath()
        local revst = ItemType(reviveStone)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You revived yourself with " .. revst:getArticle() .. " " .. revst:getName() .. ".")
    end
    return true
end


I tried it to TFS 1.3, When you "USE ITEM" the char do not revive and i cant set it back to templo or something it just still count down and cant move or do something... :(


Is it posible to TFS 1.3 ?
 
I tried it to TFS 1.3, When you "USE ITEM" the char do not revive and i cant set it back to templo or something it just still count down and cant move or do something... :(


Is it posible to TFS 1.3 ?
any console errors?
 
any console errors?

You just die with the character, then click "USE ITEM" instead of the character revive, you get stuck without being able to move and the countdown is active, you can log out and log in again and the same thing, it is stopped without being able to move, no no error message appears in the log ...

I disabled the tag in creaturesscript.xml so the character is untargetable and unreachable by other creatures and you can't attack anyone, the character is BUGGED
 
Did everything same as in 1st post but on tfs 1.3 modal window dont pop-up on death
did no changes in scripts
everything load corectly, no debugs at console
any hits why that happen?:/
 
Is it possible to implement this system on tfs 0.3.6 ??
 
Last edited:
is it possible to block in case the player dies for another player (higher damage) does not activate?
 
this script has bugs and is no longer maintained
If someone find a good solution (idea of solution) to these problems, I may reconsider rewriting it

the problems:
  • game balance: dead players could break pushing and throwing runes. Would need a lot of testing.
  • game balance: frag calculation would break, skull system would break. If someone dies, should the frag even be count? If 10 players are put on revive timer during a big war, they can coordinate causing an unexpected black skull. This would be as unfun as fake white skull bug in rl servers.
  • couldn't decide: should the game screen pause like on current death screen or not?
  • a lot of potential work to make it work in a satisfying way - fixes would most likely require source edits
 
Status
Not open for further replies.
Back
Top