time_from_last_punch);
// If digging time would be 1 second, 2 hearts go in 1 second.
- s16 hp = 2.0 * 2.0 / digprop.time + 0.5;
+ s16 hp = 2.0 * 2.0 / digprop.time;
// Wear is the same as for digging a single node
- s16 wear = (float)digprop.wear + 0.5;
+ s16 wear = (float)digprop.wear;
return HittingProperties(hp, wear);
}
ServerActiveObject(env, v3f(0,0,0)),
m_last_good_position(0,0,0),
m_last_good_position_age(0),
- m_additional_items(),
m_inventory_not_sent(false),
m_hp_not_sent(false),
m_respawn_active(false),
m_is_in_environment(false),
+ m_time_from_last_punch(0),
m_position_not_sent(false)
{
}
const char *name_):
Player(env->getGameDef()),
ServerActiveObject(env, pos_),
+ m_last_good_position(0,0,0),
+ m_last_good_position_age(0),
m_inventory_not_sent(false),
m_hp_not_sent(false),
m_is_in_environment(false),
+ m_time_from_last_punch(0),
m_position_not_sent(false)
{
setPosition(pos_);
void ServerRemotePlayer::step(float dtime, bool send_recommended)
{
+ m_time_from_last_punch += dtime;
+
if(send_recommended == false)
return;
HittingProperties hitprop = getHittingProperties(&mp, &tp,
time_from_last_punch);
+ actionstream<<"Player "<<getName()<<" punched by "
+ <<puncher->getDescription()<<", damage "<<hitprop.hp
+ <<" HP"<<std::endl;
+
setHP(getHP() - hitprop.hp);
puncher->damageWieldedItem(hitprop.wear);
-
+
+ if(hitprop.hp != 0)
{
std::ostringstream os(std::ios::binary);
// command (1 = punched)
void rightClick(ServerActiveObject *clicker);
void setPos(v3f pos);
void moveTo(v3f pos, bool continuous);
- virtual std::string getDescription(){return getName();}
+ virtual std::string getDescription()
+ {return std::string("player ")+getName();}
virtual void getWieldDiggingProperties(ToolDiggingProperties *dst);
virtual void damageWieldedItem(u16 amount);
bool m_hp_not_sent;
bool m_respawn_active;
bool m_is_in_environment;
+ // Incremented by step(), read and reset by Server
+ float m_time_from_last_punch;
private:
bool m_position_not_sent;
float dd_crumbliness;
float dd_cuttability;
- ToolDiggingProperties(float full_punch_interval_=1.0,
+ ToolDiggingProperties(float full_punch_interval_=2.0,
float a=0.75, float b=0, float c=0, float d=0, float e=0,
float f=50, float g=0, float h=0, float i=0, float j=0);
};