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

C++ ZONE_PVP Error!

zerox4365x

New Member
Joined
Apr 6, 2015
Messages
13
Solutions
2
Reaction score
1
Location
Chile
Well the theme is like this...

Resources:

  • TFS Version: 1.x+
  • Server Type: Canary (Click Here!)
  • Client Version: 12.x+

1st Topic: When a player is killed by another player in ZONE_PVP, is teleported to the temple, but can not move, it is as if the game was completely bugged or closed the connection with the player, but the player is still there in the position seeing everything stuck.

screenshot_369-png.70086

2nd Topic: When the player is killed by a monster in ZONE_PVP, literally dies, the player loses exp, skills, appears the message "You area dead", and you must reconnect to the server, as a normal death.

Screenshot_370.png

I found this by searching the sources:
C++:
bool Player::onKilledCreature(Creature* target, bool lastHit/* = true*/)
{
    bool unjustified = false;

    if (hasFlag(PlayerFlag_NotGenerateLoot)) {
        target->setDropLoot(false);
    }

    Creature::onKilledCreature(target, lastHit);

    if (Player* targetPlayer = target->getPlayer()) {
        if (targetPlayer && targetPlayer->getZone() == ZONE_PVP) {

            targetPlayer->setDropLoot(false);
            targetPlayer->setSkillLoss(false);
        } else if (!hasFlag(PlayerFlag_NotGainInFight) && !isPartner(targetPlayer)) {
            if (!Combat::isInPvpZone(this, targetPlayer) && hasAttacked(targetPlayer) && !targetPlayer->hasAttacked(this) && !isGuildMate(targetPlayer) && targetPlayer != this) {
                if (targetPlayer->hasKilled(this)) {
                    for (auto& kill : targetPlayer->unjustifiedKills) {
                        if (kill.target == getGUID() && kill.unavenged) {
                            kill.unavenged = false;
                            auto it = attackedSet.find(targetPlayer->guid);
                            attackedSet.erase(it);
                            break;
                        }
                    }
                } else if (targetPlayer->getSkull() == SKULL_NONE && !isInWar(targetPlayer)) {
                    unjustified = true;
                    addUnjustifiedDead(targetPlayer);
                }

                if (lastHit && hasCondition(CONDITION_INFIGHT)) {
                    pzLocked = true;
                    Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT, g_configManager().getNumber(WHITE_SKULL_TIME), 0);
                    addCondition(condition);
                }
            }
        }
    } else if (const Monster* monster = target->getMonster();
        TaskHuntingSlot* taskSlot = getTaskHuntingWithCreature(monster->getRaceId())) {
        if (const TaskHuntingOption* option = g_ioprey().GetTaskRewardOption(taskSlot)) {
            taskSlot->currentKills += 1;
            if ((taskSlot->upgrade && taskSlot->currentKills >= option->secondKills) ||
                (!taskSlot->upgrade && taskSlot->currentKills >= option->firstKills)) {
                taskSlot->state = PreyTaskDataState_Completed;
                sendTextMessage(MESSAGE_STATUS, "You succesfully finished your hunting task. Your reward is ready to be claimed!");
            }
            reloadTaskSlot(taskSlot->id);
        }
    }

    return unjustified;
}

I don't know if that has anything related to it. 😪
 

Attachments

  • Screenshot_369.png
    Screenshot_369.png
    153.4 KB · Views: 31 · VirusTotal
Last edited:
Solution
Well, i solved it by myself just creating an creatureEvent "onPrepareDeath" with this:

player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
player:teleportTo(player:getTown():getTemplePosition())
return false

Lua:
local pvpZoneDeath = CreatureEvent("pvpZoneDeath")

function pvpZoneDeath.onPrepareDeath(player, lastHitKiller, mostDamageKiller)
local fromPos = Position(5849, 6061, 7)
local toPos = Position(5919, 6090, 7)

    if player:isPlayer() and player:getPosition():isInRange(fromPos, toPos) then
        player:addHealth(player:getMaxHealth())
        player:addMana(player:getMaxMana())
        player:teleportTo(player:getTown():getTemplePosition())
        return false
    end
    return true
end...
Well, i solved it by myself just creating an creatureEvent "onPrepareDeath" with this:

player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
player:teleportTo(player:getTown():getTemplePosition())
return false

Lua:
local pvpZoneDeath = CreatureEvent("pvpZoneDeath")

function pvpZoneDeath.onPrepareDeath(player, lastHitKiller, mostDamageKiller)
local fromPos = Position(5849, 6061, 7)
local toPos = Position(5919, 6090, 7)

    if player:isPlayer() and player:getPosition():isInRange(fromPos, toPos) then
        player:addHealth(player:getMaxHealth())
        player:addMana(player:getMaxMana())
        player:teleportTo(player:getTown():getTemplePosition())
        return false
    end
    return true
end

pvpZoneDeath:register()

The problem is still in the sources, because the ZONE_PVP does not work as it should be programmed, but this way it was solved by the script.

SOLVED!
 
Solution
Back
Top