fixed difficulty affecting player damage & armor for creatures

This commit is contained in:
GameHerobrine 2024-05-29 03:57:31 +03:00
parent 3a15dacf51
commit fc0f3f6bde
2 changed files with 14 additions and 13 deletions

View file

@ -44,10 +44,10 @@ abstract class Creature extends Living{
} }
public function getSpeedModifer(){ public function getSpeedModifer(){
return 0.7; //$this->speedModifer; //should be 0.7? return 0.7;
} }
public function getArmorValue(){ public function getArmorValue(){
return 2; return 0;
} }
public function spawn($player){ public function spawn($player){
if(!($player instanceof Player)){ if(!($player instanceof Player)){

View file

@ -1328,9 +1328,9 @@ class Entity extends Position
if (!$this->canBeAttacked) { if (!$this->canBeAttacked) {
return false; return false;
} }
if(is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false){ if(is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false){
if($this->attackTimeout > 0) return false; if($this->attackTimeout > 0) return false;
if(!$entity->isPlayer()){
switch($this->server->difficulty){ switch($this->server->difficulty){
//case 0: looks like mobs also have 0 attack dmg in peaceful mode //case 0: looks like mobs also have 0 attack dmg in peaceful mode
// $dmg = 0; // $dmg = 0;
@ -1343,6 +1343,7 @@ class Entity extends Position
break; break;
} }
} }
}
$dmg = $this->applyArmor($dmg, $cause); $dmg = $this->applyArmor($dmg, $cause);
$ret = $this->setHealth(max(- 128, $this->getHealth() - ((int) $dmg)), $cause, $force); $ret = $this->setHealth(max(- 128, $this->getHealth() - ((int) $dmg)), $cause, $force);