当前位置: 首页>>代码示例>>C++>>正文


C++ player类代码示例

本文整理汇总了C++中player的典型用法代码示例。如果您正苦于以下问题:C++ player类的具体用法?C++ player怎么用?C++ player使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了player类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: debug

void monster::debug(player &u)
{
    debugmsg("monster::debug %s has %d steps planned.", name().c_str(), plans.size());
    debugmsg("monster::debug %s Moves %d Speed %d HP %d",name().c_str(), moves, get_speed(), hp);
    for (size_t i = 0; i < plans.size(); i++) {
        const int digit = '0' + (i % 10);
        mvaddch(plans[i].y - SEEY + u.posy(), plans[i].x - SEEX + u.posx(), digit);
    }
    getch();
}
开发者ID:reverieAlice,项目名称:Cataclysm-DDA,代码行数:10,代码来源:monster.cpp

示例2: is_valid_player

bool ma_requirements::is_valid_player(player &u)
{
    for( auto buff_id : req_buffs ) {

        if (!u.has_mabuff(buff_id)) {
            return false;
        }
    }

    //A technique is valid if it applies to unarmed strikes, if it applies generally
    //to all weapons (such as Ninjutsu sneak attacks or innate weapon techniques like RAPID)
    //or if the weapon is flagged as being compatible with the style. Some techniques have
    //further restrictions on required weapon properties (is_valid_weapon).
    bool cqb = u.has_active_bionic("bio_cqb");
    bool valid = ((unarmed_allowed && u.unarmed_attack()) ||
                  (melee_allowed && !u.unarmed_attack() && is_valid_weapon(u.weapon)) ||
                  (u.has_weapon() && martialarts[u.style_selected].has_weapon(u.weapon.type->id) &&
                   is_valid_weapon(u.weapon))) &&
                 ((u.skillLevel("melee") >= min_melee &&
                   u.skillLevel("unarmed") >= min_unarmed &&
                   u.skillLevel("bashing") >= min_bashing &&
                   u.skillLevel("cutting") >= min_cutting &&
                   u.skillLevel("stabbing") >= min_stabbing) || cqb);

    return valid;
}
开发者ID:gienkov,项目名称:Cataclysm-DDA,代码行数:26,代码来源:martialarts.cpp

示例3: put_into_vehicle

void put_into_vehicle( player &p, const std::list<item> &items, vehicle &veh, int part )
{
    if( items.empty() ) {
        return;
    }

    const tripoint where = veh.global_part_pos3( part );
    const std::string ter_name = g->m.name( where );
    int fallen_count = 0;

    for( auto it : items ) { // cant use constant reference here because of the spill_contents()
        if( it.is_bucket_nonempty() && !it.spill_contents( p ) ) {
            p.add_msg_player_or_npc(
                _( "To avoid spilling its contents, you set your %1$s on the %2$s." ),
                _( "To avoid spilling its contents, <npcname> sets their %1$s on the %2$s." ),
                it.display_name().c_str(), ter_name.c_str()
            );
            g->m.add_item_or_charges( where, it );
            continue;
        }
        if( !veh.add_item( part, it ) ) {
            if( it.count_by_charges() ) {
                // Maybe we can add a few charges in the trunk and the rest on the ground.
                it.mod_charges( -veh.add_charges( part, it ) );
            }
            g->m.add_item_or_charges( where, it );
            ++fallen_count;
        }
    }

    const std::string part_name = veh.part_info( part ).name();

    if( same_type( items ) ) {
        const item &it = items.front();
        const int dropcount = items.size() * ( it.count_by_charges() ? it.charges : 1 );

        p.add_msg_player_or_npc(
            ngettext( "You put your %1$s in the %2$s's %3$s.",
                      "You put your %1$s in the %2$s's %3$s.", dropcount ),
            ngettext( "<npcname> puts their %1$s in the %2$s's %3$s.",
                      "<npcname> puts their %1$s in the %2$s's %3$s.", dropcount ),
            it.tname( dropcount ).c_str(), veh.name.c_str(), part_name.c_str()
        );
    } else {
        p.add_msg_player_or_npc(
            _( "You put several items in the %1$s's %2$s." ),
            _( "<npcname> puts several items in the %1$s's %2$s." ),
            veh.name.c_str(), part_name.c_str()
        );
    }

    if( fallen_count > 0 ) {
        add_msg( m_warning, _( "The trunk is full, so some items fell to the %s." ), ter_name.c_str() );
    }
}
开发者ID:ProfoundDarkness,项目名称:Cataclysm-DDA,代码行数:55,代码来源:activity_item_handling.cpp

