本文整理汇总了C++中player::hit_player方法的典型用法代码示例。如果您正苦于以下问题:C++ player::hit_player方法的具体用法?C++ player::hit_player怎么用?C++ player::hit_player使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::hit_player方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hit_player
void player::hit_player(game *g, player &p, bool allow_grab)
{
bool is_u = (this == &(g->u)); // Affects how we'll display messages
if (is_u && p.is_npc()) {
npc* npcPtr = dynamic_cast<npc*>(&p);
npcPtr->make_angry();
}
std::string You = (is_u ? "You" : name);
std::string Your = (is_u ? "Your" : name + "'s");
std::string your = (is_u ? "your" : (male ? "his" : "her"));
std::string verb = "hit";
// Divide their dodge roll by 2 if this is a grab
int target_dodge = (allow_grab ? p.dodge_roll(g) : p.dodge_roll(g) / 2);
int hit_value = hit_roll() - target_dodge;
bool missed = (hit_roll() <= 0);
int move_cost = attack_speed(*this, missed);
if (missed) {
int stumble_pen = stumble(*this);
if (is_u) { // Only display messages if this is the player
if (weapon.has_technique(TEC_FEINT, this))
g->add_msg("You feint.");
else if (stumble_pen >= 60)
g->add_msg("You miss and stumble with the momentum.");
else if (stumble_pen >= 10)
g->add_msg("You swing wildly and miss.");
else
g->add_msg("You miss.");
}
melee_practice(*this, false, unarmed_attack(),
weapon.is_bashing_weapon(), weapon.is_cutting_weapon(),
(weapon.has_flag(IF_SPEAR) || weapon.has_flag(IF_STAB)));
move_cost += stumble_pen;
if (weapon.has_technique(TEC_FEINT, this))
move_cost = rng(move_cost / 3, move_cost);
moves -= move_cost;
return;
}
moves -= move_cost;
body_part bp_hit;
int side = rng(0, 1);
hit_value += rng(-10, 10);
if (hit_value >= 30)
bp_hit = bp_eyes;
else if (hit_value >= 20)
bp_hit = bp_head;
else if (hit_value >= 10)
bp_hit = bp_torso;
else if (one_in(4))
bp_hit = bp_legs;
else
bp_hit = bp_arms;
std::string target = (p.is_npc() ? p.name + "'s " : "your ");
target += body_part_name(bp_hit, side);
bool critical_hit = scored_crit(target_dodge);
int bash_dam = roll_bash_damage(NULL, critical_hit);
int cut_dam = roll_cut_damage(NULL, critical_hit);
int stab_dam = roll_stab_damage(NULL, critical_hit);
technique_id tech_def = p.pick_defensive_technique(g, NULL, this);
p.perform_defensive_technique(tech_def, g, NULL, this, bp_hit, side,
bash_dam, cut_dam, stab_dam);
if (bash_dam + cut_dam + stab_dam <= 0)
return; // Defensive technique canceled our attack!
if (critical_hit) // Crits cancel out Toad Style's armor boost
p.rem_disease(DI_ARMOR_BOOST);
int pain = 0; // Boost to pain; required for perform_technique
// Moves lost to getting your weapon stuck
int stuck_penalty = roll_stuck_penalty(NULL, (stab_dam >= cut_dam));
if (weapon.is_style())
stuck_penalty = 0;
// Pick one or more special attacks
technique_id technique = pick_technique(g, NULL, &p, critical_hit, allow_grab);
// Handles effects as well; not done in melee_affect_*
perform_technique(technique, g, NULL, &p, bash_dam, cut_dam, stab_dam, pain);
p.pain += pain;
// Mutation-based attacks
perform_special_attacks(g, NULL, &p, bash_dam, cut_dam, stab_dam);
// Handles speed penalties to monster & us, etc
melee_special_effects(g, NULL, &p, critical_hit, bash_dam, cut_dam, stab_dam);
// Make a rather quiet sound, to alert any nearby monsters
if (weapon.typeId() != "style_ninjutsu") // Ninjutsu is silent!
g->sound(posx, posy, 8, "");
//.........这里部分代码省略.........