当前位置: 首页>>代码示例>>C++>>正文


C++ setHP函数代码示例

本文整理汇总了C++中setHP函数的典型用法代码示例。如果您正苦于以下问题:C++ setHP函数的具体用法?C++ setHP怎么用?C++ setHP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setHP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setHP

void Player::calculateHP(int dmg){
	if(php<=dmg)
	{	
		setHP(0);
		pAlive = false;	
	}else
	{	
		setHP(php - dmg);
		pAlive = true; 
	}
}
开发者ID:iiwudaffk,项目名称:VirtualPowerCardGame,代码行数:11,代码来源:powercard.cpp

示例2: initTransform

Player::Player(std::string _name, osg::Vec3f _pos, float _colRad, int _hp, osg::ref_ptr<osg::MatrixTransform> _scene, int _bridgeModel)
{
	initTransform();
	rigidBodyRadius = _colRad;
	pos = _pos;
	setName(_name);
	setHP(_hp);
	setMaxHP(_hp);

	_scene->addChild(playerTransform);
	playerTransform->postMult(osg::Matrix::translate(pos));


	healthbarTransform->postMult(osg::Matrix::rotate(-PI / 8, 1.0f, 0.0f, 0.0f));

	bridgeTransform->postMult(osg::Matrix::rotate(PI + PI / 4.0, 1.0, 0.0, 0.0));
	//bridgeTransform->postMult(osg::Matrix::scale(0.1f, 0.1f, 0.1f));

	if (_bridgeModel == 1) {
		bridge = GameObject((std::string)("Kommandobryggan"), osg::Vec3f(0, 0, 0), 0, 100000, (std::string)("models/kurvbrygga_lasselagom.ive"), bridgeTransform, 100000);
		bridgeTransform->postMult(osg::Matrix::translate(0.0f, 3.5f, 0.0f));
	}
	if (_bridgeModel == 2) {
		bridge = GameObject((std::string)("Kommandobryggan"), osg::Vec3f(0, 0, 0), 0, 100000, (std::string)("models/kurvbrygga_lasselagom.ive"), bridgeTransform, 100000);
		bridgeTransform->postMult(osg::Matrix::translate(0.0f, 2.5f, 0.0f));
	}
	if (_bridgeModel == 3) {
		bridge = GameObject((std::string)("Kommandobryggan"), osg::Vec3f(0, 0, 0), 0, 100000, (std::string)("models/kurvbrygga_lassesmal.ive"), bridgeTransform, 100000);
		bridgeTransform->postMult(osg::Matrix::translate(0.0f, 3.5f, 0.0f));
	}
	if (_bridgeModel == 4) {
		bridge = GameObject((std::string)("Kommandobryggan"), osg::Vec3f(0, 0, 0), 0, 100000, (std::string)("models/kurvbrygga_lassesmal.ive"), bridgeTransform, 100000);
		bridgeTransform->postMult(osg::Matrix::translate(0.0f, 2.5f, 0.0f));
	}
}
开发者ID:flair2005,项目名称:GameOfDomes_domeClient,代码行数:35,代码来源:Player.cpp

示例3: getArmor

void GameObj::damage(int amount, SoundManager &sm) {
	// Process incoming damage
	if(getArmor() > amount)
		return;				// armor negates all damage
	else amount -= getArmor();
	setHP(getHP() - amount);

	// SFX
	t_damaged.Calculate_Ellapsed_Time();
	if(t_damaged.TotalTime() >= TIMER_SOUND_DAMAGED) {
		SoundManager::Sounds soundID;
		switch(goSettings.getTypeID()) {
			case Settings::OBJ_ID_ARCHER: soundID = sm.SND_ARCHER_DAMAGED; break;
			case Settings::OBJ_ID_STONEWALL: soundID = sm.SND_STONEWALL_DAMAGED; break;
	//			case settings.OBJ_T_DOG: soundID = sm.SND_DOG_MELEE; break;
	//			case settings.OBJ_T_SPEARMAN: soundID = sm.SND_SPEARMAN_MELEE; break;
	//			case settings.OBJ_ID_ARCHER: soundID = sm.SND_ARCHER_MELEE; break;
			default: soundID = sm.SND_ARCHER_DAMAGED; break;
		}
		sm.playSound(soundSourceID, soundID, body->GetPosition());
		t_damaged.Reset(0.0);
	}

	// Special Behavior (defined in derived classes)
	damageSpecial(amount, sm);

	// Death sequence
	if(getHP() < 0) {
		death(sm);
	}
}
开发者ID:lansdon,项目名称:Fortress2D,代码行数:31,代码来源:GameObj.cpp

