mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Digging time groups WIP
This commit is contained in:
parent
f21291211c
commit
562ac3bce9
21 changed files with 695 additions and 704 deletions
|
@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "gamedef.h"
|
||||
#include "inventory.h"
|
||||
#include "environment.h"
|
||||
#include "materials.h"
|
||||
#include "tool.h"
|
||||
|
||||
ServerRemotePlayer::ServerRemotePlayer(ServerEnvironment *env):
|
||||
Player(env->getGameDef()),
|
||||
|
@ -181,35 +181,32 @@ void ServerRemotePlayer::punch(ServerActiveObject *puncher,
|
|||
return;
|
||||
}
|
||||
|
||||
// "Material" properties of a player
|
||||
MaterialProperties mp;
|
||||
mp.diggability = DIGGABLE_NORMAL;
|
||||
mp.crackiness = -0.5;
|
||||
mp.cuttability = 0.5;
|
||||
// "Material" groups of the player
|
||||
std::map<std::string, int> groups;
|
||||
groups["snappy"] = 1;
|
||||
groups["choppy"] = 2;
|
||||
|
||||
IItemDefManager *idef = m_env->getGameDef()->idef();
|
||||
ItemStack punchitem = puncher->getWieldedItem();
|
||||
ToolDiggingProperties tp =
|
||||
punchitem.getToolDiggingProperties(idef);
|
||||
ToolCapabilities tp = punchitem.getToolCapabilities(idef);
|
||||
|
||||
HittingProperties hitprop = getHittingProperties(&mp, &tp,
|
||||
time_from_last_punch);
|
||||
HitParams hitparams = getHitParams(groups, &tp, time_from_last_punch);
|
||||
|
||||
actionstream<<"Player "<<getName()<<" punched by "
|
||||
<<puncher->getDescription()<<", damage "<<hitprop.hp
|
||||
<<puncher->getDescription()<<", damage "<<hitparams.hp
|
||||
<<" HP"<<std::endl;
|
||||
|
||||
setHP(getHP() - hitprop.hp);
|
||||
punchitem.addWear(hitprop.wear, idef);
|
||||
setHP(getHP() - hitparams.hp);
|
||||
punchitem.addWear(hitparams.wear, idef);
|
||||
puncher->setWieldedItem(punchitem);
|
||||
|
||||
if(hitprop.hp != 0)
|
||||
if(hitparams.hp != 0)
|
||||
{
|
||||
std::ostringstream os(std::ios::binary);
|
||||
// command (1 = punched)
|
||||
writeU8(os, 1);
|
||||
// damage
|
||||
writeS16(os, hitprop.hp);
|
||||
writeS16(os, hitparams.hp);
|
||||
// create message and add to list
|
||||
ActiveObjectMessage aom(getId(), false, os.str());
|
||||
m_messages_out.push_back(aom);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue