• 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!

Feature [TFS 1.x] Freez System.. (Freezing rune)

Should I release advanced reward chest system? [ Counts everything you do due to killer]

  • No, there is already advanced one.

    Votes: 0 0.0%

  • Total voters
    7
  • Poll closed .

slavi

#define SLAVI32 _WIN32
Senator
Joined
Sep 9, 2015
Messages
681
Solutions
11
Reaction score
560
GitHub
slavidodo
Hello, I've looked around and didn't find a freez system for tfs 1+.

Let's begin then.

on Creature.cpp
Replace this function :
with this code.

on Player.h
search for
Code:
bool isInGhostMode() const {
below it add this code.
Code:
bool isFreezed() const {
            return freezed;
        }
void switchFreezed() {
            freezed = !freezed;
        }

search for
Code:
bool ghostMode;
and add this below it:
Code:
bool freezed;


on luaScript.h
add this lines where you see lines like it :D
Code:
        static int luaPlayerSetFreezed(lua_State* L);
        static int luaPlayerIsFreezed(lua_State* L);

on luaScript.cpp
search for
Code:
registerMethod("Player", "setGhostMode", LuaScriptInterface::luaPlayerSetGhostMode);
add this lines below it.
Code:
    registerMethod("Player", "isFreezed", LuaScriptInterface::luaPlayerIsFreezed);
    registerMethod("Player", "setFreezed", LuaScriptInterface::luaPlayerSetFreezed);

search for
Code:
int LuaScriptInterface::luaPlayerSetGhostMode(lua_State* L)
add this lines below it.
Code:
int LuaScriptInterface::luaPlayerSetFreezed(lua_State* L)
{
    // player:luaPlayerSetFreezed(enabled)
    Player* player = getUserdata<Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    bool enabled = getBoolean(L, 2);
    if (player->isFreezed() == enabled) {
        pushBoolean(L, true);
        return 1;
    }

    player->switchFreezed();
    pushBoolean(L, true);
    return 1;
}
int LuaScriptInterface::luaPlayerIsFreezed(lua_State* L)
{
    // player:isFreezed()
    const Player* player = getUserdata<const Player>(L, 1);
    if (player) {
        pushBoolean(L, player->isFreezed());
    }
    else {
        lua_pushnil(L);
    }
    return 1;
}

[EDIT]

If you want the freez to prevent player from casting spell do this.

If you want it to prevent him from casting spell
I think you should do this steps.

in Spells.cpp
search for
Code:
bool Spell::playerSpellCheck(Player* player) const
add this lines above it.
Code:
if (player->isFreezed()){
        return false;
    }

also search for
Code:
bool InstantSpell::playerCastInstant(Player* player, std::string& param)
add this lines after it :
Code:
if (player->isFreezed()){
        return false;
    }
also search for this
Code:
bool ConjureSpell::playerCastInstant(Player* player, std::string& param)
add this lines after it :
Code:
if (player->isFreezed()){
        return false;
    }
well, I didn't test this. So idk :D


-- Now you are done to sources --

Now go to data/actions/actions.xml
add this
PHP:
<action itemid="2282" script="freez.lua"/>

create a file called freez.lua in data/actions/scripts/

add this lines to it.
Code:
local interval = 5
local additonalInterval = 5
local storageFreez = 45195
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if exhaustion.get(cid,storage) then 
        player:sendCancelMessage("You are echausted.")
        return true
    end 
    if getTilePzInfo(toPosition) == true then 
        player:sendCancelMessage("You are on pz.")
        return true
    end 

    if not isPlayer(itemEx.uid) or cid == itemEx.uid then 
        player:sendCancelMessage("You can only use this on players.")
        return true
    end 
   
    local target = Player(itemEx.uid)
   
    if player.uid == target.uid then
        player:sendCancelMessage("You can't use on your self.")
        return true
    end
   
   
    if target:getGroup():getId() > 2 then
        player:sendCancelMessage("You can't freez this player.")
        return true
    end
    if target:isFreezed() then
        player:sendCancelMessage("Target is already freezed")
        return true
    end
    if target:getStorageValue(storageFreez) ~= 0 then
        player:sendCancelMessage("The player have free time.")
        return true
    end
    target:setFreezed(true)
    target:setStorageValue(storageFreez, 1)
    target:say("Freezed!", TALKTYPE_MONSTER_SAY)
   
    local exhaust = Condition(CONDITION_EXHAUST_HEAL)
    exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))
    player:addCondition(exhaust)
   
    preReload(target:getPosition(), interval)
    addEvent(totalRemoveFreez, (interval + additonalInterval) * 1000, target.uid)
   
    addEvent(removeFreeze, interval * 1000, target.uid) 
    return true 
end

local function removeFreeze(uid)
    Player(uid):say("Melted", TALKTYPE_MONSTER_SAY)
    Player(uid):setFreezed(false)
end

local function preReload(pos, delay)
    tile_freezed_time(pos, delay)
    for i = 1, (delay-1) do       
        addEvent(tile_freezed_time, i * 1000, pos, delay-i)
    end
