Ejemplo n.º 1
0
bool cCreature::is_friendly(const iLiving& other) const {
	if(is_friendly() != other.is_friendly())
		return false;
	if(const cCreature* monst = dynamic_cast<const cCreature*>(&other)) {
		if(!is_friendly()) return attitude == monst->attitude;
	}
	// If we get this far, both monsters are friendly to the player.
	// (Or, maybe the other is a player rather than a monster.)
	return true;
}
Ejemplo n.º 2
0
/* Handle the Terrifying Aura of Fear! */
void fear_process_p(void)
{
    int i, r_level;
    for (i = 1; i < m_max; i++)
    {
        monster_type *m_ptr = &m_list[i];
        monster_race *r_ptr;

        if (!m_ptr->r_idx) continue;
        if (!m_ptr->ml) continue;

        r_ptr = &r_info[m_ptr->ap_r_idx];

        if (!(r_ptr->flags2 & RF2_AURA_FEAR)) continue;
        if (is_pet(m_ptr) || is_friendly(m_ptr)) continue;
        if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) continue;

        r_level = _r_level(r_ptr);
        if (!fear_save_p(r_level/MAX(1, m_ptr->cdis-2)))
        {
            char m_name[80];
            monster_desc(m_name, m_ptr, 0);
            msg_format("You behold the terrifying visage of %s!", m_name);
            mon_lore_2(m_ptr, RF2_AURA_FEAR);
            fear_add_p(r_level/MAX(1, m_ptr->cdis-2));
        }
    }
}
Ejemplo n.º 3
0
void HandleAdult::printAttributes(const std::vector<Adult*>& v) const {
	
	std::cout << "Personal information: \n";
	for (auto x: v) {
		std::cout << "Name: " << x->name() << "\n";
		std::cout << "Says: " << x->makenoise() << "\n";
		std::cout << "Age: " << x->age() << "\n";
		std::cout << "Is friendly?: " << is_friendly(x->isFriendly() ) << "\n";
		std::cout << "Gymnasium: " << x->gymnasium() << "\n";
		std::cout << "\n";
	}
}
Ejemplo n.º 4
0
void fear_update_m(monster_type *m_ptr)
{
    monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
    if ((r_ptr->flags2 & RF2_AURA_FEAR) && m_ptr->ml && !is_pet(m_ptr) && !is_friendly(m_ptr))
    {
        int r_level = _r_level(r_ptr);
        if (!fear_save_p(r_level))
        {
            char m_name[80];
            monster_desc(m_name, m_ptr, 0);
            msg_format("You behold the terrifying visage of %s!", m_name);
            mon_lore_2(m_ptr, RF2_AURA_FEAR);
            fear_add_p(r_level);
        }
    }
}
/*
 * Anger the monster
 */
void anger_monster(monster_type *m_ptr)
{
    if (p_ptr->inside_battle) return;
    if (is_friendly(m_ptr))
    {
        char m_name[80];

        monster_desc(m_name, m_ptr, 0);
        msg_format("%^s gets angry!", m_name);

        set_hostile(m_ptr);

        virtue_add(VIRTUE_INDIVIDUALISM, 1);
        virtue_add(VIRTUE_HONOUR, -1);
        virtue_add(VIRTUE_JUSTICE, -1);
        virtue_add(VIRTUE_COMPASSION, -1);
    }
}
Ejemplo n.º 6
0
void creature_t::try_move(int move_x, int move_y)
{
  tile_t* tile = get_tile_at(current_dungeon, move_x, move_y);
  if (tile && (tile_is_walkable_by(*tile, this)))
  {
    creature_t* thing = get_creature_at(current_dungeon, move_x, move_y);
    if (thing)
    {
      if (get_active_effects_for(this) & EF_CONFUSE)
      {
        creature_attacks(this, thing);
      }
      else if ((is_ally() && !thing->is_ally()) || (!is_ally() && thing->is_ally()))
      {
        // The two creatures are enemies.
        creature_attacks(this, thing);
      }
    }
    else if (player.pos.x == move_x && player.pos.y == move_y)
    {
      if (!is_friendly() || (get_active_effects_for(this) & EF_CONFUSE))
      {
        // Not ally with player, or confused.
        creature_attacks(this, &player);
      }
    }
    else
    {
      pos.x = move_x;
      pos.y = move_y;
    }
  }
  else if (tile && tile->id == TILE_DOOR_CLOSED)
  {
    if (flag & CF_INTELLIGENT)
    {
      open_door(current_dungeon, this, move_x, move_y);
      //creature->pos.x = move_x;
      //creature->pos.y = move_y;
    }
  }
}
Ejemplo n.º 7
0
/****************************************************************
 * Spells
 ****************************************************************/
static void _kiss_spell(int cmd, variant *res)
{
    switch (cmd)
    {
    case SPELL_NAME:
        var_set_string(res, "Kiss");
        break;
    case SPELL_DESC:
        var_set_string(res, "Attempt to charm an adjacent monster.");
        break;
    case SPELL_COST_EXTRA:
        var_set_int(res, p_ptr->lev * 2);
        break;
    case SPELL_CAST:
    {
        int y, x, dir = 0, m_idx;
        var_set_bool(res, FALSE);
        if (!get_rep_dir2(&dir)) return;
        if (dir == 5) return;

        y = py + ddy[dir];
        x = px + ddx[dir];

        m_idx = cave[y][x].m_idx;
        if (m_idx)
        {
            monster_type *m_ptr = &m_list[m_idx];
            monster_race *r_ptr = &r_info[m_ptr->r_idx];
            char desc[MAX_NLEN];
            monster_desc(desc, m_ptr, 0);
            if ((r_ptr->flags1 & RF1_UNIQUE) || mon_save_p(m_ptr->r_idx, A_CHR))
            {
                set_monster_csleep(m_idx, 0);
                if (is_hostile(m_ptr))
                {
                    switch (randint1(10))
                    {
                    case 1:
                        msg_format("%^s says 'Impudent Strumpet!'", desc);
                        break;
                    case 2:
                        msg_format("%^s says 'Ewwww! Gross!!'", desc);
                        break;
                    case 3:
                        msg_format("%^s says 'You ain't my type!'", desc);
                        break;
                    default:
                        msg_format("%^s resists your charms.", desc);
                    }

                    if (allow_ticked_off(r_ptr))
                    {
                        m_ptr->anger_ct++;
                    }

                }
                else
                    msg_format("%^s ignores you.", desc);
            }
            else
            {
                if (is_pet(m_ptr))
                    msg_format("%^s slobbers on you affectionately.", desc);
                else if (is_friendly(m_ptr))
                {
                    set_pet(m_ptr);
                    msg_format("%^s is charmed!", desc);
                }
                else
                {
                    set_friendly(m_ptr);
                    msg_format("%^s suddenly becomes friendly.", desc);
                }
            }
            var_set_bool(res, TRUE);
        }
        else
        {
            msg_print("There is no monster.");
        }
        break;
    }
    default:
        default_spell(cmd, res);
        break;
    }
}