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 :
on Player.h
search for
below it add this code.
search for
and add this below it:
on luaScript.h
add this lines where you see lines like it
on luaScript.cpp
search for
add this lines below it.
search for
add this lines below it.
[EDIT]
If you want the freez to prevent player from casting spell do this.
-- Now you are done to sources --
Now go to data/actions/actions.xml
add this
create a file called freez.lua in data/actions/scripts/
add this lines to it.
Let's begin then.
on Creature.cpp
Replace this function :
with this code.
on Player.h
search for
Code:
bool isInGhostMode() const {
Code:
bool isFreezed() const {
return freezed;
}
void switchFreezed() {
freezed = !freezed;
}
search for
Code:
bool ghostMode;
Code:
bool freezed;
on luaScript.h
add this lines where you see lines like it
Code:
static int luaPlayerSetFreezed(lua_State* L);
static int luaPlayerIsFreezed(lua_State* L);
on luaScript.cpp
search for
Code:
registerMethod("Player", "setGhostMode", LuaScriptInterface::luaPlayerSetGhostMode);
Code:
registerMethod("Player", "isFreezed", LuaScriptInterface::luaPlayerIsFreezed);
registerMethod("Player", "setFreezed", LuaScriptInterface::luaPlayerSetFreezed);
search for
Code:
int LuaScriptInterface::luaPlayerSetGhostMode(lua_State* L)
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 foradd this lines above it.Code:bool Spell::playerSpellCheck(Player* player) const
Code:if (player->isFreezed()){ return false; }
also search foradd this lines after it :Code:bool InstantSpell::playerCastInstant(Player* player, std::string& param)
also search for thisCode:if (player->isFreezed()){ return false; }
add this lines after it :Code:bool ConjureSpell::playerCastInstant(Player* player, std::string& param)
well, I didn't test this. So idkCode:if (player->isFreezed()){ return false; }
-- 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: