m_env->getScriptIface()->luaentity_Rightclick(m_id, clicker);
}
-void LuaEntitySAO::setPos(v3f pos)
+void LuaEntitySAO::setPos(const v3f &pos)
{
if(isAttached())
return;
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
-void PlayerSAO::setYaw(const float yaw, bool send_data)
+void PlayerSAO::setYaw(const float yaw)
{
if (m_player && yaw != m_yaw)
m_player->setDirty(true);
UnitSAO::setYaw(yaw);
+}
- // Datas should not be sent at player initialization
- if (send_data)
- ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
+void PlayerSAO::setYawAndSend(const float yaw)
+{
+ setYaw(yaw);
+ ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
-void PlayerSAO::setPitch(const float pitch, bool send_data)
+void PlayerSAO::setPitch(const float pitch)
{
if (m_player && pitch != m_pitch)
m_player->setDirty(true);
m_pitch = pitch;
+}
- if (send_data)
- ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
+void PlayerSAO::setPitchAndSend(const float pitch)
+{
+ setPitch(pitch);
+ ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
int PlayerSAO::punch(v3f dir,
return damage;
}
-void PlayerSAO::setHP(s16 hp, bool direct)
+void PlayerSAO::setHP(s16 hp)
{
- if (direct) {
- m_hp = hp;
- return;
- }
-
s16 oldhp = m_hp;
s16 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp);
ServerActiveObject *puncher=NULL,
float time_from_last_punch=1000000);
void rightClick(ServerActiveObject *clicker);
- void setPos(v3f pos);
+ void setPos(const v3f &pos);
void moveTo(v3f pos, bool continuous);
float getMinimumSavedMovement();
std::string getDescription();
void setBasePosition(const v3f &position);
void setPos(const v3f &pos);
void moveTo(v3f pos, bool continuous);
- void setYaw(const float yaw, bool send_data = true);
- void setPitch(const float pitch, bool send_data = true);
+ void setYaw(const float yaw);
+ // Data should not be sent at player initialization
+ void setYawAndSend(const float yaw);
+ void setPitch(const float pitch);
+ // Data should not be sent at player initialization
+ void setPitchAndSend(const float pitch);
f32 getPitch() const { return m_pitch; }
f32 getRadPitch() const { return m_pitch * core::DEGTORAD; }
// Deprecated
ServerActiveObject *puncher,
float time_from_last_punch);
void rightClick(ServerActiveObject *clicker);
- void setHP(s16 hp, bool direct = false);
+ void setHP(s16 hp);
+ void setHPRaw(s16 hp) { m_hp = hp; }
s16 readDamage();
u16 getBreath() const { return m_breath; }
void setBreath(const u16 breath);
playersao->setBasePosition(position);
player->setSpeed(speed);
- playersao->setPitch(pitch, false);
- playersao->setYaw(yaw, false);
+ playersao->setPitch(pitch);
+ playersao->setYaw(yaw);
player->keyPressed = keyPressed;
player->control.up = (keyPressed & 1);
player->control.down = (keyPressed & 2);
if (sao) {
try {
- sao->setHP(args.getS32("hp"), true);
+ sao->setHPRaw(args.getS32("hp"));
} catch(SettingNotFoundException &e) {
- sao->setHP(PLAYER_MAX_HP, true);
+ sao->setHPRaw(PLAYER_MAX_HP);
}
try {
} catch (SettingNotFoundException &e) {}
try {
- sao->setPitch(args.getFloat("pitch"), false);
+ sao->setPitch(args.getFloat("pitch"));
} catch (SettingNotFoundException &e) {}
try {
- sao->setYaw(args.getFloat("yaw"), false);
+ sao->setYaw(args.getFloat("yaw"));
} catch (SettingNotFoundException &e) {}
try {
if (co == NULL) return 0;
float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
// Do it
- co->setPitch(pitch);
+ co->setPitchAndSend(pitch);
return 1;
}
if (co == NULL) return 0;
float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
// Do it
- co->setYaw(yaw);
+ co->setYawAndSend(yaw);
return 1;
}
if (co == NULL) return 0;
float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
// Do it
- co->setPitch(pitch);
+ co->setPitchAndSend(pitch);
return 1;
}
if (co == NULL) return 0;
float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
// Do it
- co->setYaw(yaw);
+ co->setYawAndSend(yaw);
return 1;
}
sao.initialize(&rplayer, std::set<std::string>());
rplayer.setPlayerSAO(&sao);
sao.setBreath(10);
- sao.setHP(8, true);
- sao.setYaw(0.1f, false);
- sao.setPitch(0.6f, false);
+ sao.setHPRaw(8);
+ sao.setYaw(0.1f);
+ sao.setPitch(0.6f);
sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f));
rplayer.save(".", gamedef);
UASSERT(fs::PathExists("testplayer_save"));
sao.initialize(&rplayer, std::set<std::string>());
rplayer.setPlayerSAO(&sao);
sao.setBreath(10);
- sao.setHP(8, true);
- sao.setYaw(0.1f, false);
- sao.setPitch(0.6f, false);
+ sao.setHPRaw(8);
+ sao.setYaw(0.1f);
+ sao.setPitch(0.6f);
sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f));
rplayer.save(".", gamedef);
UASSERT(fs::PathExists("testplayer_load"));