Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make NPCs defend themselves when shot by player. #12

Merged
merged 1 commit into from
Jan 17, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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