예제 #1
0
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
0
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
0
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;
}