Exemplo n.º 1
0
void monster::process_effects()
{
    for (std::vector<effect>::iterator it = effects.begin();
            it != effects.end(); ++it) {
        std::string id = it->get_id();
        if (id == "nasty_poisoned") {
            speed -= rng(3, 5);
            hurt(rng(3, 6));
        } if (id == "poisoned") {
            speed -= rng(0, 3);
            hurt(rng(1, 3));

        // MATERIALS-TODO: use fire resistance
        } else if (id == "onfire") {
            if (made_of("flesh") || made_of("iflesh"))
                hurt(rng(3, 8));
            if (made_of("veggy"))
                hurt(rng(10, 20));
            if (made_of("paper") || made_of("powder") || made_of("wood") || made_of("cotton") ||
                made_of("wool"))
                hurt(rng(15, 40));
        }
    }

    Creature::process_effects();
}
Exemplo n.º 2
0
void monster::process_effects(game *g)
{
 for (int i = 0; i < effects.size(); i++) {
  switch (effects[i].type) {
  case ME_POISONED:
   speed -= rng(0, 3);
   hurt(rng(1, 3));
   break;

  case ME_ONFIRE:
   if (made_of(FLESH))
    hurt(rng(3, 8));
   if (made_of(VEGGY))
    hurt(rng(10, 20));
   if (made_of(PAPER) || made_of(POWDER) || made_of(WOOD) || made_of(COTTON) ||
       made_of(WOOL))
    hurt(rng(15, 40));
   break;

  }
  if (effects[i].duration > 0) {
   effects[i].duration--;
   if (g->debugmon)
    debugmsg("Duration %d", effects[i].duration);
  }
  if (effects[i].duration == 0) {
   if (g->debugmon)
    debugmsg("Deleting");
   effects.erase(effects.begin() + i);
   i--;
  }
 }
}
Exemplo n.º 3
0
void monster::process_effects(game *g)
{
 for (int i = 0; i < effects.size(); i++) {
  switch (effects[i].type) {
  case ME_POISONED:
   speed -= rng(0, 3);
   hurt(rng(1, 3));
   break;

// MATERIALS-TODO: use fire resistance
  case ME_ONFIRE:
   if (made_of("flesh"))
    hurt(rng(3, 8));
   if (made_of("veggy"))
    hurt(rng(10, 20));
   if (made_of("paper") || made_of("powder") || made_of("wood") || made_of("cotton") ||
       made_of("wool"))
    hurt(rng(15, 40));
   break;

  }
  if (effects[i].duration > 0) {
   effects[i].duration--;
   if (g->debugmon)
    debugmsg("Duration %d", effects[i].duration);
  }
  if (effects[i].duration == 0) {
   if (g->debugmon)
    debugmsg("Deleting");
   effects.erase(effects.begin() + i);
   i--;
  }
 }
}
Exemplo n.º 4
0
void monster::move_to(game *g, int x, int y)
{
 int mondex = g->mon_at(x, y);
 if (mondex == -1) { //...assuming there's no monster there
  if (has_effect(ME_BEARTRAP)) {
   moves = 0;
   return;
  }
  
  if (plans.size() > 0)
   plans.erase(plans.begin());

  moves -= calc_movecost(g, posx, posy, x, y);

  if (has_flag(MF_SLUDGETRAIL)){
   g->m.add_field(g, posx, posy, fd_sludge, 3);
   g->m.add_field(g, posx+1, posy, fd_sludge, 2);
   g->m.add_field(g, posx, posy+1, fd_sludge, 2);
   g->m.add_field(g, posx-1, posy, fd_sludge, 2);
   g->m.add_field(g, posx, posy-1, fd_sludge, 2);
  }

  posx = x;
  posy = y;
  footsteps(g, x, y);
  if (type->size != MS_TINY && g->m.has_flag(sharp, posx, posy) && !one_in(4))
     hurt(rng(2, 3));
  if (type->size != MS_TINY && g->m.has_flag(rough, posx, posy) && one_in(6))
     hurt(rng(1, 2));
  if (!has_flag(MF_DIGS) && !has_flag(MF_FLIES) &&
      g->m.tr_at(posx, posy) != tr_null) { // Monster stepped on a trap!
   trap* tr = g->traps[g->m.tr_at(posx, posy)];
   if (dice(3, type->sk_dodge + 1) < dice(3, tr->avoidance)) {
    trapfuncm f;
    (f.*(tr->actm))(g, this, posx, posy);
   }
  }
// Diggers turn the dirt into dirtmound
  if (has_flag(MF_DIGS)){
   g->m.ter_set(posx, posy, t_dirtmound);
  }
// Acid trail monsters leave... a trail of acid
  if (has_flag(MF_ACIDTRAIL)){
   g->m.add_field(g, posx, posy, fd_acid, 1);
  }
  if (has_flag(MF_ACIDTRAIL)){
   g->m.add_field(g, posx, posy, fd_acid, 1);
  }
  if (has_flag(MF_ACIDTRAIL)){
   g->m.add_field(g, posx, posy, fd_acid, 1);
  }

 } else if (has_flag(MF_ATTACKMON) || g->z[mondex].friendly != 0)
// If there IS a monster there, and we fight monsters, fight it!
  hit_monster(g, mondex);
}
Exemplo n.º 5
0
bool Samolot::refresh(Game& game)
{
	if(destroyed())
	{
		game.create_entity(std::make_shared<LargeExplosion>(poz, 360));
		if(--lives != 0)
			game.schedule_action_after_n_ticks(400, [&](){ game.reset_level(); });
		else
			game.schedule_action_after_n_ticks(500, [&](){ game.set_game_state(Game::game_over); });
	}
	else
	{
		poz += predkosc * 0.2;
		if(std::abs(predkosc) >= 12.0)
			predkosc = std::polar(12.0, std::arg(predkosc));
		if(predkosc.imag() < 4.5) predkosc.imag(4.5);
		if(bullet_reload_time == bullet_timeout)
		{
			game.create_entity(std::make_shared<Bullet>(poz + Zespolona(0, 50), Zespolona(0.0, 10.0), 45));
		}
		if(bullet_reload_time != 0)
			--bullet_reload_time;
		fuel -= 2;
		if(fuel <= 0)
			hurt();
	}
	return destroyed();
}
Exemplo n.º 6
0
void Player::attack(Player& rhs)
{
	//initial damage calc
	int doDam = damage*damMult;
	if (shieldColor() == "Red" && turn % 2 == 0) doDam = 0;	
	if (weaponColor() == "Red" && rand() % 100 < 20) doDam *= 2;
	if (weaponColor() == "Yellow" && rand() % 100 < 15) doDam = 0;

	//is it dodged
	if (rhs.armorColor() == "Blue" && rand()%100 < 15) 
	{
		return;
	}

	//shield properties
	if (rhs.shieldColor() == "Red" && turn % 2 == 0 && weaponColor() != "Yellow") doDam = 0;
	if (rhs.shieldColor() == "Blue" && weaponColor() != "Yellow") doDam = doDam*0.8;
	if (rhs.shieldColor() == "Green" && weaponColor() != "Yellow") poison();

	//status effects
	if (weaponColor() == "Blue" && rand() % 100 < 10 && doDam > 0) rhs.stun();
	if (weaponColor() == "Green") rhs.bleed();

	//deal damage
	rhs.hurt(doDam);
	if (rhs.armorColor() == "Green") hurt(doDam / 2);
}
Exemplo n.º 7
0
Arquivo: Shot.cpp Projeto: Zylann/Grid
    void Shot::onCollision(const Collision & c)
    {
        sf::Color clr(255,255,255);

        if(c.entity != NULL)
        {
            // Except entities with the same team or the same type
            if(c.entity->team == team || c.entity->getType() == getType())
                return;

            if(c.entity->getType() != ENT_MAP)
            {
                // Repulsion
                Vector2f repulsion = getNormalized(speed);
                // TODO find a way to access delta here, or not have to.
                // onCollision basically doesn't access to delta, then we have to choose a value...
                c.entity->accelerate(repulsion * 80.f, 0.03f);

                // Hurting
                Message hurt(M_HEA_HURT, this);
                hurt.health = 15;
                c.entity->processMessage(hurt);

                // Bloody color
                clr.g = 0;
                clr.b = 0;
            }
        }

        // Hit particles
        r_level->spawnEntity(new entity::ShockWave(0.1, 0.8, 4, clr), pos);

        invalidate();
    }
