本文整理汇总了C++中PlayerSAO::setHP方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerSAO::setHP方法的具体用法?C++ PlayerSAO::setHP怎么用?C++ PlayerSAO::setHP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerSAO
的用法示例。
在下文中一共展示了PlayerSAO::setHP方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessData
//.........这里部分代码省略.........
}
else
{
if(checkPriv(player->getName(), "shout")){
line += "<";
line += name;
line += "> ";
line += message;
send_to_others = true;
} else
line += "-!- You don't have permission to shout.";
}
if(!line.empty())
{
if(send_to_others) {
stat.add("chat", player->getName());
actionstream<<"CHAT: "<<line<<std::endl;
SendChatMessage(PEER_ID_INEXISTENT, line);
} else
SendChatMessage(peer_id, line);
}
}
else if(command == TOSERVER_DAMAGE)
{
u8 damage = packet[TOSERVER_DAMAGE_VALUE].as<u8>();
if(g_settings->getBool("enable_damage"))
{
actionstream<<player->getName()<<" damaged by "
<<(int)damage<<" hp at "<<PP(player->getPosition()/BS)
<<std::endl;
playersao->setHP(playersao->getHP() - damage);
SendPlayerHPOrDie(playersao->getPeerID(), playersao->getHP() == 0);
stat.add("damage", player->getName(), damage);
}
}
else if(command == TOSERVER_BREATH)
{
/*
* If player is dead, we don't need to update the breath
* He is dead !
*/
if (!player->isDead()) {
playersao->setBreath(packet[TOSERVER_BREATH_VALUE].as<u16>());
SendPlayerBreath(peer_id);
}
}
else if(command == TOSERVER_CHANGE_PASSWORD)
{
std::string oldpwd, newpwd;
packet[TOSERVER_CHANGE_PASSWORD_OLD].convert(&oldpwd);
packet[TOSERVER_CHANGE_PASSWORD_NEW].convert(&newpwd);
if(!base64_is_valid(newpwd)){
infostream<<"Server: "<<player->getName()<<" supplied invalid password hash"<<std::endl;
// Wrong old password supplied!!
SendChatMessage(peer_id, "Invalid new password hash supplied. Password NOT changed.");
return;
}
infostream<<"Server: Client requests a password change from "