forked from oerkki/voxelands
oerkkis drop a powder when killed - used to teleport home
This commit is contained in:
parent
db6f467caf
commit
eb3eefc1e4
Binary file not shown.
After Width: | Height: | Size: 524 B |
|
@ -682,4 +682,13 @@ void content_craftitem_init()
|
||||||
f->name = "lump_of_resin";
|
f->name = "lump_of_resin";
|
||||||
f->description = "Resin";
|
f->description = "Resin";
|
||||||
f->drop_count = 1;
|
f->drop_count = 1;
|
||||||
|
|
||||||
|
i = CONTENT_CRAFTITEM_OERKKI_DUST;
|
||||||
|
f = &g_content_craftitem_features[i];
|
||||||
|
f->content = CONTENT_CRAFTITEM_OERKKI_DUST;
|
||||||
|
f->texture = "oerkki_dust.png";
|
||||||
|
f->name = "oerkki_dust";
|
||||||
|
f->description = "Oerkki Dust";
|
||||||
|
f->drop_count = 1;
|
||||||
|
lists::add("creative",i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,5 +99,6 @@ CraftItemFeatures & content_craftitem_features(std::string subname);
|
||||||
#define CONTENT_CRAFTITEM_STRING (CONTENT_CRAFTITEM_MASK | 0x41)
|
#define CONTENT_CRAFTITEM_STRING (CONTENT_CRAFTITEM_MASK | 0x41)
|
||||||
#define CONTENT_CRAFTITEM_MESEDUST (CONTENT_CRAFTITEM_MASK | 0x42)
|
#define CONTENT_CRAFTITEM_MESEDUST (CONTENT_CRAFTITEM_MASK | 0x42)
|
||||||
#define CONTENT_CRAFTITEM_RESIN (CONTENT_CRAFTITEM_MASK | 0x43)
|
#define CONTENT_CRAFTITEM_RESIN (CONTENT_CRAFTITEM_MASK | 0x43)
|
||||||
|
#define CONTENT_CRAFTITEM_OERKKI_DUST (CONTENT_CRAFTITEM_MASK | 0x44)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -725,6 +725,15 @@ u16 Oerkki1SAO::punch(const std::string &toolname, v3f dir,
|
||||||
return 65536/100;
|
return 65536/100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InventoryItem* Oerkki1SAO::createPickedUpItem()
|
||||||
|
{
|
||||||
|
if (!m_removed)
|
||||||
|
return NULL;
|
||||||
|
std::istringstream is("CraftItem oerkki_dust 2", std::ios_base::binary);
|
||||||
|
InventoryItem *item = InventoryItem::deSerialize(is);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
void Oerkki1SAO::doDamage(u16 d)
|
void Oerkki1SAO::doDamage(u16 d)
|
||||||
{
|
{
|
||||||
infostream<<"oerkki damage: "<<d<<std::endl;
|
infostream<<"oerkki damage: "<<d<<std::endl;
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
void step(float dtime, bool send_recommended);
|
void step(float dtime, bool send_recommended);
|
||||||
std::string getClientInitializationData();
|
std::string getClientInitializationData();
|
||||||
std::string getStaticData();
|
std::string getStaticData();
|
||||||
InventoryItem* createPickedUpItem(){return NULL;}
|
InventoryItem* createPickedUpItem();
|
||||||
u16 punch(const std::string &toolname, v3f dir,
|
u16 punch(const std::string &toolname, v3f dir,
|
||||||
const std::string &playername);
|
const std::string &playername);
|
||||||
u8 level(){return MOB_AGGRESSIVE;}
|
u8 level(){return MOB_AGGRESSIVE;}
|
||||||
|
|
|
@ -2299,18 +2299,14 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
*/
|
*/
|
||||||
InventoryItem *item = obj->createPickedUpItem();
|
InventoryItem *item = obj->createPickedUpItem();
|
||||||
|
|
||||||
if(item)
|
if (item) {
|
||||||
{
|
|
||||||
InventoryList *ilist = player->inventory.getList("main");
|
InventoryList *ilist = player->inventory.getList("main");
|
||||||
if(ilist != NULL)
|
if (ilist != NULL) {
|
||||||
{
|
|
||||||
actionstream<<player->getName()<<" picked up "
|
actionstream<<player->getName()<<" picked up "
|
||||||
<<item->getName()<<std::endl;
|
<<item->getName()<<std::endl;
|
||||||
if(g_settings->getBool("creative_mode") == false)
|
if (g_settings->getBool("creative_mode") == false) {
|
||||||
{
|
|
||||||
// Skip if inventory has no free space
|
// Skip if inventory has no free space
|
||||||
if(ilist->roomForItem(item) == false)
|
if (ilist->roomForItem(item) == false) {
|
||||||
{
|
|
||||||
infostream<<"Player inventory has no free space"<<std::endl;
|
infostream<<"Player inventory has no free space"<<std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2324,9 +2320,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
// Remove object from environment
|
// Remove object from environment
|
||||||
obj->m_removed = true;
|
obj->m_removed = true;
|
||||||
}
|
}
|
||||||
}
|
}else{
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
Item cannot be picked up. Punch it instead.
|
Item cannot be picked up. Punch it instead.
|
||||||
*/
|
*/
|
||||||
|
@ -2338,11 +2332,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
std::string toolname = "";
|
std::string toolname = "";
|
||||||
|
|
||||||
InventoryList *mlist = player->inventory.getList("main");
|
InventoryList *mlist = player->inventory.getList("main");
|
||||||
if(mlist != NULL)
|
if (mlist != NULL) {
|
||||||
{
|
|
||||||
InventoryItem *item = mlist->getItem(item_i);
|
InventoryItem *item = mlist->getItem(item_i);
|
||||||
if(item && (std::string)item->getName() == "ToolItem")
|
if (item && (std::string)item->getName() == "ToolItem") {
|
||||||
{
|
|
||||||
titem = (ToolItem*)item;
|
titem = (ToolItem*)item;
|
||||||
toolname = titem->getToolName();
|
toolname = titem->getToolName();
|
||||||
}
|
}
|
||||||
|
@ -2353,9 +2345,29 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
v3f dir = (objpos - playerpos).normalize();
|
v3f dir = (objpos - playerpos).normalize();
|
||||||
|
|
||||||
u16 wear = obj->punch(toolname, dir, player->getName());
|
u16 wear = obj->punch(toolname, dir, player->getName());
|
||||||
|
item = obj->createPickedUpItem();
|
||||||
|
/* killing something might have caused a drop */
|
||||||
|
if (item) {
|
||||||
|
InventoryList *ilist = player->inventory.getList("main");
|
||||||
|
if (ilist != NULL) {
|
||||||
|
actionstream<<player->getName()<<" picked up "
|
||||||
|
<<item->getName()<<std::endl;
|
||||||
|
if (g_settings->getBool("creative_mode") == false) {
|
||||||
|
// Skip if inventory has no free space
|
||||||
|
if (ilist->roomForItem(item) == false) {
|
||||||
|
infostream<<"Player inventory has no free space"<<std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(titem)
|
// Add to inventory and send inventory
|
||||||
{
|
ilist->addItem(item);
|
||||||
|
UpdateCrafting(player->peer_id);
|
||||||
|
SendInventory(player->peer_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (titem) {
|
||||||
bool weared_out = titem->addWear(wear);
|
bool weared_out = titem->addWear(wear);
|
||||||
if(weared_out)
|
if(weared_out)
|
||||||
mlist->deleteItem(item_i);
|
mlist->deleteItem(item_i);
|
||||||
|
@ -4036,6 +4048,45 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
continue;
|
continue;
|
||||||
client->SetBlocksNotSent(modified_blocks);
|
client->SetBlocksNotSent(modified_blocks);
|
||||||
}
|
}
|
||||||
|
}else if (item->getContent() == CONTENT_CRAFTITEM_OERKKI_DUST) {
|
||||||
|
/*
|
||||||
|
If in creative mode, item dropping is disabled unless
|
||||||
|
player has build privileges
|
||||||
|
*/
|
||||||
|
if(g_settings->getBool("creative_mode") &&
|
||||||
|
(getPlayerPrivs(player) & PRIV_BUILD) == 0)
|
||||||
|
{
|
||||||
|
infostream<<"Not allowing player to drop item: "
|
||||||
|
"creative mode and no build privs"<<std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (g_settings->getBool("creative_mode") == false) {
|
||||||
|
// Delete the right amount of items from the slot
|
||||||
|
u16 dropcount = item->getDropCount();
|
||||||
|
|
||||||
|
// Delete item if all gone
|
||||||
|
if (item->getCount() <= dropcount) {
|
||||||
|
if (item->getCount() < dropcount)
|
||||||
|
infostream<<"WARNING: Server: dropped more items"
|
||||||
|
<<" than the slot contains"<<std::endl;
|
||||||
|
|
||||||
|
InventoryList *ilist = player->inventory.getList("main");
|
||||||
|
if (ilist)
|
||||||
|
// Remove from inventory and send inventory
|
||||||
|
ilist->deleteItem(item_i);
|
||||||
|
}else{
|
||||||
|
item->remove(dropcount);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send inventory
|
||||||
|
UpdateCrafting(peer_id);
|
||||||
|
SendInventory(peer_id);
|
||||||
|
}
|
||||||
|
v3f pos;
|
||||||
|
if (!player->getHome(pos))
|
||||||
|
pos = findSpawnPos(m_env.getServerMap());
|
||||||
|
player->setPosition(pos);
|
||||||
|
SendMovePlayer(player);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Place other item (not a block)
|
Place other item (not a block)
|
||||||
|
|
Loading…
Reference in New Issue