mob spawners pt3

This commit is contained in:
darkrose 2015-09-28 18:51:54 +10:00
parent 07de3e3a4c
commit ea50a2fd2e
2 changed files with 19 additions and 7 deletions

View File

@ -875,8 +875,7 @@ FoundReverseRecipe getReverseRecipe(InventoryItem *iitem, int index)
}
//how to update an ingredient list given a range of new craft items
template <typename It>
void addToIngredientList(It results_begin, It results_end, std::vector<lists::ListData>& ingredient_list)
void addToIngredientList(std::vector<lists::ListData> results, uint32_t begin, std::vector<content_t>& ingredient_list)
{
using namespace std;
@ -884,10 +883,11 @@ void addToIngredientList(It results_begin, It results_end, std::vector<lists::Li
set<content_t> ingredients (ingredient_list.begin(), ingredient_list.end());
//go through the result list
for (It it = results_begin; it != results_end; ++it) {
for (std::vector<lists::ListData>::iterator it = results.begin()+begin; it != results.end(); ++it) {
lists::ListData d = *it;
//make a temporary inventory item for the result
InventoryItem *result = InventoryItem::create(*it, 1);
InventoryItem *result = InventoryItem::create(d.content, 1, 0, d.data);
//go through every recipe for this item
for (int rec_ind = getRecipeCount(result); rec_ind--;) {
@ -923,7 +923,7 @@ std::vector<content_t>& getCraftGuideIngredientList()
//the ingredient list, and the number of items that were in the craftguide list at the last check
static vector<content_t> ingredient_list;
static unsigned last_craftguide_count = 0;
static uint32_t last_craftguide_count = 0;
//get the craftguide list
const vector<lists::ListData>& craft_list = lists::get("craftguide");
@ -932,7 +932,7 @@ std::vector<content_t>& getCraftGuideIngredientList()
if (craft_list.size() > last_craftguide_count) {
//if so, add the new stuff
addToIngredientList(craft_list.begin() + last_craftguide_count, craft_list.end(), ingredient_list);
addToIngredientList(craft_list, last_craftguide_count, ingredient_list);
//and update the craftguide count
last_craftguide_count = craft_list.size();
@ -957,7 +957,7 @@ void giveCreative(Player *player)
player->resetInventory();
for(u8 i=0; i<creativeinv.size(); i++) {
player->inventory.addItem("main",InventoryItem::create(creativeinv[i].content,creativeinv[i].count,0,creativeinv[i].data);
player->inventory.addItem("main", InventoryItem::create(creativeinv[i].content,creativeinv[i].count,0,creativeinv[i].data));
}
}

View File

@ -22,6 +22,7 @@
#include "serverobject.h"
#include "content_sao.h"
#include "content_mob.h"
#include "content_list.h"
#include "content_craftitem.h"
#include "main.h"
#include "settings.h"
@ -383,6 +384,7 @@ void content_mob_init()
f->spawn_naturally = false;
f->lifetime = 900.0;
f->setCollisionBox(aabb3f(-BS/3.,0.0,-BS/3., BS/3.,BS/2.,BS/3.));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_FIREFLY;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -402,6 +404,7 @@ void content_mob_init()
f->spawn_naturally = false;
f->lifetime = 1200.0;
f->setCollisionBox(aabb3f(-BS/4.,-BS/6.,-BS/4., BS/4.,BS/6.,BS/4.));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_OERKKI;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -452,6 +455,7 @@ void content_mob_init()
f->attack_player_range = v3f(1,1,1);
f->lifetime = 600.0;
f->setCollisionBox(aabb3f(-BS/3.,0.0,-BS/3., BS/3.,BS*2.,BS/3.));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_DUNGEON_MASTER;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -502,6 +506,7 @@ void content_mob_init()
f->attack_throw_offset = v3f(0,1.4,-1.0);
f->lifetime = 600.0;
f->setCollisionBox(aabb3f(-0.75*BS, 0.*BS, -0.75*BS, 0.75*BS, 2.0*BS, 0.75*BS));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_FIREBALL;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -545,6 +550,7 @@ void content_mob_init()
f->spawn_group = 3;
f->lifetime = 1200.0;
f->setCollisionBox(aabb3f(-0.6*BS, 0., -0.6*BS, 0.6*BS, 1.25*BS, 0.6*BS));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_STAG;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -575,6 +581,7 @@ void content_mob_init()
f->attack_player_range = v3f(1,1,1);
f->lifetime = 900.0;
f->setCollisionBox(aabb3f(-0.7*BS, 0., -0.7*BS, 0.7*BS, 1.5*BS, 0.7*BS));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_TAMESTAG;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -624,6 +631,7 @@ void content_mob_init()
f->hp = 5;
f->lifetime = 1200.0;
f->setCollisionBox(aabb3f(-0.25*BS, 0.25*BS, -0.25*BS, 0.25*BS, 0.75*BS, 0.25*BS));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_SHARK;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -650,6 +658,7 @@ void content_mob_init()
f->attack_player_range = v3f(1,1,1);
f->lifetime = 600.0;
f->setCollisionBox(aabb3f(-0.75*BS, 0., -0.75*BS, 0.75*BS, 1.*BS, 0.75*BS));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_WOLF;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -679,6 +688,7 @@ void content_mob_init()
f->attack_player_range = v3f(1,1,1);
f->lifetime = 900.0;
f->setCollisionBox(aabb3f(-0.5*BS, 0., -0.5*BS, 0.5*BS, 1.*BS, 0.5*BS));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_TAMEWOLF;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -705,6 +715,7 @@ void content_mob_init()
f->lifetime = 1800.0;
f->spawn_naturally = false;
f->setCollisionBox(aabb3f(-0.5*BS, 0., -0.5*BS, 0.5*BS, 1.*BS, 0.5*BS));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_SHEEP;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];
@ -735,6 +746,7 @@ void content_mob_init()
f->spawn_group = 4;
f->lifetime = 1800.0;
f->setCollisionBox(aabb3f(-0.4*BS, 0., -0.4*BS, 0.4*BS, 1.*BS, 0.4*BS));
lists::add("creative",CONTENT_TOOLITEM_MOB_SPAWNER,1,i);
i = CONTENT_MOB_SNOWBALL;
f = &g_content_mob_features[i&~CONTENT_MOB_MASK];