mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
explosions will damage players
This commit is contained in:
parent
b6ce6e459c
commit
89ee29a30a
1 changed files with 7 additions and 3 deletions
|
|
@ -28,11 +28,16 @@ class Explosion{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function explode(){
|
public function explode(){
|
||||||
|
$radius = 2 * $this->size;
|
||||||
|
$server = ServerAPI::request();
|
||||||
if(!Explosion::$enableExplosions){ /*Disable Explosions*/
|
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");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$server = ServerAPI::request();
|
|
||||||
if($this->size < 0.1 or $server->api->dhandle("entity.explosion", [
|
if($this->size < 0.1 or $server->api->dhandle("entity.explosion", [
|
||||||
"level" => $this->level,
|
"level" => $this->level,
|
||||||
"source" => $this->source,
|
"source" => $this->source,
|
||||||
|
|
@ -76,7 +81,6 @@ class Explosion{
|
||||||
|
|
||||||
$send = [];
|
$send = [];
|
||||||
$source = $this->source->floor();
|
$source = $this->source->floor();
|
||||||
$radius = 2 * $this->size;
|
|
||||||
foreach($server->api->entity->getRadius($this->source, $radius) as $entity){
|
foreach($server->api->entity->getRadius($this->source, $radius) as $entity){
|
||||||
$impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //placeholder, 0.7 should be exposure
|
$impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //placeholder, 0.7 should be exposure
|
||||||
$damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
|
$damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue