From bae0d4618eae1a167b9d647660261a76128fbf19 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Mon, 23 Jan 2023 17:39:57 +0300 Subject: [PATCH] armor rewrite --- src/astarnavigator/TileNavigator.php | 4 +- .../algorithms/Pythagoras3D.php | 2 +- .../providers/MCDiagonalProvider.php | 4 +- src/entity/Creature.php | 4 +- src/entity/Entity.php | 69 ++++++++----------- src/entity/Living.php | 2 +- src/entity/ai/EntityAI.php | 2 +- src/entity/monster/Creeper.php | 2 +- src/entity/monster/PigZombie.php | 2 +- src/entity/monster/Skeleton.php | 2 +- src/entity/monster/Zombie.php | 6 +- src/material/item/armor/ArmorItem.php | 2 + src/material/item/armor/ChainBootsItem.php | 5 ++ .../item/armor/ChainChestplateItem.php | 4 ++ src/material/item/armor/ChainHelmetItem.php | 4 ++ src/material/item/armor/ChainLeggingsItem.php | 4 ++ src/material/item/armor/DiamondBootsItem.php | 4 ++ .../item/armor/DiamondChestplateItem.php | 4 ++ src/material/item/armor/DiamondHelmetItem.php | 4 ++ .../item/armor/DiamondLeggingsItem.php | 4 ++ src/material/item/armor/GoldenBootsItem.php | 4 ++ .../item/armor/GoldenChestplateItem.php | 4 ++ src/material/item/armor/GoldenHelmetItem.php | 4 ++ .../item/armor/GoldenLeggingsItem.php | 4 ++ src/material/item/armor/IronBootsItem.php | 4 ++ .../item/armor/IronChestplateItem.php | 4 ++ src/material/item/armor/IronHelmetItem.php | 4 ++ src/material/item/armor/IronLeggingsItem.php | 4 ++ src/material/item/armor/LeatherBootsItem.php | 4 ++ src/material/item/armor/LeatherCapItem.php | 4 ++ src/material/item/armor/LeatherPantsItem.php | 4 ++ src/material/item/armor/LeatherTunicItem.php | 4 ++ src/utils/Utils.php | 20 +++--- src/world/Explosion.php | 8 +-- 34 files changed, 143 insertions(+), 67 deletions(-) diff --git a/src/astarnavigator/TileNavigator.php b/src/astarnavigator/TileNavigator.php index 22163dfb..67077bc7 100644 --- a/src/astarnavigator/TileNavigator.php +++ b/src/astarnavigator/TileNavigator.php @@ -1,9 +1,9 @@ blockedProvider = $blockedProvider; diff --git a/src/astarnavigator/algorithms/Pythagoras3D.php b/src/astarnavigator/algorithms/Pythagoras3D.php index 9c4ae13c..7651a3ac 100644 --- a/src/astarnavigator/algorithms/Pythagoras3D.php +++ b/src/astarnavigator/algorithms/Pythagoras3D.php @@ -7,7 +7,7 @@ class Pythagoras3D implements IDistanceAlgorithm public function calculate(PathTile $from, PathTile $to) { if($from instanceof PathTileXYZ && $to instanceof PathTileXYZ){ - return Utils::distance_noroot($from->asArray(), $to->asArray()); + return Utils::distance_noroot($from->asArray(), $to->asArray()); } return INF; } diff --git a/src/astarnavigator/providers/MCDiagonalProvider.php b/src/astarnavigator/providers/MCDiagonalProvider.php index e671b710..811c6838 100644 --- a/src/astarnavigator/providers/MCDiagonalProvider.php +++ b/src/astarnavigator/providers/MCDiagonalProvider.php @@ -13,12 +13,12 @@ class MCDiagonalProvider implements INeighborProvider foreach(MCDiagonalProvider::$neighbors as $offset){ $pnt = $tile->addOffset($offset); if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y, $pnt->z, false)->isSolid){ - if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y - 1, $pnt->z, false)->isSolid){ + if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y - 1, $pnt->z, false)->isSolid){ --$pnt->y; } $pnts[] = $pnt; }else{ - if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y + 1, $pnt->z, false)->isSolid){ + if(!$tile->level->getBlockWithoutVector($pnt->x, $pnt->y + 1, $pnt->z, false)->isSolid){ ++$pnt->y; $pnts[] = $pnt; } diff --git a/src/entity/Creature.php b/src/entity/Creature.php index 6e5d1b98..3fd81cc6 100644 --- a/src/entity/Creature.php +++ b/src/entity/Creature.php @@ -28,7 +28,9 @@ abstract class Creature extends Living{ public function getSpeedModifer(){ return $this->speedModifer * ($this->inPanic ? 1.4 : 0.7); } - + public function getArmorValue(){ + return 2; + } public function spawn($player){ if(!($player instanceof Player)){ $player = $this->server->api->player->get($player); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 38f97871..53fefbb8 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -73,7 +73,7 @@ class Entity extends Position public $hasKnockback; public $hasJumped; public $onGround, $inWater; - + public $carryoverDamage; function __construct(Level $level, $eid, $class, $type = 0, $data = array()) { $this->random = new Random(); @@ -754,7 +754,7 @@ class Entity extends Position } } if($this->knockbackTime > 0){ - --$this->knockbackTime; + --$this->knockbackTime; } if($this->moveTime > 0){ @@ -1272,6 +1272,7 @@ class Entity extends Position if (! $this->canBeAttacked) { return false; } + $dmg = $this->applyArmor($dmg, $cause); //TODO HURTCAM $ret = $this->setHealth(max(- 128, $this->getHealth() - ((int) $dmg)), $cause, $force); if ($ret != false && $this->hasKnockback && is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false) { @@ -1350,7 +1351,7 @@ class Entity extends Position public function moveEntityWithOffset($oX, $oY, $oZ) { - $oX = $oX === 0 ? $this->speedX : ($this->getSpeedModifer() * $oX * $this->getSpeed()); + $oX = $oX === 0 ? $this->speedX : ($this->getSpeedModifer() * $oX * $this->getSpeed()); $oY = $oY <= 0 ? $this->speedY : (0.5); $oZ = $oZ === 0 ? $this->speedZ : ($this->getSpeedModifer() * $oZ * $this->getSpeed()); $this->setVelocity($oX, $oY, $oZ); @@ -1360,7 +1361,29 @@ class Entity extends Position { return $this->speedModifer; } - + public function getArmorValue(){ + $pnts = 0; + if($this->isPlayer()){ + foreach($this->player->armor as $slot => $part){ + if($part instanceof ArmorItem){ + $pnts += $part->getDamageReduceAmount(); + $this->player->damageArmorPart($slot, $part); + } + } + $this->player->sendArmor($this->player); + } + return $pnts; + } + public function applyArmor($damage, $cause){ + if(is_numeric($cause)){ + $var3 = 25 - $this->getArmorValue(); + $var4 = $damage * $var3 + $this->carryoverDamage; + $damage = $var4 / 25; + $this->carryoverDamage = $var4 % 25; + } + return $damage; + } + public function setHealth($health, $cause = "generic", $force = false) { $health = (int) $health; @@ -1368,42 +1391,6 @@ class Entity extends Position if($health < $this->health){ $harm = true; $dmg = $this->health - $health; - if($this->class === ENTITY_PLAYER and ($this->player instanceof Player)){ - $points = 0; - $values = array( - LEATHER_CAP => 1, - LEATHER_TUNIC => 3, - LEATHER_PANTS => 2, - LEATHER_BOOTS => 1, - CHAIN_HELMET => 1, - CHAIN_CHESTPLATE => 5, - CHAIN_LEGGINGS => 4, - CHAIN_BOOTS => 1, - GOLDEN_HELMET => 1, - GOLDEN_CHESTPLATE => 5, - GOLDEN_LEGGINGS => 3, - GOLDEN_BOOTS => 1, - IRON_HELMET => 2, - IRON_CHESTPLATE => 6, - IRON_LEGGINGS => 5, - IRON_BOOTS => 2, - DIAMOND_HELMET => 3, - DIAMOND_CHESTPLATE => 8, - DIAMOND_LEGGINGS => 6, - DIAMOND_BOOTS => 3 - ); - foreach($this->player->armor as $slot => $part){ - if($part instanceof Item and isset($values[$part->getID()])){ - if(is_numeric($cause)){ // check was entity damage by another entity - $points += $values[$part->getID()]; - $this->player->damageArmorPart($slot, $part); - } - } - } - $this->player->sendArmor($this->player); - $dmg = (int) ($dmg - ($dmg * $points * 0.04)); - $health = $this->health - $dmg; - } if(($this->class !== ENTITY_PLAYER or (($this->player instanceof Player) and (($this->player->gamemode & 0x01) === 0x00 or $force === true))) and ($this->dmgcounter[0] < microtime(true) or $this->dmgcounter[1] < $dmg) and ! $this->dead){ $this->dmgcounter[0] = microtime(true) + 0.5; $this->dmgcounter[1] = $dmg; @@ -1492,7 +1479,7 @@ class Entity extends Position } public function getAttackDamage(){ - return 0; + return 0; } public function setSpeed($s) diff --git a/src/entity/Living.php b/src/entity/Living.php index 3b849047..6aa61a0d 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -34,7 +34,7 @@ abstract class Living extends Entity implements Damageable, Pathfindable{ $this->ai->updateTasks(); } if($this->onGround){ - //if(!$this->hasPath() && $this->pathFinder instanceof ITileNavigator){ + //if(!$this->hasPath() && $this->pathFinder instanceof ITileNavigator){ // $this->path = $this->pathFinder->navigate(new PathTileXYZ($this->x, $this->y, $this->z, $this->level), new PathTileXYZ($this->x + mt_rand(-10, 10), $this->y + mt_rand(-1, 1), $this->z + mt_rand(-10, 10), $this->level), 10); //} $this->pathFollower->followPath(); diff --git a/src/entity/ai/EntityAI.php b/src/entity/ai/EntityAI.php index 5a08915c..b9e9929f 100644 --- a/src/entity/ai/EntityAI.php +++ b/src/entity/ai/EntityAI.php @@ -47,7 +47,7 @@ class EntityAI } public function updateTasks(){ - if(!($this->entity instanceof Entity)) return; + if(!($this->entity instanceof Entity)) return; foreach($this->tasks as $t){ if(!$t->isStarted && $t->canBeExecuted($this)){ $t->isStarted = true; diff --git a/src/entity/monster/Creeper.php b/src/entity/monster/Creeper.php index ca83b02a..8ec5c501 100644 --- a/src/entity/monster/Creeper.php +++ b/src/entity/monster/Creeper.php @@ -15,7 +15,7 @@ class Creeper extends Monster{ } public function getAttackDamage(){ - return 0; //TODO special attack + return 0; //TODO special attack } public function setIgnited($v = null){ diff --git a/src/entity/monster/PigZombie.php b/src/entity/monster/PigZombie.php index d409d089..44724f67 100644 --- a/src/entity/monster/PigZombie.php +++ b/src/entity/monster/PigZombie.php @@ -10,7 +10,7 @@ class PigZombie extends Monster{ $this->update(); } public function getAttackDamage(){ - return 5; + return 5; } public function getDrops(){ return [ diff --git a/src/entity/monster/Skeleton.php b/src/entity/monster/Skeleton.php index 6ed4a269..443dc438 100644 --- a/src/entity/monster/Skeleton.php +++ b/src/entity/monster/Skeleton.php @@ -11,7 +11,7 @@ class Skeleton extends Monster{ } public function getAttackDamage(){ - return 0; //TODO special attack + return 0; //TODO special attack } public function updateBurning(){ diff --git a/src/entity/monster/Zombie.php b/src/entity/monster/Zombie.php index a91f7b96..26502a8e 100644 --- a/src/entity/monster/Zombie.php +++ b/src/entity/monster/Zombie.php @@ -10,6 +10,10 @@ class Zombie extends Monster{ $this->update(); } + public function getArmorValue(){ + return 2; + } + public function updateBurning(){ if($this->fire > 0 or !$this->level->isDay()){ return false; @@ -31,7 +35,7 @@ class Zombie extends Monster{ } public function getAttackDamage(){ - return 4; //TODO vanillafy(zombies might be able to hold items) + return 4; //TODO vanillafy(zombies might be able to hold items) } public function update(){ diff --git a/src/material/item/armor/ArmorItem.php b/src/material/item/armor/ArmorItem.php index a96dd368..ebb5536d 100644 --- a/src/material/item/armor/ArmorItem.php +++ b/src/material/item/armor/ArmorItem.php @@ -10,6 +10,8 @@ abstract class ArmorItem extends Item{ //abstract to avoid making instances of i public abstract function getBaseDurability(); + public abstract function getDamageReduceAmount(); + public function getMaxDurability(){ return $this->getMaterialDurability() * $this->getBaseDurability(); } diff --git a/src/material/item/armor/ChainBootsItem.php b/src/material/item/armor/ChainBootsItem.php index 5b191ed6..73083238 100644 --- a/src/material/item/armor/ChainBootsItem.php +++ b/src/material/item/armor/ChainBootsItem.php @@ -13,5 +13,10 @@ class ChainBootsItem extends ArmorItem{ public function getBaseDurability(){ return 13; } + public function getDamageReduceAmount() + { + return 1; + } + } \ No newline at end of file diff --git a/src/material/item/armor/ChainChestplateItem.php b/src/material/item/armor/ChainChestplateItem.php index 9cb828ea..ae28d0c5 100644 --- a/src/material/item/armor/ChainChestplateItem.php +++ b/src/material/item/armor/ChainChestplateItem.php @@ -13,4 +13,8 @@ class ChainChestplateItem extends ArmorItem{ public function getBaseDurability(){ return 16; } + public function getDamageReduceAmount() + { + return 5; + } } \ No newline at end of file diff --git a/src/material/item/armor/ChainHelmetItem.php b/src/material/item/armor/ChainHelmetItem.php index 2feb327f..df7c83d9 100644 --- a/src/material/item/armor/ChainHelmetItem.php +++ b/src/material/item/armor/ChainHelmetItem.php @@ -13,4 +13,8 @@ class ChainHelmetItem extends ArmorItem{ public function getBaseDurability(){ return 11; } + public function getDamageReduceAmount() + { + return 1; + } } \ No newline at end of file diff --git a/src/material/item/armor/ChainLeggingsItem.php b/src/material/item/armor/ChainLeggingsItem.php index 5eb2a6bd..9d1800b1 100644 --- a/src/material/item/armor/ChainLeggingsItem.php +++ b/src/material/item/armor/ChainLeggingsItem.php @@ -13,4 +13,8 @@ class ChainLeggingsItem extends ArmorItem{ public function getBaseDurability(){ return 15; } + public function getDamageReduceAmount() + { + return 4; + } } \ No newline at end of file diff --git a/src/material/item/armor/DiamondBootsItem.php b/src/material/item/armor/DiamondBootsItem.php index 1dc83743..4591f9d8 100644 --- a/src/material/item/armor/DiamondBootsItem.php +++ b/src/material/item/armor/DiamondBootsItem.php @@ -13,4 +13,8 @@ class DiamondBootsItem extends ArmorItem{ public function getBaseDurability(){ return 13; } + public function getDamageReduceAmount() + { + return 3; + } } \ No newline at end of file diff --git a/src/material/item/armor/DiamondChestplateItem.php b/src/material/item/armor/DiamondChestplateItem.php index bef55eb6..fad4edce 100644 --- a/src/material/item/armor/DiamondChestplateItem.php +++ b/src/material/item/armor/DiamondChestplateItem.php @@ -13,4 +13,8 @@ class DiamondChestplateItem extends ArmorItem{ public function getBaseDurability(){ return 16; } + public function getDamageReduceAmount() + { + return 8; + } } \ No newline at end of file diff --git a/src/material/item/armor/DiamondHelmetItem.php b/src/material/item/armor/DiamondHelmetItem.php index 85ed1d27..b0e53cbc 100644 --- a/src/material/item/armor/DiamondHelmetItem.php +++ b/src/material/item/armor/DiamondHelmetItem.php @@ -13,4 +13,8 @@ class DiamondHelmetItem extends ArmorItem{ public function getBaseDurability(){ return 11; } + public function getDamageReduceAmount() + { + return 3; + } } \ No newline at end of file diff --git a/src/material/item/armor/DiamondLeggingsItem.php b/src/material/item/armor/DiamondLeggingsItem.php index 0ce50996..ef2e005d 100644 --- a/src/material/item/armor/DiamondLeggingsItem.php +++ b/src/material/item/armor/DiamondLeggingsItem.php @@ -13,4 +13,8 @@ class DiamondLeggingsItem extends ArmorItem{ public function getBaseDurability(){ return 15; } + public function getDamageReduceAmount() + { + return 6; + } } \ No newline at end of file diff --git a/src/material/item/armor/GoldenBootsItem.php b/src/material/item/armor/GoldenBootsItem.php index b61d8647..1ac0f9a4 100644 --- a/src/material/item/armor/GoldenBootsItem.php +++ b/src/material/item/armor/GoldenBootsItem.php @@ -13,4 +13,8 @@ class GoldenBootsItem extends ArmorItem{ public function getBaseDurability(){ return 13; } + public function getDamageReduceAmount() + { + return 1; + } } \ No newline at end of file diff --git a/src/material/item/armor/GoldenChestplateItem.php b/src/material/item/armor/GoldenChestplateItem.php index ce50bf1f..739617b6 100644 --- a/src/material/item/armor/GoldenChestplateItem.php +++ b/src/material/item/armor/GoldenChestplateItem.php @@ -13,4 +13,8 @@ class GoldenChestplateItem extends ArmorItem{ public function getBaseDurability(){ return 16; } + public function getDamageReduceAmount() + { + return 5; + } } \ No newline at end of file diff --git a/src/material/item/armor/GoldenHelmetItem.php b/src/material/item/armor/GoldenHelmetItem.php index dca5cadd..c7ee4711 100644 --- a/src/material/item/armor/GoldenHelmetItem.php +++ b/src/material/item/armor/GoldenHelmetItem.php @@ -13,4 +13,8 @@ class GoldenHelmetItem extends ArmorItem{ public function getBaseDurability(){ return 11; } + public function getDamageReduceAmount() + { + return 1; + } } \ No newline at end of file diff --git a/src/material/item/armor/GoldenLeggingsItem.php b/src/material/item/armor/GoldenLeggingsItem.php index bb131921..ee9dd964 100644 --- a/src/material/item/armor/GoldenLeggingsItem.php +++ b/src/material/item/armor/GoldenLeggingsItem.php @@ -13,4 +13,8 @@ class GoldenLeggingsItem extends ArmorItem{ public function getBaseDurability(){ return 15; } + public function getDamageReduceAmount() + { + return 3; + } } \ No newline at end of file diff --git a/src/material/item/armor/IronBootsItem.php b/src/material/item/armor/IronBootsItem.php index 2c4b17ed..7f548bb9 100644 --- a/src/material/item/armor/IronBootsItem.php +++ b/src/material/item/armor/IronBootsItem.php @@ -13,4 +13,8 @@ class IronBootsItem extends ArmorItem{ public function getBaseDurability(){ return 13; } + public function getDamageReduceAmount() + { + return 2; + } } \ No newline at end of file diff --git a/src/material/item/armor/IronChestplateItem.php b/src/material/item/armor/IronChestplateItem.php index 9ebb3a10..05ca1086 100644 --- a/src/material/item/armor/IronChestplateItem.php +++ b/src/material/item/armor/IronChestplateItem.php @@ -13,4 +13,8 @@ class IronChestplateItem extends ArmorItem{ public function getBaseDurability(){ return 16; } + public function getDamageReduceAmount() + { + return 6; + } } \ No newline at end of file diff --git a/src/material/item/armor/IronHelmetItem.php b/src/material/item/armor/IronHelmetItem.php index 6b99d8fb..70c85f5e 100644 --- a/src/material/item/armor/IronHelmetItem.php +++ b/src/material/item/armor/IronHelmetItem.php @@ -13,4 +13,8 @@ class IronHelmetItem extends ArmorItem{ public function getBaseDurability(){ return 11; } + public function getDamageReduceAmount() + { + return 2; + } } \ No newline at end of file diff --git a/src/material/item/armor/IronLeggingsItem.php b/src/material/item/armor/IronLeggingsItem.php index 15856eb4..f646899d 100644 --- a/src/material/item/armor/IronLeggingsItem.php +++ b/src/material/item/armor/IronLeggingsItem.php @@ -13,4 +13,8 @@ class IronLeggingsItem extends ArmorItem{ public function getBaseDurability(){ return 15; } + public function getDamageReduceAmount() + { + return 5; + } } \ No newline at end of file diff --git a/src/material/item/armor/LeatherBootsItem.php b/src/material/item/armor/LeatherBootsItem.php index c3ea2fc4..6ec78a24 100644 --- a/src/material/item/armor/LeatherBootsItem.php +++ b/src/material/item/armor/LeatherBootsItem.php @@ -13,4 +13,8 @@ class LeatherBootsItem extends ArmorItem{ public function getBaseDurability(){ return 13; } + public function getDamageReduceAmount() + { + return 1; + } } \ No newline at end of file diff --git a/src/material/item/armor/LeatherCapItem.php b/src/material/item/armor/LeatherCapItem.php index 22b6994c..9a146839 100755 --- a/src/material/item/armor/LeatherCapItem.php +++ b/src/material/item/armor/LeatherCapItem.php @@ -13,4 +13,8 @@ class LeatherCapItem extends ArmorItem{ public function getBaseDurability(){ return 11; } + public function getDamageReduceAmount() + { + return 1; + } } \ No newline at end of file diff --git a/src/material/item/armor/LeatherPantsItem.php b/src/material/item/armor/LeatherPantsItem.php index 8f193edf..4fc3bc74 100644 --- a/src/material/item/armor/LeatherPantsItem.php +++ b/src/material/item/armor/LeatherPantsItem.php @@ -13,4 +13,8 @@ class LeatherPantsItem extends ArmorItem{ public function getBaseDurability(){ return 15; } + public function getDamageReduceAmount() + { + return 2; + } } \ No newline at end of file diff --git a/src/material/item/armor/LeatherTunicItem.php b/src/material/item/armor/LeatherTunicItem.php index f55a561e..ceaa939a 100644 --- a/src/material/item/armor/LeatherTunicItem.php +++ b/src/material/item/armor/LeatherTunicItem.php @@ -13,4 +13,8 @@ class LeatherTunicItem extends ArmorItem{ public function getBaseDurability(){ return 16; } + public function getDamageReduceAmount() + { + return 3; + } } \ No newline at end of file diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 33261b6c..24cb04cb 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -575,16 +575,16 @@ class Utils{ * Euclidian distance, but without square roots */ public static function distance_noroot($pos1, $pos2){ - if($pos1 instanceof Vector3){ - $pos1 = $pos1->toArray(); - } - if($pos2 instanceof Vector3){ - $pos2 = $pos2->toArray(); - } - $pX = ($pos1["x"] - $pos2["x"]); - $pY = ($pos1["y"] - $pos2["y"]); - $pZ = ($pos1["z"] - $pos2["z"]); - return ($pX*$pX) + ($pY*$pY) + ($pZ*$pZ); + if($pos1 instanceof Vector3){ + $pos1 = $pos1->toArray(); + } + if($pos2 instanceof Vector3){ + $pos2 = $pos2->toArray(); + } + $pX = ($pos1["x"] - $pos2["x"]); + $pY = ($pos1["y"] - $pos2["y"]); + $pZ = ($pos1["z"] - $pos2["z"]); + return ($pX*$pX) + ($pY*$pY) + ($pZ*$pZ); } /** diff --git a/src/world/Explosion.php b/src/world/Explosion.php index 65e1b3f7..b4d55667 100644 --- a/src/world/Explosion.php +++ b/src/world/Explosion.php @@ -32,10 +32,10 @@ class Explosion{ $server = ServerAPI::request(); if(!Explosion::$enableExplosions){ /*Disable Explosions*/ foreach($server->api->entity->getRadius($this->source, $radius) as $entity){ - $impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //pla> - $damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1); - $entity->harm($damage, "explosion"); - } + $impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //pla> + $damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1); + $entity->harm($damage, "explosion"); + } return; } if($this->size < 0.1 or $server->api->dhandle("entity.explosion", [