mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
randomwalking for all mobs
This commit is contained in:
parent
88cec22404
commit
4689809794
10 changed files with 27 additions and 9 deletions
|
|
@ -24,7 +24,7 @@ abstract class Creature extends Living{
|
|||
}
|
||||
|
||||
public function getSpeedModifer(){
|
||||
return $this->speedModifer;
|
||||
return 0.7; //$this->speedModifer; //should be 0.7?
|
||||
}
|
||||
public function getArmorValue(){
|
||||
return 2;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
class Monster extends Creature{
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->ai->addTask(new TaskAttackPlayer());
|
||||
//$this->ai->addTask(new TaskAttackPlayer());
|
||||
}
|
||||
|
||||
public function getAttackDamage(){
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class TaskRandomWalk extends TaskBase
|
|||
private $x, $z;
|
||||
public $moveSpeed;
|
||||
public function __construct($moveSpeed){
|
||||
$this->moveSpeed = 0.25;
|
||||
$this->moveSpeed = $moveSpeed;
|
||||
}
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
|
|
|
|||
|
|
@ -10,19 +10,28 @@ class Chicken extends Animal{
|
|||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 4, "generic");
|
||||
$this->setName('Chicken');
|
||||
$this->setSpeed(0.25);
|
||||
|
||||
$this->ai->addTask(new TaskRandomWalk(0.25));
|
||||
}
|
||||
public function isFood($id){
|
||||
return $id === PUMPKIN_SEEDS || $id === MELON_SEEDS || $id === BEETROOT_SEEDS || $id === WHEAT_SEEDS;
|
||||
}
|
||||
|
||||
public function updateEntityMovement(){
|
||||
parent::updateEntityMovement();
|
||||
|
||||
if($this->onGround && $this->speedY < 0) $this->speedY *= 0.6;
|
||||
|
||||
if($this->timeUntilEgg-- <= 0 && !$this->isBaby()){
|
||||
$this->dropAnEgg();
|
||||
$this->timeUntilEgg = mt_rand(0,6000) + 6000;
|
||||
}
|
||||
}
|
||||
|
||||
public function fall(){} //chickens have no fall dmg?
|
||||
|
||||
public function update($now){
|
||||
parent::update($now);
|
||||
if($this->timeUntilEgg-- <= 0 && !$this->isBaby()){
|
||||
$this->dropAnEgg();
|
||||
$this->timeUntilEgg = mt_rand(0,6000) + 6000;
|
||||
}
|
||||
}
|
||||
|
||||
public function dropAnEgg(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Cow extends Animal{
|
|||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 10, "generic");
|
||||
$this->setName("Cow");
|
||||
$this->setSpeed(0.2);
|
||||
$this->ai->addTask(new TaskRandomWalk(0.2));
|
||||
}
|
||||
|
||||
public function isFood($id){
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ class Sheep extends Animal{
|
|||
$this->data["Sheared"] = isset($this->data["Sheared"]) ? $this->data["Sheared"] : 0;
|
||||
$this->data["Color"] = isset($this->data["Color"]) ? $this->data["Color"] : $this->sheepColor();
|
||||
$this->setSpeed(0.25);
|
||||
|
||||
$this->ai->addTask(new TaskRandomWalk(0.25)); //in 1.5.2 it is 0.23, but according to ida it should be 1.0 which is 0.25 if converted to 1.5.2?
|
||||
$this->ai->addTask(new TaskEatTileGoal());
|
||||
|
||||
}
|
||||
|
||||
public function createSaveData(){
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ class Creeper extends Monster{
|
|||
$this->ignited = 0;
|
||||
$this->setSpeed(0.25);
|
||||
$this->timeUntilExplode = $this->isIgnited() ? self::EXPL_TIME : 0;
|
||||
|
||||
$this->ai->addTask(new TaskRandomWalk(0.25));
|
||||
}
|
||||
|
||||
public function getAttackDamage(){
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ class Skeleton extends Monster{
|
|||
$this->setName("Skeleton");
|
||||
$this->ai->removeTask("TaskAttackPlayer");
|
||||
//$this->ai->addTask(new TaskDestroyServerPerformance());
|
||||
$this->setSpeed(0.25);
|
||||
|
||||
$this->ai->addTask(new TaskRandomWalk(0.25));
|
||||
}
|
||||
|
||||
public function getAttackDamage(){
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class Spider extends Monster{
|
|||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
|
||||
$this->setName("Spider");
|
||||
$this->setSpeed(0.3);
|
||||
$this->ai->addTask(new TaskRandomWalk(0.25)); //TODO this mob doesnt use newAI -> speed is not correct
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ class Zombie extends Monster{
|
|||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 12, "generic");
|
||||
$this->setName("Zombie");
|
||||
$this->setSpeed(0.23);
|
||||
|
||||
$this->ai->addTask(new TaskRandomWalk(0.25));
|
||||
}
|
||||
|
||||
public function getArmorValue(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue