Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobs #335

Open
wants to merge 18 commits into
base: development
Choose a base branch
from
Open

Mobs #335

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/En_Minecraft.pdf
Binary file not shown.
Binary file added docs/Minecraft.pdf
Binary file not shown.
1,299 changes: 1,299 additions & 0 deletions docs/RU_YoungPersonsGuideToProgrammingMinecraft.md

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions src/main/js/plugins/maps/galua2.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/main/js/plugins/maps/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.greet = function(greeting, player ) { player.sendMessage(greeting + player.name); };


16 changes: 16 additions & 0 deletions src/main/js/plugins/maps/myskyscraper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var myskyscraper = function(floors) {
var i ;
if ( typeof floors == 'undefined' ) {
floors = 10;
}
this.chkpt('myskyscraper'); // saves the drone position so it can return there later
for ( i = 0; i < floors; i++ ) {
this.box(blocks.iron,20,1,20)
.up()
.box0(blocks.glass_pane,20,3,20)
.up(3);
}
return this.move('myskyscraper'); // return to where we started
};
var Drone = require('../drone/drone').Drone;
Drone.extend('myskyscraper',myskyscraper);
18 changes: 18 additions & 0 deletions src/main/js/plugins/maps/rainboway.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var Drone = require( 'drone' ).Drone,
blocks = require('blocks');

var rainboway = function( height, length ) {
var rainbowColors = [blocks.wool.red, blocks.wool.orange, blocks.wool.yellow, blocks.wool.lime, blocks.wool.lightblue, blocks.wool.blue, blocks.wool.purple];
if ( typeof height == 'undefined' ) {
height = 1;
}
if ( typeof length == 'undefined' ) {
length = 30;
}
this.chkpt( 'rainboway' );
this.boxa( rainbowColors, 7, height, length );
return this.move( 'rainboway' );
};

exports.rainboway = rainboway;

115 changes: 115 additions & 0 deletions src/main/js/plugins/mobs/bot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*

https://dullahansoftware.wordpress.com/2013/01/26/scripting-a-simple-minecraft-wolfbot/

Usage:

/jsp summon
/jsp dismiss
/jsp come
/jsp stay
/jsp pack
*/
var _store = {players: {}};

var entities = require('entities');
var Drone = require('drone');

var bot = plugin('bot',{
/* helper methods for a player's bot */
get_bot: function(player){
return _store.players[player.name];
},
set_bot: function(player,bot,inventory){
_store.players[player.name] = {bot:bot,inventory:inventory};
},

/* display the commands and what they do */
help: function(player){
player.sendMessage("Wolfbot Help Menu: Available Commands \n\n");
player.sendMessage("Summon: Summons a new wolfbot \n");
player.sendMessage("Dismiss: Dismisses your wolfbot \n");
player.sendMessage("Stay: Tells your wolfbot to stay \n");
player.sendMessage("Come: Tells your wolfbot to come \n");
player.sendMessage("Pack: Displays the inventory of your wolfbot's pack \n");
},

/* summons your bot */
summon: function(player){
var world = Drone.world;

// in case you already have one spawned
this.dismiss(player);

// place wolf two squares in front of you
var my_bot = world.spawnEntity(player.getLocation().add(0,0,2), entities.wolf());

my_bot.setTamed(true);
my_bot.setOwner(player);
my_bot.setTarget(player);

var inventory;
var b = this.get_bot(player);
if(b == null || b.inventory == null)
inventory = player.getServer().createInventory(player, 36, "Bot's Pack");
else
inventory = b.inventory;

this.set_bot(player,my_bot,inventory);
},
/* dismisses your bot */
dismiss: function(player){
var b = this.get_bot(player);
if( b != null && b.bot !== null){
b.bot.remove();
b.bot = null;
}
},
/* instructs your bot to stay */
stay: function(player){
var b = this.get_bot(player);
if(b!= null && b.bot !== null){
b.bot.setTarget(null);
b.bot.setSitting(true);
}
},
/* instructs your bot to follow you */
come: function(player){
var b = this.get_bot(player);
if(b!= null){
b.bot.setSitting(false);
b.bot.setTarget(player);
}
},
/* instructs your bot to display its pack */
pack: function(player){
var b = this.get_bot(player);
if(b!= null && b.bot !== null){
b.bot.setSitting(true);
player.openInventory(b.inventory);
}
},
store: _store
},true);

exports.bot = bot;