示例4: hit

int monster::hit(game *g, player &p, body_part &bp_hit)
{
 int numdice = type->melee_skill;
 if (dice(numdice, 10) <= dice(p.dodge(g), 10) && !one_in(20)) {
  if (numdice > p.sklevel[sk_dodge])
   p.practice(sk_dodge, 10);
  return 0;	// We missed!
 }
 p.practice(sk_dodge, 5);
 int ret = 0;
 int highest_hit;
 switch (type->size) {
 case MS_TINY:
  highest_hit = 3;
 break;
 case MS_SMALL:
  highest_hit = 12;
 break;
 case MS_MEDIUM:
  highest_hit = 20;
 break;
 case MS_LARGE:
  highest_hit = 28;
 break;
 case MS_HUGE:
  highest_hit = 35;
 break;
 }

 if (has_flag(MF_DIGS))
  highest_hit -= 8;
 if (has_flag(MF_FLIES))
  highest_hit += 20;
 if (highest_hit <= 1)
  highest_hit = 2;
 if (highest_hit > 20)
  highest_hit = 20;

 int bp_rand = rng(0, highest_hit - 1);
      if (bp_rand <=  2)
  bp_hit = bp_legs;
 else if (bp_rand <= 10)
  bp_hit = bp_torso;
 else if (bp_rand <= 14)
  bp_hit = bp_arms;
 else if (bp_rand <= 16)
  bp_hit = bp_mouth;
 else if (bp_rand == 17)
  bp_hit = bp_eyes;
 else
  bp_hit = bp_head;
 ret += dice(type->melee_dice, type->melee_sides);
 return ret;
}
开发者ID:pistacchio,项目名称:Cataclysm,代码行数:54,代码来源:monster.cpp

示例5: get_item_from_inventory

item_location game::get_item_from_inventory( player &p, const std::string &title )
{
    const std::string msg = p.is_npc() ? string_format( _( "%s's inventory is empty." ),
                            p.name.c_str() ) :
                            std::string( _( "Your inventory is empty." ) );

    return inv_internal( p,
    inventory_filter_preset( convert_filter( [ &p ]( const item & it ) {
        return !p.is_worn( it ) && &p.weapon != &it;
    } ) ), title, -1, msg );
}
开发者ID:EpicOrange,项目名称:Cataclysm-DDA,代码行数:11,代码来源:game_inventory.cpp

示例6: test_consumable_ammo

void test_consumable_ammo( player &p, std::string &itemname, bool when_empty, bool when_full )
{
    item it = item( itemname, 0, 0 ) ;

    it.ammo_unset();
    INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.ammo_remaining() ) + " charges" );
    REQUIRE( p.can_consume( it ) == when_empty );

    it.ammo_set( it.ammo_type()->default_ammotype(), -1 ); // -1 -> full
    INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.ammo_remaining() ) + " charges" );
    REQUIRE( p.can_consume( it ) == when_full );
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:12,代码来源:bionics_test.cpp

示例7: pick_up_from_feet

void pick_up_from_feet( player &p, int pos ) {
    auto size_before = g->m.i_at( p.pos() ).size();
    REQUIRE( size_before > pos );
    p.moves = 100;
    p.assign_activity( activity_id( "ACT_PICKUP" ) );
    p.activity.placement = tripoint(0, 0, 0);
    p.activity.values.push_back( false );   // not from vehicle
    p.activity.values.push_back( pos );     // index of item to pick up
    p.activity.values.push_back( 0 );
    p.activity.do_turn( p );
    REQUIRE( g->m.i_at( p.pos() ).size() == size_before - 1 );
}
开发者ID:alapazam,项目名称:Cataclysm-DDA,代码行数:12,代码来源:invlet_test.cpp

示例8: fs2netd_get_pilot_info

int fs2netd_get_pilot_info(const char *callsign, player *out_plr, bool first_call)
{
	if ( !Logged_in ) {
		return -2;
	}

	if ( (out_plr == NULL) || (callsign == NULL) || !(strlen(callsign)) ) {
		return -2;
	}

	static player new_plr;

	if (first_call) {
		new_plr.reset();
		strncpy( new_plr.callsign, callsign, CALLSIGN_LEN );

		// initialize the stats to default values
		init_scoring_element( &new_plr.stats );

		out_plr->reset();

		Local_timeout = timer_get_seconds() + 30;

		In_process = true;

		ml_printf("FS2NetD MSG: Requesting pilot stats for '%s' ...", callsign);
	}

	int rc = FS2NetD_GetPlayerData(callsign, &new_plr, false, first_call);

	// some sort of failure
	if (rc > 0) {
		In_process = false;
		Local_timeout = -1;
		return -2;
	}

	// if timeout passes then bail on failure
	if ( timer_get_seconds() > Local_timeout ) {
		In_process = false;
		Local_timeout = -1;
		return -2;
	}

	if (rc == 0) {
		memcpy( out_plr, &new_plr, sizeof(player) );
		In_process = false;
		Local_timeout = -1;
	}

	// we should only be returning -1 (processing) or 0 (got data successfully)
	return rc;
}
开发者ID:n-kawamt,项目名称:fs2open_snapshot,代码行数:53,代码来源:fs2netd_client.cpp

