Exemple #1
0
bool Mission::handle(int atWave)
{
	ServerEntity *boss = EntityHandler::getServerEntity(this->bossId);

	if(atWave>=this->startWave&&atWave<=this->endWave&&!this->missionStarted&&!missionRunning)
	{
		this->missionStarted=true;
		this->missionRunning=true;
		this->m_messageQueue->pushOutgoingMessage(new MissionMessage(this->missionName,"start"));
		this->startMission();
	}
	if(boss != NULL && EntityHandler::getServerEntity(this->bossId)->getHealth()<=0)
	{
		this->missionComplete=true;
		if(boss != NULL)
		{
			boss->tellBossToDropGold();
			boss->getMessageQueue()->pushOutgoingMessage(new RemoveServerEntityMessage(0, EntityHandler::getId(), boss->getId()));
			this->m_messageQueue->pushOutgoingMessage(new MissionMessage(this->missionName,"completed"));

			this->m_messageQueue->pushOutgoingMessage(new CreateActionMessage(Skill::DEATH, this->m_id, this->m_position));				
		
		}
	}
	if(this->missionRunning)
	{
		//missionTime+=dt;
		if(atWave>=this->endWave)
		{
			this->missionRunning=false;
			//if the enemy died 
		
			this->missionTime=0.0f;
			ServerEntity *boss = EntityHandler::getServerEntity(this->bossId);
			if(boss != NULL)
			{
				boss->getMessageQueue()->pushOutgoingMessage(new RemoveServerEntityMessage(0, EntityHandler::getId(), boss->getId()));
				this->m_messageQueue->pushOutgoingMessage(new MissionMessage(this->missionName,"failed"));
			}
		}
	}
	return missionStarted;
}
bool SwiftAsACatPowerfulAsABoar::activate(unsigned int _senderId)
{
	if(this->getCurrentCooldown() == 0)
	{
		ServerEntity *e = EntityHandler::getServerEntity(_senderId);

		if(e)
		{
			UnitEntity* ue = (UnitEntity*)e;
			ue->setSwiftAsACatPowerfulAsABear(true);
			this->resetCooldown();;
			e->getMessageQueue()->pushOutgoingMessage(new CreateActionMessage(Skill::SWIFT_AS_A_CAT_POWERFUL_AS_A_BEAR, e->getId(), e->getPosition()));
			
			return true;
		}
		else
			return false;
	}
	else
		return false;
}