示例4: setShield

void Player::onInit()
{
	const ItemManager& items = ItemManager::getInstance();

	// Reset score
	m_score = 0;
	m_panel.setScore(0);

	// Equip Shield item
	items.getItem(Item::SHIELD, UserSettings::getItemLevel(Item::SHIELD)).equip(*this);
	setShield(m_shield); // Keep previous shield value

	// Equip Hull item and repair spaceship
	items.getItem(Item::HULL, UserSettings::getItemLevel(Item::HULL)).equip(*this);
	setHP(m_max_hp);
	m_panel.setHP(m_max_hp);

	// Equip Engine item
	items.getItem(Item::ENGINE, UserSettings::getItemLevel(Item::ENGINE)).equip(*this);

	// Equip Heatsink item and for cooldown
	items.getItem(Item::HEATSINK, UserSettings::getItemLevel(Item::HEATSINK)).equip(*this);
	m_heat = 0;
	m_panel.setHeat(m_heat);
	m_overheat = false;
	m_panel.setOverheat(false);

	// Equip Weapon item
	items.getItem(Item::WEAPON, UserSettings::getItemLevel(Item::WEAPON)).equip(*this);
}
开发者ID:HoekWax,项目名称:cosmoscroll,代码行数:30,代码来源:Player.cpp

示例5: gob_cmd_punched

int PlayerSAO::punch(v3f dir,
	const ToolCapabilities *toolcap,
	ServerActiveObject *puncher,
	float time_from_last_punch)
{
	// It's best that attachments cannot be punched
	if (isAttached())
		return 0;

	if (!toolcap)
		return 0;

	// No effect if PvP disabled
	if (g_settings->getBool("enable_pvp") == false) {
		if (puncher->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
			std::string str = gob_cmd_punched(0, getHP());
			// create message and add to list
			ActiveObjectMessage aom(getId(), true, str);
			m_messages_out.push(aom);
			return 0;
		}
	}

	HitParams hitparams = getHitParams(m_armor_groups, toolcap,
			time_from_last_punch);

	std::string punchername = "nil";

	if (puncher != 0)
		punchername = puncher->getDescription();

	PlayerSAO *playersao = m_player->getPlayerSAO();

	bool damage_handled = m_env->getScriptIface()->on_punchplayer(playersao,
				puncher, time_from_last_punch, toolcap, dir,
				hitparams.hp);

	if (!damage_handled) {
		setHP(getHP() - hitparams.hp);
	} else { // override client prediction
		if (puncher->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
			std::string str = gob_cmd_punched(0, getHP());
			// create message and add to list
			ActiveObjectMessage aom(getId(), true, str);
			m_messages_out.push(aom);
		}
	}


	actionstream << "Player " << m_player->getName() << " punched by "
			<< punchername;
	if (!damage_handled) {
		actionstream << ", damage " << hitparams.hp << " HP";
	} else {
		actionstream << ", damage handled by lua";
	}
	actionstream << std::endl;

	return hitparams.wear;
}
开发者ID:t0suj4,项目名称:minetest,代码行数:60,代码来源:content_sao.cpp

示例6: Item

//----------------------------------------------------------------------
// Spawn
Spawn::Spawn()
  : Item(tSpawn, 0)
{
  m_name = "fake";
  setNPC(SPAWN_NPC_UNKNOWN);

  Item::setPos(0, 0, 0);
  setDeltas(0, 0, 0);
  setHeading(0, 0);
  setAnimation(0);
  setPetOwnerID(0);
  setLight(0);
  setGender(0);
  setDeity(0);
  setRace(0);
  setClassVal(0);
  setHP(0);
  setMaxHP(0);
  setGuildID(0xffff);
  setGuildTag(NULL);
  setLevel(0);
  setTypeflag(0);
  for (int i = 0; i < tNumWearSlots; i++)
    setEquipment(i, 0);

  // just clear the considred flag since data would be outdated
  setConsidered(false);

  // finally, note when this update occurred.
  updateLast();
}
开发者ID:xbackupx,项目名称:showeqx,代码行数:33,代码来源:spawn.cpp

