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

upgrade system field issue

highsanta

Advanced OT User
Joined
Dec 20, 2023
Messages
488
Solutions
6
Reaction score
198
Hey im using oens upgrade system and the elemental protection seems to work fine with player created fields but monster fields deal full damage in the element despite the protection.
has anyone experienced it or found solution reason for the bug?
Post automatically merged:

update seems to stop working completely even for player fields after stepping in the monster one! (or map aswell probably) so it must be because there is no owner of field?
Post automatically merged:

71d2f3fd57bfb477d32b650c53064074.gif
including short video presenting this
Post automatically merged:

C++:
void MagicField::onStepInField(Creature* creature)
{
    //remove magic walls/wild growth
    if (id == ITEM_MAGICWALL || id == ITEM_WILDGROWTH || id == ITEM_MAGICWALL_SAFE || id == ITEM_WILDGROWTH_SAFE || isBlocking()) {
        if (!creature->isInGhostMode()) {
            g_game.internalRemoveItem(this, 1);
        }

        return;
    }

    //remove magic walls/wild growth (only nopvp tiles/world)
    if (id == ITEM_MAGICWALL_NOPVP || id == ITEM_WILDGROWTH_NOPVP) {
        if (g_game.getWorldType() == WORLD_TYPE_NO_PVP || getTile()->hasFlag(TILESTATE_NOPVPZONE)) {
            g_game.internalRemoveItem(this, 1);
        }
        return;
    }

    const ItemType& it = items[getID()];
    if (it.conditionDamage) {
        Condition* conditionCopy = it.conditionDamage->clone();
        uint32_t ownerId = getOwner();
        if (ownerId) {
            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;
                    }
                }
            }

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

        creature->addCondition(conditionCopy);
    }
}

it seems that
conditionCopy->setParam(CONDITION_PARAM_OWNER, ownerId);
only fields with actual ownerId have divided damage. is there any way or option to fix that issue without having to add ownerId to every field at all times?
Post automatically merged:

added debug prints
Lua:
HealthChangeEvent.onHealthChange called
Creature: Test
Attacker: Test
Primary Damage: 15
Primary Type: 2
Secondary Damage: 0
Secondary Type: 0
Origin: 1
Creature is attacking itself
HealthChangeEvent.onHealthChange called
Creature: Test
Attacker is nil
Primary Damage: 30
Primary Type: 2
Secondary Damage: 0
Secondary Type: 0
Origin: 1
Creature or attacker is nil
as suspected by me it is the ownership of fields after all.
 
Last edited:

Similar threads

Back
Top