Example #1
0
void FenwarBoss::doCollision(float dt)
{
	collisionBox->Set(x - FENWAR_WIDTH / 2.0, 
					  y - floatingYOffset - FENWAR_HEIGHT / 2.0,
					  x + FENWAR_WIDTH / 2.0,
					  y - floatingYOffset + FENWAR_HEIGHT / 2.0);

	//Player collision
	if (smh->player->collisionCircle->testBox(collisionBox))
	{
		smh->player->dealDamageAndKnockback(FenwarAttributes::COLLISION_DAMAGE, true, false, FenwarAttributes::COLLISION_KNOCKBACK, x, y);
	}

	//Tongue collision
	if (smh->player->getTongue()->testCollision(collisionBox))
	{
		dealDamage(smh->player->getDamage(),true);
	}

	//Fire breath collision
	if (smh->player->fireBreathParticle->testCollision(collisionBox))
	{
		dealDamage(smh->player->getFireBreathDamage() * dt,false);
	}

	//Frisbee collision
	if (smh->projectileManager->reflectProjectilesInBox(collisionBox, PROJECTILE_FRISBEE))
	{
		smh->soundManager->playSound("snd_HitInvulnerable");
	}

	//Lightning orb collision
	if (smh->projectileManager->killProjectilesInBox(collisionBox, PROJECTILE_LIGHTNING_ORB))
	{
		if (state == FenwarStates::BATTLE || state==FenwarStates::STUNNED_AFTER_LOSING_ORBS || state == FenwarStates::RETURN_TO_ARENA || state == FenwarStates::DROPPING_SPIDERS)
		{
			dealDamage(smh->player->getLightningOrbDamage()/3,true);
			if (!tauntedAboutOrbs && orbManager->numOrbsAlive() <= 0) {
				smh->windowManager->openDialogueTextBox(-1, FENWAR_ORB_TAUNT_TEXT);
				tauntedAboutOrbs = true;
			}
		}
	}

	//Frisbee collision
	if (smh->projectileManager->killProjectilesInBox(collisionBox, PROJECTILE_FRISBEE))
	{
		smh->soundManager->playSound("snd_HitInvulnerable");
	}
}
Example #2
0
UINT MasterYi::passive(Champion* enemy){

	double critAttack = attackDamage * .50;
	if (attackCounter == 4){

		cout << "Yi Passive 1st Attack!" << endl;
		out << "Yi Passive 1st Attack!" << endl;
		dealDamage(attackDamage, 0,enemy);

		cout << "2nd Crit!" << endl<<endl<<endl;
		out << "2nd Crit!" << endl << endl << endl;
		dealDamage(critAttack, 0,enemy);
		attackCounter = 0;
	}
	return 0;
}
Example #3
0
void MasterYi::q(Champion* enemy){
	
	if (mana >= 70){
		mana = mana - 70;
		physicalDamage = 25 + (attackDamage);
		dealDamage(physicalDamage, 0,enemy);
	}
}
Example #4
0
void MasterYi::basicAttack(double clock, Champion* enemy){

	range = 125;
	clock = floor(clock * 10 + 0.5) / 10;
	out << "TIME TO ATTCK: " << clock << endl;
	//cout << "TIME TO ATTACK: " << clock << endl;
	coolDownQ = coolDownQ - 1;
	dealDamage(attackDamage, 0,enemy);
	attackCounter++;
}
Example #5
0
void FenwarBoss::enterState(int newState) 
{
	//Exit state stuff
	if (state == FenwarStates::TERRAFORMING)
	{
		smh->soundManager->stopEnvironmentChannel();
		smh->soundManager->playMusic("bossMusic");
	}

	state = newState;
	timeInState = 0.0;
	timeEnteredState = smh->getGameTime();

	//Enter state stuff
	if (newState == FenwarStates::TERRAFORMING)
	{
		smh->soundManager->playEnvironmentEffect("snd_RumbleLoop", true);
	}
	else if (newState == FenwarStates::BATTLE) 
	{
		lastAttackTime = smh->getGameTime();
		lastBombTime = smh->getGameTime();
		orbManager->spawnOrbs();
	}
	else if (newState == FenwarStates::STUNNED_AFTER_LOSING_ORBS)
	{
		//make him flash since he was stunned
		dealDamage(0,true);

		//Initialize stun star angles
		for (int i = 0; i < NUM_STUN_STARS; i++) {
			stunStarAngles[i] = (float)i * ((2.0*PI) / (float)NUM_STUN_STARS);
		}
	}
	else if (newState == FenwarStates::DROPPING_SPIDERS)
	{		
		for (int i = 0; i < 9; i++)
		{
			platformsVisited[i] = false;
		}
		numSpidersDropped = 0;
		chooseRandomPlatformUponWhichToDropASpider();
	}
	else if (newState == FenwarStates::RETURN_TO_ARENA)
	{
		smh->soundManager->fadeOutMusic();
		smh->player->dontUpdate = true;
	}
	else if (newState == FenwarStates::NEAR_DEATH)
	{
		smh->player->dontUpdate = false;
		smh->player->abilitiesLocked = true;
		smh->player->getTongue()->dontPlaySound = true;
	}
}
Example #6
0
void AttackSystem::update()
{
    for(auto attackComponent : m_EntitySystem.getComponentsOfType<AttackComponent>())
    {
        if(attackComponent->canAttack())
        {
            auto playerHealth = getCurrentPlayer()->getComponent<HealthComponent>();
            playerHealth->dealDamage(attackComponent->Damage);
            attackComponent->startTimer();
        }
    }
}
void FlyingCreature::attack(Creature& other){
	fly();
	dealDamage(other);
	stopFly();

}
Example #8
0
bool CandyBoss::update(float dt) 
{
	//When smiley triggers the boss' enemy blocks start his dialogue.
	if (state == CANDY_STATE_INACTIVE && !startedIntroDialogue) {
		if (smh->enemyGroupManager->groups[groupID].triggeredYet) {
			smh->windowManager->openDialogueTextBox(-1, CANDY_INTRO_TEXT);
			startedIntroDialogue = true;
		} else {
			return false;
		}
	}

	//Activate the boss when the intro dialogue is closed
	if (state == CANDY_STATE_INACTIVE && startedIntroDialogue && !smh->windowManager->isTextBoxOpen()) {
		enterState(FIRST_STATE);
		smh->soundManager->playMusic("bossMusic");
	}

	//Squash silly pads with Bartli's massive girth
	if (!jumping)
	{
		gridX = Util::getGridX(x);
		gridY = Util::getGridY(y);
		for (int i = gridX-1; i < gridX + 1; i++)
		{
			for (int j = gridY-1; j < gridY + 1; j++)
			{
				smh->environment->destroySillyPad(i, j);
			}
		}
	}

	if (shrinking) 
	{
		size -= (NUM_LIVES - numLives + 1) * .0225 * dt;
		if (smh->timePassedSince(timeStartedShrink) > SHRINKING_DURATION) {
			shrinking = false;
		} else if (!spawnedBartletYet && smh->timePassedSince(timeStartedShrink) > SHRINKING_DURATION / 2.0) {
			spawnBartlet(x, y);
			spawnedBartletYet = true;
		}
	}
	else
	{
		timeInState += dt;

		//Stage 1 - running
		if (state == CANDY_STATE_RUNNING) {
			updateRun(dt);
			if (timeInState > RUN_STATE_DURATION) {
				enterState(CANDY_STATE_MOVING_TO_CENTER);
			}
		}

		//Stage 2a - move back to the middle of the arena before throwing candy
		if (state == CANDY_STATE_MOVING_TO_CENTER) {
			updateRun(dt);
			if (timeInState >= timeToGetToCenter) {
				enterState(CANDY_STATE_THROWING_CANDY);
				//Play a sound
				smh->soundManager->playSound("snd_BartliRapid");
			}
		}

		//Stage 2b - throwing candy
		if (state == CANDY_STATE_THROWING_CANDY) {
			updateThrowingCandy(dt);
			if (timeInState > THROWING_CANDY_STATE_DURATION) {
				enterState(CANDY_STATE_JUMPING);
			}
		}

		//Stage 3a - jumping
		if (state == CANDY_STATE_JUMPING) {
			updateJumping(dt);
			if (numJumps >= 6) {
				jumping = false;
				enterState(CANDY_STATE_RESTING);
			}
		}

		//Stage 3b - multi jump (only if you get hit by the shockwave)
		if (state == CANDY_STATE_MULTI_JUMP) {
			updateJumping(dt);
			if (numJumps >= 5) {
				jumping = false;
				//Go back to stage one if they got hit by the shockwave!
				enterState(CANDY_STATE_RUNNING);
			}
		}

		//Stage 4 - resting
		if (state == CANDY_STATE_RESTING) {
			updateResting(dt);
			if (timeInState > REST_STATE_DURATION) {
				enterState(CANDY_STATE_RUNNING);
			}
		}

		//Player collision
		if (jumpYOffset < 65.0) 
		{
			setCollisionBox(collisionBox, x, y - jumpYOffset);
		}
		else
		{
			//Bartli can't collide with the player when she is in the air
			setCollisionBox(collisionBox, -1.0, -1.0);
		}

		if (smh->player->collisionCircle->testBox(collisionBox)) {
			if (state == CANDY_STATE_MULTI_JUMP) {
				if (smh->timePassedSince(lastTimeHitSmiley) > 0.5 * (1.0 / speedMultiplier)) {
					smh->player->dealDamage(0.25, false);
					lastTimeHitSmiley = smh->getGameTime();
				}
				smh->setDebugText("Smiley hit by CandyBoss during MultiJump");
			} else {
				if (smh->timePassedSince(lastTimeHitSmiley) > 0.5 * (1.0 / speedMultiplier)) {
					smh->player->dealDamageAndKnockback(COLLISION_DAMAGE, true, 225.0, x, y);
					smh->setDebugText("Smiley hit by CandyBoss");
				}
			}
		}

		updateLimbs(dt);
			
		//Take damage from stuff
		if (smh->player->getTongue()->testCollision(collisionBox) && smh->timePassedSince(lastTimeHit) > FLASHING_DURATION) 
		{
			dealDamage(smh->player->getDamage());
		}
		if (smh->player->fireBreathParticle->testCollision(collisionBox)) 
		{
			//Scale down fire breath a bit otherwise its too strong
			dealDamage(smh->player->getFireBreathDamage() * 0.8 * dt);
		}

		//Immune to frisbees and lightning orbs
		if (smh->projectileManager->killProjectilesInBox(collisionBox, PROJECTILE_FRISBEE) > 0 ||
			smh->projectileManager->killProjectilesInBox(collisionBox, PROJECTILE_LIGHTNING_ORB) > 0)
		{
			smh->soundManager->playSound("snd_HitInvulnerable");
		}
	}

	updateNovas(dt);
	updateBartlets(dt);
	shouldDrawAfterSmiley = (y > smh->player->y);
	
	//Do flashing
	if (smh->timePassedSince(lastTimeHit) < FLASHING_DURATION) {
		float n = FLASHING_DURATION / 4.0;
		float x = smh->timePassedSince(lastTimeHit);
		while (x > n) x -= n;
		if (x < n/2.0) {
			flashingAlpha = 100.0 + (310.0 * x) / n;
		} else {
			flashingAlpha = 255.0 - 155.0 * (x - n/2.0);
		}
	} else {
		flashingAlpha = 255.0;
	}

	//Update mouth
	if (smh->timePassedSince(timeMouthOpened) > mouthOpenDuration) {
		smh->resources->GetAnimation("bartli")->SetFrame(0);
	}

	if (health < 0.0 && state != CANDY_STATE_FRIENDLY && state != CANDY_STATE_MULTI_JUMP) {
		numLives--;
		if (numLives == 0) {	
			health = 0.0;
			enterState(CANDY_STATE_FRIENDLY);		
			smh->windowManager->openDialogueTextBox(-1, CANDY_DEFEAT_TEXT);	
			smh->saveManager->killBoss(CANDY_BOSS);
			smh->soundManager->fadeOutMusic();
		} else {
			shrinking = true;
			spawnedBartletYet = false;
			timeStartedShrink = smh->getGameTime();
			speedMultiplier += .08;
			health = maxHealth;
		}
	}

	///////// Death State stuff ///////////////

	//After being defeated, wait for the text box to be closed
	if (state == CANDY_STATE_FRIENDLY && !smh->windowManager->isTextBoxOpen()) {
		enterState(CANDY_STATE_RUNNING_AWAY);
		fadeOutAlpha = 255.0;
	}

	//After defeat and the text box is closed, bartli fades away
	if (state == CANDY_STATE_RUNNING_AWAY) {
		
		fadeOutAlpha -= 255.0 * dt;
		
		//When done fading away, drop the loot and return true so this boss is disposed of
		if (fadeOutAlpha <= 0.0) {
			fadeOutAlpha = 0.0;
			smh->soundManager->playMusic("iceMusic");
			smh->lootManager->addLoot(LOOT_NEW_ABILITY, x, y, ICE_BREATH, groupID);
			smh->player->setHealth(smh->player->getMaxHealth());
			return true;
		}
	}

}
void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi)
{
    cWeapon["FireCooldown"] = 60.0 / (double)cWeapon["RPM"];

    // Stop reloading
    Field<bool> isReloading = cWeapon["IsReloading"];
    isReloading = false;

    // Ammo
    Field<int> magAmmo = cWeapon["MagazineAmmo"];
    if (magAmmo <= 0) {
        return;
    } else {
        magAmmo -= 1;
    }

    // We can't really do any valuable calculations without a valid camera
    if (!m_CurrentCamera.Valid()) {
        return;
    }

    int numPellets = cWeapon["NumPellets"];

    // Create a spread pattern
    std::vector<glm::vec2> pattern;
    // The first pellet is always centered
    pattern.push_back(glm::vec2(0, 0));
    // Any additional pellets form circles around the middle
    int numOuterPellets = numPellets - 1;
    float angleIncrement = glm::two_pi<float>() / numOuterPellets;
    for (int i = 0; i < numOuterPellets; ++i) {
        float angle = angleIncrement * i;
        glm::vec2 pellet = glm::vec2(glm::cos(angle), glm::sin(angle));
        pattern.push_back(pellet);
    }

    // Deal damage (clientside)
    dealDamage(cWeapon, wi, pattern);

    // Spawn tracers
    spawnTracers(cWeapon, wi, pattern);

    // View punch
    if (IsClient) {
        EntityWrapper camera = wi.Player.FirstChildByName("Camera");
        if (camera.Valid()) {
            Field<glm::vec3> cameraOrientation = camera["Transform"]["Orientation"];
            float viewPunch = cWeapon["ViewPunch"];
            float maxTravelAngle = (const float&)cWeapon["MaxTravelAngle"];
            Field<float> currentTravel = cWeapon["CurrentTravel"];
            if (currentTravel < maxTravelAngle) {
                float change = viewPunch;
                if (currentTravel + change > maxTravelAngle) {
                    change = maxTravelAngle - currentTravel;
                }
                cameraOrientation.x(cameraOrientation.x() + change);
                currentTravel += change;
            }
        }
    }

    // Play animation
    playAnimationAndReturn(wi.FirstPersonEntity, "FinalBlend", "Fire");
    playAnimationAndReturn(wi.ThirdPersonPlayerModel, "FinalBlend", "Fire");

    // Sound
    Events::PlaySoundOnEntity e;
    e.Emitter = wi.Player;
    e.FilePath = "Audio/weapon/Blast.wav";
    m_EventBroker->Publish(e);
}