change the arming code for tnt, and add tin bucket textures

This commit is contained in:
darkrose 2013-10-27 17:00:18 +10:00
parent 274c93d627
commit d1a1e6f832
10 changed files with 70 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

View File

@ -3668,6 +3668,9 @@ void setWaterLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
list.set("WBucket",
DiggingProperties(true, 0.0, 65535./30.*toughness));
list.set("TinBucket",
DiggingProperties(true, 0.0, 65535./50.*toughness));
list.set("SteelBucket",
DiggingProperties(true, 0.0, 65535./80.*toughness));
}

View File

@ -624,6 +624,8 @@ bool TNTNodeMetadata::step(float dtime)
if (!m_armed)
return false;
m_time -= dtime;
if (m_time < 0.0)
m_time = 0.0;
return true;
}
void TNTNodeMetadata::serializeBody(std::ostream &os)

View File

@ -162,9 +162,25 @@ public:
virtual std::string infoText();
virtual bool step(float dtime);
float getTime() {return m_time;}
bool getArmed() {return m_armed;}
void setArmed(bool state) {m_armed = state; if (state) m_time = 5.0;}
//float getTime() {return m_time;}
//bool getArmed() {return m_armed;}
//void setArmed(bool state) {m_armed = state; if (state) m_time = 5.0;}
virtual bool energise(u8 level, v3s16 powersrc, v3s16 signalsrc, v3s16 pos)
{
if (level == 0) {
m_armed = false;
return true;
}
m_armed = true;
m_time = 5.0;
return true;
}
virtual u8 getEnergy()
{
if (!m_armed)
return 0;
return ENERGY_MAX-((u8)m_time);
}
private:
bool m_armed;

View File

@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h"
#include "collision.h"
#include "content_mapnode.h"
#include "content_nodemeta.h"
#include "nodemetadata.h"
#include "mapblock.h"
#include "serverobject.h"
#include "content_sao.h"
@ -1260,8 +1260,8 @@ void ServerEnvironment::step(float dtime)
boom
*/
if (n.getContent() == CONTENT_TNT) {
TNTNodeMetadata *meta = (TNTNodeMetadata*)m_map->getNodeMetadata(p);
if (meta && meta->getArmed() && meta->getTime() < 0.0) {
NodeMetadata *meta = m_map->getNodeMetadata(p);
if (meta && meta->getEnergy() == ENERGY_MAX) {
bool can_spread = true;
s16 bs_rad = g_settings->getS16("borderstone_radius");
bs_rad += 3;
@ -1283,9 +1283,9 @@ void ServerEnvironment::step(float dtime)
if (n_test.getContent() == CONTENT_AIR)
continue;
if (n_test.getContent() == CONTENT_TNT) {
meta = (TNTNodeMetadata*)m_map->getNodeMetadata(p+v3s16(x,y,z));
if (meta && !meta->getArmed())
meta->setArmed(true);
meta = m_map->getNodeMetadata(p+v3s16(x,y,z));
if (meta && !meta->getEnergy())
meta->energise(ENERGY_MAX,p,p,p+v3s16(x,y,z));
continue;
}
if (

View File

@ -334,6 +334,7 @@ void getPointedNode(Client *client, v3f player_position,
|| (
wieldname != std::string("SteelBucket")
&& wieldname != std::string("WBucket")
&& wieldname != std::string("TinBucket")
)
) {
continue;

View File

@ -425,8 +425,12 @@ public:
return "Shears";
}else if(m_toolname == "WBucket") {
return "Wooden Bucket";
}else if (m_toolname == "TinBucket") {
return "Tin Bucket";
}else if(m_toolname == "WBucket_water") {
return "Wooden Bucket of Water";
}else if (m_toolname == "TinBucket_water") {
return "Tin Bucket of Water";
}else if(m_toolname == "SteelBucket") {
return "Steel Bucket";
}else if(m_toolname == "SteelBucket_water") {

View File

@ -24,6 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <string>
#include <iostream>
#define ENERGY_MAX 16
/*
Used for storing:
@ -68,6 +70,26 @@ public:
// primarily used for locking chests, but others can play too
virtual std::string getOwner(){ return std::string(""); }
virtual void setOwner(std::string t){ }
// used by tnt to arm it, but also for future circuitry
// level is the amount of power
// powersrc is the generator or such that created the power
// signalsrc is the node that sent this node the energise signal
// pos is the position of this node
// returns false if propogation was stopped
virtual bool energise(u8 level, v3s16 powersrc, v3s16 signalsrc, v3s16 pos) {return false;}
bool energise(u8 level, v3f powersrc, v3f signalsrc, v3s16 pos)
{
v3s16 p;
v3s16 s;
p.X = powersrc.X;
p.Y = powersrc.Y;
p.Z = powersrc.Z;
s.X = signalsrc.X;
s.Y = signalsrc.Y;
s.Z = signalsrc.Z;
return energise(level,p,s,pos);
}
virtual u8 getEnergy() {return 0;}
protected:
static void registerType(u16 id, Factory f);

View File

@ -2495,9 +2495,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
wield && wield->getName() == std::string("ToolItem")
&& ((ToolItem*)wield)->getToolName() == "FireStarter"
) {
TNTNodeMetadata *meta = (TNTNodeMetadata*)m_env.getMap().getNodeMetadata(p_under);
if (meta && !meta->getArmed())
meta->setArmed(true);
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p_under);
if (meta && !meta->getEnergy())
meta->energise(ENERGY_MAX,player->getPosition(),player->getPosition(),p_under);
}
}
/*
@ -2894,10 +2894,15 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
&& (wieldname = ((ToolItem*)wield)->getToolName()) != std::string("")
&& (
wieldname == std::string("WBucket")
|| wieldname == std::string("TinBucket")
|| wieldname == std::string("SteelBucket")
)
) {
if (g_settings->getBool("enable_lavabuckets") == false || wieldname == std::string("WBucket")) {
if (
g_settings->getBool("enable_lavabuckets") == false
|| wieldname == std::string("WBucket")
|| wieldname == std::string("TinBucket")
) {
mlist->deleteItem(item_i);
HandlePlayerHP(player,4);
}else{
@ -3238,6 +3243,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
item->getName() == std::string("ToolItem")
&& (
((ToolItem*)item)->getToolName() == std::string("WBucket_water")
|| ((ToolItem*)item)->getToolName() == std::string("TinBucket_water")
|| ((ToolItem*)item)->getToolName() == std::string("SteelBucket_water")
|| ((ToolItem*)item)->getToolName() == std::string("SteelBucket_lava")
)
@ -3246,12 +3252,15 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
std::string wieldname = ((ToolItem*)item)->getToolName();
if (
wieldname == std::string("WBucket_water")
|| wieldname == std::string("TinBucket_water")
|| wieldname == std::string("SteelBucket_water")
) {
if (ilist != NULL) {
std::string dug_s = std::string("ToolItem ");
if (wieldname == std::string("WBucket_water")) {
dug_s += "WBucket 1";
}else if (wieldname == std::string("TinBucket_water")) {
dug_s += "TinBucket 1";
}else{
dug_s += "SteelBucket 1";
}