mirror of https://github.com/minetest/minetest.git
Non idle punches.
Punch(play animation and calculate damage) entity only if time from last punch greater or equal to full punch interval.
This commit is contained in:
parent
fb6a789991
commit
7473306dd3
|
@ -242,6 +242,11 @@ public:
|
||||||
m_time_from_last_punch = 0.0;
|
m_time_from_last_punch = 0.0;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
float getTimeFromLastPunch()
|
||||||
|
{
|
||||||
|
return m_time_from_last_punch;
|
||||||
|
}
|
||||||
|
|
||||||
void noCheatDigStart(v3s16 p)
|
void noCheatDigStart(v3s16 p)
|
||||||
{
|
{
|
||||||
m_nocheat_dig_pos = p;
|
m_nocheat_dig_pos = p;
|
||||||
|
|
14
src/game.cpp
14
src/game.cpp
|
@ -2818,9 +2818,17 @@ void the_game(
|
||||||
v3f objpos = selected_object->getPosition();
|
v3f objpos = selected_object->getPosition();
|
||||||
v3f dir = (objpos - player_position).normalize();
|
v3f dir = (objpos - player_position).normalize();
|
||||||
|
|
||||||
bool disable_send = selected_object->directReportPunch(
|
bool disable_send = true;
|
||||||
dir, &playeritem, time_from_last_punch);
|
if(time_from_last_punch >= playeritem.getToolCapabilities(gamedef->idef()).full_punch_interval)
|
||||||
time_from_last_punch = 0;
|
{
|
||||||
|
disable_send = selected_object->directReportPunch(
|
||||||
|
dir, &playeritem, time_from_last_punch);
|
||||||
|
time_from_last_punch = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
left_punch = false;
|
||||||
|
}
|
||||||
if(!disable_send)
|
if(!disable_send)
|
||||||
client.interact(0, pointed);
|
client.interact(0, pointed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2925,10 +2925,12 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
v3f dir = (pointed_object->getBasePosition() -
|
v3f dir = (pointed_object->getBasePosition() -
|
||||||
(player->getPosition() + player->getEyeOffset())
|
(player->getPosition() + player->getEyeOffset())
|
||||||
).normalize();
|
).normalize();
|
||||||
float time_from_last_punch =
|
|
||||||
playersao->resetTimeFromLastPunch();
|
if(playersao->getTimeFromLastPunch() >= toolcap.full_punch_interval)
|
||||||
pointed_object->punch(dir, &toolcap, playersao,
|
{
|
||||||
time_from_last_punch);
|
pointed_object->punch(dir, &toolcap, playersao,
|
||||||
|
playersao->resetTimeFromLastPunch());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // action == 0
|
} // action == 0
|
||||||
|
|
Loading…
Reference in New Issue