end
local function tile_freezed_time(pos, delay)

    if delay > 1 then
        addEvent(tile_timer, 1000, id, pos, delay - 1, color)
    end
   
    local people = Game.getSpectators(pos, 7, 7, 5, 5, false, true)
   
    for i = 1, #people do
        people[i]:sendTextMessage(MESSAGE_EXPERIENCE, "Player will be unfreezed in " .. delay .. " second" .. (delay > 1 and "s" or "") .. ".", pos, delay, TEXTCOLOR_LIGHTGREEN)
    end
end
local function totalRemoveFreez(cid)
    local player = Player(cid)
    player:setStorageValue(storageFreez, 0)
end
 
Last edited:
just a question:
if the player get freeze, he can attack anothers, and cast spells and be attacked?
 
It just prevent the player from moving, but you could expand it using the "tools" that Slavi~ provided.
 
just a question:
if the player get freeze, he can attack anothers, and cast spells and be attacked?
No it's as Colors said, just preventing the player from moving.
But I can add this features when I get free time, I have a lot of chemistry and maths to study :D
 
just a question:
if the player get freeze, he can attack anothers, and cast spells and be attacked?
If you want it to prevent him from casting spell
I think you should do this steps.

in Spells.cpp
search for
Code:
bool Spell::playerSpellCheck(Player* player) const
add this lines above it.
Code:
if (player->isFreezed()){
        return false;
    }

also search for
Code:
bool InstantSpell::playerCastInstant(Player* player, std::string& param)
add this lines after it :
Code:
if (player->isFreezed()){
        return false;
    }
also search for this
Code:
bool ConjureSpell::playerCastInstant(Player* player, std::string& param)
add this lines after it :
Code:
if (player->isFreezed()){
        return false;
    }
well, I didn't test this. So idk :D
 
Nice mate! So u decided to share your reward system or not yet?

Can you please explain what does it make this "freez" system?
 
Last edited:
Question: Is this rune "spammeable" ?
I mean, 4 players can use this rune agaisn't same target 1 per 1?

In that case, that could become a kind of bug, is there a way to add some protection time to the target who has been freezed in the last "x" seconds/minutes?
Something like "This target has been recently freezed, you can freeze this target again in "x" seconds" or ..."x" minutes...
 
Question: Is this rune "spammeable" ?
I mean, 4 players can use this rune agaisn't same target 1 per 1?

In that case, that could become a kind of bug, is there a way to add some protection time to the target who has been freezed in the last "x" seconds/minutes?
Something like "This target has been recently freezed, you can freeze this target again in "x" seconds" or ..."x" minutes...
I forget to edit the freez.lua but you can make this.
Code:
if target:isFreezed() then
    player:say("This player is already freezed", 1)
    return false
end

I just made a freez system in sources.

I just made this function in sources :
Code:
//player:setFreezed(enabled) -- returns (un) or freezes the target
//player:isFreezed() -- returns bool of player freez state.

I tested it and no found any bugs.
 
I forget to edit the freez.lua but you can make this.
Code:
if target:isFreezed() then
    player:say("This player is already freezed", 1)
    return false
end

I just made a freez system in sources.

I just made this function in sources :
Code:
//player:setFreezed(enabled) -- returns (un) or freezes the target
//player:isFreezed() -- returns bool of player freez state.

I tested it and no found any bugs.

Thanks for the reply.

But what i mean is this:

1.- The target got freezed by player number 1
2.- The target got melted and then, player number 2 freeze the target again
3.- The same thing happends, the target got melted and get freezed again by player number 3

By this way, 4 players can "combo" freeze the player and that's pretty unfair... Is there a way to give the target a time protection agaisnt freeze effect after he's been freezed?
 
Thanks for the reply.

But what i mean is this:

1.- The target got freezed by player number 1
2.- The target got melted and then, player number 2 freeze the target again
3.- The same thing happends, the target got melted and get freezed again by player number 3

By this way, 4 players can "combo" freeze the player and that's pretty unfair... Is there a way to give the target a time protection agaisnt freeze effect after he's been freezed?
So you mean:
After the player is melted he have x time not to be freezed.
Can be done using storages.
 
#updated freez.lua so that the player can't be freezed for #additional interval configurable.
 
Last edited:
Unless I really really messed something up badly is doesn't handle 1.2 very well. No one on my server can move and no one can use the run the server console is filled with messages of
freez.lua:8 attempt to index global 'exhaustion' (a nil value)

But hey on the bright side when you said freeze it really does freeze literally everyone is frozen in spot.

I am also going to add in that I am in no way upset, this is obviously not a live server and I think it's hilarious. It made me day way better.
 
Unless I really really messed something up badly is doesn't handle 1.2 very well. No one on my server can move and no one can use the run the server console is filled with messages of

But hey on the bright side when you said freeze it really does freeze literally everyone is frozen in spot.

I am also going to add in that I am in no way upset, this is obviously not a live server and I think it's hilarious. It made me day way better.

I just added it to sources, i didn't care much with that lua script.

And this error you are facing is because you don't have exahust.lua in your libs.


and add this to your login.lua

Code:
if player:isFreezed() then
            player:setFreezed(false)
        end

or edit your sources.

in protocolgame.cpp

seach for :
Code:
player->setName(name);
Add above it
Code:
if (player->isFreezed) {
            player->switchFreezed();
        }
 
Back
Top