本文整理汇总了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);
}
}
示例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);
}
示例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;
}