2011-06-18 00:46:50 +03:00
|
|
|
/*
|
|
|
|
Minetest-c55
|
|
|
|
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "content_craft.h"
|
|
|
|
#include "inventory.h"
|
|
|
|
#include "content_mapnode.h"
|
|
|
|
#include "player.h"
|
2011-07-23 16:55:26 +03:00
|
|
|
#include "mapnode.h" // For content_t
|
2011-11-16 14:08:31 +02:00
|
|
|
#include "gamedef.h"
|
2011-06-18 00:46:50 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
items: actually *items[9]
|
|
|
|
return value: allocates a new item, or returns NULL.
|
2011-11-17 02:30:52 +02:00
|
|
|
|
|
|
|
NOTE: Not used anymore; TODO: Remove
|
2011-06-18 00:46:50 +03:00
|
|
|
*/
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
2011-06-18 00:46:50 +03:00
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
INodeDefManager *ndef = gamedef->ndef();
|
|
|
|
|
2011-06-18 00:46:50 +03:00
|
|
|
// Wood
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_TREE"));
|
2011-06-18 00:46:50 +03:00
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_WOOD"), 4);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stick
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-06-18 00:46:50 +03:00
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new CraftItem(gamedef, "Stick", 4);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fence
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[5] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[6] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[8] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_FENCE"), 2);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sign
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
//return new MapBlockObjectItem(gamedef, "Sign");
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_SIGN_WALL"), 1);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Torch
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[0] = ItemSpec(ITEM_CRAFT, "lump_of_coal");
|
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 4);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wooden pick
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "WPick", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stone pick
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "STPick", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Steel pick
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[2] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "SteelPick", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mese pick
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_MESE"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_MESE"));
|
|
|
|
specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_MESE"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "MesePick", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wooden shovel
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "WShovel", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stone shovel
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "STShovel", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Steel shovel
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "SteelShovel", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wooden axe
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "WAxe", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stone axe
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "STAxe", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Steel axe
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "SteelAxe", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wooden sword
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "WSword", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stone sword
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
2011-06-18 00:46:50 +03:00
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "STSword", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Steel sword
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new ToolItem(gamedef, "SteelSword", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-26 12:24:32 +02:00
|
|
|
// Rail
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[1] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[2] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[5] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[6] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[8] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_RAIL"), 15);
|
2011-06-26 12:24:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-18 00:46:50 +03:00
|
|
|
// Chest
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-06-18 00:46:50 +03:00
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_CHEST"), 1);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-22 19:11:48 +10:00
|
|
|
// Locking Chest
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-09-22 19:11:48 +10:00
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-09-22 19:11:48 +10:00
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_LOCKABLE_CHEST"), 1);
|
2011-09-22 19:11:48 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-18 00:46:50 +03:00
|
|
|
// Furnace
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
|
|
|
specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
|
2011-06-18 00:46:50 +03:00
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_FURNACE"), 1);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Steel block
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[2] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[5] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[6] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[8] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_STEEL"), 1);
|
2011-06-18 00:46:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-26 12:24:32 +02:00
|
|
|
// Sandstone
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
|
|
|
|
specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
|
|
|
|
specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
|
|
|
|
specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
|
2011-06-26 12:24:32 +02:00
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_SANDSTONE"), 1);
|
2011-06-26 12:24:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clay
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
|
|
|
|
specs[6] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_CLAY"), 1);
|
2011-06-26 12:24:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Brick
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "clay_brick");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "clay_brick");
|
|
|
|
specs[6] = ItemSpec(ITEM_CRAFT, "clay_brick");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "clay_brick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_BRICK"), 1);
|
2011-06-26 12:24:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paper
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_PAPYRUS"));
|
|
|
|
specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_PAPYRUS"));
|
|
|
|
specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_PAPYRUS"));
|
2011-06-26 12:24:32 +02:00
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new CraftItem(gamedef, "paper", 1);
|
2011-06-26 12:24:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Book
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[1] = ItemSpec(ITEM_CRAFT, "paper");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "paper");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "paper");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new CraftItem(gamedef, "book", 1);
|
2011-06-26 12:24:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Book shelf
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-06-26 12:24:32 +02:00
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "book");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "book");
|
|
|
|
specs[5] = ItemSpec(ITEM_CRAFT, "book");
|
2011-11-16 14:08:31 +02:00
|
|
|
specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
|
|
|
specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
|
2011-06-26 12:24:32 +02:00
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_BOOKSHELF"), 1);
|
2011-06-26 12:24:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-27 10:18:09 -07:00
|
|
|
// Ladder
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[0] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[2] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[5] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[6] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
specs[8] = ItemSpec(ITEM_CRAFT, "Stick");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_LADDER"), 1);
|
2011-07-27 10:18:09 -07:00
|
|
|
}
|
|
|
|
}
|
2011-09-12 20:10:17 +02:00
|
|
|
|
|
|
|
// Iron Apple
|
|
|
|
{
|
|
|
|
ItemSpec specs[9];
|
|
|
|
specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[4] = ItemSpec(ITEM_CRAFT, "apple");
|
|
|
|
specs[5] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
specs[7] = ItemSpec(ITEM_CRAFT, "steel_ingot");
|
|
|
|
if(checkItemCombination(items, specs))
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
return new CraftItem(gamedef, "apple_iron", 1);
|
2011-09-12 20:10:17 +02:00
|
|
|
}
|
|
|
|
}
|
2011-07-27 10:18:09 -07:00
|
|
|
|
2011-06-18 00:46:50 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-14 00:19:48 +02:00
|
|
|
void craft_set_creative_inventory(Player *player, IGameDef *gamedef)
|
2011-06-18 00:46:50 +03:00
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
INodeDefManager *ndef = gamedef->ndef();
|
|
|
|
|
2011-06-18 00:46:50 +03:00
|
|
|
player->resetInventory();
|
|
|
|
|
|
|
|
// Give some good tools
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new ToolItem(gamedef, "MesePick", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new ToolItem(gamedef, "SteelPick", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new ToolItem(gamedef, "SteelAxe", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new ToolItem(gamedef, "SteelShovel", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Give materials
|
|
|
|
*/
|
|
|
|
|
|
|
|
// CONTENT_IGNORE-terminated list
|
2011-07-23 16:55:26 +03:00
|
|
|
content_t material_items[] = {
|
2011-11-16 14:08:31 +02:00
|
|
|
LEGN(ndef, "CONTENT_TORCH"),
|
|
|
|
LEGN(ndef, "CONTENT_COBBLE"),
|
|
|
|
LEGN(ndef, "CONTENT_MUD"),
|
|
|
|
LEGN(ndef, "CONTENT_STONE"),
|
|
|
|
LEGN(ndef, "CONTENT_SAND"),
|
|
|
|
LEGN(ndef, "CONTENT_SANDSTONE"),
|
|
|
|
LEGN(ndef, "CONTENT_CLAY"),
|
|
|
|
LEGN(ndef, "CONTENT_BRICK"),
|
|
|
|
LEGN(ndef, "CONTENT_TREE"),
|
|
|
|
LEGN(ndef, "CONTENT_LEAVES"),
|
|
|
|
LEGN(ndef, "CONTENT_CACTUS"),
|
|
|
|
LEGN(ndef, "CONTENT_PAPYRUS"),
|
|
|
|
LEGN(ndef, "CONTENT_BOOKSHELF"),
|
|
|
|
LEGN(ndef, "CONTENT_GLASS"),
|
|
|
|
LEGN(ndef, "CONTENT_FENCE"),
|
|
|
|
LEGN(ndef, "CONTENT_RAIL"),
|
|
|
|
LEGN(ndef, "CONTENT_MESE"),
|
|
|
|
LEGN(ndef, "CONTENT_WATERSOURCE"),
|
|
|
|
LEGN(ndef, "CONTENT_CLOUD"),
|
|
|
|
LEGN(ndef, "CONTENT_CHEST"),
|
|
|
|
LEGN(ndef, "CONTENT_FURNACE"),
|
|
|
|
LEGN(ndef, "CONTENT_SIGN_WALL"),
|
|
|
|
LEGN(ndef, "CONTENT_LAVASOURCE"),
|
2011-06-18 00:46:50 +03:00
|
|
|
CONTENT_IGNORE
|
|
|
|
};
|
|
|
|
|
2011-07-23 16:55:26 +03:00
|
|
|
content_t *mip = material_items;
|
2011-06-18 00:46:50 +03:00
|
|
|
for(u16 i=0; i<PLAYER_INVENTORY_SIZE; i++)
|
|
|
|
{
|
|
|
|
if(*mip == CONTENT_IGNORE)
|
|
|
|
break;
|
|
|
|
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new MaterialItem(gamedef, *mip, 1);
|
2011-06-18 00:46:50 +03:00
|
|
|
player->inventory.addItem("main", item);
|
|
|
|
|
|
|
|
mip++;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2011-11-16 14:08:31 +02:00
|
|
|
assert(USEFUL_LEGN(ndef, "CONTENT_COUNT") <= PLAYER_INVENTORY_SIZE);
|
2011-06-18 00:46:50 +03:00
|
|
|
|
|
|
|
// add torch first
|
2011-11-16 14:08:31 +02:00
|
|
|
InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 1);
|
2011-06-18 00:46:50 +03:00
|
|
|
player->inventory.addItem("main", item);
|
|
|
|
|
|
|
|
// Then others
|
2011-11-16 14:08:31 +02:00
|
|
|
for(u16 i=0; i<USEFUL_LEGN(ndef, "CONTENT_COUNT"); i++)
|
2011-06-18 00:46:50 +03:00
|
|
|
{
|
|
|
|
// Skip some materials
|
2011-11-16 14:08:31 +02:00
|
|
|
if(i == LEGN(ndef, "CONTENT_WATER") || i == LEGN(ndef, "CONTENT_TORCH")
|
|
|
|
|| i == LEGN(ndef, "CONTENT_COALSTONE"))
|
2011-06-18 00:46:50 +03:00
|
|
|
continue;
|
|
|
|
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new MaterialItem(gamedef, i, 1);
|
2011-06-18 00:46:50 +03:00
|
|
|
player->inventory.addItem("main", item);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*// Sign
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new MapBlockObjectItem(gamedef, "Sign Example text");
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
2011-11-14 00:19:48 +02:00
|
|
|
void craft_give_initial_stuff(Player *player, IGameDef *gamedef)
|
2011-06-18 00:46:50 +03:00
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
INodeDefManager *ndef = gamedef->ndef();
|
|
|
|
|
2011-06-18 00:46:50 +03:00
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new ToolItem(gamedef, "SteelPick", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 99);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new ToolItem(gamedef, "SteelAxe", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new ToolItem(gamedef, "SteelShovel", 0);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_COBBLE"), 99);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
/*{
|
2011-11-16 14:08:31 +02:00
|
|
|
InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_MESE"), 6);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_COALSTONE"), 6);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_WOOD"), 6);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new CraftItem(gamedef, "Stick", 4);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new ToolItem(gamedef, "WPick", 32000);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new ToolItem(gamedef, "STPick", 32000);
|
2011-06-18 00:46:50 +03:00
|
|
|
void* r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == NULL);
|
|
|
|
}*/
|
|
|
|
/*// and some signs
|
|
|
|
for(u16 i=0; i<4; i++)
|
|
|
|
{
|
2011-11-14 00:19:48 +02:00
|
|
|
InventoryItem *item = new MapBlockObjectItem(gamedef, "Sign Example text");
|
2011-06-18 00:46:50 +03:00
|
|
|
bool r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == true);
|
|
|
|
}*/
|
|
|
|
/*// Give some other stuff
|
|
|
|
{
|
2011-11-16 14:08:31 +02:00
|
|
|
InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TREE"), 999);
|
2011-06-18 00:46:50 +03:00
|
|
|
bool r = player->inventory.addItem("main", item);
|
|
|
|
assert(r == true);
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|