Skip to content

Instantly share code, notes, and snippets.

@Omattyao
Created March 3, 2013 14:38
Show Gist options
  • Save Omattyao/5076348 to your computer and use it in GitHub Desktop.
Save Omattyao/5076348 to your computer and use it in GitHub Desktop.
<?php
/*
__PocketMine Plugin__
name=Vals
version=0.0.1
author=Omattyao
apiversion=2
class=scVals
*/
class scVals extends scClass{
public function init() {
$this->sc->register("vals", "Don't recite this spell !!.", array($this, "commandH"));
}
public function commandH($cmd, $args, $sign){
$output = "";
switch ($cmd) {
case 'vals':
$x = $sign->x;
$y = $sign->y;
$z = $sign->z;
$this->api->chat->send("Seata", "Vals!!!!");
$this->api->chat->send("Pazoo", "Vals!!!!");
$players = $this->api->player->getAll();
foreach ($players as $player) {
$this->causeDamage($x, $y, $z, $player);
}
$this->hollowWorld();
break;
}
return $output;
}
public function causeDamage($sx, $sy, $sz, $player){
$px = $player->x;
$py = $player->y;
$pz = $player->z;
$e = $this->api->entity->get($player->eid);
$hp = $e->getHealth();
$dist = sqrt(pow($sx - $px, 2) + pow($sy - $py, 2));
$damage = round(0.4 * $dist - 32);
$e->setHealth($hp - $damage, "console", false);
}
public function hollowWorld() {
$random = array_fill(0, 128, false);
for($x = 0; $x <= 255; ++$x){
for($y = 0; $y <= 128; ++$y){
$random[$y] = true;
for($z = 0; $z <= 255; ++$z){
if ($random[array_rand($random)] == true) {
$this->api->level->setBlock($x, $y, $z, 0, 0, false);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment