• 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++ onKilledCreature

alcapone

Member
Joined
Jan 13, 2021
Messages
247
Reaction score
19
Lua:
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(true);
   
            
        } else if (!hasFlag(PlayerFlag_NotGainInFight) && !isPartner(targetPlayer)) {
            bool canGainUnjust = hasAttacked(targetPlayer);
            if (!canGainUnjust && g_game.getWorldType() == WORLD_TYPE_RETRO_PVP) {
                canGainUnjust = lastHit;
            }

            if (!Combat::isInPvpZone(this, targetPlayer) && canGainUnjust && !targetPlayer->hasAttacked(this) && !isGuildMate(targetPlayer) && targetPlayer != this) {
                if (targetPlayer->hasKilled(this) && hasAttacked(targetPlayer)) {
                    
                    for (auto& kill : targetPlayer->unjustifiedKills) {
                        if (kill.target == getGUID() && kill.unavenged) {
                             auto it = attackedSet.find(targetPlayer->guid);
                            if (it != attackedSet.end()) {
                                kill.unavenged = false;
                                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_config.getNumber(ConfigManager::WHITE_SKULL_TIME), 0);
                    addCondition(condition);
                }
            }
        }
    }

    return unjustified;
}

I have a problem when I kill the player who is in a pvp zone he is taking a teleport to the temple without dropping his exp. when I activate to drop your xp everything works normal but the player is not sent to the temple
 
No expert in C++ but I think you need to post more information. What distro are you using, where do you "activate to drop your xp"?

From looking at it this function it returns the bool unjustified when called.

It returns false unless these parameters are met:
C++:
!Combat::isInPvpZone(this, targetPlayer) && canGainUnjust && !targetPlayer->hasAttacked(this) && !isGuildMate(targetPlayer) && targetPlayer != this
Not in PVP-Zone, can gain unjust, has not attacked?(unsure about this one), and is not a guild mate of the target player
C++:
else if (targetPlayer->getSkull() == SKULL_NONE && !isInWar(targetPlayer)) {
                    unjustified = true;
                    addUnjustifiedDead(targetPlayer);
                }
If target/victim player has no skull and is not participating in a war.

I cant find anything related to temple teleport or XP loss. You should be looking at another function, not sure which one tho. Where did you get this code, and what changes did you make?
 
No expert in C++ but I think you need to post more information. What distro are you using, where do you "activate to drop your xp"?

From looking at it this function it returns the bool unjustified when called.

It returns false unless these parameters are met:
C++:
!Combat::isInPvpZone(this, targetPlayer) && canGainUnjust && !targetPlayer->hasAttacked(this) && !isGuildMate(targetPlayer) && targetPlayer != this
Not in PVP-Zone, can gain unjust, has not attacked?(unsure about this one), and is not a guild mate of the target player
C++:
else if (targetPlayer->getSkull() == SKULL_NONE && !isInWar(targetPlayer)) {
                    unjustified = true;
                    addUnjustifiedDead(targetPlayer);
                }
If target/victim player has no skull and is not participating in a war.

I cant find anything related to temple teleport or XP loss. You should be looking at another function, not sure which one tho. Where did you get this code, and what changes did you make?
I made no change in the case is otbr plus tfs is the same as I remember. the teleport to the temple I think it's when he dies the problem is in the pvpzone check
in this case I'm doing an event in a pvp zone but the server is no-pvp.
 
Last edited:
Back
Top