HypnoticStareEffect::HypnoticStareEffect(unsigned int _affectedUnit, unsigned int _casterId, int _wits)
{
	m_affectedUnit = _affectedUnit;
	this->m_obb = NULL;
	this->m_bs = new BoundingSphere();
	m_visible = false;
	m_type = OtherType;

	m_timer = _wits*2;
	m_mentalDamage = _wits;
	m_movementSpeed = EnigmaticPresenceEffect::MOVEMENT_SPEED_FACTOR*_wits;
	
	ServerEntity* affectedUnit = EntityHandler::getServerEntity(m_affectedUnit);
	if(affectedUnit)
	{
		((UnitEntity*)affectedUnit)->alterMentalDamage(m_mentalDamage);
		((UnitEntity*)affectedUnit)->alterMovementSpeed(m_movementSpeed);
		((Enemy*)affectedUnit)->setTargetType(UnitEntity::EnemyType);
		this->m_messageQueue->pushOutgoingMessage(new CreateActionTargetMessage(
			Skill::HYPNOTIC_STARE, _casterId, affectedUnit->getId(), FLOAT3(m_timer, 0, 0))); // Set position.x to the duration so we use it as that instead mohahhaha >:D
	}
	else
		this->m_messageQueue->pushOutgoingMessage(new RemoveServerEntityMessage(0, EntityHandler::getId(), this->m_id));
}
void DemonicPresenceEffect::update(float _dt)
{
	ServerEntity* caster = EntityHandler::getServerEntity(m_caster);

	if(caster)
	{
		m_timer += _dt;

		// If the spell duration has expired, remove all affected dudes and buffs.
		if(m_timer >= LIFETIME)
		{
			for(int i = 0; i < m_affectedGuys.size(); i++)
			{
				ServerEntity* se = EntityHandler::getServerEntity(m_affectedGuys[i]);
				if(se && (caster->getPosition()-se->getPosition()).length() <= AOE)
				{
					((UnitEntity*)se)->alterMovementSpeed(-MOVEMENT_SPEED_BOOST);
					((UnitEntity*)se)->alterAttackSpeed(-ATTACK_SPEED_BOOST);
					this->m_messageQueue->pushOutgoingMessage(new RemoveActionTargetMessage(Skill::DEMONIC_PRESENCE, 0, se->getId()));
					m_affectedGuys.erase(m_affectedGuys.begin()+i);
					i--;
				}
			}
			this->m_messageQueue->pushOutgoingMessage(new RemoveServerEntityMessage(0, EntityHandler::getId(), this->m_id));
		}
		else
		{
			// Check if any of the affected guys have died or escaped the aura area.
			for(int i = 0; i < m_affectedGuys.size(); i++)
			{
				// Dont mind the caster, he is taken care of elsewhere i hope(?).
				if(m_affectedGuys[i] != m_caster)
				{
					ServerEntity* se = EntityHandler::getServerEntity(m_affectedGuys[i]);
					// Check if the affected guy has died recently then remove it.
					if(!se)
					{
						m_affectedGuys.erase(m_affectedGuys.begin()+i);
						i--;
						this->m_messageQueue->pushOutgoingMessage(new RemoveActionTargetMessage(Skill::DEMONIC_PRESENCE, 0, se->getId()));
					}
					// Else the affected guys is still alive and might have escaped the aura area and needs to be taken down!
					else if((caster->getPosition()-se->getPosition()).length() > AOE)
					{
						((UnitEntity*)se)->alterMovementSpeed(-MOVEMENT_SPEED_BOOST);
						((UnitEntity*)se)->alterAttackSpeed(-ATTACK_SPEED_BOOST);
						m_affectedGuys.erase(m_affectedGuys.begin()+i);
						i--;
						this->m_messageQueue->pushOutgoingMessage(new RemoveActionTargetMessage(Skill::DEMONIC_PRESENCE, 0, se->getId()));
					}
				}
			}

			// Check if any newcomers want to join in on the oral (aural) fun.
			vector<ServerEntity*> heroes = EntityHandler::getAllHeroes();
			for(int i = 0; i < heroes.size(); i++)
			{
				if(heroes[i]->getId() != m_caster)
				{
					bool alreadyAffected = false;
					for(int j = 0; j < m_affectedGuys.size(); j++)
					{
						if(heroes[i]->getId() == m_affectedGuys[j])
						{
							alreadyAffected = true;
							j = m_affectedGuys.size();
						}
					}

					if(!alreadyAffected)
					{
						if((caster->getPosition()-heroes[i]->getPosition()).length() <= AOE)
						{
							m_affectedGuys.push_back(heroes[i]->getId());
							((UnitEntity*)heroes.at(i))->alterMovementSpeed(MOVEMENT_SPEED_BOOST);
							((UnitEntity*)heroes.at(i))->alterAttackSpeed(ATTACK_SPEED_BOOST);
							this->m_messageQueue->pushOutgoingMessage(new CreateActionTargetMessage(Skill::DEMONIC_PRESENCE, 0, heroes[i]->getId(), heroes[i]->getPosition()));
						}
					}
				}
			}
		}
	}
}
Example #3
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;
}