| 7978 | } |
| 7979 | |
| 7980 | void bolt::do_ranged_attack(actor& targ) |
| 7981 | { |
| 7982 | actor *ag = agent(true); |
| 7983 | // if the immediate agent is now dead, check to see if we can get a |
| 7984 | // usable agent by factoring in reflections. |
| 7985 | // At this point, it is possible that the agent is the dummy monster |
| 7986 | // associated with YOU_FAULTLESS. This case will cause |
| 7987 | // "INVALID YOU_FAULTLESS" to show up in dprfs and mess up the to-hit, |
| 7988 | // but it otherwise works. |
| 7989 | // TODO: is there a good way of handling the to-hit correctly? (And why |
| 7990 | // should the to-hit be affected by reflections at all?) |
| 7991 | // An alternative would be to stop the missile at this point. |
| 7992 | if (!ag) |
| 7993 | ag = agent(false); |
| 7994 | // if that didn't work, blanket fall back on YOU_FAULTLESS. This covers |
| 7995 | // a number of other weird penetration cases. |
| 7996 | if (!ag) |
| 7997 | ag = &env.mons[YOU_FAULTLESS]; |
| 7998 | ASSERT(ag); |
| 7999 | |
| 8000 | // XXX: Use this to track if the player was firing in the direction of a |
| 8001 | // real foe, for purposes of Coglin Rev and similar effects. |
| 8002 | // (This takes advantage of the fact that foes_hurt is not used for |
| 8003 | // any other purpose by ranged attack beams, but this is maybe a little |
| 8004 | // brittle...) |
| 8005 | if (ag->is_player() && !targ.wont_attack() && !targ.is_firewood()) |
| 8006 | foes_hurt++; |
| 8007 | |
| 8008 | ranged_attack attk(ag, &targ, ranged_atk->weapon, use_target_as_pos, agent()); |
| 8009 | attk.will_mulch = ranged_atk->will_mulch; |
| 8010 | |
| 8011 | attk.attack(); |
| 8012 | // XXX: hit_verb is used later to make Damnation bolts only explode on it. |
| 8013 | if (attk.ev_margin >= 0 && hit_verb.empty()) |
| 8014 | hit_verb = attk.attack_verb; |
| 8015 | if (attk.reflected) |
| 8016 | reflect(); |
| 8017 | extra_range_used += attk.range_used; |
| 8018 | if (attk.did_net()) |
| 8019 | drop_item = false; |
| 8020 | } |
| 8021 | |
| 8022 | // Returns the effective willpower an actor with a given willpower would have |
| 8023 | // against hexes from a given source. |
nothing calls this directly
no test coverage detected