Skip to content

Commit

Permalink
Fix sInv monster spellcasting logic (acrobat)
Browse files Browse the repository at this point in the history
Tracers didn't have can_see_invisible set, badly breaking targeting
for spells like LRD when the player was invisible. Pretty funny,
admittedly.
  • Loading branch information
PleasingFungus committed Dec 8, 2022
1 parent 7324886 commit 946f484
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions crawl-ref/source/beam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,7 @@ void bolt::initialise_fire()
if (reflections > 0)
nightvision = can_see_invis = true;
else
{
// XXX: Should non-agents count as seeing invisible?
nightvision = agent() && agent()->nightvision();
can_see_invis = agent() && agent()->can_see_invisible();
}
precalc_agent_properties();

#ifdef DEBUG_DIAGNOSTICS
// Not a "real" tracer, merely a range/reachability check.
Expand All @@ -747,6 +743,15 @@ void bolt::initialise_fire()
#endif
}

void bolt::precalc_agent_properties()
{
const actor* a = agent();
// XXX: Should non-agents count as seeing invisible?
if (!a) return;
nightvision = a->nightvision();
can_see_invis = a->can_see_invisible();
}

void bolt::apply_beam_conducts()
{
if (!is_tracer && YOU_KILL(thrower))
Expand Down Expand Up @@ -2076,6 +2081,7 @@ void fire_tracer(const monster* mons, bolt &pbolt, bool explode_only,
pbolt.source = mons->pos();
pbolt.source_id = mons->mid;
pbolt.attitude = mons_attitude(*mons);
pbolt.precalc_agent_properties();

// Init tracer variables.
pbolt.foe_info.reset();
Expand Down
1 change: 1 addition & 0 deletions crawl-ref/source/beam.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ struct bolt
void set_target(const dist &targ);
void set_agent(const actor *agent);
void setup_retrace();
void precalc_agent_properties();

// Returns YOU_KILL or MON_KILL, depending on the source of the beam.
killer_type killer() const;
Expand Down

0 comments on commit 946f484

Please sign in to comment.