mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
fixed setHealth, small tweaks to ranged attack
This commit is contained in:
parent
207a055f9b
commit
2bf7564bd7
3 changed files with 26 additions and 21 deletions
|
|
@ -1019,14 +1019,14 @@ class Player{
|
||||||
public function sendSettings($nametags = true){
|
public function sendSettings($nametags = true){
|
||||||
/*
|
/*
|
||||||
bit mask | flag name
|
bit mask | flag name
|
||||||
0x00000001 world_inmutable
|
0b00000001 allowInteract
|
||||||
0x00000010 -
|
0b00000010 - enablePVP
|
||||||
0x00000100 -
|
0b00000100 - enablePVE
|
||||||
0x00001000 - (autojump)
|
0b00001000 - field_3 (<?>autojump)
|
||||||
0x00010000 -
|
0b00010000 - field_0
|
||||||
0x00100000 - (nametags_visible)
|
0b00100000 - field_5 (<?>nametags_visible)
|
||||||
0x01000000 ?
|
0b01000000 - unused
|
||||||
0x10000000 ?
|
0b10000000 - unused
|
||||||
*/
|
*/
|
||||||
$flags = 0;
|
$flags = 0;
|
||||||
if(($this->gamemode & 0x02) === 0x02){
|
if(($this->gamemode & 0x02) === 0x02){
|
||||||
|
|
@ -1036,6 +1036,10 @@ class Player{
|
||||||
if($nametags !== false){
|
if($nametags !== false){
|
||||||
$flags |= 0x20; //Show Nametags
|
$flags |= 0x20; //Show Nametags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$flags |= 0x2; //pvp
|
||||||
|
$flags |= 0x4; //pve
|
||||||
|
|
||||||
$pk = new AdventureSettingsPacket;
|
$pk = new AdventureSettingsPacket;
|
||||||
$pk->flags = $flags;
|
$pk->flags = $flags;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
|
|
|
||||||
|
|
@ -1318,10 +1318,6 @@ class Entity extends Position
|
||||||
$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);
|
||||||
|
|
||||||
if($this->isPlayer() && $this->player->gamemode & 0x01 == 0x01){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ret != false && $this->hasKnockback && is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false) {
|
if ($ret != false && $this->hasKnockback && is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false) {
|
||||||
$d = $entity->x - $this->x;
|
$d = $entity->x - $this->x;
|
||||||
|
|
||||||
|
|
@ -1420,13 +1416,18 @@ class Entity extends Position
|
||||||
public function setHealth($health, $cause = "generic", $force = false)
|
public function setHealth($health, $cause = "generic", $force = false)
|
||||||
{
|
{
|
||||||
$health = (int) $health;
|
$health = (int) $health;
|
||||||
$harm = true;
|
$harm = false;
|
||||||
$dmg = $this->health - $health;
|
if($health < $this->health){
|
||||||
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){
|
$harm = true;
|
||||||
$this->dmgcounter[0] = microtime(true) + 0.5;
|
$dmg = $this->health - $health;
|
||||||
$this->dmgcounter[1] = $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){
|
||||||
} else{
|
$this->dmgcounter[0] = microtime(true) + 0.5;
|
||||||
return false; // Entity inmunity
|
$this->dmgcounter[1] = $dmg;
|
||||||
|
} else{
|
||||||
|
return false; // Entity inmunity
|
||||||
|
}
|
||||||
|
}elseif($health === $this->health and !$this->dead){
|
||||||
|
$harm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->server->api->dhandle("entity.health.change", array(
|
if($this->server->api->dhandle("entity.health.change", array(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use EntityAI;
|
|
||||||
|
|
||||||
class TaskRangedAttack extends \TaskBase
|
class TaskRangedAttack extends \TaskBase
|
||||||
{
|
{
|
||||||
public $server;
|
public $server;
|
||||||
|
|
@ -43,6 +41,8 @@ class TaskRangedAttack extends \TaskBase
|
||||||
|
|
||||||
if($dist > 100){
|
if($dist > 100){
|
||||||
$ai->mobController->setMovingTarget($ai->entity->target->x, $ai->entity->target->y, $ai->entity->target->z, $this->speedMultiplier);
|
$ai->mobController->setMovingTarget($ai->entity->target->x, $ai->entity->target->y, $ai->entity->target->z, $this->speedMultiplier);
|
||||||
|
}else{
|
||||||
|
$ai->mobController->headYawIsYaw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ai->mobController->setLookPosition($ai->entity->target->x, $ai->entity->target->y + 0.12, $ai->entity->target->z, 10, $ai->entity->getVerticalFaceSpeed());
|
$ai->mobController->setLookPosition($ai->entity->target->x, $ai->entity->target->y + 0.12, $ai->entity->target->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue