forked from oerkki/voxelands
forge pt1
This commit is contained in:
parent
befcd235a5
commit
7800b9161b
Binary file not shown.
After Width: | Height: | Size: 787 B |
Binary file not shown.
After Width: | Height: | Size: 342 B |
Binary file not shown.
After Width: | Height: | Size: 805 B |
Binary file not shown.
After Width: | Height: | Size: 908 B |
|
@ -52,11 +52,12 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
#define CONTENT_TORCH_LEGACY 0x003
|
||||
#define CONTENT_GLASSLIGHT 0x004
|
||||
#define CONTENT_CHAIR 0x005
|
||||
// FREE 0x006
|
||||
#define CONTENT_FORGE 0x006
|
||||
#define CONTENT_TORCH 0x007
|
||||
#define CONTENT_TABLE 0x008
|
||||
#define CONTENT_WATERSOURCE 0x009
|
||||
// FREE 0x00A-0x00C
|
||||
#define CONTENT_FORGE_FIRE 0x00A
|
||||
// FREE 0x00B-0x00C
|
||||
#define CONTENT_SAFE 0x00D
|
||||
#define CONTENT_SIGN_WALL 0x00E
|
||||
#define CONTENT_CHEST 0x00F
|
||||
|
|
|
@ -2038,4 +2038,52 @@ void content_mapnode_special(bool repeat)
|
|||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
f->suffocation_per_second = 0;
|
||||
|
||||
i = CONTENT_FORGE;
|
||||
f = &content_features(i);
|
||||
f->description = wgettext("Forge");
|
||||
f->setAllTextures("forge_side.png");
|
||||
f->setTexture(0,"forge_top.png");
|
||||
f->setTexture(1,"forge_bottom.png");
|
||||
f->draw_type = CDT_NODEBOX;
|
||||
f->type = CMT_STONE;
|
||||
f->hardness = 3.0;
|
||||
f->solidness = 0;
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
content_nodebox_forge(f);
|
||||
f->setInventoryTextureNodeBox(i,"forge_top.png", "forge_side.png", "forge_side.png");
|
||||
if (f->initial_metadata == NULL)
|
||||
f->initial_metadata = new ForgeNodeMetadata();
|
||||
{
|
||||
content_t r[9] = {
|
||||
CONTENT_ROUGHSTONE, CONTENT_CHARCOAL, CONTENT_ROUGHSTONE,
|
||||
CONTENT_ROUGHSTONE, CONTENT_SAND, CONTENT_ROUGHSTONE,
|
||||
CONTENT_ROUGHSTONE, CONTENT_STEEL, CONTENT_ROUGHSTONE
|
||||
};
|
||||
crafting::setRecipe(r,CONTENT_FORGE,1);
|
||||
}
|
||||
f->pressure_type = CST_SOLID;
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
f->suffocation_per_second = 0;
|
||||
|
||||
i = CONTENT_FORGE_FIRE;
|
||||
f = &content_features(i);
|
||||
f->description = wgettext("Forge Fire");
|
||||
f->setAllTextures("forge_fire.png");
|
||||
f->setAllTextureFlags(0);
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->draw_type = CDT_PLANTLIKE;
|
||||
f->light_propagates = true;
|
||||
f->light_source = LIGHT_MAX-4;
|
||||
f->solidness = 0; // Drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->pointable = false;
|
||||
f->diggable = false;
|
||||
f->buildable_to = true;
|
||||
f->sound_ambient = "env-fire";
|
||||
#ifndef SERVER
|
||||
f->post_effect_color = video::SColor(192, 255, 64, 0);
|
||||
#endif
|
||||
f->pressure_type = CST_CRUSHED;
|
||||
}
|
||||
|
|
|
@ -1512,3 +1512,22 @@ void content_nodebox_cauldron(ContentFeatures *f)
|
|||
-0.375*BS,-0.125*BS,-0.4375*BS,0.375*BS,0.5*BS,-0.375*BS
|
||||
));
|
||||
}
|
||||
|
||||
void content_nodebox_forge(ContentFeatures *f)
|
||||
{
|
||||
f->setNodeBox(NodeBox(
|
||||
-0.375*BS,-0.5*BS,-0.375*BS,0.375*BS,0.375*BS,0.375*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.375*BS,0.375*BS,-0.375*BS,-0.1875*BS,0.4375*BS,-0.1875*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
-0.375*BS,0.375*BS,0.1875*BS,-0.1875*BS,0.4375*BS,0.375*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
0.1875*BS,0.375*BS,-0.375*BS,0.375*BS,0.4375*BS,-0.1875*BS
|
||||
));
|
||||
f->addNodeBox(NodeBox(
|
||||
0.1875*BS,0.375*BS,0.1875*BS,0.375*BS,0.4375*BS,0.375*BS
|
||||
));
|
||||
}
|
||||
|
|
|
@ -67,5 +67,6 @@ void content_nodebox_flag(ContentFeatures *f);
|
|||
void content_nodebox_flower_pot(ContentFeatures *f);
|
||||
void content_nodebox_parcel(ContentFeatures *f);
|
||||
void content_nodebox_cauldron(ContentFeatures *f);
|
||||
void content_nodebox_forge(ContentFeatures *f);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "settings.h"
|
||||
#include "main.h"
|
||||
#include "mapblock.h"
|
||||
#include "enchantment.h"
|
||||
|
||||
/*
|
||||
SignNodeMetadata
|
||||
|
@ -2834,7 +2835,7 @@ std::string CauldronNodeMetadata::getDrawSpecString()
|
|||
{
|
||||
return
|
||||
std::string("size[8,7]"
|
||||
"label[1,0.5;")+gettext("Add fuel, then punch to incinerate wielded item")+"]"
|
||||
"label[1,0.5;")+gettext("Add fuel, then punch to add or remove water")+"]"
|
||||
"label[3.5,1.5;Fuel]"
|
||||
"list[current_name;fuel;4,1;1,1;]"
|
||||
"list[current_player;main;0,3;8,4;]";
|
||||
|
@ -2866,6 +2867,161 @@ std::vector<NodeBox> CauldronNodeMetadata::getNodeBoxes(MapNode &n) {
|
|||
return transformNodeBox(n,boxes);
|
||||
}
|
||||
|
||||
/*
|
||||
ForgeNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
ForgeNodeMetadata proto_ForgeNodeMetadata;
|
||||
|
||||
ForgeNodeMetadata::ForgeNodeMetadata():
|
||||
m_show_craft(false)
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), create);
|
||||
|
||||
m_inventory = new Inventory();
|
||||
m_inventory->addList("mithril", 9);
|
||||
m_inventory->addList("gem", 9);
|
||||
m_inventory->addList("craft", 9);
|
||||
m_inventory->addList("craftresult", 1);
|
||||
{
|
||||
InventoryList *l = m_inventory->getList("mithril");
|
||||
l->addAllowed(CONTENT_CRAFTITEM_MITHRIL_UNBOUND);
|
||||
}
|
||||
{
|
||||
InventoryList *l = m_inventory->getList("gem");
|
||||
l->addAllowed(CONTENT_CRAFTITEM_QUARTZ);
|
||||
}
|
||||
}
|
||||
ForgeNodeMetadata::~ForgeNodeMetadata()
|
||||
{
|
||||
}
|
||||
u16 ForgeNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_FORGE;
|
||||
}
|
||||
NodeMetadata* ForgeNodeMetadata::clone()
|
||||
{
|
||||
ForgeNodeMetadata *d = new ForgeNodeMetadata();
|
||||
d->m_show_craft = m_show_craft;
|
||||
*d->m_inventory = *m_inventory;
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* ForgeNodeMetadata::create(std::istream &is)
|
||||
{
|
||||
ForgeNodeMetadata *d = new ForgeNodeMetadata();
|
||||
|
||||
d->m_inventory->deSerialize(is);
|
||||
int c;
|
||||
is>>c;
|
||||
d->m_show_craft = !!c;
|
||||
|
||||
return d;
|
||||
}
|
||||
void ForgeNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
m_inventory->serialize(os);
|
||||
os<<itos(m_show_craft ? 1 : 0)<<" ";
|
||||
}
|
||||
std::wstring ForgeNodeMetadata::infoText()
|
||||
{
|
||||
return wgettext("Forge");
|
||||
}
|
||||
void ForgeNodeMetadata::inventoryModified()
|
||||
{
|
||||
infostream<<"Forge inventory modification callback"<<std::endl;
|
||||
}
|
||||
bool ForgeNodeMetadata::step(float dtime, v3s16 pos, ServerEnvironment *env)
|
||||
{
|
||||
v3s16 abv = pos+v3s16(0,1,0);
|
||||
MapNode n = env->getMap().getNodeNoEx(abv);
|
||||
if (n.getContent() == CONTENT_AIR) {
|
||||
bool show_flame = false;
|
||||
if (m_show_craft) {
|
||||
}else{
|
||||
InventoryList *mlist = m_inventory->getList("mithril");
|
||||
InventoryList *glist = m_inventory->getList("gem");
|
||||
if (!mlist || !glist)
|
||||
return false;
|
||||
InventoryItem *mithril = mlist->getItem(0);
|
||||
InventoryItem *gem = glist->getItem(0);
|
||||
if (mithril && gem)
|
||||
show_flame = true;
|
||||
}
|
||||
if (show_flame) {
|
||||
n.setContent(CONTENT_FORGE_FIRE);
|
||||
env->getMap().addNodeWithEvent(abv,n);
|
||||
}
|
||||
}else if (n.getContent() == CONTENT_FORGE_FIRE) {
|
||||
env->getMap().removeNodeWithEvent(abv);
|
||||
if (m_show_craft) {
|
||||
}else{
|
||||
InventoryList *mlist = m_inventory->getList("mithril");
|
||||
InventoryList *glist = m_inventory->getList("gem");
|
||||
InventoryList *result = m_inventory->getList("craftresult");
|
||||
if (!mlist || !glist || !result)
|
||||
return false;
|
||||
InventoryItem *mithril = mlist->getItem(0);
|
||||
InventoryItem *gem = glist->getItem(0);
|
||||
if (!mithril || !gem)
|
||||
return false;
|
||||
u16 data = 0;
|
||||
if (!enchantment_enchant(&data,gem->getContent()))
|
||||
return false;
|
||||
InventoryItem *newitem = new CraftItem(CONTENT_CRAFTITEM_MITHRIL,1,data);
|
||||
if (!newitem)
|
||||
return false;
|
||||
if (!result->itemFits(0,newitem)) {
|
||||
delete newitem;
|
||||
return false;
|
||||
}
|
||||
result->addItem(newitem);
|
||||
mlist->decrementMaterials(1);
|
||||
glist->decrementMaterials(1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool ForgeNodeMetadata::nodeRemovalDisabled()
|
||||
{
|
||||
/*
|
||||
Disable removal if not empty
|
||||
*/
|
||||
InventoryList *list = m_inventory->getList("craft");
|
||||
if (list && list->getUsedSlots() > 0)
|
||||
return true;
|
||||
|
||||
list = m_inventory->getList("mithril");
|
||||
if (list && list->getUsedSlots() > 0)
|
||||
return true;
|
||||
|
||||
list = m_inventory->getList("gem");
|
||||
if (list && list->getUsedSlots() > 0)
|
||||
return true;
|
||||
|
||||
list = m_inventory->getList("craftresult");
|
||||
if (list && list->getUsedSlots() > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
std::string ForgeNodeMetadata::getDrawSpecString()
|
||||
{
|
||||
if (m_show_craft)
|
||||
return std::string("size[8,8]")+
|
||||
"list[current_name;craft;2,0;3,3;]"
|
||||
"list[current_name;craftresult;6,1;1,1;]"
|
||||
"list[current_player;main;0,3.8;8,1;0,8;]"
|
||||
"list[current_player;main;0,5;8,3;8,-1;]";
|
||||
return std::string("size[8,8]")+
|
||||
"list[current_name;mithril;1,1;1,1;]"
|
||||
"list[current_name;gem;3,1;1,1;]"
|
||||
"list[current_name;craftresult;6,1;1,1;]"
|
||||
"list[current_player;main;0,3.8;8,1;0,8;]"
|
||||
"list[current_player;main;0,5;8,3;8,-1;]";
|
||||
}
|
||||
|
||||
/*
|
||||
CircuitNodeMetadata
|
||||
*/
|
||||
|
|
|
@ -589,6 +589,28 @@ private:
|
|||
float m_cool_time;
|
||||
};
|
||||
|
||||
class ForgeNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
ForgeNodeMetadata();
|
||||
~ForgeNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
virtual NodeMetadata* clone();
|
||||
static NodeMetadata* create(std::istream &is);
|
||||
virtual void serializeBody(std::ostream &os);
|
||||
virtual std::wstring infoText();
|
||||
virtual Inventory* getInventory() {return m_inventory;}
|
||||
virtual void inventoryModified();
|
||||
virtual bool step(float dtime, v3s16 pos, ServerEnvironment *env);
|
||||
virtual bool nodeRemovalDisabled();
|
||||
virtual std::string getDrawSpecString();
|
||||
|
||||
private:
|
||||
bool m_show_craft;
|
||||
Inventory *m_inventory;
|
||||
};
|
||||
|
||||
class CircuitNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "enchantment.h"
|
||||
#include <stdio.h>
|
||||
#include "content_craftitem.h"
|
||||
|
||||
/*
|
||||
1 - Aeterna ---
|
||||
|
@ -54,6 +55,7 @@ static void enchantment_init()
|
|||
f->mask = 0;
|
||||
f->overlay = "";
|
||||
f->name = L"";
|
||||
f->gem = CONTENT_IGNORE;
|
||||
}
|
||||
|
||||
i = ENCHANTMENT_FLAME;
|
||||
|
@ -90,6 +92,7 @@ static void enchantment_init()
|
|||
f->mask = (1<<(i-1));
|
||||
f->overlay = "longlast";
|
||||
f->name = L"Aeterna";
|
||||
f->gem = CONTENT_CRAFTITEM_QUARTZ;
|
||||
|
||||
enchantment_isinit = 1;
|
||||
}
|
||||
|
@ -104,8 +107,6 @@ bool enchantment_get(uint16_t *data, EnchantmentInfo *info)
|
|||
if (!data)
|
||||
return false;
|
||||
|
||||
printf("enchantment_get( %u , X) - START\n",*data);
|
||||
|
||||
d = *data;
|
||||
if (d == ENCHANTMENT_NONE)
|
||||
return false;
|
||||
|
@ -139,9 +140,7 @@ bool enchantment_get(uint16_t *data, EnchantmentInfo *info)
|
|||
|
||||
for (d=0; d<3 && i>-1; d++,i--) {
|
||||
(*data) &= ~(1<<i);
|
||||
printf("enchantment_get( %u , X) - TICK %u\n",*data,i);
|
||||
}
|
||||
printf("enchantment_get( %u , X) - END\n",*data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -156,3 +155,20 @@ bool enchantment_have(uint16_t data, uint16_t enchantment)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool enchantment_set(uint16_t *data, uint16_t enchantment)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool enchantment_enchant(uint16_t *data, content_t item)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<=ENCHANTMENT_MAX; i++) {
|
||||
if (enchantments[i].gem == item) {
|
||||
*data = enchantments[i].mask;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include "mapnode.h"
|
||||
|
||||
#define ENCHANTMENT_NONE 0
|
||||
#define ENCHANTMENT_FLAME 2
|
||||
|
@ -37,9 +38,12 @@ struct EnchantmentInfo {
|
|||
uint16_t mask;
|
||||
std::string overlay;
|
||||
std::wstring name;
|
||||
content_t gem;
|
||||
};
|
||||
|
||||
bool enchantment_get(uint16_t *data, EnchantmentInfo *info);
|
||||
bool enchantment_have(uint16_t data, uint16_t enchantment);
|
||||
bool enchantment_set(uint16_t *data, uint16_t enchantment);
|
||||
bool enchantment_enchant(uint16_t *data, content_t item);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue