New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wandering NPC #1331

Closed
KeyTG opened this Issue Oct 15, 2017 · 6 comments

Comments

Projects
None yet
5 participants
@KeyTG

KeyTG commented Oct 15, 2017

Hey there, I'm having issues with NPC wandering?

I am trying to have the npc only wander a small area but am having issues with them wandering off into the wilderness randomly. I have tried using /npc movehere, /npc prange, and the wander waypoint modifiers xrange and yrange to keep him in one area, but none of them have worked. Am I doing something wrong, or is there something else that I can do?

@Midnight9746

This comment has been minimized.

Show comment
Hide comment
@Midnight9746

Midnight9746 Jan 23, 2018

Are you using /npc path?

That lets you set waypoints for the npc to walk between.

Example:

A and B, npc will walk back and forth

A, B, and C, npc will walk from a to b to c then back to a.

Watch how far you make the waypoints as the npc might speed up or tp to cover ground, also the surroundings where it might jump up onto blocks and zig zag to the destination.

Midnight9746 commented Jan 23, 2018

Are you using /npc path?

That lets you set waypoints for the npc to walk between.

Example:

A and B, npc will walk back and forth

A, B, and C, npc will walk from a to b to c then back to a.

Watch how far you make the waypoints as the npc might speed up or tp to cover ground, also the surroundings where it might jump up onto blocks and zig zag to the destination.

@fullwall

This comment has been minimized.

Show comment
Hide comment
@fullwall

fullwall Mar 15, 2018

Member

Latest build adds a tentative way to do this. Basically you can set up regions where the NPC is allowed to wander using the xrange/yrange as a box around each region. I'm not totally happy with how it works but let me know what you think.

Member

fullwall commented Mar 15, 2018

Latest build adds a tentative way to do this. Basically you can set up regions where the NPC is allowed to wander using the xrange/yrange as a box around each region. I'm not totally happy with how it works but let me know what you think.

@SlimeDog

This comment has been minimized.

Show comment
Hide comment
@SlimeDog

SlimeDog Mar 20, 2018

I am confused. Can you give an example of the commands, please?

SlimeDog commented Mar 20, 2018

I am confused. Can you give an example of the commands, please?

@fullwall

This comment has been minimized.

Show comment
Hide comment
@fullwall

fullwall Mar 20, 2018

Member

/wp provider wander
/npc path

Follow the instructions

Member

fullwall commented Mar 20, 2018

/wp provider wander
/npc path

Follow the instructions

@SlimeDog

This comment has been minimized.

Show comment
Hide comment
@SlimeDog

SlimeDog Mar 20, 2018

/npc select Killer
/waypoints provider wander
/npc path

does not give instructions to set xrange/yrange. However, range was set to default:

/citizens save

npc:
  '1':
    name: Killer
    uuid: 57523cee-360d-4468-a0fa-46949dfbb3fe
    traits:
      spawned: true
      lookclose:
        enabled: true
        range: '5.0'
        realisticlooking: false
      type: WOLF
      location:
        world: world
        x: '-464.1852'
        y: '69.0'
        z: '-245.076'
        yaw: '271.8398742675781'
        pitch: '0.0'
      waypoints:
        linear:
          points:
            '0':
              location:
                world: world
                x: '-465.5'
                y: '69.0'
                z: '-225.5'
                yaw: '135.0'
                pitch: '0.0'
        provider: wander
        wander:
          xrange: 3
          yrange: 25
      sentinel:
        stats_ticksSpawned: 71420650
        stats_timesSpawned: 2628
        stats_arrowsFired: 0
        stats_potionsThrow: 0
        stats_fireballsFired: 0
        stats_punches: 733
        stats_attackAttempts: 3645
        stats_damageTaken: 8.841066865921022
        stats_damageGiven: 540.9799998402596
        range: 20.0
        damage: 10.0
        armor: -1.0
        health: 20.0
        ranged_chase: false
        close_chase: true
        invincible: false
        fightback: true
        attackRate: 30
        healRate: 30
        guardingUpper: 0
        guardingLower: 0
        needsAmmo: false
        safeShot: true
        respawnTime: 100
        chaseRange: 64.0
        enemyDrops: false
        enemyTargetTime: 0
        stats_snowballsThrown: 0
        stats_eggsThrown: 0
        stats_skullsThrown: 0
        stats_pearlsUsed: 0
        attackRateRanged: 30
        speed: 2.0
        greet_range: 10.0
        autoswitch: false
        accuracy: 0.0
        spawnPoint:
          world: world
          x: '-465.5'
          y: '69.0'
          z: '-225.5'
          yaw: '135.0'
          pitch: '0.0'
        realistic: false
        reach: 3.0
        targets:
          '0': PASSIVE_MOB
          '1': MONSTER
        ignores:
          '0': PLAYER
          '1': OWNER
      wolfmodifiers:
        angry: false
        collarColor: RED
        sitting: false
        tamed: true
      age:
        age: 0
        locked: true
      owner:
