Effect: Added Fatal Poison effect

This is identical to normal Poison, except that it kills the victim. Parrots receive this effect when they are fed cookies.
This commit is contained in:
Dylan K. Taylor 2017-12-13 18:59:49 +00:00
parent 4ae278686c
commit f5ebfc3418
2 changed files with 14 additions and 3 deletions

View File

@ -55,6 +55,7 @@ class Effect{
public const ABSORPTION = 22; public const ABSORPTION = 22;
public const SATURATION = 23; public const SATURATION = 23;
public const LEVITATION = 24; //TODO public const LEVITATION = 24; //TODO
public const FATAL_POISON = 25;
/** @var Effect[] */ /** @var Effect[] */
protected static $effects = []; protected static $effects = [];
@ -295,6 +296,7 @@ class Effect{
public function canTick() : bool{ public function canTick() : bool{
switch($this->id){ switch($this->id){
case Effect::POISON: case Effect::POISON:
case Effect::FATAL_POISON:
if(($interval = (25 >> $this->amplifier)) > 0){ if(($interval = (25 >> $this->amplifier)) > 0){
return ($this->duration % $interval) === 0; return ($this->duration % $interval) === 0;
} }
@ -332,11 +334,14 @@ class Effect{
*/ */
public function applyEffect(Entity $entity){ public function applyEffect(Entity $entity){
switch($this->id){ switch($this->id){
/** @noinspection PhpMissingBreakStatementInspection */
case Effect::POISON: case Effect::POISON:
if($entity->getHealth() > 1){ if($entity->getHealth() <= 1){
$ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_MAGIC, 1); break;
$entity->attack($ev);
} }
case Effect::FATAL_POISON:
$ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_MAGIC, 1);
$entity->attack($ev);
break; break;
case Effect::WITHER: case Effect::WITHER:

View File

@ -131,5 +131,11 @@
"id": 24, "id": 24,
"color": "#FFCEFFFF", "color": "#FFCEFFFF",
"name": "levitation" "name": "levitation"
},
"fatal_poison": {
"id": 25,
"color": "#FF4E9331",
"name": "poison",
"isBad": true
} }
} }