Example #1
0
plane::plane(const colordata& colors,
			 const FLOAT3& pos,
			 const FLOAT3& normal) {
	m_colors = new colordata(colors);
	m_pos = new FLOAT3(pos);
	m_norm = new FLOAT3(normal.normalize());
	m_d = new float(normal.dot(pos));
}
Example #2
0
	//----------------------------------------------------------------------------------------------------
	MATRIX MatrixRotationAxis(const FLOAT3& axis, const FLOAT radians)
	{
		FLOAT3 axisN = axis.GetNormalization();

		FLOAT sinAngle = sinf(radians);
		FLOAT cosAngle = cosf(radians);
		FLOAT rmCosAngle = 1 - cosAngle;

		MATRIX result;
		result(0, 0) = (FLOAT)((axisN.x * axisN.x) * rmCosAngle + cosAngle);
		result(0, 1) = (FLOAT)((axisN.x * axisN.y) * rmCosAngle + (axisN.z * sinAngle));
		result(0, 2) = (FLOAT)((axisN.x * axisN.z) * rmCosAngle - (axisN.y * sinAngle));

		result(1, 0) = (FLOAT)((axisN.y * axisN.x) * rmCosAngle - (axisN.z * sinAngle));
		result(1, 1) = (FLOAT)((axisN.y * axisN.y) * rmCosAngle + cosAngle);
		result(1, 2) = (FLOAT)((axisN.y * axisN.z) * rmCosAngle + (axisN.x * sinAngle));

		result(2, 0) = (FLOAT)((axisN.z * axisN.x) * rmCosAngle + (axisN.y * sinAngle));
		result(2, 1) = (FLOAT)((axisN.z * axisN.y) * rmCosAngle - (axisN.x * sinAngle));
		result(2, 2) = (FLOAT)((axisN.z * axisN.z) * rmCosAngle + cosAngle);

		result(0, 3) = result(1, 3) = result(2, 3) = 0.0f;
		result(3, 0) = result(3, 1) = result(3, 2) = 0.0f;
		result(3, 3) = 1.0f;

		return result;
	}