示例9: setPlayerSprites

//initialize player - more to come, for now just animations
void setPlayerSprites()
{
    if (mainPlayer.getCharName().compare("Flu") == 0)
    {
        mainPlayer.loadPlayerSprites(6);
        mainPlayer.getSprites()[0] = SOIL_load_OGL_texture("Textures/Flu.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
        mainPlayer.getSprites()[1] = SOIL_load_OGL_texture("Textures/Fluattack1.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
        mainPlayer.getSprites()[2] = SOIL_load_OGL_texture("Textures/Fluattack2.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
        mainPlayer.getSprites()[3] = SOIL_load_OGL_texture("Textures/Fluattack3.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
        mainPlayer.getSprites()[4] = SOIL_load_OGL_texture("Textures/Fluattack4.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
        mainPlayer.getSprites()[5] = SOIL_load_OGL_texture("Textures/Fluattack5.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
    }
}
开发者ID:rellena,项目名称:GERMS2.01,代码行数:14,代码来源:playermovefuncs.cpp

示例10: comestible_inventory_preset

        comestible_inventory_preset( const player &p ) : inventory_selector_preset(), p( p ) {

            append_cell( [ p, this ]( const item_location & loc ) {
                return good_bad_none( p.nutrition_for( get_comestible_item( loc ) ) );
            }, _( "NUTRITION" ) );

            append_cell( [ this ]( const item_location & loc ) {
                return good_bad_none( get_edible_comestible( loc ).quench );
            }, _( "QUENCH" ) );

            append_cell( [ p, this ]( const item_location & loc ) {
                return good_bad_none( p.fun_for( get_comestible_item( loc ) ).first );
            }, _( "JOY" ) );

            append_cell( [ this ]( const item_location & loc ) {
                const int spoils = get_edible_comestible( loc ).spoils;
                if( spoils > 0 ) {
                    return to_string_clipped( time_duration::from_turns( spoils ) );
                }
                return std::string();
            }, _( "SPOILS IN" ) );

            append_cell( [ this, &p ]( const item_location & loc ) {
                std::string cbm_name;

                switch( p.get_cbm_rechargeable_with( get_comestible_item( loc ) ) ) {
                    case rechargeable_cbm::none:
                        break;
                    case rechargeable_cbm::battery:
                        cbm_name = _( "Battery" );
                        break;
                    case rechargeable_cbm::reactor:
                        cbm_name = _( "Reactor" );
                        break;
                    case rechargeable_cbm::furnace:
                        cbm_name = _( "Furnace" );
                        break;
                }

                if( !cbm_name.empty() ) {
                    return string_format( "<color_cyan>%s</color>", cbm_name.c_str() );
                }

                return std::string();
            }, _( "CBM" ) );

            append_cell( [ this, &p ]( const item_location & loc ) {
                return good_bad_none( p.get_acquirable_energy( get_comestible_item( loc ) ) );
            }, _( "ENERGY" ) );
        }
开发者ID:RyanMcManaman,项目名称:Cataclysm-DDA,代码行数:50,代码来源:game_inventory.cpp

示例11: crafting_allowed

static bool crafting_allowed( const player &p, const recipe &rec )
{
    if( !p.has_morale_to_craft() ) {
        add_msg( m_info, _( "Your morale is too low to craft..." ) );
        return false;
    }

    if( p.lighting_craft_speed_multiplier( rec ) <= 0.0f ) {
        add_msg( m_info, _( "You can't see to craft!" ) );
        return false;
    }

    return true;
}
开发者ID:AlecWhite,项目名称:Cataclysm-DDA,代码行数:14,代码来源:crafting.cpp

示例12: calculate_missed_by

double calculate_missed_by(player &p, int trange, item* weapon)
{
    // No type for gunmods,so use player weapon.
    it_gun* firing = dynamic_cast<it_gun*>(p.weapon.type);
    // Calculate deviation from intended target (assuming we shoot for the head)
    double deviation = 0.; // Measured in quarter-degrees.
    // Up to 0.75 degrees for each skill point < 8.
    if (p.skillLevel(firing->skill_used) < 8) {
        deviation += rng(0, 3 * (8 - p.skillLevel(firing->skill_used)));
    }

    // Up to 0.25 deg per each skill point < 9.
    if (p.skillLevel("gun") < 9) { deviation += rng(0, 9 - p.skillLevel("gun")); }

    deviation += rng(0, p.ranged_dex_mod());
    deviation += rng(0, p.ranged_per_mod());

    deviation += rng(0, 2 * p.encumb(bp_arms)) + rng(0, 4 * p.encumb(bp_eyes));

    deviation += rng(0, weapon->curammo->dispersion);
    // item::dispersion() doesn't support gunmods.
    deviation += rng(0, p.weapon.dispersion());
    int adj_recoil = p.recoil + p.driving_recoil;
    deviation += rng(int(adj_recoil / 4), adj_recoil);

    if (deviation < 0) { return 0; }
    // .013 * trange is a computationally cheap version of finding the tangent.
    // (note that .00325 * 4 = .013; .00325 is used because deviation is a number
    //  of quarter-degrees)
    // It's also generous; missed_by will be rather short.
    return (.00325 * deviation * trange);
}
开发者ID:CinghialeCdda,项目名称:Cataclysm-DDA,代码行数:32,代码来源:ranged.cpp

示例13: drop_on_map

void drop_on_map( const player &p, const std::list<item> &items, const tripoint &where )
{
    if( items.empty() ) {
        return;
    }
    const std::string ter_name = g->m.name( where );
    const bool can_move_there = g->m.passable( where );

    if( same_type( items ) ) {
        const item &it = items.front();
        const int dropcount = items.size() * ( it.count_by_charges() ? it.charges : 1 );
        const std::string it_name = it.tname( dropcount );

        if( can_move_there ) {
            p.add_msg_player_or_npc(
                ngettext( "You drop your %1$s on the %2$s.",
                          "You drop your %1$s on the %2$s.", dropcount ),
                ngettext( "<npcname> drops their %1$s on the %2$s.",
                          "<npcname> drops their %1$s on the %2$s.", dropcount ),
                it_name.c_str(), ter_name.c_str()
            );
        } else {
            p.add_msg_player_or_npc(
                ngettext( "You put your %1$s in the %2$s.",
                          "You put your %1$s in the %2$s.", dropcount ),
                ngettext( "<npcname> puts their %1$s in the %2$s.",
                          "<npcname> puts their %1$s in the %2$s.", dropcount ),
                it_name.c_str(), ter_name.c_str()
            );
        }
    } else {
        if( can_move_there ) {
            p.add_msg_player_or_npc(
                _( "You drop several items on the %s." ),
                _( "<npcname> drops several items on the %s." ),
                ter_name.c_str()
            );
        } else {
            p.add_msg_player_or_npc(
                _( "You put several items in the %s." ),
                _( "<npcname> puts several items in the %s." ),
                ter_name.c_str()
            );
        }
    }
    for( const auto &it : items ) {
        g->m.add_item_or_charges( where, it );
    }
}
开发者ID:ProfoundDarkness,项目名称:Cataclysm-DDA,代码行数:49,代码来源:activity_item_handling.cpp

示例14: attack_speed

int attack_speed(player &u, bool missed)
{
 int move_cost = u.weapon.attack_time() + 20 * u.encumb(bp_torso);
 if (u.has_trait(PF_LIGHT_BONES))
  move_cost *= .9;
 if (u.has_trait(PF_HOLLOW_BONES))
  move_cost *= .8;

 move_cost -= u.disease_intensity(DI_SPEED_BOOST);

 if (move_cost < 25)
  return 25;

 return move_cost;
}
开发者ID:StoicDwarf,项目名称:Cataclysm-DDA,代码行数:15,代码来源:melee.cpp

示例15: absorb_water

void stomach_contents::absorb_water( player &p, units::volume amount )
{
    if( water < amount ) {
        amount = water;
        water = 0_ml;
    } else {
        water -= amount;
    }
    if( p.get_thirst() < -100 ) {
        return;
    } else if( p.get_thirst() - units::to_milliliter( amount / 5 ) < -100 ) {
        p.set_thirst( -100 );
    }
    p.mod_thirst( -units::to_milliliter( amount ) / 5 );
}
开发者ID:Robik81,项目名称:Cataclysm-DDA,代码行数:15,代码来源:stomach.cpp


注:本文中的player类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。