Comportamiento de los monstros / Monster AI

A

arah

Invited
Actualmente me interesa manipular el comportamiento del follow de las criaturas, ellas se manejan por un follow attack el cual funciona INMEDIATO lo cual limita a los jugadores de hacer plays entre otras cosas, dicho esto alguien me podría encaminar donde podría hacerlo?, he investigado mis sources entre otras cosas pero no ha sido tarea fácil, adicional a esto si hay alguien que sepa manipular este tipo de cosas podría contratarlo.

Segun mis investigaciones todo el comportamiento se basa al rededor de este Código:


Code:
if (const auto &followCreature = getFollowCreature()) {
                const Position &followPosition = followCreature->getPosition();
                const Position &pos = getPosition();

                int32_t offset_x = Position::getDistanceX(followPosition, pos);
                int32_t offset_y = Position::getDistanceY(followPosition, pos);
                if ((offset_x > 1 || offset_y > 1) && mType->info.changeTargetChance > 0) {
                    Direction dir = getDirectionTo(pos, followPosition);
                    const auto &checkPosition = getNextPosition(dir, pos);

                    if (const auto &nextTile = g_game().map.getTile(checkPosition)) {
                        const auto &topCreature = nextTile->getTopCreature();
                        if (followCreature != topCreature && isOpponent(topCreature)) {
                            selectTarget(topCreature);
                        }
                    }
                }
                if (offset_x <= 1 && offset_y <= 1) {
                    // seems like a target is near, it this case we need to slow down our movements (as a monster)
                    if (stepDuration < 2) {
                        stepDuration++;
                    }
                } else if (stepDuration > 0) {
                    stepDuration--;
                }
            } else if (isOpponent(creature)) {
                // we have no target lets try pick this one
                selectTarget(creature);
            }
        }
    }
}

El comportamiento que necesito actualmente seria que la criatura de una pequena pausa cuando el jugador se aleja por 1 segundo y vuelve a su spot, el codigo como esta actualmente la criatura SIEMPRE lo seguira instantaneamente y por ende el jugador jamas podra volver al sqm donde estaba, la criatura tiene una reaccion demasiado rapida.
 
Solution
Actualmente me interesa manipular el comportamiento del follow de las criaturas, ellas se manejan por un follow attack el cual funciona INMEDIATO lo cual limita a los jugadores de hacer plays entre otras cosas, dicho esto alguien me podría encaminar donde podría hacerlo?, he investigado mis sources entre otras cosas pero no ha sido tarea fácil, adicional a esto si hay alguien que sepa manipular este tipo de cosas podría contratarlo.

Segun mis investigaciones todo el comportamiento se basa al rededor de este Código:


Code:
if (const auto &followCreature = getFollowCreature()) {
                const Position &followPosition = followCreature->getPosition();
                const Position &pos = getPosition();

                int32_t...
Actualmente me interesa manipular el comportamiento del follow de las criaturas, ellas se manejan por un follow attack el cual funciona INMEDIATO lo cual limita a los jugadores de hacer plays entre otras cosas, dicho esto alguien me podría encaminar donde podría hacerlo?, he investigado mis sources entre otras cosas pero no ha sido tarea fácil, adicional a esto si hay alguien que sepa manipular este tipo de cosas podría contratarlo.

Segun mis investigaciones todo el comportamiento se basa al rededor de este Código:


Code:
if (const auto &followCreature = getFollowCreature()) {
                const Position &followPosition = followCreature->getPosition();
                const Position &pos = getPosition();

                int32_t offset_x = Position::getDistanceX(followPosition, pos);
                int32_t offset_y = Position::getDistanceY(followPosition, pos);
                if ((offset_x > 1 || offset_y > 1) && mType->info.changeTargetChance > 0) {
                    Direction dir = getDirectionTo(pos, followPosition);
                    const auto &checkPosition = getNextPosition(dir, pos);

                    if (const auto &nextTile = g_game().map.getTile(checkPosition)) {
                        const auto &topCreature = nextTile->getTopCreature();
                        if (followCreature != topCreature && isOpponent(topCreature)) {
                            selectTarget(topCreature);
                        }
                    }
                }
                if (offset_x <= 1 && offset_y <= 1) {
                    // seems like a target is near, it this case we need to slow down our movements (as a monster)
                    if (stepDuration < 2) {
                        stepDuration++;
                    }
                } else if (stepDuration > 0) {
                    stepDuration--;
                }
            } else if (isOpponent(creature)) {
                // we have no target lets try pick this one
                selectTarget(creature);
            }
        }
    }
}

El comportamiento que necesito actualmente seria que la criatura de una pequena pausa cuando el jugador se aleja por 1 segundo y vuelve a su spot, el codigo como esta actualmente la criatura SIEMPRE lo seguira instantaneamente y por ende el jugador jamas podra volver al sqm donde estaba, la criatura tiene una reaccion demasiado rapida.
Hola,

parece que si sea en esta parte, yo pienso que habria que hacer una variable para "saber en donde aparece el monstruo" tipo: getPosition ( a saber si existe ese tipo de function ), de ahi en la parte donde mueve el monstruo hacer lo necessario en caso , ejemplo el monstruo tiene que estar a 5sqm maximo de su spawn,

Code:
Position spawnMonsterPosition = getPosition();

Y trabajar algo tipo:

Code:
if (const auto& followCreature = getFollowCreature()) {
    const Position& followPosition = followCreature->getPosition();
    const Position& pos = getPosition();

    int32_t offset_x = Position::getDistanceX(followPosition, pos);
    int32_t offset_y = Position::getDistanceY(followPosition, pos);

    int32_t distanceFromSpawn = Position::getDistanceX(spawnMonsterPosition, pos) + Position::getDistanceY(spawnMonsterPosition, pos);

    if (distanceFromSpawn > 5) {
        Direction dirToSpawn = getDirectionTo(pos, spawnMonsterPosition);
        const auto& checkPosition = getNextPosition(dirToSpawn, pos);

        if (const auto& nextTile = g_game().map.getTile(checkPosition)) {
            if (nextTile->isWalkable()) {
                walk(dirToSpawn);
            }
        }
        return;
    }

Algo asi seria quizas, pero no puedo confirmar si es algo que funcionaria, hay que probar, y quizas preguntar a alguien que sepa mas C++
 
Solution

Tibia Server Lists

#1 FEATURED US Ultron OT 1,503 / 5,000Online EXPStages PROTO8.6 ENGINEUltron OT RANK PTS5.9 +100% VOTES0 #2 FEATURED US Nefera 179 / 0Online EXPx1 PROTO15.20 ENGINECrystal Server RANK PTS5.1 +100% VOTES0 #3 FEATURED ES Deixis 1 / 0Online EXPStages PROTO1098 ENGINETFS RANK PTS3.7 +100% VOTES1 #4 FEATURED ES Maeli 10 / 150Online EXPx10 PROTO10.98 ENGINETFS 1.4.2 RANK PTS3.7 +100% VOTES0 #5 MX Marlboro War 36 / 300Online EXP999 PROTO8.6 ENGINETFS 0.3.7 RANK PTS5.5 -33% VOTES0 #6 BR Tibinha YurOts 18 / 150Online EXPStages PROTO7.4 ENGINEYurOTS 1.5 RANK PTS5.2 -14% VOTES0 #7 US Halera 2 / 0Online EXPStages PROTO10.98 ENGINETFS 1.4.2 RANK PTS4.9 -83% VOTES0 #8 BR Exordion Legacy 52 / 2,000Online EXPx2 PROTO7.72 ENGINEExordion RANK PTS4.9 +100% VOTES0 #9 PL Lubelski 5 / 1,000Online EXP200 PROTO7.6 ENGINELubelskiOTS 2.56.0 RANK PTS4.6 -15% VOTES0 #10 DE DBU Online 0 / 400Online EXP11 PROTO8.6 ENGINETFS 1.0 RANK PTS4.3 +100% VOTES0 #11 PL ReWar 0 / 2,000Online EXPcustom PROTO8.6 ENGINEOther RANK PTS4.3 0% VOTES0 #12 PL Velesta 0 / 1,000Offline EXP20 PROTO8.0 ENGINETFS 1.4.2 RANK PTS4.3 -99% VOTES0 #13 ES JustRL FreeTC 1530 22 / 250Online EXPx2 PROTO15.30 ENGINECrystal Server RANK PTS4.3 +100% VOTES0 #14 ES Farlia Global 2026 0 / 333Offline EXPx5 PROTO15.25 ENGINEFarliaServ 1.525 RANK PTS3.9 -22% VOTES0 #15 SE MortalisOT Custom 0 / 500Offline EXP100x -1.2x PROTO10.98 ENGINEMortalisOT V1 RANK PTS3.8 +100% VOTES0 #16 US Rommania 0 / 500Online EXPstages, x10 PROTO7.4 ENGINETFS 0.4 RANK PTS3.6 +100% VOTES0 #17 US BerethaOnline 3 / 2,000Online EXPStages PROTO10.98 ENGINETFS RANK PTS3.5 +100% VOTES0
Top