Exemplo n.º 8
0
    //!!!WARNING: Code in this method should not depend on how many times this method is run
    void Player::updateState() {
        //states
        if (mHpLossTimer.exceededReset()) {
            hurt(mInCloud);
        }

        //Apply impulse
        cpVect totalVel = cpvadd(mVel,mVectp);
        if (cpvlength(totalVel) != 0) {
            cpBodyApplyImpulseAtWorldPoint(mEntity->body(), totalVel, cpv(0, 0));
            mVel = cpvzero;
            mVectp = cpvzero;
        }

        mVectp = cpvzero;
        cpBody * body = mEntity->body();
        for(int i=0; i<mMaxAmmo; i++)
            if( mAmmo[i].checkExist() )
                mAmmo[i].move();

        //Move around screen
        if( body->p.x > SCREEN_WIDTH + mEntity->width()/2 )
            body->p.x = -mEntity->width();
        if( body->p.x < -mEntity->width() )
            body->p.x = SCREEN_WIDTH + mEntity->width()/2;
        if( body->p.y > SCREEN_HEIGHT + mEntity->height()/2)
            body->p.y = -mEntity->height();
        if( body->p.y < -mEntity->height() )
            body->p.y = SCREEN_HEIGHT + mEntity->height()/2;
    }
Exemplo n.º 9
0
float BaseCreatureEntity::animateStates(float delay)
{
  for (int i = 0; i < NB_SPECIAL_STATES; i++)
  {
    if (specialState[i].active)
    {
      specialState[i].timer -= delay;
      if (specialState[i].timer <= 0.0f) specialState[i].active = false;
    }
  }
  // ice
  if (specialState[SpecialStateIce].active) delay *= specialState[SpecialStateIce].param1;

  // poison
  if (specialState[SpecialStatePoison].active)
  {
    specialState[SpecialStatePoison].param3 -= delay;
    if (specialState[SpecialStatePoison].param3 <= 0.0f)
    {
      specialState[SpecialStatePoison].param3 += specialState[SpecialStatePoison].param2;
      hurt(specialState[SpecialStatePoison].param1, ShotTypeDeterministic, 0, false);
    }
  }

  return delay;
}
Exemplo n.º 10
0
void update(team *overall, batsman *team1, bowler *team2, matchinfo *info) { /*it is main updater function*/
	char a[4];
	char *e = "%s";
	int v, x;
	system("clear");
	start(overall);
	in_the_ground(team1);
	warming_up(team2);
	move(10, 11);
	printf("\e[1menter name of batsman on stike: " ANSI_COLOR_RESET);
	move(45, 11);
	scanf(e, name);
	onstrike = send_batsman(team1, name);
	move(10, 12);
	printf("\e[1menter name of batsman off strike:"  ANSI_COLOR_RESET);
	move(45, 12);
	scanf(e, name);
	offstrike = send_batsman(team1, name);
	taking_guard(onstrike);
	taking_guard(offstrike);
	move(10, 13);
	printf("\e[1menter name of bowler: "  ANSI_COLOR_RESET);
	move(35, 13);		
	scanf(e, name);	
	bowling = give_bowl(team2, name);
	shining_bowl(bowling);
	x = 27;
	while((overall->balls != (info->overs * 6)) && (overall->wickets != 10)) {
		move(0, 26);     	
		printf("\e[1menter runs made , wicket(w), wide(y), noball(n), extra(e) end inning(esc)"  ANSI_COLOR_RESET);
		move(0, x);		
		scanf("%s", a);
		x = 27;
		if(a[0] == 27)
			break;
		input(a);
		if(wrong) {
			move(0, 28);
			printf("\e[1mINVALIND INPUT:"  ANSI_COLOR_RESET);
			x = 29;
			wrong = 0;
			continue;
		}
		else if(ab[0] == '\0')
			add_runs_with_no_extra(team1, team2, overall, info);
		else {			
			if(ab[0] == 'y' || ab[0] == 'n' || ab[0] == 'e') {
				add_runs_with_extra(team1, team2, overall, info);
			}
			else {
				move(0,28);
				printf("\e[1mbowled(b), caught(c), lbw(l), run out(r), retired hurt(h), heatwicket(t), time out(o)"  ANSI_COLOR_RESET);
				move(0, 29);
				wicket(team1, team2, overall, info);			
			}
		}
		if((overall->innings == 2) && overall->target <= 0) 
			break;			
	}
Exemplo n.º 11
0
bool HardRockTile::interact(Level *level, int xt, int yt, Player *player, Item *item, int attackDir)
{
	if(ToolItem *tool = dynamic_cast<ToolItem*>(item)) {
		if((tool->type == ToolType::pickaxe) && (tool->level == 4) && (player->payStamina(4 - tool->level))) {
			hurt(level, xt, yt, qrand() % 10 + tool->level * 5 + 10);

			return true;
		}
	}

	return false;
}
Exemplo n.º 12
0
void monster::process_effects(game *g)
{
    for (int i = 0; i < effects.size(); i++) {
        switch (effects[i].type) {
        case ME_ONFIRE:
            if (made_of(FLESH))
                hurt(rng(3, 8));
            if (made_of(VEGGY))
                hurt(rng(10, 20));
            if (made_of(PAPER) || made_of(POWDER) || made_of(WOOD) || made_of(COTTON) ||
                    made_of(WOOL))
                hurt(rng(15, 40));
            break;

        }
        effects[i].duration--;
        if (effects[i].duration <= 0) {
            effects.erase(effects.begin() + i);
            i--;
        }
    }
}
Exemplo n.º 13
0
void CEnemySprite::update(float dt)
{
	if(m_pSprite->isVisible() == false) return;
	CPlayerSprite *pPlayer = CGameManager::getPlayer();
	if(pPlayer->isShield() == false)
	{
		if(pPlayer->getSprite()->boundingBox().intersectsRect(m_pSprite->boundingBox()))
		{
			hurt(1);
			pPlayer->hurt(1);
		}
	}
}
Exemplo n.º 14
0
bool OreTile::interact(Level* level, int xt, int yt, Player * player, Item * item, int attackDir) {
	if (item->instanceOf(TOOL_ITEM))
	{
		ToolItem * tool = (ToolItem*) item;
		if (tool->type == ToolType::pickaxe) {
			if (player->payStamina(6 - tool->level)) {
				hurt(level, xt, yt, 1);
				return true;
			}
		}
	}
	return false;
}
Exemplo n.º 15
0
void SpiderWebEntity::collideWithEnemy(EnemyEntity* enemyEntity)
{
  if (enemyEntity->getEnemyType() != EnemyTypeSpiderLittle_invocated
      && enemyEntity->getEnemyType() != EnemyTypeSpiderGiant
      && enemyEntity->getEnemyType() != EnemyTypeSpiderEgg_invocated
      && enemyEntity->getEnemyType() != EnemyTypeSpiderWeb)
  {
    if (!enemyEntity->isSpecialStateActive(SpecialStateSlow))
    {
      enemyEntity->setSpecialState(SpecialStateSlow, true, 0.15f, 0.25f, 0.0f);
      hurt(getHurtParams(2, ShotTypeStandard, 0, false, SourceTypeMelee, enemyEntity->getEnemyType(), false));
    }
  }
}
Exemplo n.º 16
0
void Health::hit(int damage)
{
	if(!invincible())
	{
		m_clock.restart();
		hits -= damage;

		hurt();

		if (hits < 0)
		{
			died();
		}
	}
}
Exemplo n.º 17
0
void ComponentHealth::onIncomingDamage(float damage)
{
	if(health <= 0)
	{
		return;
	}

	if(damage > 0) //Daño normal
	{
		hurt(damage);
	}
	else			//Cura
	{
		heal(damage * -1);
	}
}
Exemplo n.º 18
0
void heal_update(void)
{
	CREATURE *crit=0;

	for(crit = creature_list; crit; crit = crit->next)
	{
		if(crit->hp < -4)
			hurt(crit,1);
		else if(crit->hp < crit->max_hp)
			heal(crit,1);

		if(crit->move < crit->max_move && crit->hp > 0)
			crit->move++;

		position_check(crit);
	}
}
Exemplo n.º 19
0
void Character::collisionAction(Character *c) {
	if(!c || (c->isNPC() || !isNPC()) || (c->isPlayer() || !isPlayer())) {
		// Stop movement timer
		m_movementTimer.stop();
		
		// Update collision state
		m_inCollision = true;
		
		// Exit function to avoid problems if c == NULL
		return;
	}
	
	if(c->isMonster() && isPlayer()) {
		// Hurt player
		hurt(m_x + m_hitboxW / 2 - c->x() + c->hitboxW() / 2, m_y + m_hitboxH / 2 - c->y() + c->hitboxH() / 2);
	}
}
Exemplo n.º 20
0
// warning: might kill (and thus delete) cn
void ritual_hurt(int cn, struct lab5_player_data *pd, int x, int y)
{
        int fn;

        fn=create_show_effect(EF_PULSEBACK,cn,ticker,ticker+17,20,42);
        if (fn) {
                ef[fn].x=x;
                ef[fn].y=y;
        }

        log_char(cn,LOG_SYSTEM,0,"°c3The Ritual Of %s ended.°c0",daemonname[pd->ritualdaemon]);
        pd->ritualdaemon=0;
        pd->ritualstate=0;

	// always do hurt last as it might kill the character
	hurt(cn,5*POWERSCALE,0,1,0,0);
}
Exemplo n.º 21
0
void staffer_spiketrap(int in,int cn)
{
	if (cn && !it[in].drdata[1]) {
		it[in].sprite++;
		it[in].drdata[1]=1;

		hurt(cn,it[in].drdata[2]*POWERSCALE,0,1,75,75);

		call_item(it[in].driver,in,0,ticker+TICKS);
		return;
	}
	if (!cn && it[in].drdata[1]) {
		it[in].sprite--;
		it[in].drdata[1]=0;
		set_sector(it[in].x,it[in].y);
		return;
	}
}
Exemplo n.º 22
0
void LogicLayer::bulletVsEnemy()
{
	auto tankbu = BulletManager::getInstance()->getTankBulletManager();
	auto enemy = EnemyManager::getInstance()->getEnemyManger();
	for(auto titer = tankbu.begin();titer!=tankbu.end();titer++)
	{  auto tankbullet = *titer;
	   for (auto eiter = enemy.begin();eiter!=enemy.end();eiter++)
	   {   
		   auto enemy = *eiter;
		   if (enemy->getBoundingBox().intersectsRect(tankbullet->getBoundingBox())&&!enemy->getISdie())
		   {
			   //ÉèÖÃÏûʧ״̬
			   tankbullet->remove();
			   enemy->hurt(tankbullet->getATTACK());
		   }
	   }
	}
}
Exemplo n.º 23
0
void LogicLayer::bulletVsTank()
{
	auto enemybu = BulletManager::getInstance()->getEnemyBulletManger();
	auto scene =dynamic_cast<GameScene *> (Director::getInstance()->getRunningScene());
	auto tank =(BaseTank *) scene->getTanklayer()->getChildByName("tank");
	
	if (tank==nullptr)
	{
		return;
	}
	tank->retain();
	for (auto eiter = enemybu.begin();eiter!=enemybu.end();eiter++)
	{   auto bullet = *eiter;
		if (tank->getBoundingBox().intersectsRect(bullet->getBoundingBox()))
		{
			//tankµôѪ gameover
			tank->hurt(bullet->getATTACK());
			bullet->remove();
			
		}
	}
	tank->release();
}
Exemplo n.º 24
0
void FightLayer::combatAction(int index){
    
    if(index>=_combatVec.size()){
        
        runAction(Sequence::create(DelayTime::create(0.6),CallFunc::create(CC_CALLBACK_0(FightLayer::combatEnd, this)) ,NULL));
        return;
    }
 
    auto cb = _combatVec.at(index);
    
    auto attacker = getCardByHash(cb->getAttacker());
    auto beattacked = getCardByHash(cb->getBeattacked());
    
    if(!attacker||!beattacked){
        return;
    }
    
    auto delay =2;

    if (cb->getSkill()>0) {
        
        attacker->attack(cb->getSkill());

        beattacked->runAction(Sequence::create(DelayTime::create(1.4),CallFunc::create([beattacked](){beattacked->hurt(1, true);}),NULL));
        delay = 2.5;
    }else{
        
        attacker->attack(0);
        auto ba = Sequence::create(DelayTime::create(delay),
                                   CallFunc::create([&](){beattacked->hurt(cb->getDamage(), false);}),NULL);
        beattacked->runAction(ba);
    }
    
    auto action = Sequence::create(DelayTime::create(delay),CallFunc::create([index, this](){auto ni = index+1; combatAction(ni);}), NULL);
    
    runAction(action);
}
Exemplo n.º 25
0
void SpiderWebEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
  if (!isDying && !isAgonising && collideWithEntity(entity))
  {
    if (entity->getType() == ENTITY_PLAYER || entity->getType() == ENTITY_BOLT )
    {
      PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(entity);
      BoltEntity* boltEntity = dynamic_cast<BoltEntity*>(entity);

      if (!isFromPlayer && playerEntity != NULL && !playerEntity->isDead())
      {
        if (!playerEntity->isSpecialStateActive(SpecialStateSlow))
        {
          playerEntity->setSpecialState(SpecialStateSlow, true, 0.1f, 0.33f, 0.0f);
          // TODO
          hurt(getHurtParams(2, ShotTypeStandard, 0, false, SourceTypeMelee, EnemyTypeNone, false));
        }
      }

      else if (!isFromPlayer && boltEntity != NULL && !boltEntity->getDying() && boltEntity->getAge() > 0.05f)
      {
        EnemyEntity::collideWithBolt(boltEntity);
      }
    }
    else // collision with other enemy ?
    {
      if (entity->getType() >= ENTITY_ENEMY && entity->getType() <= ENTITY_ENEMY_MAX)
      {
        if (this != entity)
        {
          EnemyEntity* enemyEntity = static_cast<EnemyEntity*>(entity);
          if (enemyEntity->canCollide()) collideWithEnemy(enemyEntity);
        }
      }
    }
  }
}
Exemplo n.º 26
0
void ObstacleEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
  if (entity == this) return;
  if (!isDying && !isAgonising && collideWithEntity(entity))
  {
    if (entity->getType() == ENTITY_BOLT )
    {
      BoltEntity* boltEntity = dynamic_cast<BoltEntity*>(entity);

      if (!boltEntity->getDying() && boltEntity->getAge() > 0.05f)
      {
        EnemyEntity::collideWithBolt(boltEntity);
        correctFrame();
      }
    }
    else if (entity->getType() == ENTITY_ENEMY_BOLT )
    {
      EnemyBoltEntity* boltEntity = dynamic_cast<EnemyBoltEntity*>(entity);

      if (!boltEntity->getDying() && boltEntity->getAge() > 0.05f)
      {
        EnemyEntity::collideWithBolt(boltEntity);
        correctFrame();
      }
    }
    else if (entity->getType() >= ENTITY_ENEMY && entity->getType() <= ENTITY_ENEMY_MAX)
    {
      EnemyEntity* enemyEntity = dynamic_cast<EnemyEntity*>(entity);

      if (!enemyEntity->getDying() && enemyEntity->canCollide()&& enemyEntity->getMovingStyle() != movFlying)
      {
        hurt(getHurtParams(hp, ShotTypeStandard, 0, false, SourceTypeMelee, enemyEntity->getEnemyType(), false));
      }
    }
  }
}
Exemplo n.º 27
0
// Why put this in a Big Switch?  Why not let bionics have pointers to
// functions, much like monsters and items?
//
// Well, because like diseases, which are also in a Big Switch, bionics don't
// share functions....
void player::activate_bionic(int b, game *g)
{
 bionic bio = my_bionics[b];
 int power_cost = bionics[bio.id].power_cost;
 if (weapon.type->id == itm_bio_claws && bio.id == bio_claws)
  power_cost = 0;
 if (power_level < power_cost) {
  if (my_bionics[b].powered) {
   g->add_msg("Your %s powers down.", bionics[bio.id].name.c_str());
   my_bionics[b].powered = false;
  } else
   g->add_msg("You cannot power your %s", bionics[bio.id].name.c_str());
  return;
 }

 if (my_bionics[b].powered && my_bionics[b].charge > 0) {
// Already-on units just lose a bit of charge
  my_bionics[b].charge--;
 } else {
// Not-on units, or those with zero charge, have to pay the power cost
  if (bionics[bio.id].charge_time > 0) {
   my_bionics[b].powered = true;
   my_bionics[b].charge = bionics[bio.id].charge_time;
  }
  power_level -= power_cost;
 }

 std::string junk;
 std::vector<point> traj;
 std::vector<std::string> good;
 std::vector<std::string> bad;
 WINDOW* w;
 int dirx, diry, t, index;
 unsigned int l;
 item tmp_item;

 switch (bio.id) {
 case bio_painkiller:
  pkill += 6;
  pain -= 2;
  if (pkill > pain)
   pkill = pain;
  break;

 case bio_nanobots:
  healall(4);
  break;

 case bio_resonator:
  g->sound(posx, posy, 30, "VRRRRMP!");
  for (int i = posx - 1; i <= posx + 1; i++) {
   for (int j = posy - 1; j <= posy + 1; j++) {
    g->m.bash(i, j, 40, junk);
    g->m.bash(i, j, 40, junk);	// Multibash effect, so that doors &c will fall
    g->m.bash(i, j, 40, junk);
    if (g->m.is_destructable(i, j) && rng(1, 10) >= 4)
     g->m.ter(i, j) = t_rubble;
   }
  }
  break;

 case bio_time_freeze:
  moves += 100 * power_level;
  power_level = 0;
  g->add_msg("Your speed suddenly increases!");
  if (one_in(3)) {
   g->add_msg("Your muscles tear with the strain.");
   hurt(g, bp_arms, 0, rng(5, 10));
   hurt(g, bp_arms, 1, rng(5, 10));
   hurt(g, bp_legs, 0, rng(7, 12));
   hurt(g, bp_legs, 1, rng(7, 12));
   hurt(g, bp_torso, 0, rng(5, 15));
  }
  if (one_in(5))
   add_disease(DI_TELEGLOW, rng(50, 400), g);
  break;

 case bio_teleport:
  g->teleport();
  add_disease(DI_TELEGLOW, 300, g);
  break;

// TODO: More stuff here (and bio_blood_filter)
 case bio_blood_anal:
  w = newwin(20, 40, 3, 10);
  wborder(w, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
             LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
  if (has_disease(DI_FUNGUS))
   bad.push_back("Fungal Parasite");
  if (has_disease(DI_DERMATIK))
   bad.push_back("Insect Parasite");
  if (has_disease(DI_POISON))
   bad.push_back("Poison");
  if (radiation > 0)
   bad.push_back("Irradiated");
  if (has_disease(DI_PKILL1))
   good.push_back("Minor Painkiller");
  if (has_disease(DI_PKILL2))
   good.push_back("Moderate Painkiller");
  if (has_disease(DI_PKILL3))
   good.push_back("Heavy Painkiller");
  if (has_disease(DI_PKILL_L))
   good.push_back("Slow-Release Painkiller");
  if (has_disease(DI_DRUNK))
   good.push_back("Alcohol");
  if (has_disease(DI_CIG))
   good.push_back("Nicotine");
  if (has_disease(DI_HIGH))
   good.push_back("Intoxicant: Other");
  if (has_disease(DI_TOOK_PROZAC))
   good.push_back("Prozac");
  if (has_disease(DI_TOOK_FLUMED))
   good.push_back("Antihistamines");
  if (has_disease(DI_ADRENALINE))
   good.push_back("Adrenaline Spike");
  if (good.size() == 0 && bad.size() == 0)
   mvwprintz(w, 1, 1, c_white, "No effects.");
  else {
   for (unsigned int line = 1; line < 39 && line <= good.size() + bad.size(); line++) {
    if (line <= bad.size())
     mvwprintz(w, line, 1, c_red, bad[line - 1].c_str());
    else
     mvwprintz(w, line, 1, c_green, good[line - 1 - bad.size()].c_str());
   }
  }
  wrefresh(w);
  refresh();
  getch();
  delwin(w);
  break;

 case bio_blood_filter:
  rem_disease(DI_FUNGUS);
  rem_disease(DI_POISON);
  rem_disease(DI_PKILL1);
  rem_disease(DI_PKILL2);
  rem_disease(DI_PKILL3);
  rem_disease(DI_PKILL_L);
  rem_disease(DI_DRUNK);
  rem_disease(DI_CIG);
  rem_disease(DI_HIGH);
  rem_disease(DI_TOOK_PROZAC);
  rem_disease(DI_TOOK_FLUMED);
  rem_disease(DI_ADRENALINE);
  break;

 case bio_evap:
  if (query_yn("Drink directly? Otherwise you will need a container.")) {
   tmp_item = item(g->itypes[itm_water], 0);
   thirst -= 50;
   if (has_trait(PF_GOURMAND) && thirst < -60) {
     g->add_msg("You can't finish it all!");
     thirst = -60;
   } else if (!has_trait(PF_GOURMAND) && thirst < -20) {
     g->add_msg("You can't finish it all!");
     thirst = -20;
   }
  } else {
   t = g->inv("Choose a container:");
   if (i_at(t).type == 0) {
    g->add_msg("You don't have that item!");
    power_level += bionics[bio_evap].power_cost;
   } else if (!i_at(t).is_container()) {
    g->add_msg("That %s isn't a container!", i_at(t).tname().c_str());
    power_level += bionics[bio_evap].power_cost;
   } else {
    it_container *cont = dynamic_cast<it_container*>(i_at(t).type);
    if (i_at(t).volume_contained() + 1 > cont->contains) {
     g->add_msg("There's no space left in your %s.", i_at(t).tname().c_str());
     power_level += bionics[bio_evap].power_cost;
    } else if (!(cont->flags & con_wtight)) {
     g->add_msg("Your %s isn't watertight!", i_at(t).tname().c_str());
     power_level += bionics[bio_evap].power_cost;
    } else {
     g->add_msg("You pour water into your %s.", i_at(t).tname().c_str());
     i_at(t).put_in(item(g->itypes[itm_water], 0));
    }
   }
  }
  break;

 case bio_lighter:
  g->draw();
  mvprintw(0, 0, "Torch in which direction?");
  get_direction(g, dirx, diry, input());
  if (dirx == -2) {
   g->add_msg("Invalid direction.");
   power_level += bionics[bio_lighter].power_cost;
   return;
  }
  dirx += posx;
  diry += posy;
  if (!g->m.add_field(g, dirx, diry, fd_fire, 1))	// Unsuccessful.
   g->add_msg("You can't light a fire there.");
  break;

 case bio_claws:
  if (weapon.type->id == itm_bio_claws) {
   g->add_msg("You withdraw your claws.");
   weapon = ret_null;
  } else if (weapon.type->id != 0) {
   g->add_msg("Your claws extend, forcing you to drop your %s.",
              weapon.tname().c_str());
   g->m.add_item(posx, posy, weapon);
   weapon = item(g->itypes[itm_bio_claws], 0);
   weapon.invlet = '#';
  } else {
   g->add_msg("Your claws extend!");
   weapon = item(g->itypes[itm_bio_claws], 0);
   weapon.invlet = '#';
  }
  break;

 case bio_blaster:
  tmp_item = weapon;
  weapon = item(g->itypes[itm_bio_blaster], 0);
  weapon.curammo = dynamic_cast<it_ammo*>(g->itypes[itm_bio_fusion]);
  weapon.charges = 1;
  g->refresh_all();
  g->plfire(false);
  weapon = tmp_item;
  break;

 case bio_laser:
  tmp_item = weapon;
  weapon = item(g->itypes[itm_v29], 0);
  weapon.curammo = dynamic_cast<it_ammo*>(g->itypes[itm_laser_pack]);
  weapon.charges = 1;
  g->refresh_all();
  g->plfire(false);
  weapon = tmp_item;
  break;

 case bio_emp:
  g->draw();
  mvprintw(0, 0, "Fire EMP in which direction?");
  get_direction(g, dirx, diry, input());
  if (dirx == -2) {
   g->add_msg("Invalid direction.");
   power_level += bionics[bio_emp].power_cost;
   return;
  }
  dirx += posx;
  diry += posy;
  g->emp_blast(dirx, diry);
  break;

 case bio_hydraulics:
  g->add_msg("Your muscles hiss as hydraulic strength fills them!");
  break;

 case bio_water_extractor:
  for (unsigned int i = 0; i < g->m.i_at(posx, posy).size(); i++) {
   item tmp = g->m.i_at(posx, posy)[i];
   if (tmp.type->id == itm_corpse && query_yn("Extract water from the %s",
                                              tmp.tname().c_str())) {
    i = g->m.i_at(posx, posy).size() + 1;	// Loop is finished
    t = g->inv("Choose a container:");
    if (i_at(t).type == 0) {
     g->add_msg("You don't have that item!");
     power_level += bionics[bio_water_extractor].power_cost;
    } else if (!i_at(t).is_container()) {
     g->add_msg("That %s isn't a container!", i_at(t).tname().c_str());
     power_level += bionics[bio_water_extractor].power_cost;
    } else {
     it_container *cont = dynamic_cast<it_container*>(i_at(t).type);
     if (i_at(t).volume_contained() + 1 > cont->contains) {
      g->add_msg("There's no space left in your %s.", i_at(t).tname().c_str());
      power_level += bionics[bio_water_extractor].power_cost;
     } else {
      g->add_msg("You pour water into your %s.", i_at(t).tname().c_str());
      i_at(t).put_in(item(g->itypes[itm_water], 0));
     }
    }
   }
   if (i == g->m.i_at(posx, posy).size() - 1)	// We never chose a corpse
    power_level += bionics[bio_water_extractor].power_cost;
  }
  break;

 case bio_magnet:
  for (int i = posx - 10; i <= posx + 10; i++) {
   for (int j = posy - 10; j <= posy + 10; j++) {
    if (g->m.i_at(i, j).size() > 0) {
     if (g->m.sees(i, j, posx, posy, -1, t))
      traj = line_to(i, j, posx, posy, t);
     else
      traj = line_to(i, j, posx, posy, 0);
    }
    traj.insert(traj.begin(), point(i, j));
    for (unsigned int k = 0; k < g->m.i_at(i, j).size(); k++) {
     if (g->m.i_at(i, j)[k].made_of(IRON) || g->m.i_at(i, j)[k].made_of(STEEL)){
      tmp_item = g->m.i_at(i, j)[k];
      g->m.i_rem(i, j, k);
      for (l = 0; l < traj.size(); l++) {
       index = g->mon_at(traj[l].x, traj[l].y);
       if (index != -1) {
        if (g->z[index].hurt(tmp_item.weight() * 2))
         g->kill_mon(index, true);
        g->m.add_item(traj[l].x, traj[l].y, tmp_item);
        l = traj.size() + 1;
       } else if (l > 0 && g->m.move_cost(traj[l].x, traj[l].y) == 0) {
        g->m.bash(traj[l].x, traj[l].y, tmp_item.weight() * 2, junk);
        g->sound(traj[l].x, traj[l].y, 12, junk);
        if (g->m.move_cost(traj[l].x, traj[l].y) == 0) {
         g->m.add_item(traj[l - 1].x, traj[l - 1].y, tmp_item);
         l = traj.size() + 1;
        }
       }
      }
      if (l == traj.size())
       g->m.add_item(posx, posy, tmp_item);
     }
    }
   }
  }
  break;

 case bio_lockpick:
  g->draw();
  mvprintw(0, 0, "Unlock in which direction?");
  get_direction(g, dirx, diry, input());
  if (dirx == -2) {
   g->add_msg("Invalid direction.");
   power_level += bionics[bio_lockpick].power_cost;
   return;
  }
  dirx += posx;
  diry += posy;
  if (g->m.ter(dirx, diry) == t_door_locked) {
   moves -= 40;
   g->add_msg("You unlock the door.");
   g->m.ter(dirx, diry) = t_door_c;
  } else
   g->add_msg("You can't unlock that %s.", g->m.tername(dirx, diry).c_str());
  break;

  // Unused enums added for completeness.
 default:
  break;
 }
}
Exemplo n.º 28
0
void monster::hurt(body_part, int, int dam) {
    hurt(dam);
}
Exemplo n.º 29
0
void monster::apply_damage(Creature* source, body_part bp, int side, int amount) {
    if (is_dead_state()) return; // don't do any more damage if we're already dead
    hurt(bp, side, amount);
    if (is_dead_state()) die(source);
}
Exemplo n.º 30
0
void OreTile::hurt(Level * level, int x, int y, Mob * source, int dmg, int attackDir) {
	hurt(level, x, y, 0);
}