Replace
Alternative forgottenserver versions for older protocols support - nekiro/TFS-1.5-Downgrades
github.com
With
C++:
if (it.conditionDamage) {
Condition* conditionCopy = it.conditionDamage->clone();
uint32_t ownerId = getOwner();
if (ownerId) {
bool setOwner = true;
bool harmfulField = true;
if (g_game.getWorldType() == WORLD_TYPE_NO_PVP || getTile()->hasFlag(TILESTATE_NOPVPZONE)) {
Creature* owner = g_game.getCreatureByID(ownerId);
if (owner) {
if (owner->getPlayer() || (owner->isSummon() && owner->getMaster()->getPlayer())) {
harmfulField = false;
}
}
}
Player* targetPlayer = creature->getPlayer();
if (targetPlayer) {
Player* attackerPlayer = g_game.getPlayerByID(ownerId);
if (attackerPlayer) {
if (Combat::isProtected(attackerPlayer, targetPlayer)) {
harmfulField = false;
}
Tile* attackerTile = attackerPlayer->getTile();
if (attackerTile && attackerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
setOwner = false;
}
}
}
if (setOwner && (!harmfulField || (OTSYS_TIME() - createTime <= 5000) || creature->hasBeenAttacked(ownerId))) {
conditionCopy->setParam(CONDITION_PARAM_OWNER, ownerId);
}
}
creature->addCondition(conditionCopy);
}
do you know how can i add some time of pz locked on a player after using field runes?
thanks!
Post automatically merged: Apr 15, 2023
maybe it can be done here:
C++:
void Combat::combatTileEffects(const SpectatorVec& spectators, Creature* caster, Tile* tile, const CombatParams& params)
{
if (params.itemId != 0) {
uint16_t itemId = params.itemId;
switch (itemId) {
case ITEM_FIREFIELD_PERSISTENT_FULL:
itemId = ITEM_FIREFIELD_PVP_FULL;
break;
case ITEM_FIREFIELD_PERSISTENT_MEDIUM:
itemId = ITEM_FIREFIELD_PVP_MEDIUM;
break;
case ITEM_FIREFIELD_PERSISTENT_SMALL:
itemId = ITEM_FIREFIELD_PVP_SMALL;
break;
case ITEM_ENERGYFIELD_PERSISTENT:
itemId = ITEM_ENERGYFIELD_PVP;
break;
case ITEM_POISONFIELD_PERSISTENT:
itemId = ITEM_POISONFIELD_PVP;
break;
case ITEM_MAGICWALL_PERSISTENT:
itemId = ITEM_MAGICWALL;
break;
case ITEM_WILDGROWTH_PERSISTENT:
itemId = ITEM_WILDGROWTH;
break;
default:
break;
}
if (caster) {
Player* casterPlayer;
if (caster->isSummon()) {
casterPlayer = caster->getMaster()->getPlayer();
} else {
casterPlayer = caster->getPlayer();
}
if (casterPlayer) {
if (g_game.getWorldType() == WORLD_TYPE_NO_PVP || tile->hasFlag(TILESTATE_NOPVPZONE)) {
if (itemId == ITEM_FIREFIELD_PVP_FULL) {
itemId = ITEM_FIREFIELD_NOPVP;
} else if (itemId == ITEM_POISONFIELD_PVP) {
itemId = ITEM_POISONFIELD_NOPVP;
} else if (itemId == ITEM_ENERGYFIELD_PVP) {
itemId = ITEM_ENERGYFIELD_NOPVP;
} else if (itemId == ITEM_MAGICWALL) {
itemId = ITEM_MAGICWALL_NOPVP;
} else if (itemId == ITEM_WILDGROWTH) {
itemId = ITEM_WILDGROWTH_NOPVP;
}
} else if (itemId == ITEM_FIREFIELD_PVP_FULL || itemId == ITEM_POISONFIELD_PVP || itemId == ITEM_ENERGYFIELD_PVP) {
casterPlayer->addInFightTicks();
}
}
}
Item* item = Item::CreateItem(itemId);
if (caster) {
item->setOwner(caster->getID());
}
ReturnValue ret = g_game.internalAddItem(tile, item);
if (ret == RETURNVALUE_NOERROR) {
g_game.startDecay(item);
} else {
delete item;
}
}
if (params.tileCallback) {
params.tileCallback->onTileCombat(caster, tile);
}
if (params.impactEffect != CONST_ME_NONE) {
Game::addMagicEffect(spectators, tile->getPosition(), params.impactEffect);
}
}
Post automatically merged: Apr 15, 2023
ok, just had to change
casterPlayer->addInFightTicks();
to
casterPlayer->addInFightTicks(true);
because this is the function in player.cpp:
C++:
void Player::addInFightTicks(bool pzlock /*= false*/)
{
if (hasFlag(PlayerFlag_NotGainInFight)) {
return;
}
if (pzlock) {
pzLocked = true;
}
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT, g_config.getNumber(ConfigManager::PZ_LOCKED), 0);
addCondition(condition);
}
Post automatically merged: Apr 15, 2023
ok.. one more thing ^^
i tried to make it add pz lock for less time than default pz_lock.. so i've changed:
player.h
from
void addInFightTicks(bool pzlock = false);
to
void addInFightTicks(bool pzlock = false, int duration = -1);
player.cpp
from
C++:
void Player::addInFightTicks(bool pzlock /*= false*/)
{
if (hasFlag(PlayerFlag_NotGainInFight)) {
return;
}
if (pzlock) {
pzLocked = true;
}
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT, g_config.getNumber(ConfigManager::PZ_LOCKED), 0);
addCondition(condition);
}
to:
C++:
void Player::addInFightTicks(bool pzlock /*= false*/, int duration /*= -1*/)
{
if (hasFlag(PlayerFlag_NotGainInFight)) {
return;
}
if (pzlock) {
pzLocked = true;
}
int ticks = duration == -1 ? g_config.getNumber(ConfigManager::PZ_LOCKED) : duration;
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT, ticks, 0);
addCondition(condition);
}
and in combat.cpp
from
casterPlayer->addInFightTicks(true);
to
casterPlayer->addInFightTicks(true, 30000);
but, stills locking pz for 60s
(if i put more than default, it works, but less no..)
if anyone knows something about it, i would appreciate. thanks!