1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Some work-in-progress in hp and mobs and a frightening amount of random fixes.

This commit is contained in:
Perttu Ahola 2011-04-21 19:35:17 +03:00
parent 3c61d57f6d
commit c638442e78
40 changed files with 1837 additions and 920 deletions

View file

@ -33,6 +33,7 @@ Player::Player():
in_water_stable(false),
swimming_up(false),
craftresult_is_preview(true),
hp(20),
peer_id(PEER_ID_INEXISTENT),
m_pitch(0),
m_yaw(0),
@ -102,6 +103,7 @@ void Player::serialize(std::ostream &os)
args.setFloat("yaw", m_yaw);
args.setV3F("position", m_position);
args.setBool("craftresult_is_preview", craftresult_is_preview);
args.setS32("hp", hp);
args.writeLines(os);
@ -138,6 +140,11 @@ void Player::deSerialize(std::istream &is)
}catch(SettingNotFoundException &e){
craftresult_is_preview = true;
}
try{
hp = args.getS32("hp");
}catch(SettingNotFoundException &e){
hp = 20;
}
inventory.deSerialize(is);
}
@ -276,7 +283,8 @@ LocalPlayer::~LocalPlayer()
{
}
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d)
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
core::list<CollisionInfo> *collision_info)
{
v3f position = getPosition();
v3f oldpos = position;
@ -530,9 +538,23 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d)
*/
if(other_axes_overlap && main_axis_collides)
{
v3f old_speed = m_speed;
m_speed -= m_speed.dotProduct(dirs[i]) * dirs[i];
position -= position.dotProduct(dirs[i]) * dirs[i];
position += oldpos.dotProduct(dirs[i]) * dirs[i];
if(collision_info)
{
// Report fall collision
if(old_speed.Y < m_speed.Y - 0.1)
{
CollisionInfo info;
info.t = COLLISION_FALL;
info.speed = m_speed.Y - old_speed.Y;
collision_info->push_back(info);
}
}
}
}
@ -617,6 +639,11 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d)
setPosition(position);
}
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d)
{
move(dtime, map, pos_max_d, NULL);
}
void LocalPlayer::applyControl(float dtime)
{
// Clear stuff