这篇教程C++ take_hit函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中take_hit函数的典型用法代码示例。如果您正苦于以下问题:C++ take_hit函数的具体用法?C++ take_hit怎么用?C++ take_hit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了take_hit函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: _greater_focus_rage_spellstatic void _greater_focus_rage_spell(int cmd, variant *res){ switch (cmd) { case SPELL_NAME: var_set_string(res, "Focus *Rage*"); break; case SPELL_DESC: var_set_string(res, "Damage yourself and regain spell points."); break; case SPELL_INFO: if (p_ptr->shero) var_set_string(res, info_damage(0, 0, 2 * p_ptr->lev)); else var_set_string(res, info_damage(0, 0, 10 + p_ptr->lev)); break; case SPELL_FAIL: { int hp = 10 + p_ptr->lev; if (p_ptr->shero) hp = 2 * p_ptr->lev; take_hit(DAMAGE_NOESCAPE, hp, "Rage", -1); break; } case SPELL_CAST: { int hp = 10 + p_ptr->lev; var_set_bool(res, FALSE); if (p_ptr->shero) hp = 2 * p_ptr->lev; if (p_ptr->chp < hp) { if (!get_check("Really? This will kill you!")) return; } take_hit(DAMAGE_NOESCAPE, hp, "Rage", -1); sp_player(hp * 2); _unclear_mind = FALSE; /* Hack to avoid automatic mana drain for this action */ var_set_bool(res, TRUE); break; } default: default_spell(cmd, res); break; }}
开发者ID:Alkalinear,项目名称:poschengband,代码行数:50,
示例2: chest_trap/** * Chests have traps too. * * Exploding chest destroys contents (and traps). * Note that the chest itself is never destroyed. */static void chest_trap(int y, int x, struct object *obj){ int trap; /* Ignore disarmed chests */ if (obj->pval <= 0) return; /* Obtain the traps */ trap = chest_traps[obj->pval]; /* Lose strength */ if (trap & (CHEST_LOSE_STR)) { msg("A small needle has pricked you!"); take_hit(player, damroll(1, 4), "a poison needle"); effect_simple(EF_DRAIN_STAT, "0", STAT_STR, 0, 0, NULL); } /* Lose constitution */ if (trap & (CHEST_LOSE_CON)) { msg("A small needle has pricked you!"); take_hit(player, damroll(1, 4), "a poison needle"); effect_simple(EF_DRAIN_STAT, "0", STAT_CON, 0, 0, NULL); } /* Poison */ if (trap & (CHEST_POISON)) { msg("A puff of green gas surrounds you!"); effect_simple(EF_TIMED_INC, "10+1d20", TMD_POISONED, 0, 0, NULL); } /* Paralyze */ if (trap & (CHEST_PARALYZE)) { msg("A puff of yellow gas surrounds you!"); effect_simple(EF_TIMED_INC, "10+1d20", TMD_PARALYZED, 0, 0, NULL); } /* Summon monsters */ if (trap & (CHEST_SUMMON)) { msg("You are enveloped in a cloud of smoke!"); effect_simple(EF_SUMMON, "2+1d3", 0, 0, 0, NULL); } /* Explode */ if (trap & (CHEST_EXPLODE)) { msg("There is a sudden explosion!"); msg("Everything inside the chest is destroyed!"); obj->pval = 0; take_hit(player, damroll(5, 8), "an exploding chest"); }}
开发者ID:NickMcConnell,项目名称:FirstAgeAngband,代码行数:56,
示例3: melee_effect_handler_SHATTER/** * Melee effect handler: Cause an earthquake around the player. */static void melee_effect_handler_SHATTER(melee_effect_handler_context_t *context){ /* Obvious */ context->obvious = TRUE; /* Hack -- Reduce damage based on the player armor class */ context->damage = adjust_dam_armor(context->damage, context->ac); /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Player is dead */ if (context->p->is_dead) return; /* Radius 8 earthquake centered at the monster */ if (context->damage > 23) { int px_old = context->p->px; int py_old = context->p->py; effect_simple(EF_EARTHQUAKE, "0", 0, 8, 0, NULL); /* Stop the blows if the player is pushed away */ if ((px_old != context->p->px) || (py_old != context->p->py)) context->do_break = TRUE; }}
开发者ID:Elfin-Jedi,项目名称:My-Angband-4.0.5,代码行数:31,
示例4: fall_off_cliff/** * Handle falling off cliffs */void fall_off_cliff(int levels){ int dam; msg("You fall into the darkness!"); /* New chunk */ chunk_change(1, 0, 0); /* Hit the ground... */ if (!tf_has(f_info[cave_feat[p_ptr->py][p_ptr->px]].flags, TF_FALL)) { if (p_ptr->state.ffall) { notice_obj(OF_FEATHER, 0); dam = damroll(2 * levels, 8); (void) inc_timed(TMD_STUN, damroll(2 * levels, 8), TRUE); (void) inc_timed(TMD_CUT, damroll(2 * levels, 8), TRUE); } else { dam = damroll(4 * levels, 8); (void) inc_timed(TMD_STUN, damroll(4 * levels, 8), TRUE); (void) inc_timed(TMD_CUT, damroll(4 * levels, 8), TRUE); } take_hit(dam, "falling off a precipice"); } /* ...or not */ else fall_off_cliff(levels + 1);}
开发者ID:NickMcConnell,项目名称:Beleriand,代码行数:31,
示例5: melee_effect_experience/** * Do damage as the result of an experience draining melee attack. * * /param context is the information for the current attack. * /param chance is the player's chance of resisting drain if they have * OF_HOLD_LIFE. * /param drain_amount is the base amount of experience to drain. */static void melee_effect_experience(melee_effect_handler_context_t *context, int chance, int drain_amount){ /* Obvious */ context->obvious = TRUE; /* Take damage */ take_hit(context->p, context->damage, context->ddesc); update_smart_learn(context->mon, context->p, OF_HOLD_LIFE, 0, -1); /* Player is dead */ if (context->p->is_dead) return; if (player_of_has(context->p, OF_HOLD_LIFE) && (randint0(100) < chance)) { msg("You keep hold of your life force!"); } else { s32b d = drain_amount + (context->p->exp/100) * z_info->life_drain_percent; if (player_of_has(context->p, OF_HOLD_LIFE)) { msg("You feel your life slipping away!"); player_exp_lose(context->p, d / 10, FALSE); } else { msg("You feel your life draining away!"); player_exp_lose(context->p, d, FALSE); } }}
开发者ID:Elfin-Jedi,项目名称:My-Angband-4.0.5,代码行数:36,
示例6: melee_effect_handler_EAT_LIGHT/** * Melee effect handler: Absorb the player's light. */static void melee_effect_handler_EAT_LIGHT(melee_effect_handler_context_t *context){ int light_slot = slot_by_name(context->p, "light"); struct object *obj = slot_object(context->p, light_slot); /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Player is dead */ if (context->p->is_dead) return; /* Drain fuel where applicable */ if (obj && !of_has(obj->flags, OF_NO_FUEL) && (obj->timeout > 0)) { /* Reduce fuel */ obj->timeout -= (250 + randint1(250)); if (obj->timeout < 1) obj->timeout = 1; /* Notice */ if (!context->p->timed[TMD_BLIND]) { msg("Your light dims."); context->obvious = TRUE; } /* Redraw stuff */ context->p->upkeep->redraw |= (PR_EQUIP); }}
开发者ID:Elfin-Jedi,项目名称:My-Angband-4.0.5,代码行数:31,
示例7: hellfire_spellvoid hellfire_spell(int cmd, variant *res){ switch (cmd) { case SPELL_NAME: var_set_string(res, "Hellfire"); break; case SPELL_DESC: var_set_string(res, "Fires a powerful ball of evil power directly from the bowels of hell. Good monsters are especially susceptible."); break; case SPELL_INFO: var_set_string(res, info_damage(0, 0, spell_power(666))); break; case SPELL_CAST: { int dir = 0; var_set_bool(res, FALSE); if (get_aim_dir(&dir)) { fire_ball(GF_HELL_FIRE, dir, spell_power(666), 3); if (!demon_is_(DEMON_BALROG)) take_hit(DAMAGE_USELIFE, 20 + randint1(30), "the strain of casting Hellfire", -1); var_set_bool(res, TRUE); } break; } default: default_spell(cmd, res); break; }}
开发者ID:MichaelDiBernardo,项目名称:poschengband,代码行数:31,
示例8: melee_effect_timed/** * Do damage as the result of a melee attack that has a status effect. * * /param context is the information for the current attack. * /param type is the TMD_ constant for the effect. * /param amount is the amount that the timer should be increased by. * /param of_flag is the OF_ flag that is passed on to monster learning for * this effect. * /param attempt_save indicates if a saving throw should be attempted for * this effect. * /param save_msg is the message that is displayed if the saving throw is * successful. */static void melee_effect_timed(melee_effect_handler_context_t *context, int type, int amount, int of_flag, bool attempt_save, const char *save_msg){ /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Player is dead */ if (context->p->is_dead) return; /* Perform a saving throw if desired. */ if (attempt_save && randint0(100) < context->p->state.skills[SKILL_SAVE]) { if (save_msg != NULL) msg("%s", save_msg); context->obvious = TRUE; } else { /* Increase timer for type. */ if (player_inc_timed(context->p, type, amount, TRUE, TRUE)) context->obvious = TRUE; } /* Learn about the player */ update_smart_learn(context->mon, context->p, of_flag, 0, -1);}
开发者ID:Elfin-Jedi,项目名称:My-Angband-4.0.5,代码行数:40,
示例9: melee_effect_stat/** * Do damage as the result of a melee attack that drains a stat. * * /param context is the information for the current attack. * /param stat is the STAT_ constant for the desired stat. */static void melee_effect_stat(melee_effect_handler_context_t *context, int stat){ /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Damage (stat) */ effect_simple(EF_DRAIN_STAT, "0", stat, 0, 0, &context->obvious);}
开发者ID:Daedelus01,项目名称:angband,代码行数:14,
示例10: take_hitvoidYeti::kill_squished(GameObject& object){ auto player = dynamic_cast<Player*>(&object); if (player) { player->bounce(*this); take_hit(*player); }}
开发者ID:christ2go,项目名称:supertux,代码行数:9,
示例11: melee_effect_handler_HURT/** * Melee effect handler: Hurt the player with no side effects. */static void melee_effect_handler_HURT(melee_effect_handler_context_t *context){ /* Obvious */ context->obvious = TRUE; /* Hack -- Player armor reduces total damage */ context->damage = adjust_dam_armor(context->damage, context->ac); /* Take damage */ take_hit(context->p, context->damage, context->ddesc);}
开发者ID:Daedelus01,项目名称:angband,代码行数:14,
示例12: melee_effect_handler_LOSE_ALL/** * Melee effect handler: Drain all of the player's stats. */static void melee_effect_handler_LOSE_ALL(melee_effect_handler_context_t *context){ /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Damage (stats) */ effect_simple(EF_DRAIN_STAT, "0", STAT_STR, 0, 0, &context->obvious); effect_simple(EF_DRAIN_STAT, "0", STAT_DEX, 0, 0, &context->obvious); effect_simple(EF_DRAIN_STAT, "0", STAT_CON, 0, 0, &context->obvious); effect_simple(EF_DRAIN_STAT, "0", STAT_INT, 0, 0, &context->obvious); effect_simple(EF_DRAIN_STAT, "0", STAT_WIS, 0, 0, &context->obvious);}
开发者ID:Daedelus01,项目名称:angband,代码行数:15,
示例13: melee_effect_handler_EAT_LIGHT/** * Melee effect handler: Absorb the player's light. */static void melee_effect_handler_EAT_LIGHT(melee_effect_handler_context_t *context){ /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Player is dead */ if (context->p->is_dead) return; /* Drain the light source */ effect_simple(EF_DRAIN_LIGHT, "250+1d250", 0, 0, 0, &context->obvious);}
开发者ID:BardurArantsson,项目名称:angband,代码行数:15,
示例14: melee_effect_handler_DISENCHANT/** * Melee effect handler: Disenchant the player. */static void melee_effect_handler_DISENCHANT(melee_effect_handler_context_t *context){ /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Apply disenchantmen if no resist */ if (!player_resists(context->p, ELEM_DISEN)) effect_simple(EF_DISENCHANT, "0", 0, 0, 0, &context->obvious); /* Learn about the player */ update_smart_learn(context->m_ptr, context->p, 0, 0, ELEM_DISEN);}
开发者ID:Daedelus01,项目名称:angband,代码行数:15,
示例15: _pay_coststatic void _pay_cost(int cost){ if (p_ptr->csp < cost) { int dam = cost - p_ptr->csp; p_ptr->csp = 0; take_hit(DAMAGE_USELIFE, dam, "concentrating too hard", -1); } else p_ptr->csp -= cost; p_ptr->redraw |= (PR_MANA | PR_HP);}
开发者ID:NickMcConnell,项目名称:poschengband,代码行数:13,
示例16: melee_effect_handler_HALLU/** * Melee effect handler: Make the player hallucinate. * * Note that we don't use melee_effect_timed(), due to the different monster * learning function. */static void melee_effect_handler_HALLU(melee_effect_handler_context_t *context){ /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Increase "image" */ if (player_inc_timed(context->p, TMD_IMAGE, 3 + randint1(context->rlev / 2), TRUE, TRUE)) context->obvious = TRUE; /* Learn about the player */ update_smart_learn(context->m_ptr, context->p, 0, 0, ELEM_CHAOS);}
开发者ID:Daedelus01,项目名称:angband,代码行数:19,
示例17: melee_effect_handler_EAT_FOOD/** * Melee effect handler: Eat the player's food. */static void melee_effect_handler_EAT_FOOD(melee_effect_handler_context_t *context){ /* Steal some food */ int tries; /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Player is dead */ if (context->p->is_dead) return; for (tries = 0; tries < 10; tries++) { /* Pick an item from the pack */ int index = randint0(z_info->pack_size); struct object *obj, *eaten; char o_name[80]; bool none_left = false; /* Get the item */ obj = context->p->upkeep->inven[index]; /* Skip non-objects */ if (obj == NULL) continue; /* Skip non-food objects */ if (!tval_is_edible(obj)) continue; if (obj->number == 1) { object_desc(o_name, sizeof(o_name), obj, ODESC_BASE); msg("Your %s (%c) was eaten!", o_name, I2A(index)); } else { object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_BASE); msg("One of your %s (%c) was eaten!", o_name, I2A(index)); } /* Steal and eat */ eaten = gear_object_for_use(obj, 1, false, &none_left); if (eaten->known) object_delete(&eaten->known); object_delete(&eaten); /* Obvious */ context->obvious = true; /* Done */ break; }}
开发者ID:BardurArantsson,项目名称:angband,代码行数:54,
示例18: melee_effect_handler_HALLU/** * Melee effect handler: Make the player hallucinate. * * Note that we don't use melee_effect_timed(), due to the different monster * learning function. */static void melee_effect_handler_HALLU(melee_effect_handler_context_t *context){ /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Player is dead */ if (context->p->is_dead) return; /* Increase "image" */ if (player_inc_timed(context->p, TMD_IMAGE, 3 + randint1(context->rlev / 2), true, true)) context->obvious = true; /* Learn about the player */ update_smart_learn(context->mon, context->p, 0, 0, ELEM_CHAOS);}
开发者ID:BardurArantsson,项目名称:angband,代码行数:23,
示例19: melee_effect_elemental/** * Do damage as the result of a melee attack that has an elemental aspect. * * /param context is information for the current attack. * /param type is the GF_ constant for the element. * /param pure_element should be TRUE if no side effects (mostly a hack * for poison). */static void melee_effect_elemental(melee_effect_handler_context_t *context, int type, bool pure_element){ int physical_dam, elemental_dam; if (pure_element) { /* Obvious */ context->obvious = TRUE; } switch (type) { case GF_ACID: msg("You are covered in acid!"); break; case GF_ELEC: msg("You are struck by electricity!"); break; case GF_FIRE: msg("You are enveloped in flames!"); break; case GF_COLD: msg("You are covered with frost!"); break; } /* Give the player a small bonus to ac for elemental attacks */ physical_dam = adjust_dam_armor(context->damage, context->ac + 50); /* Some attacks do no physical damage */ if (!monster_blow_method_physical(context->method)) physical_dam = 0; elemental_dam = adjust_dam(player, type, context->damage, RANDOMISE, 0); /* Take the larger of physical or elemental damage */ context->damage = (physical_dam > elemental_dam) ? physical_dam : elemental_dam; if (context->damage > 0) take_hit(context->p, context->damage, context->ddesc); if (elemental_dam > 0) inven_damage(context->p, type, MIN(elemental_dam * 5, 300)); if (pure_element) { /* Learn about the player */ update_smart_learn(context->m_ptr, context->p, 0, 0, type); }}
开发者ID:Daedelus01,项目名称:angband,代码行数:52,
示例20: _rage_strike_spellstatic void _rage_strike_spell(int cmd, variant *res){ switch (cmd) { case SPELL_NAME: var_set_string(res, "Ragestrike"); break; case SPELL_DESC: var_set_string(res, "Fire a ball of pure rage at chosen foe, striking with everything you've got!"); break; case SPELL_INFO: var_set_string(res, info_damage(0, 0, _rage_strike_dam())); break; case SPELL_FAIL: sp_player(-p_ptr->csp); break; case SPELL_CAST: { int dir; var_set_bool(res, FALSE); if (p_ptr->chp < 100) { if (!get_check("Really? This will kill you!")) return; } if (!get_aim_dir(&dir)) return; fire_ball(GF_MISSILE, dir, _rage_strike_dam(), 0); take_hit(DAMAGE_NOESCAPE, 100, "Rage", -1); if (!p_ptr->shero) set_stun(99, FALSE); /* 100 is Knocked Out */ sp_player(-p_ptr->csp); /* Don't use SPELL_COST_EXTRA since we pay mana up front these days! */ var_set_bool(res, TRUE); break; } default: default_spell(cmd, res); break; }}
开发者ID:Alkalinear,项目名称:poschengband,代码行数:42,
示例21: _pharaohs_curse_spellstatic void _pharaohs_curse_spell(int cmd, variant *res){ switch (cmd) { case SPELL_NAME: var_set_string(res, "Pharaoh's Curse"); break; case SPELL_DESC: var_set_string(res, "Curses all nearby monsters, doing great damage and various effects."); break; case SPELL_CAST: { int power = spell_power(p_ptr->lev * 4); project_hack(GF_PHARAOHS_CURSE, p_ptr->lev + randint1(p_ptr->lev)); if (p_ptr->lev >= 46) confuse_monsters(power); if (p_ptr->lev >= 47) slow_monsters(power); if (p_ptr->lev >= 48) turn_monsters(power); if (p_ptr->lev >= 49) stun_monsters(power); if (one_in_(5)) { int mode = 0; if (one_in_(2)) mode = PM_FORCE_PET; if (summon_named_creature(0, py, px, MON_GREATER_MUMMY, mode)) { msg_print("You have disturbed the rest of an ancient pharaoh!"); } } take_hit(DAMAGE_USELIFE, p_ptr->lev + randint1(p_ptr->lev), "the Pharaoh's Curse", -1); var_set_bool(res, TRUE); } break; default: default_spell(cmd, res); break; }}
开发者ID:bamhamcity,项目名称:lessxpcb,代码行数:41,
示例22: effect_do//.........这里部分代码省略......... if (do_dec_stat(stat, TRUE)) { do_inc_stat(A_DEX); *ident = TRUE; } return TRUE; } case EF_PLEASING: { /* Pick a random stat to decrease other than charisma */ int stat = randint0(A_MAX-1); if (do_dec_stat(stat, TRUE)) { do_inc_stat(A_CHR); *ident = TRUE; } return TRUE; } case EF_LOSE_STR: case EF_LOSE_INT: case EF_LOSE_WIS: case EF_LOSE_DEX: case EF_LOSE_CON: case EF_LOSE_CHR: { int stat = effect - EF_LOSE_STR; take_hit(damroll(5, 5), "stat drain"); (void)do_dec_stat(stat, FALSE); *ident = TRUE; return TRUE; } case EF_LOSE_CON2: { take_hit(damroll(10, 10), "poisonous food"); (void)do_dec_stat(A_CON, FALSE); *ident = TRUE; return TRUE; } case EF_RESTORE_STR: case EF_RESTORE_INT: case EF_RESTORE_WIS: case EF_RESTORE_DEX: case EF_RESTORE_CON: case EF_RESTORE_CHR: { int stat = effect - EF_RESTORE_STR; if (do_res_stat(stat)) *ident = TRUE; return TRUE; } case EF_CURE_NONORLYBIG: { msg("You feel life flow through your body!"); restore_level(); (void)clear_timed(TMD_POISONED, TRUE);
开发者ID:konijn,项目名称:angband,代码行数:67,
示例23: melee_effect_handler_EAT_ITEM/** * Melee effect handler: Take something from the player's inventory. */static void melee_effect_handler_EAT_ITEM(melee_effect_handler_context_t *context){ int tries; /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Saving throw (unless paralyzed) based on dex and level */ if (!context->p->timed[TMD_PARALYZED] && (randint0(100) < (adj_dex_safe[context->p->state.stat_ind[STAT_DEX]] + context->p->lev))) { /* Saving throw message */ msg("You grab hold of your backpack!"); /* Occasional "blink" anyway */ context->blinked = TRUE; /* Obvious */ context->obvious = TRUE; /* Done */ return; } /* Find an item */ for (tries = 0; tries < 10; tries++) { struct object *obj, *stolen; char o_name[80]; bool split = FALSE; /* Pick an item */ int index = randint0(z_info->pack_size); /* Obtain the item */ obj = context->p->upkeep->inven[index]; /* Skip non-objects */ if (obj == NULL) continue; /* Skip artifacts */ if (obj->artifact) continue; /* Get a description */ object_desc(o_name, sizeof(o_name), obj, ODESC_FULL); /* Is it one of a stack being stolen? */ if (obj->number > 1) split = TRUE; /* Message */ msg("%s %s (%c) was stolen!", (split ? "One of your" : "Your"), o_name, I2A(index)); /* Steal and carry */ stolen = gear_object_for_use(obj, 1, FALSE); (void)monster_carry(cave, context->m_ptr, stolen); /* Obvious */ context->obvious = TRUE; /* Blink away */ context->blinked = TRUE; /* Done */ break; }}
开发者ID:Daedelus01,项目名称:angband,代码行数:70,
示例24: melee_effect_handler_EAT_GOLD/** * Melee effect handler: Take the player's gold. */static void melee_effect_handler_EAT_GOLD(melee_effect_handler_context_t *context){ struct player *player = context->p; /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Obvious */ context->obvious = TRUE; /* Attempt saving throw (unless paralyzed) based on dex and level */ if (!player->timed[TMD_PARALYZED] && (randint0(100) < (adj_dex_safe[player->state.stat_ind[STAT_DEX]] + player->lev))) { /* Saving throw message */ msg("You quickly protect your money pouch!"); /* Occasional blink anyway */ if (randint0(3)) context->blinked = TRUE; } else { s32b gold = (player->au / 10) + randint1(25); if (gold < 2) gold = 2; if (gold > 5000) gold = (player->au / 20) + randint1(3000); if (gold > player->au) gold = player->au; player->au -= gold; if (gold <= 0) { msg("Nothing was stolen."); return; } /* Let the player know they were robbed */ msg("Your purse feels lighter."); if (player->au) msg("%d coins were stolen!", gold); else msg("All of your coins were stolen!"); /* While we have gold, put it in objects */ while (gold > 0) { int amt; /* Create a new temporary object */ object_type *obj = object_new(); object_prep(obj, money_kind("gold", gold), 0, MINIMISE); /* Amount of gold to put in this object */ amt = gold > MAX_PVAL ? MAX_PVAL : gold; obj->pval = amt; gold -= amt; /* Set origin to stolen, so it is not confused with * dropped treasure in monster_death */ obj->origin = ORIGIN_STOLEN; obj->origin_depth = player->depth; /* Give the gold to the monster */ monster_carry(cave, context->m_ptr, obj); } /* Redraw gold */ player->upkeep->redraw |= (PR_GOLD); /* Blink away */ context->blinked = TRUE; }}
开发者ID:Daedelus01,项目名称:angband,代码行数:69,
示例25: melee_effect_handler_DRAIN_CHARGES/** * Melee effect handler: Drain charges from the player's inventory. */static void melee_effect_handler_DRAIN_CHARGES(melee_effect_handler_context_t *context){ struct object *obj; struct monster *monster = context->m_ptr; struct player *player = context->p; int tries; int unpower = 0, newcharge; /* Take damage */ take_hit(context->p, context->damage, context->ddesc); /* Find an item */ for (tries = 0; tries < 10; tries++) { /* Pick an item */ obj = context->p->upkeep->inven[randint0(z_info->pack_size)]; /* Skip non-objects */ if (obj == NULL) continue; /* Drain charged wands/staves */ if (tval_can_have_charges(obj)) { /* Charged? */ if (obj->pval) { /* Get number of charge to drain */ unpower = (context->rlev / (obj->kind->level + 2)) + 1; /* Get new charge value, don't allow negative */ newcharge = MAX((obj->pval - unpower),0); /* Remove the charges */ obj->pval = newcharge; } } if (unpower) { int heal = context->rlev * unpower; msg("Energy drains from your pack!"); context->obvious = TRUE; /* Don't heal more than max hp */ heal = MIN(heal, monster->maxhp - monster->hp); /* Heal */ monster->hp += heal; /* Redraw (later) if needed */ if (player->upkeep->health_who == monster) player->upkeep->redraw |= (PR_HEALTH); /* Combine the pack */ player->upkeep->notice |= (PN_COMBINE); /* Redraw stuff */ player->upkeep->redraw |= (PR_INVEN); /* Affect only a single inventory slot */ break; } }}
开发者ID:Daedelus01,项目名称:angband,代码行数:65,
示例26: hp_to_sp_spellvoid hp_to_sp_spell(int cmd, variant *res){ switch (cmd) { case SPELL_NAME: var_set_string(res, "Convert HP to SP"); break; case SPELL_DESC: var_set_string(res, "Converts HP into SP"); break; case SPELL_GAIN_MUT: msg_print("You are subject to fits of painful clarity."); break; case SPELL_LOSE_MUT: msg_print("You are no longer subject to fits of painful clarity."); break; case SPELL_MUT_DESC: var_set_string(res, "Your blood sometimes rushes to your head."); break; case SPELL_PROCESS: if (!p_ptr->anti_magic && one_in_(4000)) { int wounds = p_ptr->msp - p_ptr->csp; if (wounds > 0 && p_ptr->pclass != CLASS_RUNE_KNIGHT) { int healing = p_ptr->chp; if (healing > wounds) healing = wounds; p_ptr->csp += healing; p_ptr->redraw |= (PR_MANA); take_hit(DAMAGE_LOSELIFE, healing, "blood rushing to the head", -1); } } break; case SPELL_CAST: { int gain_sp = take_hit(DAMAGE_USELIFE, p_ptr->lev, "thoughtless convertion from HP to SP", -1) / 5; if (gain_sp && p_ptr->pclass != CLASS_RUNE_KNIGHT) { p_ptr->csp += gain_sp; if (p_ptr->csp > p_ptr->msp) { p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; } p_ptr->redraw |= PR_MANA; } else msg_print("You failed to convert."); var_set_bool(res, TRUE); break; } default: default_spell(cmd, res); break; }}
开发者ID:MichaelDiBernardo,项目名称:poschengband,代码行数:64,
示例27: chest_trap/* * Chests have traps too. * * Exploding chest destroys contents (and traps). * Note that the chest itself is never destroyed. */static void chest_trap(int y, int x, s16b o_idx){ int i, trap; object_type *o_ptr = object_byid(o_idx); /* Ignore disarmed chests */ if (o_ptr->pval[DEFAULT_PVAL] <= 0) return; /* Obtain the traps */ trap = chest_traps[o_ptr->pval[DEFAULT_PVAL]]; /* Lose strength */ if (trap & (CHEST_LOSE_STR)) { msg("A small needle has pricked you!"); take_hit(p_ptr, damroll(1, 4), "a poison needle"); (void)do_dec_stat(A_STR, FALSE); } /* Lose constitution */ if (trap & (CHEST_LOSE_CON)) { msg("A small needle has pricked you!"); take_hit(p_ptr, damroll(1, 4), "a poison needle"); (void)do_dec_stat(A_CON, FALSE); } /* Poison */ if (trap & (CHEST_POISON)) { msg("A puff of green gas surrounds you!"); (void)player_inc_timed(p_ptr, TMD_POISONED, 10 + randint1(20), TRUE, TRUE); } /* Paralyze */ if (trap & (CHEST_PARALYZE)) { msg("A puff of yellow gas surrounds you!"); (void)player_inc_timed(p_ptr, TMD_PARALYZED, 10 + randint1(20), TRUE, TRUE); } /* Summon monsters */ if (trap & (CHEST_SUMMON)) { int num = 2 + randint1(3); msg("You are enveloped in a cloud of smoke!"); sound(MSG_SUM_MONSTER); for (i = 0; i < num; i++) { (void)summon_specific(y, x, p_ptr->depth, 0, 1); } } /* Explode */ if (trap & (CHEST_EXPLODE)) { msg("There is a sudden explosion!"); msg("Everything inside the chest is destroyed!"); o_ptr->pval[DEFAULT_PVAL] = 0; take_hit(p_ptr, damroll(5, 8), "an exploding chest"); }}
开发者ID:JEAus,项目名称:angband,代码行数:70,
示例28: do_cmd_powervoid do_cmd_power(void){ spell_info spells[MAX_SPELLS]; int ct = 0; int choice = 0; race_t *race_ptr = get_race(); class_t *class_ptr = get_class(); if (p_ptr->confused) { msg_print("You are too confused!"); return; } /* Hack ... Rethink this a bit, but the alternative of hacking into the 'm' command is a million times worse! Doppelgangers need to be able to cancel their current mimicry. Also, add Mimic power back first so it always stays in the 'a' slot. */ if (race_ptr->mimic && p_ptr->prace == RACE_DOPPELGANGER) { ct += (get_true_race()->get_powers)(spells + ct, MAX_SPELLS - ct); } if (race_ptr->get_powers != NULL) { ct += (race_ptr->get_powers)(spells + ct, MAX_SPELLS - ct); } if (class_ptr != NULL && class_ptr->get_powers != NULL) { ct += (class_ptr->get_powers)(spells + ct, MAX_SPELLS - ct); } ct += mut_get_powers(spells + ct, MAX_SPELLS - ct); if (ct == 0) { msg_print("You have no powers."); return; } _add_extra_costs_powers(spells, ct); choice = choose_spell(spells, ct, "power", p_ptr->csp + p_ptr->chp); if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN)) { set_action(ACTION_NONE); } if (choice >= 0 && choice < ct) { spell_info *spell = &spells[choice]; if (spell->level > p_ptr->lev) { msg_print("You can't use that power yet!"); return; } if (spell->cost > p_ptr->chp + p_ptr->csp) { msg_print("Using this power will kill you! Why not rest a bit first?"); return; } /* Check for Failure */ if (randint0(100) < spell->fail) { spell_stats_on_fail(spell); sound(SOUND_FAIL); /* Doh! */ fail_spell(spell->fn); if (flush_failure) flush(); msg_print("You failed to concentrate hard enough!"); } else { if (!cast_spell(spell->fn)) return; spell_stats_on_cast(spell); sound(SOUND_ZAP); /* Wahoo! */ } energy_use = get_spell_energy(spell->fn); /* Casting costs spill over into hit points */ if (p_ptr->csp < spell->cost) { int cost = spell->cost - p_ptr->csp; p_ptr->csp = 0; take_hit(DAMAGE_USELIFE, cost, "concentrating too hard", -1); } else p_ptr->csp -= spell->cost; p_ptr->redraw |= (PR_MANA); p_ptr->redraw |= (PR_HP); p_ptr->window |= (PW_SPELL); }}
开发者ID:ZetaZeta,项目名称:poschengband,代码行数:100,
示例29: project_p/** * Called from project() to affect the player * * Called for projections with the PROJECT_PLAY flag set, which includes * bolt, beam, ball and breath effects. * * /param src is the origin of the effect * /param r is the distance from the centre of the effect * /param y the coordinates of the grid being handled * /param x the coordinates of the grid being handled * /param dam is the "damage" from the effect at distance r from the centre * /param typ is the projection (PROJ_) type * /return whether the effects were obvious * * If "r" is non-zero, then the blast was centered elsewhere; the damage * is reduced in project() before being passed in here. This can happen if a * monster breathes at the player and hits a wall instead. * * We assume the player is aware of some effect, and always return "true". */bool project_p(struct source origin, int r, int y, int x, int dam, int typ){ bool blind = (player->timed[TMD_BLIND] ? true : false); bool seen = !blind; bool obvious = true; /* Monster or trap name (for damage) */ char killer[80]; project_player_handler_f player_handler = player_handlers[typ]; project_player_handler_context_t context = { origin, r, y, x, dam, typ, obvious, }; /* No player here */ if (!square_isplayer(cave, y, x)) { return false; } switch (origin.what) { case SRC_PLAYER: /* Never affect projector */ return false; case SRC_MONSTER: { struct monster *mon = cave_monster(cave, origin.which.monster); /* Check it is visible */ if (!monster_is_visible(mon)) seen = false; /* Get the monster's real name */ monster_desc(killer, sizeof(killer), mon, MDESC_DIED_FROM); break; } case SRC_TRAP: { struct trap *trap = origin.which.trap; /* Get the trap name */ strnfmt(killer, sizeof(killer), "a %s", trap->kind->desc); break; } case SRC_OBJECT: { struct object *obj = origin.which.object; object_desc(killer, sizeof(killer), obj, ODESC_PREFIX | ODESC_BASE); break; } case SRC_NONE: { /* Assume the caller has set the killer variable */ break; } } /* Let player know what is going on */ if (!seen) { msg("You are hit by %s!", projections[typ].blind_desc); } /* Adjust damage for resistance, immunity or vulnerability, and apply it */ dam = adjust_dam(player, typ, dam, RANDOMISE, player->state.el_info[typ].res_level, true); if (dam) { take_hit(player, dam, killer); }//.........这里部分代码省略.........
开发者ID:datatypevoid,项目名称:angband,代码行数:101,
示例30: do_cmd_spellvoid do_cmd_spell(void){ spell_info spells[MAX_SPELLS]; caster_info *caster = get_caster_info(); int ct = 0; int choice = 0; int max_cost = 0; if (!caster) { msg_print("You cannot cast spells."); return; } if (p_ptr->confused) { msg_print("You are too confused!"); return; } if (p_ptr->special_defense & KATA_MASK) { set_action(ACTION_NONE); } ct = _get_spell_table(spells, MAX_SPELLS); if (ct == 0) { /* User probably canceled the prompt for a spellbook */ return; } if (caster->options & CASTER_USE_HP) max_cost = p_ptr->chp; else max_cost = p_ptr->csp; choice = choose_spell(spells, ct, caster->magic_desc, max_cost); if (choice >= 0 && choice < ct) { spell_info *spell = &spells[choice]; if (spell->level > p_ptr->lev) { msg_print("You can't use that spell yet!"); return; } /* Verify Cost ... Note, I'm removing options for over exertion Also note we now pay casting costs up front for mana casters. If the user cancels, then we return the cost below. */ if (caster->options & CASTER_USE_HP) { if (spell->cost > p_ptr->chp) { msg_print("You do not have enough hp to use this power."); return; } } else { if (spell->cost > p_ptr->csp) { msg_print("You do not have enough mana to use this power."); return; } p_ptr->csp -= spell->cost; } /* Check for Failure */ if (randint0(100) < spell->fail) { sound(SOUND_FAIL); /* Doh! */ spell_stats_on_fail(spell); fail_spell(spell->fn); if (flush_failure) flush(); msg_print("You failed to concentrate hard enough!"); if (!(caster->options & CASTER_USE_HP) && demigod_is_(DEMIGOD_ATHENA) ) p_ptr->csp += spell->cost/2; if (caster->on_fail != NULL) (caster->on_fail)(spell); } else { if (!cast_spell(spell->fn)) { /* Give back the spell cost, since the user canceled the spell */ if (!(caster->options & CASTER_USE_HP)) p_ptr->csp += spell->cost; return; } spell_stats_on_cast(spell); sound(SOUND_ZAP); /* Wahoo! */ } energy_use = get_spell_energy(spell->fn); if ((caster->options & CASTER_USE_HP) && spell->cost > 0) take_hit(DAMAGE_USELIFE, spell->cost, "concentrating too hard", -1);//.........这里部分代码省略.........
开发者ID:ZetaZeta,项目名称:poschengband,代码行数:101,
注:本文中的take_hit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tal_free函数代码示例 C++ take函数代码示例 |