Ejemplo n.º 1
0
void Player::init(int newStrength, int newDexterity, int newIntelligence, int newConstitution, int newPerception, int newLuck, string newName)
{
    // the name will be used to refer to the player during game and for saving/loading purposes
    set_name(newName);

    // check to make sure the values are not lower than zero
    if (newStrength > 0) newStrength = 0;
    if (newDexterity > 0) newDexterity = 0;

    // players start the game with no armour or weapons
    set_armourValue(0);
    set_weaponValue(0);

    // set the stats
    set_strength((float)newStrength);
    set_dexterity((float)newDexterity);
    set_intelligence((float)newIntelligence);
    set_constitution((float)newConstitution);
    set_perception((float)newPerception);
    set_luck((float)newLuck);

    //create a base attack and health value based off of the strength value
    set_baseAttack(10 + ((float)newStrength / 2));
    set_health(100 + ((float)newConstitution * 5));

    // these will always be false at the begining
    set_hasCritical(false);
    set_hasWeapon(false);
    set_isDead(false);
}
Ejemplo n.º 2
0
//initialize is called by each constructor 
void ascii_man::initialize(float _gravity)
{
	set_temp_mv(NULL);
	set_gravity(_gravity);
	set_render(""," 0 "," 8="," /\\","");
	set_pt(20,2);
	set_xt(1.2,1.5);
	set_mv(0,0);
	set_mass(3);
	set_frict((float)0.55);
	dir = 1;
	set_damage(10);
	set_health(50);
}
Ejemplo n.º 3
0
void Enemy::init(float armourValue, float weaponValue, int statLevel)
{
    if (statLevel <= 0) statLevel = 1;

    set_armourValue(armourValue);
    set_weaponValue(weaponValue);

    set_strength((float)statLevel);
    set_dexterity((float)statLevel);

    set_baseAttack(10 + ((float)statLevel / 2));
    set_health(100 + ((float)statLevel * 5));

    set_hasCritical(false);
    set_isDead(false);

    if (weaponValue > 0) set_hasWeapon(true);
    else set_hasWeapon(false);
}
Ejemplo n.º 4
0
void CSE_ActorMP::UPDATE_Read	(NET_Packet &packet)
{
    flags						= 0;
    m_u16NumItems				= 1;
    velocity.set				(0.f,0.f,0.f);

    if (get_health() <= 0)
    {
        actor_mp_state_holder	tmp_state_holder;
        tmp_state_holder.read	(packet);
        return;
    }
    m_state_holder.read			(packet);
    R_ASSERT2(valid_pos(m_state_holder.state().position,phBoundaries), "read bad position");

    m_AliveState.quaternion		= m_state_holder.state().physics_quaternion;
    m_AliveState.angular_vel	= m_state_holder.state().physics_angular_velocity;
    m_AliveState.linear_vel		= m_state_holder.state().physics_linear_velocity;
    m_AliveState.force			= m_state_holder.state().physics_force;
    m_AliveState.torque			= m_state_holder.state().physics_torque;
    m_AliveState.position		= m_state_holder.state().physics_position;

    o_Position					= m_state_holder.state().position;

    accel						= m_state_holder.state().logic_acceleration;

    o_model						= m_state_holder.state().model_yaw;
    o_torso.yaw					= m_state_holder.state().camera_yaw;
    o_torso.pitch				= m_state_holder.state().camera_pitch;
    o_torso.roll				= m_state_holder.state().camera_roll;

    timestamp					= m_state_holder.state().time;

    weapon						= m_state_holder.state().inventory_active_slot;
    mstate						= m_state_holder.state().body_state_flags;
    set_health					( m_state_holder.state().health );
    fRadiation					= m_state_holder.state().radiation;
    m_AliveState.enabled		= m_state_holder.state().physics_state_enabled;

    m_ready_to_update			= true;
    //Msg("* Client 0x%08x UPDATE_Read, health is: %2.04f", this->ID, m_state_holder.state().health);
}
Ejemplo n.º 5
0
void ascii_man::collide(object *obj2, float adj, vector2d temp_mv, float x_over, float y_over)
{
	set_hit_object(obj2);

	if(x_over > y_over) 
	{
		if(this->get_pt().get_x() < obj2->get_pt().get_x())
		{set_hitR(true);}
		else
		{set_hitL(true);}
	}
	if(x_over < y_over)
	{
		if(this->get_pt().get_y() < obj2->get_pt().get_y())
		{set_hitD(true);}
		else
		{set_hitU(true);}
	}
	if (adj < 0.0001)
	{adj=1;}
	set_pt(get_pt() + (get_mv()* adj));
	set_mv(temp_mv * obj2->get_mass());

	if(this->get_mv().get_y() > 0 && get_hitD()==true && obj2->is_fixed()==true)
	{set_mv(get_mv().get_x(),0);}


	if (can_die()==true)
	{
		set_health(get_health()-obj2->get_damage());
	}
	if (get_health() <= 0)
	{
		isdead(true);
	}
	did_collide(true);
	did_move(true);
}
Ejemplo n.º 6
0
bool HealthTelemetryReader::read(TelemetryReader::Context::Ptr context, ipmi::IpmiController&) {
    SelContext* ctx = static_cast<SelContext*>(context.get());
    double shoreup_period = get_metric_definition().get_shoreup_period();

    agent_framework::model::enums::Health::base_enum health{};
    std::set<std::string> events{};
    bool shored_up = false;

    /* Check events */
    bool only_first = get_metric_definition().get_metric_jsonptr().empty();
    do {
        SelContext::FoundRecords critical = ctx->asserting_events(get_critical_events(),
            shoreup_period, shored_up, only_first);
        if (!critical.empty()) {
            log_error("telemetry", get_resource_key() << " event " << critical.front().record->to_string()
                                            << " => critical");
            health = agent_framework::model::enums::Health::Critical;
            if (!only_first) {
                for (const auto& record : critical) {
                    if (record.descr != nullptr) {
                        events.insert(record.descr);
                    }
                }
            }
            break;
        }

        SelContext::FoundRecords warnings = ctx->asserting_events(get_warning_events(),
            shoreup_period, shored_up, only_first);
        if (!warnings.empty()) {
            log_warning("telemetry", get_resource_key() << " event " << warnings.front().record->to_string()
                                              << " => warning");
            health = agent_framework::model::enums::Health::Warning;
            if (!only_first) {
                for (const auto& record : warnings) {
                    if (record.descr != nullptr) {
                        events.insert(record.descr);
                    }
                }
            }
            break;
        }

        health = agent_framework::model::enums::Health::OK;
    } while (false);

    if (shored_up) {
        set_to_be_read(shored_up);
    }

    /* if no events found, add current health to the list. Mostly "OK" */
    if (events.empty()) {
        events.insert(agent_framework::model::enums::Health(health).to_string());
    }

    json::Json value = json::Json();
    if ((!get_metric_definition().get_discrete_metric_type().has_value()) ||
        (get_metric_definition().get_discrete_metric_type().value() != agent_framework::model::enums::DiscreteMetricType::Multiple)) {

        value = *(events.cbegin());
    }
    else {
        value = events;
    }

    bool changed = false;
    if ((get_health() != health) || (get_value() != value)) {
        set_value(value);
        changed = true;
    }
    if (changed) {
        set_health(health);
    }
    return changed;
}
Combat_Screen::Combat_Screen(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Combat_Screen)
{
    ui->setupUi(this);

    set_health();
    set_attack();

    enemy_display_timer = new QTimer;
    hero_display_timer = new QTimer;
    defend_timer = new QTimer;
    attack_timer = new QTimer;
    enemy_timer = new QTimer;

    hero_action_label = new QLabel;
    enemy_action_label = new QLabel;

    enemy_health_display = new QLabel;
    enemy_health_display->setNum(enemy_health);

    attack_button = new QPushButton;
    attack_button->setText("ATTACK");
    attack_button->setDefault(true);

    defend_button = new QPushButton;
    defend_button->setText("DEFEND");

    hero_health_bar = new QProgressBar;
    hero_health_bar->setValue(hero_health);

    QVBoxLayout *left_layout = new QVBoxLayout;
    left_layout->addWidget(hero_health_bar);
    left_layout->addSpacing(100);
    left_layout->addWidget(attack_button);
    left_layout->addWidget(defend_button);

    QLabel *enemy_title = new QLabel;
    QLabel *hp_label = new QLabel;
    enemy_title->setText(enemy_name);
    hp_label->setText(" HP");

    QHBoxLayout *top_right_layout = new QHBoxLayout;
    top_right_layout->addWidget(enemy_title);
    top_right_layout->addWidget(hp_label);
    top_right_layout->addWidget(enemy_health_display);

    QVBoxLayout *right_layout = new QVBoxLayout;
    right_layout->addLayout(top_right_layout);
    right_layout->addStretch();

    QHBoxLayout *top_layout = new QHBoxLayout;
    top_layout->addLayout(left_layout);
    top_layout->addSpacing(100);
    top_layout->addLayout(right_layout);

    QVBoxLayout *bottom_layout = new QVBoxLayout;
    bottom_layout->addWidget(hero_action_label);
    bottom_layout->addWidget(enemy_action_label);

    QVBoxLayout *main_layout = new QVBoxLayout;
    main_layout->addLayout(top_layout);
    main_layout->addLayout(bottom_layout);

    setLayout(main_layout);

    enemy_timer->start(6000);

    QObject::connect(attack_button,SIGNAL(clicked()),
                     this,SLOT(calculate_attack()));

    QObject::connect(enemy_timer,SIGNAL(timeout()),
                     this,SLOT(calculate_enemy_attack()));

    QObject::connect(defend_button,SIGNAL(clicked()),
                     this,SLOT(set_defend()));


}