• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setHP函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: CCRANDOM_MINUS1_1

void SkillNormalBombStep::update(float dt)
{
	if (!_start || !_stepData || _targetRoles.size()==0) return;

	if (_step == 0)
	{
		for(int i=0; i<_targetRoles.size(); i++)
		{
			auto role = _targetRoles.at(i);
			auto player = AnimiPlayer::create(_frames, _stepData->frameDt);
			player->setTag(1000+i);
			player->start(1);
			player->setUserObject(role);
			player->setStopEvent([&](AnimiPlayer* player)
			{
				auto effect = DamageEffect::create(_stepData->_hurtHP);
				effect->setPosition(Point(CCRANDOM_MINUS1_1()*10, CCRANDOM_MINUS1_1()*10+60));

				auto role = static_cast<BattleRole*>(player->getUserObject());
				role->getNode()->addChild(effect, 10);

				int hp = role->getHP() + _stepData->_hurtHP;
				role->setHP(hp);

				player->removeFromParent();
			});
			player->setPosition(GRID_CONVER_TO_PIXEL(role->getGridIndex().x, role->getGridIndex().y));
			BattleController::getInstance()->addChild(player, ZORDER_BATTLE_EFFECT);
		}
		_step ++;
	}
	else if (_step == 1)
	{
		bool over = true;
		for(int i=0; i<_targetRoles.size(); i++)
		{
			auto node = BattleController::getInstance()->getChildByTag(1000+i);
			if (node)
			{
				over = false;
			}
		}
		if (over)
		{
			setOver(over);
			_step++;
		}
	}
}
开发者ID:qing7ling0,项目名称:LQProjects,代码行数:49,代码来源:SkillStep.cpp


示例17: initTransform

GameObject::GameObject(std::string _name, osg::Vec3f _pos, float _colRad, int _hp, std::string _model, osg::ref_ptr<osg::MatrixTransform> _scene, int _id)
{
    initTransform();
    setVel(0.0);
    setDir(osg::Vec3f(0.0f, 0.0f, 1.0f));
    setOrientation(osg::Quat(0.0f, 0.0f, 0.0f, 1.0f));
    rigidBodyRadius = _colRad;
    translate(_pos);
    setName(_name);
    setHP(_hp);
    setDescr((std::string)("hej"));
    _scene->addChild(getTrans());
    setID(_id);
    setModel(_model);
}
开发者ID:flair2005,项目名称:GameOfDomes_domeClient,代码行数:15,代码来源:GameObject.cpp


示例18: m_size

Asteroid::Asteroid(Size size, float angle):
	m_size(size),
	m_rotation_speed(math::rand(ROTATION_SPEED_MIN, ROTATION_SPEED_MAX))
{
	setHP(size * 2 + 1);
	setTexture(Resources::getTexture("entities/asteroids.png"));
	setRandomImage();

	// Compute speed vector from angle and velocity
	angle = math::to_radians(angle);
	m_speed.x = std::cos(angle) * BASE_SPEED;
	m_speed.y = -std::sin(angle) * BASE_SPEED;

	// Origin must be located at sprite center to enable centered rotation
	setOrigin(getWidth() / 2, getHeight() / 2);
}
开发者ID:HoekWax,项目名称:cosmoscroll,代码行数:16,代码来源:Asteroid.cpp


示例19: 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_back(aom);
			return 0;
		}
	}

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

	std::string punchername = "nil";

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

	actionstream<<"Player "<<m_player->getName()<<" punched by "
			<<punchername<<", damage "<<hitparams.hp
			<<" HP"<<std::endl;

	setHP(getHP() - hitparams.hp);

	if(hitparams.hp != 0)
	{
		std::string str = gob_cmd_punched(hitparams.hp, getHP());
		// create message and add to list
		ActiveObjectMessage aom(getId(), true, str);
		m_messages_out.push_back(aom);
	}

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


示例20: m_target

FlyingSaucerBoss::FlyingSaucerBoss():
	m_target(NULL),
	m_timer(0),
	m_angle(0)
{
	setHP(400);
	setTexture(Resources::getTexture("entities/flying-saucer-boss.png"));
	setY(CIRCLE_CENTER_Y);

	m_left_tube.init("laser-pink");
	m_left_tube.setOwner(this);
	m_left_tube.setPosition(34, 122);
	m_right_tube.init("laser-pink");
	m_right_tube.setOwner(this);
	m_right_tube.setPosition(157, 122);
	setTeam(Entity::BAD);
}
开发者ID:HoekWax,项目名称:cosmoscroll,代码行数:17,代码来源:FlyingSaucerBoss.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setHandle函数代码示例发布时间:2022-05-30
下一篇:
C++ setGraphicsEffect函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap