default difficulty is now 2(normal), damage will change on easy/hard difficulty

This commit is contained in:
GameHerobrine 2024-04-01 12:29:20 +03:00
parent 2fb69cf607
commit 093efa0f2e
5 changed files with 21 additions and 3 deletions

View file

@ -126,7 +126,7 @@ class ServerAPI{
"gamemode" => SURVIVAL,
"hardcore" => false,
"pvp" => true,
"difficulty" => 1,
"difficulty" => 2,
"generator-settings" => "",
"level-name" => "world",
"level-seed" => "",

View file

@ -48,7 +48,7 @@ class PocketMinecraftServer{
$this->handlers = [];
$this->invisible = false;
$this->levelData = false;
$this->difficulty = 1;
$this->difficulty = 2;
$this->tiles = [];
$this->entities = [];
$this->custom = [];

View file

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

View file

@ -16,7 +16,7 @@ class Skeleton extends Monster{
}
public function getAttackDamage(){
return 0; //TODO special attack
return 0;
}
public function updateBurning(){

View file

@ -14,6 +14,9 @@ class Spider extends Monster{
$this->ai->addTask(new TaskAttackPlayer(1.0, 16)); //TODO fix range?
}
public function getAttackDamage(){
return 2;
}
public function attackEntity($entity, $distance){
if($distance > 2.0 && $distance < 6.0){