Skip to content

Commit

Permalink
Merge pull request Whales#12 from ShadowZero/master
Browse files Browse the repository at this point in the history
Make NPCs defend themselves when shot by player.
  • Loading branch information
TheDarklingWolf committed Jan 17, 2013
2 parents 717d335 + 0995248 commit d39f4ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ void shoot_monster(game *g, player &p, monster &mon, int &dam, double goodhit, i

void shoot_player(game *g, player &p, player *h, int &dam, double goodhit)
{
int npcdex = g->npc_at(h->posx, h->posy);
// Gunmods don't have a type, so use the player gun type.
it_gun* firing = dynamic_cast<it_gun*>(p.weapon.type);
body_part hit;
Expand Down Expand Up @@ -979,10 +980,11 @@ void shoot_player(game *g, player &p, player *h, int &dam, double goodhit)
g->add_msg("%s shoots your %s for %d damage!", p.name.c_str(),
body_part_name(hit, side).c_str(), dam);
else {
if (&p == &(g->u))
if (&p == &(g->u)) {
g->add_msg("You shoot %s's %s.", h->name.c_str(),
body_part_name(hit, side).c_str());
else if (g->u_see(h->posx, h->posy, junk))
g->active_npc[npcdex].make_angry();
} else if (g->u_see(h->posx, h->posy, junk))
g->add_msg("%s shoots %s's %s.",
(g->u_see(p.posx, p.posy, junk) ? p.name.c_str() : "Someone"),
h->name.c_str(), body_part_name(hit, side).c_str());
Expand Down

0 comments on commit d39f4ce

Please sign in to comment.