mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
entity ai classes, pigs should look around
This commit is contained in:
parent
6f603fcbe9
commit
8d454e5ec9
12 changed files with 206 additions and 38 deletions
|
|
@ -1,16 +1,14 @@
|
|||
<?php
|
||||
class Pig extends Animal{
|
||||
const TYPE = MOB_PIG;
|
||||
public $pathFinder, $pathFound, $path, $server, $pathNavigator;
|
||||
public $server;
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||
$this->pathFinder = new AStar($this); //make it before everything else as entity class constructor sends update
|
||||
$this->pathFound = false;
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic");
|
||||
$this->server = ServerAPI::request();
|
||||
$this->pathNavigator = new PathNavigator($this);
|
||||
$this->setSize($this->isBaby() ? 0.45 : 0.9, $this->isBaby() ? 0.45 : 0.9);
|
||||
$this->setName('Pig');
|
||||
$this->ai->addTask(new TaskLookAround());
|
||||
$this->update();
|
||||
}
|
||||
public function isFood($id){
|
||||
|
|
@ -22,22 +20,4 @@ class Pig extends Animal{
|
|||
array(($this->fire > 0 ? COOKED_PORKCHOP:RAW_PORKCHOP), 0, mt_rand(0,2)),
|
||||
);
|
||||
}
|
||||
|
||||
public function update(){
|
||||
/*if($this->pathFound && $this->path !== false && count($this->path) > 0){
|
||||
$this->pathFound = !$this->pathNavigator->followPath($this->path);
|
||||
}else{
|
||||
$start = new MinecraftNode(ceil($this->x), ceil($this->y), ceil($this->z));
|
||||
$stop = $start->add(mt_rand(-10, 10), 0, mt_rand(-10, 10));
|
||||
$this->path = $this->pathFinder->findPath($start, $stop); //allows diagonals, path should be ~5 blocks
|
||||
//var_dump($this->path);
|
||||
if($this->path !== false && count($this->path) > 0){
|
||||
$this->pathFound = true;
|
||||
}else{
|
||||
$this->moveTime = 30;
|
||||
}
|
||||
}*/ //uncomment to enable test moving
|
||||
|
||||
parent::update();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue