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


C++ Monster::changeHealth方法代码示例

本文整理汇总了C++中Monster::changeHealth方法的典型用法代码示例。如果您正苦于以下问题:C++ Monster::changeHealth方法的具体用法?C++ Monster::changeHealth怎么用?C++ Monster::changeHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Monster的用法示例。


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

示例1: pushCreatures

void Monster::pushCreatures(Tile* tile)
{
	//We can not use iterators here since we can push a creature to another tile
	//which will invalidate the iterator.
	if(CreatureVector* creatures = tile->getCreatures())
	{
		uint32_t removeCount = 0;
		for(uint32_t i = 0; i < creatures->size();)
		{
			Monster* monster = creatures->at(i)->getMonster();
			if(monster && monster->isPushable())
			{
				if(pushCreature(monster))
					continue;
				else
				{
					monster->changeHealth(-monster->getHealth());
					monster->setDropLoot(false);
					removeCount++;
				}
			}
			++i;
		}

		if(removeCount > 0)
			g_game.addMagicEffect(tile->getPosition(), NM_ME_BLOCKHIT);
	}
}
开发者ID:armadaazteca,项目名称:tfs0.2.15,代码行数:28,代码来源:monster.cpp

示例2: pushCreatures

void Monster::pushCreatures(Tile* tile)
{
	CreatureVector* creatures = tile->getCreatures();
	if(!creatures)
		return;

	bool effect = false;
	Monster* monster = NULL;
	for(uint32_t i = 0; i < creatures->size();)
	{
		if((monster = creatures->at(i)->getMonster()) && monster->isPushable())
		{
			if(pushCreature(monster))
				continue;

			monster->setDropLoot(LOOT_DROP_NONE);
			monster->changeHealth(-monster->getHealth());
			if(!effect)
				effect = true;
		}

		++i;
	}

	if(effect)
		g_game.addMagicEffect(tile->getPosition(), MAGIC_EFFECT_BLOCKHIT);
}
开发者ID:alexisjojo,项目名称:darkkonia,代码行数:27,代码来源:monster.cpp

示例3: spawnMonster

bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, bool startup /*= false*/)
{
	std::unique_ptr<Monster> monster_ptr(new Monster(mType));

	//add por jose eduardo
	Monster* monsterPk = monster_ptr.get();
	int genderRang = monsterPk->getGenderRange();
	if (genderRang == 0){ // random
		int gendeR = uniform_random(1, 2);
		if (gendeR == 1){
			monsterPk->setSkull(SKULL_FEMALE);
		}
		else{
			monsterPk->setSkull(SKULL_MALE);
		}
	}
	else if (genderRang == 1){ // male
		monsterPk->setSkull(SKULL_MALE);
	}
	else if (genderRang == 2){ // female
		monsterPk->setSkull(SKULL_FEMALE);
	}
	else if (genderRang == 3){ // undefined
		monsterPk->setSkull(SKULL_UNDEFINED);
	}

	int levelPoke = uniform_random(monsterPk->getMaxLevel(), monsterPk->getMinLevel());
	monsterPk->name = monsterPk->name + " [" + std::to_string(levelPoke) + "]";

	int Health = (levelPoke / 2)*monsterPk->getMaxHealth();
	monsterPk->changeHealth(Health, false);
	
	int shinyR = uniform_random(1, 100);
	if (shinyR == 75){
		monsterPk->switchShiny(true);
	}else{
		monsterPk->switchShiny(false);
	}
	//add Jose Eduardo

	if (startup) {
		//No need to send out events to the surrounding since there is no one out there to listen!
		if (!g_game.internalPlaceCreature(monster_ptr.get(), pos, true)) {
			return false;
		}
	} else {
		if (!g_game.placeCreature(monster_ptr.get(), pos, false, true)) {
			return false;
		}
	}

	Monster* monster = monster_ptr.release();
	monster->setDirection(dir);
	monster->setSpawn(this);
	monster->setMasterPos(pos, radius);
	monster->useThing2();

	spawnedMap.insert(spawned_pair(spawnId, monster));
	spawnMap[spawnId].lastSpawn = OTSYS_TIME();

	return true;
}
开发者ID:JoseEduardo,项目名称:o_487qpaos89PsIQ,代码行数:62,代码来源:spawn.cpp


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