summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/beam.cc37
-rw-r--r--crawl-ref/source/beam.h4
-rw-r--r--crawl-ref/source/item_use.cc7
-rw-r--r--crawl-ref/source/mstuff2.cc6
4 files changed, 41 insertions, 13 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 85258125e7..3542b790ef 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -1265,7 +1265,7 @@ static void zappy( zap_type z_type, int power, bolt &pbolt )
void fire_beam( bolt &pbolt, item_def *item )
{
bool beamTerminate; // has beam been 'stopped' by something?
- int tx = 0, ty = 0; // test(new) x,y - integer
+ int &tx(pbolt.pos.x), &ty(pbolt.pos.y); // test(new) x,y - integer
int rangeRemaining;
bool did_bounce = false;
cursor_control coff(false);
@@ -1383,7 +1383,6 @@ void fire_beam( bolt &pbolt, item_def *item )
break;
tx = ray.x();
ty = ray.y();
-
} // end else - beam doesn't affect walls
} // endif - is tx, ty wall?
@@ -1416,7 +1415,8 @@ void fire_beam( bolt &pbolt, item_def *item )
pbolt.flavour = BEAM_FIRE + random2(7);
}
- rangeRemaining -= affect(pbolt, tx, ty);
+ if (!pbolt.affects_nothing)
+ rangeRemaining -= affect(pbolt, tx, ty);
if (random_beam)
{
@@ -4763,19 +4763,19 @@ bool nice_beam( struct monsters *mon, struct bolt &beam )
// (extended from setup_mons_cast() and zapping() which act as limited ones).
bolt::bolt() : range(0), rangeMax(0), type(SYM_ZAP), colour(BLACK),
flavour(BEAM_MAGIC), source_x(0), source_y(0), damage(0,0),
- ench_power(0), hit(0), target_x(0), target_y(0),
+ ench_power(0), hit(0), target_x(0), target_y(0), pos(),
thrower(KILL_MISC), ex_size(0), beam_source(MHITNOT), name(),
is_beam(false), is_explosion(false), is_big_cloud(false),
is_enchant(false), is_energy(false), is_launched(false),
is_thrown(false), target_first(false), aimed_at_spot(false),
- aux_source(), obvious_effect(false), effect_known(true),
- fr_count(0), foe_count(0), fr_power(0), foe_power(0),
- fr_hurt(0), foe_hurt(0), fr_helped(0), foe_helped(0),
- is_tracer(false), aimed_at_feet(false), msg_generated(false),
- in_explosion_phase(false), smart_monster(false),
- can_see_invis(false), attitude(ATT_HOSTILE), foe_ratio(0),
- chose_ray(false)
-{ }
+ aux_source(), affects_nothing(false), obvious_effect(false),
+ effect_known(true), fr_count(0), foe_count(0), fr_power(0),
+ foe_power(0), is_tracer(false), aimed_at_feet(false),
+ msg_generated(false), in_explosion_phase(false),
+ smart_monster(false), can_see_invis(false),
+ attitude(ATT_HOSTILE), foe_ratio(0), chose_ray(false)
+{
+}
killer_type bolt::killer() const
{
@@ -4812,3 +4812,16 @@ void bolt::set_target(const dist &d)
if (d.isEndpoint)
aimed_at_spot = true;
}
+
+void bolt::setup_retrace()
+{
+ if (pos.x && pos.y)
+ {
+ target_x = pos.x;
+ target_y = pos.y;
+ }
+ std::swap(source_x, target_x);
+ std::swap(source_y, target_y);
+ affects_nothing = true;
+ aimed_at_spot = true;
+}
diff --git a/crawl-ref/source/beam.h b/crawl-ref/source/beam.h
index ee8819748b..1e24915025 100644
--- a/crawl-ref/source/beam.h
+++ b/crawl-ref/source/beam.h
@@ -130,6 +130,7 @@ struct bolt
dice_def damage;
int ench_power, hit;
int target_x, target_y; // intended target
+ coord_def pos; // actual position
char thrower; // what kind of thing threw this?
char ex_size; // explosion radius (0==none)
int beam_source; // NON_MONSTER or monster index #
@@ -145,6 +146,8 @@ struct bolt
bool aimed_at_spot; // aimed at (x,y), should not cross
std::string aux_source; // source of KILL_MISC beams
+ bool affects_nothing; // should not hit monsters or features
+
// OUTPUT parameters (tracing, ID)
bool obvious_effect; // did an 'obvious' effect happen?
bool effect_known; // did we _know_ this would happen?
@@ -172,6 +175,7 @@ public:
bolt();
void set_target(const dist &);
+ void setup_retrace();
// Returns YOU_KILL or MON_KILL, depending on the source of the beam.
killer_type killer() const;
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index d3fa865f49..aeca7119d9 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -2255,8 +2255,15 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
}
if ( returning )
+ {
+ // Fire beam in reverse
+ pbolt.setup_retrace();
+ viewwindow(true, false);
+ fire_beam(pbolt, NULL);
+
msg::stream << item.name(DESC_CAP_THE) << " returns to your pack!"
<< std::endl;
+ }
else
dec_inv_item_quantity( throw_2, 1 );
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 621011645d..cfeac23965 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -1375,9 +1375,13 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
if ( really_returns )
{
+ // Fire beam in reverse
+ pbolt.setup_retrace();
+ viewwindow(true, false);
+ fire_beam(pbolt, NULL);
msg::stream << "The weapon returns to "
<< monster->name(DESC_NOCAP_THE)
- << "'s hand!" << std::endl;
+ << "!" << std::endl;
}
if ( !really_returns )