command('help',function(params, sender){
bot.help(sender);
});
command('summon',function(params, sender){
bot.summon(sender);
});
command('dismiss',function(params, sender){
bot.dismiss(sender);
});
command('stay',function(params, sender){
bot.stay(sender);
});
command('come',function(params, sender){
bot.come(sender);
});
command('pack',function(params, sender){
bot.pack(sender);
});

113 changes: 113 additions & 0 deletions src/main/js/plugins/mobs/skeleton-quest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@

/*

https://dullahansoftware.wordpress.com/2013/02/11/scriptcrafting-a-quest-in-minecraft/

*/

var entities = require('entities');
var utils = require('utils');
var Drone = require('drone');

var quest = quest || plugin("quest",{
initialize_quest:function(player_name){
quest.store.players[player_name] = {
current:-1,
accepted:false,
skeleton_counter:0,
steps:[{
step:1,
text:"Hello, " + player_name + ". I have an unpleasant task if you desire some work."
},
{
step:2,
text:"You see a gang of skeletons have grown bold and are attacking travelers in the area. If you thinned their numbers, the area would again be safe."
},
{
step:3,
text:"Kill 10 skeletons and return to me for your reward. \nType /jsp accept to accept: SKELETON MENACE."
},
{
step:4,
text:"Thank you " + player_name + ". The roads are now much safer. Here is your reward."
}]};
},
skeleton_kill_counter:function(event,data){
var target = event.getEntity();
var killer = target.getKiller();
// check if it is the player who did the killing and if a skeleton was the target
//if(killer != null && killer.getUniqueId() == getPlayerObject().getUniqueId() && target == org.bukkit.entity.EntityType.SKELETON && quest.store.players[killer.name] != null){
if(killer != null && target.getType() == org.bukkit.entity.EntityType.SKELETON && quest.store.players[killer.name] != null){
killer.sendMessage("Name 2 : " + killer.name);
quest.store.players[killer.name].skeleton_counter = (quest.store.players[killer.name].skeleton_counter + 1);
if(quest.store.players[killer.name].skeleton_counter < 10){
killer.sendMessage("Name : 3 " + killer.name);
killer.sendMessage("" + quest.store.players[killer.name].skeleton_counter + "/10 skeletons killed.");
}
else{
killer.sendMessage("Return to the priest to recieve your reward.");
}
}
},
accept_quest:function(player){
if(quest.store.players[player.name] != null){
quest.store.players[player.name].accepted = true;
// add skeleton killing watch
events.entityDeath(this.skeleton_kill_counter);
player.sendMessage("\nYou accepted the quest: SKELETON MENACE.\n");
}
},
proc_quest:function(event,data){
// make sure we are interacting with the quest giver
var target = event.rightClicked;
var player = event.player;
if(quest.store.npcs[target.getUniqueId()] != null){
// get the player's current quest progress
var quest_progress = quest.store.players[player.name];

if(quest_progress == null){
quest.initialize_quest(player.name);
}
if(quest.store.players[player.name].current > 1){
if(quest.store.players[player.name].skeleton_counter >= 10){
//var world = player.getWorld();
var world = player.world;
quest.store.players[player.name].current = (quest.store.players[player.name].current + 1) % 4;
//world.spawnEntity(player.getLocation().add(1,0,1), entities.experience_orb()).setExperience(20);
world.spawnEntity(player.getLocation().add(1,0,1), entities.experience_orb()).setExperience(20);
world.spawnEntity(player.getLocation().add(2,0,1), entities.experience_orb()).setExperience(10);
world.spawnEntity(player.getLocation().add(4,0,1), entities.experience_orb()).setExperience(5);
quest.store.players[player.name].skeleton_counter = 0;
quest.store.players[player.name].accepted = false;
quest.store.players[player.name].current = 3;
}
}
else{
quest.store.players[player.name].current = (quest.store.players[player.name].current + 1) % 4;
}
player.sendMessage(quest.store.players[player.name].steps[quest.store.players[player.name].current].text);
}
},
spawn:function(player){
var world = player.world;

// create a villager
var quest_npc = world.spawnEntity(player.getLocation().add(1,0,0), entities.villager());
quest_npc.setProfession(org.bukkit.entity.Villager.Profession.PRIEST);
quest.store.npcs[quest_npc.getUniqueId()] = quest_npc;
quest.initialize_quest(player.name);
// listen for interaction events
events.playerInteractEntity(this.proc_quest);
}
},true);

exports.quest = quest;

/* stores player's progress */
quest.store.players = quest.store.players || {};
/* stores spawned npcs */
quest.store.npcs = quest.store.npcs || {};

command("spawn_npc",function(params,sender){ quest.spawn(sender); });
command("accept",function(params,sender){ quest.accept_quest(sender); });