Inheritance: extends EntityEvent
Example #1
0
 /**
  *
  * @param ProjectileHitEvent $event        	
  */
 public function onProjectTileHit(ProjectileHitEvent $event)
 {
     try {
         foreach ($this->plugin->gameLevelManager->levels as &$lv) {
             if ($lv instanceof GameLevelModel) {
                 if (count($lv->joinedPlayers) === 0) {
                     continue;
                 }
                 // skip on-level related
                 // if ($event->getEntity ()->getLevel ()->getName () != $lv->levelName) {
                 // continue;
                 // }
                 if (isset($lv->currentMap)) {
                     if (isset($lv->currentMap->shooters[$event->getEntity()->getId()])) {
                         $shooterName = $lv->currentMap->shooters[$event->getEntity()->getId()];
                         unset($lv->currentMap->shooters[$event->getEntity()->getId()]);
                         $scores = $lv->currentMap->playerscores[$shooterName];
                         $scores["hits"] = $scores["hits"] + 1;
                         $lv->currentMap->playerscores[$shooterName] = $scores;
                         $lv->currentMap->killedPlayers[$shooterName] = $shooterName;
                         break;
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         $this->plugin->printError($e);
     }
 }
Example #2
0
 public function onArrowHit(ProjectileHitEvent $event)
 {
     $victim = $event->getEntity();
     $shooter = $victim->getLastDamageCause();
     if ($shooter instanceof EntityDamageByEntityEvent) {
         $shooter = $shooter->getDamager();
         if ($shooter instanceof Player) {
             $level->addSound(new AnvilFallSound($shooter->getLocation()));
             $victim->getLevel()->addParticle(new AngryVillagerParticle(self::randVector($entity), mt_rand() / mt_getrandmax() * 2));
         }
     }
 }
Example #3
0
 public function onProjectileHit(ProjectileHitEvent $event)
 {
     $entity = $event->getEntity();
     if ($entity instanceof Arrow) {
         $theX = $entity->getX();
         $theY = $entity->getY();
         $theZ = $entity->getZ();
         $level = $entity->getLevel();
         $thePosition = new Position($theX, $theY, $theZ, $level);
         $theExplosion = new Explosion($thePosition, 5, NULL);
         $theExplosion->explode();
         $level->remove($entity);
     }
 }
Example #4
0
 public function onProjectileHit(ProjectileHitEvent $event)
 {
     if (isset($event->getEntity()->namedtag["ExplosionDamage"])) {
         (new SafeExplosion($event->getEntity()->getPosition(), $event->getEntity()->namedtag["ExplosionDamage"]))->explodeB();
     }
     if (isset($event->getEntity()->namedtag["Custom"])) {
         if ($event->getEntity()->namedtag["Custom"] === 2 && isset($event->getEntity()->namedtag["Handler"])) {
             self::$arrowHandlers[$event->getEntity()->namedtag["Handler"]]->handle($event);
         }
         if ($event->getEntity()->namedtag["Custom"] >= 1) {
             $event->getEntity()->kill();
         }
     }
 }
Example #5
0
 public function onArrowHit(ProjectileHitEvent $ev)
 {
     //if ($ev->isCancelled()) return; // NOT CANCELLABLE!
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     $et = $ev->getEntity();
     if (!$et->namedtag) {
         return;
     }
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     $c = explode(":", $et->namedtag->getName());
     if (count($c) != 3) {
         return;
     }
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if ($c[0] != "dumdum") {
         return;
     }
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     $this->getServer()->getPluginManager()->callEvent($cc = new ExplosionPrimeEvent($et, intval($c[1])));
     if ($cc->isCancelled()) {
         return;
     }
     $explosion = new Explosion($et, intval($c[1]), $et);
     //,$source);
     if (!$c[2]) {
         $explosion->explodeA();
     }
     $explosion->explodeB();
 }
Example #6
0
 /**
  *
  * Handle Level 3 - Exploding Arrows
  *
  * @param ProjectileHitEvent $event        	
  */
 public function onProjectTileHit(ProjectileHitEvent $event)
 {
     if ($event->getEntity() instanceof Arrow) {
         foreach ($this->plugin->getAvailableLevels() as &$lv) {
             try {
                 if ($lv instanceof GameLevelModel) {
                     if ($lv->type === GameLevelModel::LEVEL_THREE || $lv->type === GameLevelModel::LEVEL_VIP || $lv->type === GameLevelModel::LEVEL_FOUR) {
                         if (empty($lv->currentMap)) {
                             continue;
                         }
                         $pos = new Position($event->getEntity()->getPosition()->x, $event->getEntity()->getPosition()->y, $event->getEntity()->getPosition()->z, $event->getEntity()->getLevel());
                         MagicUtil::makeExplosion($event->getEntity()->getLevel(), $pos);
                         MagicUtil::addParticles($event->getEntity()->getLevel(), "explode", $event->getEntity()->getPosition(), 20);
                         MagicUtil::addParticles($event->getEntity()->getLevel(), "flame", $event->getEntity()->getPosition(), 20);
                         break;
                     }
                 }
             } catch (\Exception $e) {
                 $this->plugin->printError($e);
             }
         }
     }
 }
 public function handle(ProjectileHitEvent $event)
 {
     $shootingEntity = $event->getEntity()->shootingEntity;
     if (!$shootingEntity instanceof Player) {
         return;
     }
     $rpgPlayer = ToAruPG::getInstance()->getRPGPlayerByName($shootingEntity->getName());
     if ($rpgPlayer === null) {
         return;
     }
     $skill = $rpgPlayer->getSkillById(SkillLightningShot::getId());
     if (!$skill instanceof SkillLightningShot) {
         return;
     }
     $pos = $event->getEntity();
     $aedPk = new AddEntityPacket();
     $aedPk->eid = Entity::$entityCount++;
     $aedPk->type = 93;
     $aedPk->x = $pos->getX();
     $aedPk->y = $pos->getY();
     $aedPk->z = $pos->getZ();
     $aedPk->speedX = 0;
     $aedPk->speedY = 0;
     $aedPk->speedZ = 0;
     $aedPk->yaw = 0;
     $aedPk->pitch = 0;
     $aedPk->metadata = [];
     $expPk = new ExplodePacket();
     $expPk->x = $pos->getX();
     $expPk->y = $pos->getY();
     $expPk->z = $pos->getZ();
     $expPk->radius = self::EXPLOSION_SIZE;
     $pos->getLevel()->addChunkPacket($pos->chunk->getX(), $pos->chunk->getZ(), $aedPk);
     $pos->getLevel()->addChunkPacket($pos->chunk->getX(), $pos->chunk->getZ(), $expPk);
     $aabb = new AxisAlignedBB($pos->getX() - self::EXPLOSION_SIZE - 1, $pos->getY() - self::EXPLOSION_SIZE - 1, $pos->getZ() - self::EXPLOSION_SIZE - 1, $pos->getX() + self::EXPLOSION_SIZE + 1, $pos->getY() + self::EXPLOSION_SIZE + 1, $pos->getZ() + self::EXPLOSION_SIZE + 1);
     foreach ($pos->getLevel()->getNearbyEntities($aabb, $shootingEntity) as $e) {
         if ($e instanceof Player && !ToAruPG::$pvpEnabled) {
             continue;
         }
         $event = new EntityDamageByEntityEvent($shootingEntity, $e, EntityDamageByEntityEvent::CAUSE_CUSTOM, $skill->getDamage());
         Server::getInstance()->getPluginManager()->callEvent($event);
         if (!$event->isCancelled()) {
             $e->attack($skill->getDamage(), $event);
             $thread = new SafeBurnThread($e, $shootingEntity, $skill->getFireTick());
             $thread->setHandler(Server::getInstance()->getScheduler()->scheduleRepeatingTask($thread, 40));
         }
     }
 }