...
    traitnames: type,waypoints,owner,wolfmodifiers,lookclose,mounttrait,location,spawned,sentinel,age,inventory
    navigator:
      stationaryticks: 100
      speedmodifier: '2.0'
      avoidwater: true
      usedefaultstuckaction: true
      pathfindingrange: '100.0'
    metadata:
      protected: false

(previous provider was linear). Killer immediately wandered off chasing rabbits, and was soon 100+ blocks distant.

SlimeDog commented Mar 20, 2018

/npc select Killer
/waypoints provider wander
/npc path

does not give instructions to set xrange/yrange. However, range was set to default:

/citizens save

npc:
  '1':
    name: Killer
    uuid: 57523cee-360d-4468-a0fa-46949dfbb3fe
    traits:
      spawned: true
      lookclose:
        enabled: true
        range: '5.0'
        realisticlooking: false
      type: WOLF
      location:
        world: world
        x: '-464.1852'
        y: '69.0'
        z: '-245.076'
        yaw: '271.8398742675781'
        pitch: '0.0'
      waypoints:
        linear:
          points:
            '0':
              location:
                world: world
                x: '-465.5'
                y: '69.0'
                z: '-225.5'
                yaw: '135.0'
                pitch: '0.0'
        provider: wander
        wander:
          xrange: 3
          yrange: 25
      sentinel:
        stats_ticksSpawned: 71420650
        stats_timesSpawned: 2628
        stats_arrowsFired: 0
        stats_potionsThrow: 0
        stats_fireballsFired: 0
        stats_punches: 733
        stats_attackAttempts: 3645
        stats_damageTaken: 8.841066865921022
        stats_damageGiven: 540.9799998402596
        range: 20.0
        damage: 10.0
        armor: -1.0
        health: 20.0
        ranged_chase: false
        close_chase: true
        invincible: false
        fightback: true
        attackRate: 30
        healRate: 30
        guardingUpper: 0
        guardingLower: 0
        needsAmmo: false
        safeShot: true
        respawnTime: 100
        chaseRange: 64.0
        enemyDrops: false
        enemyTargetTime: 0
        stats_snowballsThrown: 0
        stats_eggsThrown: 0
        stats_skullsThrown: 0
        stats_pearlsUsed: 0
        attackRateRanged: 30
        speed: 2.0
        greet_range: 10.0
        autoswitch: false
        accuracy: 0.0
        spawnPoint:
          world: world
          x: '-465.5'
          y: '69.0'
          z: '-225.5'
          yaw: '135.0'
          pitch: '0.0'
        realistic: false
        reach: 3.0
        targets:
          '0': PASSIVE_MOB
          '1': MONSTER
        ignores:
          '0': PLAYER
          '1': OWNER
      wolfmodifiers:
        angry: false
        collarColor: RED
        sitting: false
        tamed: true
      age:
        age: 0
        locked: true
      owner:
...
    traitnames: type,waypoints,owner,wolfmodifiers,lookclose,mounttrait,location,spawned,sentinel,age,inventory
    navigator:
      stationaryticks: 100
      speedmodifier: '2.0'
      avoidwater: true
      usedefaultstuckaction: true
      pathfindingrange: '100.0'
    metadata:
      protected: false

(previous provider was linear). Killer immediately wandered off chasing rabbits, and was soon 100+ blocks distant.

@SlimeDog

This comment has been minimized.

Show comment
Hide comment
@SlimeDog

SlimeDog Mar 20, 2018

I think I got it. I needed to set a wander waypoint (btw, I didn't see any documentation that this was necessary). Now Killer performs closer to expectations. One glitch: occasionally, he encounters a tall and wide glass wall, hovers for a while, then disappears (visually) and reappears further away on the other side of the wall. I guess he has trouble navigating around/through the wall (there are openings 10 blocks away from him). It seems like he navigates (internally) to a further point, struggles a while at the wall, then just teleports through it. That isn't good for my design, but it's better than previous behaviors.

SlimeDog commented Mar 20, 2018

I think I got it. I needed to set a wander waypoint (btw, I didn't see any documentation that this was necessary). Now Killer performs closer to expectations. One glitch: occasionally, he encounters a tall and wide glass wall, hovers for a while, then disappears (visually) and reappears further away on the other side of the wall. I guess he has trouble navigating around/through the wall (there are openings 10 blocks away from him). It seems like he navigates (internally) to a further point, struggles a while at the wall, then just teleports through it. That isn't good for my design, but it's better than previous behaviors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment