Beispiel #1
0
static bool HitItemFunc(TTileItem *ti, void *data)
{
	HitItemData *hData = data;
	if (!CanHit(hData->Obj->flags, hData->Obj->ActorUID, ti))
	{
		goto bail;
	}
	int targetUID = -1;
	hData->HitType = GetHitType(ti, hData->Obj, &targetUID);
	Damage(
		hData->Obj->vel, hData->Obj->bulletClass->Power,
		hData->Obj->flags, hData->Obj->PlayerUID, hData->Obj->ActorUID,
		ti->kind, targetUID,
		hData->Obj->bulletClass->Special);
	if (hData->Obj->tileItem.SoundLock <= 0)
	{
		hData->Obj->tileItem.SoundLock += SOUND_LOCK_TILE_OBJECT;
	}
	if (ti->SoundLock <= 0)
	{
		ti->SoundLock += SOUND_LOCK_TILE_OBJECT;
	}
	if (hData->Obj->specialLock <= 0)
	{
		hData->Obj->specialLock += SPECIAL_LOCK;
	}

bail:
	// Whether to produce multiple hits from the same TMobileObject
	return hData->MultipleHits;
}
Beispiel #2
0
void Enemy::AttackPlayer()
{
    // First, we check the enemy's dex to see if we've hit.
    int toHit = rand() % 100 + 1;
    int hitsOn = 100 - ( ENEMY_BASE_TO_HIT + m_dex );
    std::cout << "\nEnemy to hit roll: REQ(" << hitsOn << ") + ROLLED(" << toHit << ")\n";

    if ( toHit > hitsOn )
    {
        // Then we check the enemy's strength to see the damage. Bit of randomisation in there.
        int baseDmg = m_str + m_level;
        int randomDamage = (rand() % baseDmg - ( baseDmg / 2));
        int damage = baseDmg + randomDamage;
        std::cout << "Enemy damage roll: RND(" << randomDamage << ") + BASE(" << baseDmg << ")\n";

        // Then we damage the player.
        Game::GetInstance().GetPlayer()->AlterHealth(-damage);

        std::string randomAttack = GetHitType();
        std::string randomLocation = GetHitLocation();

        std::cout << "The " << m_name << " " <<  randomAttack << " you in the " << randomLocation << " for "
            << damage << " damage. You have " << Game::GetInstance().GetPlayer()->GetCurrentHealth() << " HP remaining.\n";
    }
    else
    {
        std::cout << "The " << m_name << " misses you utterly.\n";
    }
}