/** * \brief The monster is injure. * \param attacker The monster attacking me. * \param side The side on which I am attacked. * \param duration The duration of injure state. */ void ptb::gorilla::injure ( const monster& attacker, bear::universe::zone::position side, double duration ) { if ( ( get_current_action_name() == "idle" ) || ( get_current_action_name() == "scan_left" ) || ( get_current_action_name() == "scan_right" ) || ( get_current_action_name() == "come_back" ) ) { m_scan_distance= 500; choose_angry_action(); const base_item* m = dynamic_cast<const base_item*>(&attacker); if ( m != NULL ) { if ( m->get_speed().x > 0 ) get_rendering_attributes().mirror(true); else get_rendering_attributes().mirror(false); } } super::injure(attacker, side, duration); } // ptb::gorilla::injure()
/** * \brief Inform the item tat he is entering the active region. */ void rp::switching::enters_active_region() { super::enters_active_region(); if ( m_initial_state != get_current_action_name() ) { if ( get_current_action_name() == "up" && m_initial_state == "down" ) start_model_action("move down"); else if ( get_current_action_name() == "down" && m_initial_state == "up" ) start_model_action("move up"); } } // switching::enters_active_region()
/** * \brief Inform the item tat he left the active region. */ void ptb::gorilla::leaves_active_region() { super::leaves_active_region(); if ( get_current_action_name() == "dead" ) kill(); } // gorilla::leaves_active_region()
/** * \brief Start dead state. */ void ptb::gorilla::start_dead() { if ( get_current_action_name() != "dead" ) { start_model_action("dead"); m_progress = &gorilla::progress_dead; } } // gorilla::start_dead()
/** * \brief The item has attacked. * \param other The monster that is attacked. */ void ptb::gorilla::has_attacked(const monster& other) { if ( other.get_monster_type() == monster::player_monster ) if ( get_current_action_name() == "attack" ) { set_speed(bear::universe::speed_type(0, 0)); m_want_come_back = true; } } // gorilla::has_attacked()
/** * \brief Inform the item that he have no energy now. * \param attacker The attacker monster. */ void ptb::gorilla::inform_no_energy(const monster& attacker) { m_is_injured = false; if ( get_current_action_name() != "dead" ) { start_dead(); die(attacker); } } // gorilla::inform_no_energy()
/** * \brief Give a string representation of the item. * \param str (out) The result of the convertion. */ void ptb::gorilla::to_string( std::string& str ) const { std::ostringstream oss; super::to_string(str); oss << "state: " << get_current_action_name() << "\n"; oss << "origin_position: " << m_origin_position.x << " " << m_origin_position.y << "\n"; str += oss.str(); } // gorilla::to_string()
/** * \brief Tell is the item has a defensive power. * \param index Index of the power. * \param attacker The attacker. * \param side The side on which the power is checked. */ bool ptb::gorilla::get_defensive_power_by_side ( unsigned int index, const monster& attacker, bear::universe::zone::position side ) const { bool result = super::get_defensive_power_by_side(index, attacker, side); if ( !result ) { if ( side == bear::universe::zone::middle_zone ) { if ( get_current_action_name() == "come_back" ) { const base_item* item = dynamic_cast<const base_item*>(&attacker); if ( ( item != NULL ) && get_rendering_attributes().is_mirrored() ) { if ( item->get_left() >= get_left() ) result = 0; } else if ( item->get_right() <= get_right() ) result = 0; } else result = true; } else if ( get_current_action_name() == "attack" ) { if ( get_rendering_attributes().is_mirrored() ) result = ( side == bear::universe::zone::middle_left_zone ); else result = ( side == bear::universe::zone::middle_right_zone ); } else if ( ( get_current_action_name() == "angry_1" ) || ( get_current_action_name() == "angry_2" ) || ( get_current_action_name() == "angry_3" ) ) result = true; } return result; } // gorilla::get_defensive_power_by_side()
/** * \brief Get the offensive coefficient for a given attacked item and a given * side. * \param index The index of the coefficient. * \param other The attacked monster. * \param side The side of this through which the attack is done. */ unsigned int ptb::gorilla::get_offensive_coefficient ( unsigned int index, const monster& other, bear::universe::zone::position side ) const { unsigned int result; if ( get_current_action_name() == "come_back" ) result = get_offensive_coefficient_come_back(index, other, side); else if ( get_current_action_name() == "attack" ) result = get_offensive_coefficient_attack(index, other, side); else if ( get_current_action_name() == "angry" ) result = get_offensive_coefficient_angry(index, other, side); else { result = super::get_offensive_coefficient(index, other, side); if ( ( index == indefensible_attack ) || ( index == normal_attack ) ) { unsigned int result_attack; if ( index == indefensible_attack ) result_attack = 1; else result_attack = 0; if ( side == bear::universe::zone::middle_zone ) { if ( m_is_injured ) result = 0; else result = result_attack; } } } return result; } // gorilla::get_offensive_coefficient()