CloudOfDarknessClientSkillEffect::CloudOfDarknessClientSkillEffect(unsigned int _masterId, FLOAT3 _position)
{
    m_position = _position;
    //m_graphicalEffects[0] = g_graphicsEngine->createModel("CloudOfDarkness", FLOAT3(_position.x, 0.1f, _position.z), "color2");
    //m_graphicalEffects[1] = g_graphicsEngine->createModel("CloudOfDarkness", FLOAT3(_position.x, 0.2f, _position.z), "color1");
    //m_graphicalEffects[2] = g_graphicsEngine->createModel("CloudOfDarkness", FLOAT3(_position.x, 0.3f, _position.z), "color");
    //m_graphicalEffects[0]->setScale(0.5f, 0.5f, 0.5f);
    //m_graphicalEffects[2]->setScale(0.5f, 0.5f, 0.5f);
    //m_graphicalEffects[1]->setScale(0.5f, 0.5f, 0.5f);
    //m_graphicalEffects[0]->setAlpha(0.999f);
    //m_graphicalEffects[1]->setAlpha(0.999f);
    //m_graphicalEffects[2]->setAlpha(0.999f);
    //m_graphicalEffects[0]->neutralize();
    //m_graphicalEffects[1]->neutralize();
    //m_graphicalEffects[2]->neutralize();
    m_lifetime = 0.0f;

    m_cloud = g_graphicsEngine->createParticleEngine("CloudOfDarkness", D3DXVECTOR4(_position.toD3DXVector(), 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(1, 1));

    int sound = createSoundHandle("skills/codWindStartEnd.wav", false, true, _position);
    playSound(sound);
    deactivateSound(sound);
    m_masterId = _masterId;

    Entity *e = ClientEntityHandler::getEntity(_masterId);
    if(e != NULL)
    {
        e->m_model->getAnimation()->Play("Spell");
        m_weapon = e->m_model->getRightHand();
        e->m_model->SetRightHand(NULL);
    }
}
Example #4
0
spotlight::spotlight(const RGBA& color, const FLOAT3& position, const FLOAT3& direction, const float& angle, const float& softAngle) {
	m_color = new RGBA(color);
	m_position = new FLOAT3(position);
	m_direction = new FLOAT3(direction.normalize());
	m_angle = new float(angle);
	m_softAngle = new float(softAngle);
}
FrostTurretProjectile::FrostTurretProjectile(unsigned int _master, unsigned int _target, float _slowEffect, int _damage)
{
	m_master = _master;
	m_target = _target;
	m_visible = false;
	this->m_type = OtherType;
	this->m_slowEffect = _slowEffect;
	ServerEntity* master = EntityHandler::getServerEntity(m_master);
	ServerEntity* target = EntityHandler::getServerEntity(m_target);
	m_timeToImpact = (target->getPosition() - master->getPosition()).length()/FrostTurretProjectile::VELOCITY;
	this->m_masterOwner = ((Turret*)master)->getOwnerId();

	// Calc position of projectile with offset from the pipe of the turret and send network msg
	FLOAT3 distance = target->getPosition() - master->getPosition();
	distance = distance/distance.length();
	this->m_messageQueue->pushOutgoingMessage(new CreateActionTargetMessage(Skill::FROST_TURRET_PROJECTILE, m_master, m_target, master->getPosition()+distance*0.5f));
	this->m_damage = _damage;
}
Example #6
0
	//----------------------------------------------------------------------------------------------------
	Quaternion QuaternionRotationAxis(const FLOAT3& _axis, const FLOAT _radians)
	{
		Quaternion result;
		FLOAT3 axis = _axis.GetNormalization();
		FLOAT ccc = cos(0.5f * _radians);
		FLOAT sss = sin(0.5f * _radians);

		result.t = ccc;
		result.x = sss * axis.x;
		result.y = sss * axis.y;
		result.z = sss * axis.z;

		return result;
	}
void ArrowClientSkillEffect::update(float _dt)
{
	Entity* target = ClientEntityHandler::getEntity(m_targetId);
	if(target && target->m_health > 0)
	{
		D3DXVECTOR3 newPos = D3DXVECTOR3(m_graphicalEffect->getPosition().x, m_graphicalEffect->getPosition().y, m_graphicalEffect->getPosition().z);
		this->m_particleSystem->setPosition(newPos);

		FLOAT3 dist = target->m_model->getPosition()-m_graphicalEffect->getPosition();
		FLOAT3 movement = dist/dist.length()*RangedAttack::VELOCITY*_dt;

		if(dist.length() > movement.length())
		{
			m_graphicalEffect->move(movement);
			m_graphicalEffect->setRotation(FLOAT3(atan2(-movement.x, -movement.z), 0.0f, 0.0f));
		}
		else
		{
			m_active = false;
			if(target->m_type == UnitEntity::EnemyType)
			{
				int sound;

				switch(random(0, 2))
				{
				case 0:
					sound = createSoundHandle("enemy/Monster_Imp_Damage_0.wav", false, false);
					break;
				case 1:
					sound = createSoundHandle("enemy/Monster_Imp_Damage_1.wav", false, false);
					break;
				case 2:
					sound = createSoundHandle("enemy/Monster_Imp_Damage_2.wav", false, false);
					break;
				}
					
				SpeechManager::speak(m_targetId, sound); // The unit must be killed on the client before on the server for this sound solution to actually work.
				deactivateSound(sound);
			}
			else if(target->m_type == UnitEntity::HeroType)
			{
				int sound;

				switch(target->m_subtype)
				{
				case Hero::RED_KNIGHT:
					switch(random(0, 2))
					{
					case 0:
						sound = createSoundHandle("red_knight/RedKnight_Damage_0.wav", false, false);
						break;
					case 1:
						sound = createSoundHandle("red_knight/RedKnight_Damage_1.wav", false, false);
						break;
					case 2:
						sound = createSoundHandle("red_knight/RedKnight_Damage_2.wav", false, false);
						break;
					}
					break;
				case Hero::ENGINEER:
					switch(random(0, 2))
					{
					case 0:
						sound = createSoundHandle("engineer/Engineer_Damage_0.wav", false, false);
						break;
					case 1:
						sound = createSoundHandle("engineer/Engineer_Damage_1.wav", false, false);
						break;
					case 2:
						sound = createSoundHandle("engineer/Engineer_Damage_2.wav", false, false);
						break;
					}
					break;
				case Hero::THE_MENTALIST:
					switch(random(0, 2))
					{
					case 0:
						sound = createSoundHandle("mentalist/Mentalist_Damage_0.wav", false, false);
						break;
					case 1:
						sound = createSoundHandle("mentalist/Mentalist_Damage_1.wav", false, false);
						break;
					case 2:
						sound = createSoundHandle("mentalist/Mentalist_Damage_2.wav", false, false);
						break;
					}
					break;
				case Hero::OFFICER:
					switch(random(0, 2))
					{
					case 0:
						sound = createSoundHandle("officer/Officer_Damage_0.wav", false, false);
						break;
					case 1:
						sound = createSoundHandle("officer/Officer_Damage_1.wav", false, false);
						break;
					case 2:
						sound = createSoundHandle("officer/Officer_Damage_2.wav", false, false);
						break;
					}
					break;
				case Hero::DOCTOR:
					switch(random(0, 2))
					{
					case 0:
						sound = createSoundHandle("doctor/Doctor_Damage_0.wav", false, false);
						break;
					case 1:
						sound = createSoundHandle("doctor/Doctor_Damage_1.wav", false, false);
						break;
					case 2:
						sound = createSoundHandle("doctor/Doctor_Damage_2.wav", false, false);
						break;
					}
					break;
				}

				SpeechManager::speak(m_targetId, sound); // The unit must be killed on the client before on the server for this sound solution to actually work.
				deactivateSound(sound);
			}
		}
	}
	else
	{
		m_active = false;
	}
}
Example #8
0
void Hero::updateSpecificUnitEntity(float dt)
{
	if(this->m_health > 0)
	{
		//Handle incoming messages
		Message *m;

		while(this->m_messageQueue->incomingQueueEmpty() == false)
		{
			m = this->m_messageQueue->pullIncomingMessage();

			if(m->type == Message::Collision)
			{
				//this->m_position = FLOAT3(0.0f, 0.0f, 0.0f);
			}

			delete m;
		}

		if(this->m_attackCooldown > 0.0f)
		{
			this->m_attackCooldown = this->m_attackCooldown - dt;
		}
		if(this->m_hasTarget == true)
		{
			ServerEntity *se = EntityHandler::getServerEntity(this->m_target);

			if(se == NULL)
			{
				this->m_hasTarget = false;
				this->m_messageQueue->pushOutgoingMessage(new CreateActionMessage(Skill::IDLE, this->m_id, this->m_position));
			}
			else
			{
				FLOAT3 distance = se->getPosition() - this->m_position;
				this->m_rotation.x = atan2(-distance.x, -distance.z);

				//If the hero is in range, KILL IT!
				if(se != NULL)
				{
					if((se->getPosition() - this->m_position).length() <= this->m_regularAttack->getRange())
					{
						if(this->m_attackCooldown <= 0.0f)
						{
							//this->m_messageQueue->pushOutgoingMessage(new CreateActionTargetMessage(Skill::ATTACK, this->m_id, se->getId(), this->m_position));
							//EntityHandler::addEntity(new Arrow((m_position-se->getPosition()).length(), se->getId(), m_id));
							//this->dealDamage(se, this->m_physicalDamage, this->m_mentalDamage); // dont
							this->attack(this->m_target);
							this->m_attackCooldown = this->m_attackSpeed;
							this->m_nextPosition = this->m_position;
							this->m_messageQueue->pushOutgoingMessage(this->getUpdateEntityMessage());
						}

						if(this->m_reachedPosition == false)
						{
							this->m_reachedPosition = true;
							this->m_messageQueue->pushOutgoingMessage(new CreateActionMessage(Skill::IDLE, this->m_id, this->m_position));
						}
					}
					else //Otherwise you should find a way to get to the enemy
					{
						if(this->m_reachedPosition == true)
						{
							this->m_path = g_pathfinder->getPath(FLOAT2(this->m_position.x, this->m_position.z), FLOAT2(se->getPosition().x, se->getPosition().z));

							if(this->m_path.nrOfPoints > 0)
							{
								this->m_pathCounter = 1;
								this->m_nextPosition = FLOAT3(this->m_path.points[0].x, 0.0f, this->m_path.points[0].y);
								this->m_reachedPosition = false;
								this->m_messageQueue->pushOutgoingMessage(new CreateActionMessage(Skill::MOVE, this->m_id, this->m_position));
								this->m_messageQueue->pushOutgoingMessage(this->getUpdateEntityMessage());
							}
						}
						else //Move along the path
						{
							distance = this->m_nextPosition - this->m_position;

							if(distance.length() - 0.125f > this->m_movementSpeed * dt)
							{
								distance = distance / distance.length();
								this->m_position = this->m_position + (distance * this->m_movementSpeed * dt);
								this->m_rotation.x = atan2(-distance.x, -distance.z);
							}
							else
							{
								if(this->m_pathCounter < this->m_path.nrOfPoints)
								{
									this->m_nextPosition = FLOAT3(this->m_path.points[this->m_pathCounter].x, 0.0f, this->m_path.points[this->m_pathCounter].y);
									this->m_pathCounter++;
									this->m_messageQueue->pushOutgoingMessage(this->getUpdateEntityMessage());
								}
								else if(this->m_reachedPosition == false)
								{
									this->m_position = this->m_nextPosition;
									this->m_reachedPosition = true;
									this->m_messageQueue->pushOutgoingMessage(new CreateActionMessage(Skill::IDLE, this->m_id, this->m_position));
									this->m_messageQueue->pushOutgoingMessage(this->getUpdateEntityMessage());
									this->m_messageQueue->pushOutgoingMessage(new UpdateEntityMessage(this->getId(),this->getPosition().x,this->getPosition().z,this->getRotation().x,0.0f,0.0f,0.0f,0.0f,this->getMovementSpeed()));
								}

								this->m_obb->Center = XMFLOAT3(this->m_position.x, this->m_position.y, this->m_position.z);
							}
						}
					}
				}
				else //The target doesn't exist
				{
					this->m_hasTarget = false;
					this->m_reachedPosition = true;
					this->m_messageQueue->pushOutgoingMessage(new CreateActionMessage(Skill::IDLE, this->m_id, this->m_position));
				}
			}
		}
		else if(this->m_reachedPosition == false)
		{
			FLOAT3 distance = this->m_nextPosition - this->m_position;
			float lol = 0.0f;

			if(this->m_reallyReachedPosition == false)
			{
				lol = 0.125f;
			}

			if(distance.length() - lol > this->m_movementSpeed * dt)
			{
				distance = distance / distance.length();
				this->m_position = this->m_position + (distance * this->m_movementSpeed * dt);
			}
			else
			{
				if(this->m_pathCounter < this->m_path.nrOfPoints)
				{
					this->m_nextPosition = FLOAT3(this->m_path.points[this->m_pathCounter].x, 0.0f, this->m_path.points[this->m_pathCounter].y);
					this->m_pathCounter++;

					this->m_obb->Center = XMFLOAT3(this->m_position.x, this->m_position.y, this->m_position.z);
					this->m_rotation.x = atan2(-distance.x, -distance.z);

					this->m_messageQueue->pushOutgoingMessage(this->getUpdateEntityMessage());
				}
				else
				{
					this->m_nextPosition = this->m_position;
					this->m_reachedPosition = true;
					//this->m_startPos= m_nextPosition;
					this->m_messageQueue->pushOutgoingMessage(this->getUpdateEntityMessage());
					this->m_messageQueue->pushOutgoingMessage(new CreateActionMessage(Skill::IDLE, this->m_id, this->m_position));
				}
			}

			this->m_obb->Center = XMFLOAT3(this->m_position.x, this->m_position.y, this->m_position.z);
			this->m_rotation.x = atan2(-distance.x, -distance.z);
		}
	}
	else if(this->m_alive == true)
	{
		this->m_messageQueue->pushOutgoingMessage(new CreateActionMessage(Skill::DEATH, this->m_id, this->m_position));
		this->m_position = FLOAT3(-1000.0f, 0.0f, -1000.0f);
		this->m_hasTarget = NULL;
		this->m_reachedPosition = true;
		this->m_messageQueue->pushOutgoingMessage(this->getUpdateEntityMessage());
		this->m_messageQueue->pushOutgoingMessage(new HeroDiedMessage(this->m_id, this->m_playerId));
		this->m_alive = false;
	}
}