summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/beam.cc2
-rw-r--r--crawl-ref/source/effects.cc1
-rw-r--r--crawl-ref/source/item_use.cc135
-rw-r--r--crawl-ref/source/item_use.h3
-rw-r--r--crawl-ref/source/spells4.cc42
-rw-r--r--crawl-ref/source/spells4.h2
-rw-r--r--crawl-ref/source/spl-cast.cc24
7 files changed, 101 insertions, 108 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 4be9722605..a05b8dc9b6 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -5363,7 +5363,7 @@ static void _explosion_cell(bolt &beam, int x, int y, bool drawOnly)
if (!drawOnly)
{
- // random beams: randomize before affect
+ // Random beams: randomize before affect.
if (beam.flavour == BEAM_RANDOM)
{
random_beam = true;
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index b4d918c1fe..d394a173bd 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -1989,6 +1989,7 @@ void yell(bool force)
one_chance_in(20)? " (and be thought a fool)" : "");
unsigned char keyn = get_ch();
+ mesclr();
switch (keyn)
{
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 7b95625f88..167049ed32 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -341,11 +341,11 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
mpr(you.inv[item_slot].name(DESC_INVENTORY_EQUIP).c_str());
- // warn player about low str/dex or throwing skill
+ // Warn player about low str/dex or throwing skill.
if (show_weff_messages)
wield_warning();
- // time calculations
+ // Time calculations.
you.time_taken /= 2;
you.wield_change = true;
@@ -1408,7 +1408,8 @@ command_type fire_target_behaviour::get_command(int key)
return targeting_behaviour::get_command(key);
}
-static bool _fire_choose_item_and_target(int& slot, dist& target)
+static bool _fire_choose_item_and_target(int& slot, dist& target,
+ bool teleport = false)
{
fire_target_behaviour beh;
const bool was_chosen = (slot != -1);
@@ -1421,12 +1422,12 @@ static bool _fire_choose_item_and_target(int& slot, dist& target)
mpr(warn.c_str());
return false;
}
- beh.m_slot = slot; // force item to be the prechosen one
+ beh.m_slot = slot; // Force item to be the prechosen one.
}
beh.message_ammo_prompt();
- message_current_target(); // XXX: this stuff should be done by direction()
- direction( target, DIR_NONE, TARG_ENEMY, -1, false, true, NULL, &beh );
+ message_current_target(); // XXX: This stuff should be done by direction()!
+ direction( target, DIR_NONE, TARG_ENEMY, -1, false, !teleport, NULL, &beh );
if (beh.m_slot == -1)
{
@@ -1532,29 +1533,41 @@ static bool _fire_warn_if_impossible()
return false;
}
-// if item == -1, prompt the user.
-// if item passed, it will be put into the quiver.
-void fire_thing(int item)
+int get_ammo_to_shoot(int item, dist &target, bool teleport)
{
+ mpr("in get_ammo_to_shoot()");
if (_fire_warn_if_impossible())
{
flush_input_buffer( FLUSH_ON_FAILURE );
- return;
+ return (-1);
}
- if (Options.tutorial_left)
- Options.tut_throw_counter++;
-
- dist target;
- if (!_fire_choose_item_and_target(item, target))
- return;
+ if (!_fire_choose_item_and_target(item, target, teleport))
+ return (-1);
std::string warn;
if (!_fire_validate_item(item, warn))
{
mpr(warn.c_str());
- return;
+ return (-1);
}
+ return (item);
+}
+
+
+// If item == -1, prompt the user.
+// If item passed, it will be put into the quiver.
+void fire_thing(int item)
+{
+ mpr("in fire_thing()");
+ dist target;
+ item = get_ammo_to_shoot(item, target);
+ mpr("back in fire_thing()");
+ if (item == -1)
+ return;
+
+ if (Options.tutorial_left)
+ Options.tut_throw_counter++;
if (check_warning_inscriptions(you.inv[item], OPER_FIRE))
{
@@ -1751,27 +1764,24 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
bool did_return = false; // Returning item actually does return to pack.
int slayDam = 0;
- if (!teleport)
+ if (target)
+ thr = *target;
+ else
{
- if (target)
- thr = *target;
- else
- {
- message_current_target();
- direction( thr, DIR_NONE, TARG_ENEMY );
+ message_current_target();
+ direction( thr, DIR_NONE, TARG_ENEMY );
- if (!thr.isValid)
- {
- if (thr.isCancel)
- canned_msg(MSG_OK);
+ if (!thr.isValid)
+ {
+ if (thr.isCancel)
+ canned_msg(MSG_OK);
- return (false);
- }
+ return (false);
}
}
pbolt.set_target(thr);
- // Making a copy of the item: changed only for venom launchers
+ // Making a copy of the item: changed only for venom launchers.
item_def item = you.inv[throw_2];
item.quantity = 1;
item.slot = index_to_letter(item.link);
@@ -1780,7 +1790,7 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
const object_class_type wepClass = item.base_type;
const int wepType = item.sub_type;
- // figure out if we're thrown or launched
+ // Figure out if we're thrown or launched.
const launch_retval projected = is_launched(&you, you.weapon(), item);
pbolt.name = item.name(DESC_PLAIN, false, false, false);
@@ -1839,24 +1849,26 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
pbolt.attitude = ATT_FRIENDLY;
pbolt.is_tracer = true;
- // init tracer variables
- pbolt.foe_count = pbolt.fr_count = 0;
- pbolt.foe_power = pbolt.fr_power = 0;
- pbolt.fr_helped = pbolt.fr_hurt = 0;
- pbolt.foe_helped = pbolt.foe_hurt = 0;
- pbolt.foe_ratio = 100;
+ // Don't do the tracing when using Portaled Projectile, or when confused.
+ if (!teleport && !you.duration[DUR_CONF])
+ {
+ // Init tracer variables.
+ pbolt.foe_count = pbolt.fr_count = 0;
+ pbolt.foe_power = pbolt.fr_power = 0;
+ pbolt.fr_helped = pbolt.fr_hurt = 0;
+ pbolt.foe_helped = pbolt.foe_hurt = 0;
+ pbolt.foe_ratio = 100;
- // Don't do the tracing when confused.
- if (!you.duration[DUR_CONF])
fire_beam(pbolt);
- // Should only happen if the player answered 'n' to one of those
- // "Fire through friendly?" prompts.
- if (pbolt.fr_count > 0)
- {
- canned_msg(MSG_OK);
- you.turn_is_over = false;
- return (false);
+ // Should only happen if the player answered 'n' to one of those
+ // "Fire through friendly?" prompts.
+ if (pbolt.fr_count > 0)
+ {
+ canned_msg(MSG_OK);
+ you.turn_is_over = false;
+ return (false);
+ }
}
// Now start real firing!
@@ -1886,7 +1898,7 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
thr.ty = you.y_pos + random2(13) - 6;
}
- // even though direction is allowed, we're throwing so we
+ // Even though direction is allowed, we're throwing so we
// want to use tx, ty to make the missile fly to map edge.
if (!teleport)
pbolt.set_target(thr);
@@ -2025,7 +2037,7 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
// i.e. not launched ones. (Sep 10, 2007)
shoot_skill = you.skills[launcher_skill];
- effSkill = shoot_skill;
+ effSkill = shoot_skill;
const int speed = launcher_final_speed(launcher, player_shield());
#ifdef DEBUG_DIAGNOSTICS
@@ -2209,12 +2221,12 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
dice_mult = (dice_mult * 150) / 100;
pbolt.flavour = BEAM_COLD;
- pbolt.name = "bolt of ";
+ pbolt.name = "bolt of ";
if (poisoned)
pbolt.name += "poison ";
- pbolt.name += "frost";
+ pbolt.name += "frost";
pbolt.colour = WHITE;
pbolt.type = dchar_glyph(DCHAR_FIRED_BOLT);
pbolt.thrower = KILL_YOU_MISSILE;
@@ -2349,9 +2361,9 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
baseHit = 1;
break;
case MI_DART:
- exHitBonus = you.skills[SK_DARTS] * 2;
+ exHitBonus = you.skills[SK_DARTS] * 2;
exHitBonus += (you.skills[SK_THROWING] * 2) / 3;
- exDamBonus = you.skills[SK_DARTS] / 3;
+ exDamBonus = you.skills[SK_DARTS] / 3;
exDamBonus += you.skills[SK_THROWING] / 5;
// exercise skills
@@ -2491,8 +2503,9 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
#endif
// Create message.
- mprf( "You %s%s %s.",
- projected? "" : "awkwardly ",
+ mprf( "%s %s%s %s.",
+ teleport ? "Magically, you" : "You",
+ projected ? "" : "awkwardly ",
projected == LRET_LAUNCHED ? "shoot" : "throw",
item.name(DESC_NOCAP_A).c_str() );
@@ -2566,7 +2579,7 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
you.turn_is_over = true;
return (hit);
-} // end throw_it()
+}
bool thrown_object_destroyed( item_def *item, int x, int y, bool returning )
{
@@ -2586,12 +2599,12 @@ bool thrown_object_destroyed( item_def *item, int x, int y, bool returning )
chance = (get_ammo_brand(*item) == SPMSL_CURARE ? 3 : 6);
break;
case MI_SLING_BULLET:
- case MI_STONE: chance = 4; break;
- case MI_DART: chance = 3; break;
- case MI_ARROW: chance = 4; break;
- case MI_BOLT: chance = 4; break;
+ case MI_STONE: chance = 4; break;
+ case MI_DART: chance = 3; break;
+ case MI_ARROW: chance = 4; break;
+ case MI_BOLT: chance = 4; break;
case MI_JAVELIN: chance = 10; break;
- case MI_THROWING_NET: break; // doesn't get destroyed by throwing
+ case MI_THROWING_NET: break; // Doesn't get destroyed by throwing.
case MI_LARGE_ROCK:
default:
diff --git a/crawl-ref/source/item_use.h b/crawl-ref/source/item_use.h
index 311d687317..ed6aece344 100644
--- a/crawl-ref/source/item_use.h
+++ b/crawl-ref/source/item_use.h
@@ -105,7 +105,8 @@ bool remove_ring(int slot = -1, bool announce = false);
* called from: acr
* *********************************************************************** */
int get_next_fire_item(int current, int offset);
-void fire_thing(int item=-1);
+int get_ammo_to_shoot(int item, dist &target, bool teleport = false);
+void fire_thing(int item = -1);
// last updated 12may2000 {dlb}
/* ***********************************************************************
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 3e57abd743..9ef2376bd2 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -30,6 +30,7 @@
#include "directn.h"
#include "dungeon.h"
#include "effects.h"
+#include "invent.h"
#include "it_use2.h"
#include "item_use.h"
#include "itemname.h"
@@ -2099,45 +2100,40 @@ void cast_twist(int pow)
// distribution is much more uniform). -- bwr
int damage = 1 + random2( 3 + pow / 5 );
- // Inflict the damage
+ // Inflict the damage.
player_hurt_monster( mons, damage );
- return;
-} // end cast_twist()
+}
-bool cast_portal_projectile(int pow, bolt& beam)
+bool cast_portal_projectile(int pow)
{
if (pow > 50)
pow = 50;
- if (grid_is_solid(beam.target_x, beam.target_y))
+ dist target;
+ int item = get_ammo_to_shoot(-1, target, true);
+ if (item == -1)
+ return (false);
+
+ if (grid_is_solid(target.tx, target.ty))
{
mpr("You can't shoot at gazebos.");
- return false;
+ return (false);
}
- if (trans_wall_blocking( beam.target_x, beam.target_y ))
+ // Can't use portal through walls. (That'd be just too cheap!)
+ if (trans_wall_blocking( target.tx, target.ty ))
{
mpr("A translucent wall is in the way.");
- return 0;
+ return (false);
}
- int idx;
- const item_def* item;
- you.m_quiver->get_desired_item(&item, &idx);
- if (item == NULL)
- {
- mpr("No suitable missiles.");
- return false;
- }
- else if (idx == -1)
- {
- mpr("No missiles left.");
- return false;
- }
+ if (!check_warning_inscriptions(you.inv[item], OPER_FIRE))
+ return (false);
- throw_it(beam, idx, true, random2(pow/4));
+ bolt beam;
+ throw_it( beam, item, true, random2(pow/4), &target );
- return true;
+ return (true);
}
//
diff --git a/crawl-ref/source/spells4.h b/crawl-ref/source/spells4.h
index 1272857433..71be6ef14a 100644
--- a/crawl-ref/source/spells4.h
+++ b/crawl-ref/source/spells4.h
@@ -54,6 +54,6 @@ void cast_snake_charm(int pow);
void cast_stoneskin(int pow);
int cast_semi_controlled_blink(int pow);
-bool cast_portal_projectile(int pow, bolt& beam);
+bool cast_portal_projectile(int pow);
#endif
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index eb1feb86ed..fa9acad1a2 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -932,7 +932,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail)
// there are others that do their own that will be missed by this
// (and thus will not properly ESC without cost because of it).
// Hopefully, those will eventually be fixed. -- bwr
- if (flags & SPFLAG_TARGETING_MASK)
+ if ((flags & SPFLAG_TARGETING_MASK) && spell != SPELL_PORTAL_PROJECTILE)
{
targ_mode_type targ =
(testbits(flags, SPFLAG_HELPFUL) ? TARG_FRIEND : TARG_ENEMY);
@@ -943,25 +943,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail)
testbits( flags, SPFLAG_DIR ) ? DIR_DIR : DIR_NONE);
const char *prompt = get_spell_target_prompt(spell);
- if (spell == SPELL_PORTAL_PROJECTILE)
- {
- const item_def* item;
- int idx;
- you.m_quiver->get_desired_item(&item, &idx);
- if ( item == NULL )
- {
- mpr("No suitable missiles.");
- return (SPRET_ABORT);
- }
- else if ( idx == -1 )
- {
- mpr("No missiles left.");
- return SPRET_ABORT;
- }
- mprf(MSGCH_PROMPT, "Where do you want to aim %s?",
- you.inv[idx].name(DESC_NOCAP_YOUR).c_str());
- }
- else if (spell == SPELL_EVAPORATE)
+ if (spell == SPELL_EVAPORATE)
{
potion = prompt_invent_item( "Throw which potion?",
MT_INVLIST, OBJ_POTIONS );
@@ -1999,7 +1981,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail)
break;
case SPELL_PORTAL_PROJECTILE:
- if ( !cast_portal_projectile(powc, beam) )
+ if (!cast_portal_projectile(powc))
return SPRET_ABORT;
break;