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

Skull in PZ (fields)

LeOnArd0

Member
Joined
Jan 24, 2010
Messages
76
Reaction score
14
Hello guys.

Problem: Player A uses a fire field on the ground and enters a protection zone. Player B, steps on the field and player A takes the skull inside the protect zone and walks around with the skull inside the pz.
How do I block this action? I imagine "softening" this problem with a movements revscript that blocks the player from moving if he has a white skull in the protect zone. But if you understand another solution and can help me, please.

giphy (1).gif

Tks!!
 
This may solve your problem
C++:
        if (!targetPlayer->isInProtectionZone()) {
            setSkull(SKULL_WHITE);
            g_game.updateCreatureSkull(this);
        }

C++:
if(skull == SKULL_NONE)
{
    if(targetPlayer->getSkull() != SKULL_NONE)
        targetPlayer->sendCreatureSkull(this);
    else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
    {
        if (!targetPlayer->isInProtectionZone()) {
            setSkull(SKULL_WHITE);
            g_game.updateCreatureSkull(this);
        }
    }
}
 
Last edited:
This may solve your problem
C++:
        if (!targetPlayer->isInProtectionZone()) {
            setSkull(SKULL_WHITE);
            g_game.updateCreatureSkull(this);
        }

C++:
if(skull == SKULL_NONE)
{
    if(targetPlayer->getSkull() != SKULL_NONE)
        targetPlayer->sendCreatureSkull(this);
    else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
    {
        if (!targetPlayer->isInProtectionZone()) {
            setSkull(SKULL_WHITE);
            g_game.updateCreatureSkull(this);
        }
    }
}

Can you tell me which part of player.cpp I add?
 
TFS 1.5 - Downgrade Nekiro 7.72

Replace

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);
    }
 
C++:
if (it.conditionDamage) {
    auto conditionCopy = it.conditionDamage->clone();
    const auto ownerId = getOwner();
    if (ownerId) {

        bool setOwner = true;
        bool harmfulField = true;

        const auto worldType = g_game.getWorldType();
        const auto tile = getTile();
        if (worldType == WORLD_TYPE_NO_PVP || tile->hasFlag(TILESTATE_NOPVPZONE)) {
            if (const auto owner = g_game.getCreatureByID(ownerId)) {
                if (owner->getPlayer() || (owner->isSummon() && owner->getMaster()->getPlayer())) {
                    harmfulField = false;
                }
            }
        }

        if (const auto targetPlayer = creature->getPlayer()) {
            if (const auto attackerPlayer = g_game.getPlayerByID(ownerId)) {
                if (Combat::isProtected(attackerPlayer, targetPlayer)) {
                    harmfulField = false;
                }

                if (const auto attackerTile = attackerPlayer->getTile()) {
                    if (attackerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
                        setOwner = false;
                    }
                }
            }
        }

        const auto hasBeenAttacked = creature->hasBeenAttacked(ownerId);
        const auto withinAttackWindow = OTSYS_TIME() - createTime <= 5000;
        if (setOwner && (!harmfulField || withinAttackWindow || hasBeenAttacked)) {
            conditionCopy->setParam(CONDITION_PARAM_OWNER, ownerId);
        }
    }

    creature->addCondition(conditionCopy);
}
 
Replace

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);
    }

Perfect!!

Thank you very much, it worked perfectly.
 
Replace

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:

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:

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:

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!
 
Last edited:
Back
Top