示例7: setMaxHP

void Player::applyKonamiCode()
{
	m_konami_code_activated = true;

	// Set max hp
	setMaxHP(10);
	setHP(m_max_hp);
	m_panel.setHP(m_max_hp);

	// Set max shield
	setMaxShield(10);
	setShield(m_max_shield);

	m_icecubes = 42;
	m_panel.setIcecubes(42);
	m_missiles = 42;
	m_panel.setMissiles(42);

	m_weapon.setMultiply(3);
	m_missile_launcher.setMultiply(3);

	MessageSystem::write("KONAMI CODE ON", getPosition());
	m_powerup_emitter.setPosition(getCenter());
	m_powerup_emitter.createParticles(50);
}
开发者ID:HoekWax,项目名称:cosmoscroll,代码行数:25,代码来源:Player.cpp

示例8: PP

void Server::handleCommand_Damage(NetworkPacket* pkt) {
	//const auto peer_id = pkt->getPeerId();
	auto & packet = *(pkt->packet);
	auto player = m_env->getPlayer(pkt->getPeerId());
	if (!player) {
		m_con.DisconnectPeer(pkt->getPeerId());
		return;
	}
	auto playersao = player->getPlayerSAO();
	if (!playersao) {
		m_con.DisconnectPeer(pkt->getPeerId());
		return;
	}
	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);

		stat.add("damage", player->getName(), damage);
	}
}
开发者ID:Mab879,项目名称:freeminer,代码行数:27,代码来源:fm_serverpackethandler.cpp

示例9: setState

bool Hero::init()
{
	if (!Entity::init())
	{
		return false;
	}
	setState(NORMAL);					//初始化状态
	setHP(100);
	setSP(100);
	TP = 0;										//初始化三大数据
	m_mode = SHIELD;					//初始化模式状态
	velocityY = 0;							//初始化水平和竖直方向的速度
	faceto = false;
	inTheAir_flag = true;
	initSprite();								//初始化动画
	initBlock();									//初始化碰撞框


	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/Cloak.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/Clock.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/e.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/ea.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/en.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/haaaaa.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/heng.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/kale.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/maxArmor.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/seiya.ogg");
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/souyuken.ogg");



	return true;
}
开发者ID:Jormungendr,项目名称:HotPunch,代码行数:34,代码来源:Hero.cpp

示例10: m_id

MultiPartEntity::Part::Part(int id, int hp):
    m_id(id),
    m_destructible(true),
    m_parent(NULL)
{
    setHP(hp);
}
开发者ID:abodelot,项目名称:cosmoscroll,代码行数:7,代码来源:MultiPartEntity.cpp

示例11: getPunchDamage

int LuaEntitySAO::punch(v3f dir,
		const ToolCapabilities *toolcap,
		ServerActiveObject *puncher,
		float time_from_last_punch)
{
	if(!m_registered){
		// Delete unknown LuaEntities when punched
		m_removed = true;
		return 0;
	}

	// It's best that attachments cannot be punched 
	if(isAttached())
		return 0;
	
	ItemStack *punchitem = NULL;
	ItemStack punchitem_static;
	if(puncher){
		punchitem_static = puncher->getWieldedItem();
		punchitem = &punchitem_static;
	}

	PunchDamageResult result = getPunchDamage(
			m_armor_groups,
			toolcap,
			punchitem,
			time_from_last_punch);
	
	if(result.did_punch)
	{
		setHP(getHP() - result.damage);
		

		std::string punchername = "nil";

		if ( puncher != 0 )
			punchername = puncher->getDescription();

		actionstream<<getDescription()<<" punched by "
				<<punchername<<", damage "<<result.damage
				<<" hp, health now "<<getHP()<<" hp"<<std::endl;
		
		{
			std::string str = gob_cmd_punched(result.damage, getHP());
			// create message and add to list
			ActiveObjectMessage aom(getId(), true, str);
			m_messages_out.push_back(aom);
		}

		if(getHP() == 0)
			m_removed = true;
	}

	ENV_TO_SA(m_env)->luaentity_Punch(m_id, puncher,
			time_from_last_punch, toolcap, dir);

	return result.wear;
}
开发者ID:Imberflur,项目名称:minetest,代码行数:58,代码来源:content_sao.cpp

示例12: getPunchDamage

int LuaEntitySAO::punch(v3f dir,
		const ToolCapabilities *toolcap,
		ServerActiveObject *puncher,
		float time_from_last_punch)
{
	if (!m_registered) {
		// Delete unknown LuaEntities when punched
		m_pending_removal = true;
		return 0;
	}

	ItemStack *punchitem = NULL;
	ItemStack punchitem_static;
	if (puncher) {
		punchitem_static = puncher->getWieldedItem();
		punchitem = &punchitem_static;
	}

	PunchDamageResult result = getPunchDamage(
			m_armor_groups,
			toolcap,
			punchitem,
			time_from_last_punch);

	bool damage_handled = m_env->getScriptIface()->luaentity_Punch(m_id, puncher,
			time_from_last_punch, toolcap, dir, result.did_punch ? result.damage : 0);

	if (!damage_handled) {
		if (result.did_punch) {
			setHP(getHP() - result.damage,
				PlayerHPChangeReason(PlayerHPChangeReason::SET_HP));

			if (result.damage > 0) {
				std::string punchername = puncher ? puncher->getDescription() : "nil";

				actionstream << getDescription() << " punched by "
						<< punchername << ", damage " << result.damage
						<< " hp, health now " << getHP() << " hp" << std::endl;
			}

			std::string str = gob_cmd_punched(result.damage, getHP());
			// create message and add to list
			ActiveObjectMessage aom(getId(), true, str);
			m_messages_out.push(aom);
		}
	}

	if (getHP() == 0 && !isGone()) {
		m_pending_removal = true;
		clearParentAttachment();
		clearChildAttachments();
		m_env->getScriptIface()->luaentity_on_death(m_id, puncher);
	}

	return result.wear;
}
开发者ID:Gael-de-Sailly,项目名称:minetest,代码行数:56,代码来源:content_sao.cpp

示例13: setMaxHP

//============HumanoidCombatComponent=======
HumanoidCombatComponent::HumanoidCombatComponent(int HP, int maxHP, float damage, float attackRange, float attackSpeed) {
	
	setMaxHP(maxHP);
	setHP(maxHP);

	setDamage(damage);
	setAttackRange(attackRange);
	setAttackSpeed(attackSpeed);
	setMarkedForRemoval(false);

}
开发者ID:CS-RPG,项目名称:BADASSLAND,代码行数:12,代码来源:HumanoidCombatComponent.cpp

示例14: throw

void EffectArmageddon::decreaseHP(Damage_t damage )
	throw()
{
	//cout << "EffectArmageddon Damaged : " << (int)damage << endl;

	HP_t RemainHP = max(0, m_HP - damage);

	setHP(RemainHP);
	// 남은 HP가 0일 경우 다음 EffectManager::heartbeat() 에서 이펙트를 날려준다.
	if(RemainHP == 0 )
		setDeadline(0);
}
开发者ID:hillwah,项目名称:darkeden,代码行数:12,代码来源:EffectArmageddon.cpp

示例15: setHP

void Pokemon::SetStatsForLevel()
{
	setHP(round(ceil(2 * getBaseHP() + 31) * getLevel() / 100 + getLevel() + 10));
   setAtt(round(ceil(2 * getBaseAtt() + 31) * getLevel() / 100 + 5));
   setDef(round(ceil(2 * getBaseDef() + 31) * getLevel() / 100 + 5));
   setSpeed(round(ceil(2 * getBaseSpeed() + 31) * getLevel() / 100 + 5));

	setCurrentHP(getHP());
	setCurrentAtt(getAtt());
	setCurrentDef(getDef());
	setCurrentSpeed(getSpeed());
}
开发者ID:PoneyLoverXz,项目名称:BattleTest,代码行数:12,代码来源:Pokemon.cpp


注:本文中的setHP函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。