summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/beam.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-04-20 09:37:00 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-04-20 09:37:00 +0000
commitbb3b8b8286b84de95546d1121d0c305bbdc85851 (patch)
treec56eaeeca56855ac86631fa37b2b3128784f7fc1 /crawl-ref/source/beam.cc
parent6452e938ce43d8447bba63a5fcfbaee5e4673baa (diff)
downloadcrawl-ref-bb3b8b8286b84de95546d1121d0c305bbdc85851.tar.gz
crawl-ref-bb3b8b8286b84de95546d1121d0c305bbdc85851.zip
* Fix non-prompting when firing through allies.
* Don't autopickup chunks if starving. (Yes, I died because of that. Xom was very much amused...) * Some spacing fixes. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9668 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/beam.cc')
-rw-r--r--crawl-ref/source/beam.cc217
1 files changed, 111 insertions, 106 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 22f2ca83b4..2110903319 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -189,7 +189,6 @@ static void _ench_animation( int flavour, const monsters *mon, bool force )
bool zapping(zap_type ztype, int power, bolt &pbolt,
bool needs_tracer, const char* msg)
{
-
#if DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "zapping: power=%d", power );
#endif
@@ -1397,7 +1396,7 @@ static void _munge_bounced_bolt(bolt &old_bolt, bolt &new_bolt,
for (int tries = 0; tries < 20; tries++)
{
shift = (double) random_range((int)(min * 10000),
- (int)(max * 10000)) / 10000.0;
+ (int)(max * 10000)) / 10000.0;
if (new_deg < old_deg)
shift = -shift;
@@ -1477,11 +1476,10 @@ void bolt::initialize_fire()
std::string item_name = item ? item->name(DESC_PLAIN, false, true)
: "none";
+
std::string source_name = "unknown";
if (beam_source == NON_MONSTER && source == you.pos())
- {
source_name = "player";
- }
else if (!invalid_monster_index(beam_source))
source_name = menv[beam_source].name(DESC_PLAIN, true);
@@ -1532,7 +1530,7 @@ void bolt::initialize_fire()
draw_delay /= 600;
}
-#if DEBUG_DIAGNOSTICS
+#ifdef DEBUG_DIAGNOSTICS
mprf( MSGCH_DIAGNOSTICS, "%s%s%s [%s] (%d,%d) to (%d,%d): "
"ty=%d col=%d flav=%d hit=%d dam=%dd%d range=%d",
(is_beam) ? "beam" : "missile",
@@ -1603,9 +1601,9 @@ void bolt::draw(const coord_def& p)
{
#ifndef USE_TILE
cgotoxy(drawpos.x, drawpos.y);
- put_colour_ch(
- colour == BLACK ? random_colour() : element_colour(colour),
- type);
+ put_colour_ch(colour == BLACK ? random_colour()
+ : element_colour(colour),
+ type);
#endif
// Get curses to update the screen so we can see the beam.
update_screen();
@@ -1620,13 +1618,15 @@ void bolt::bounce()
bolt old_bolt = *this;
do
{
- do {
+ do
ray.regress();
- } while (grid_is_solid(grd(ray.pos())));
+ while (grid_is_solid(grd(ray.pos())));
+
bounce_pos = ray.pos();
ray.advance_and_bounce();
range_used += 2;
- } while (range_used < range && grid_is_solid(grd(ray.pos())));
+ }
+ while (range_used < range && grid_is_solid(grd(ray.pos())));
if (!grid_is_solid(grd(ray.pos())))
_munge_bounced_bolt(old_bolt, *this, old_ray, ray);
@@ -1803,9 +1803,10 @@ void bolt::hit_wall()
if (pos() != source
&& ((is_explosion && !in_explosion_phase) || drop_item))
{
- do {
+ do
ray.regress();
- } while (ray.pos() != source && grid_is_solid(ray.pos()));
+ while (ray.pos() != source && grid_is_solid(ray.pos()));
+
// target is where the explosion is centered, so update it.
if (is_explosion && !is_tracer)
target = ray.pos();
@@ -1862,15 +1863,16 @@ void bolt::affect_cell()
bool bolt::apply_hit_funcs(actor* victim, int dmg, int corpse)
{
bool affected = false;
- for (unsigned int i = 0; i < hit_funcs.size(); i++)
+ for (unsigned int i = 0; i < hit_funcs.size(); ++i)
affected = (*hit_funcs[i])(*this, victim, dmg, corpse) || affected;
+
return (affected);
}
bool bolt::apply_dmg_funcs(actor* victim, int &dmg,
std::vector<std::string> &messages)
{
- for (unsigned int i = 0; i < damage_funcs.size(); i++)
+ for (unsigned int i = 0; i < damage_funcs.size(); ++i)
{
std::string dmg_msg;
@@ -2449,7 +2451,7 @@ bool mass_enchantment( enchant_type wh_enchant, int pow, int origin,
const kill_category kc = (origin == MHITYOU ? KC_YOU : KC_OTHER);
- for (int i = 0; i < MAX_MONSTERS; i++)
+ for (int i = 0; i < MAX_MONSTERS; ++i)
{
monsters* const monster = &menv[i];
@@ -2718,7 +2720,7 @@ void mimic_alert(monsters *mimic)
return;
bool should_id = !testbits(mimic->flags, MF_KNOWN_MIMIC)
- && you.can_see(mimic);
+ && you.can_see(mimic);
// If we got here, we at least got a resists message, if not
// a full wounds printing. Thus, might as well id the mimic.
@@ -3107,7 +3109,7 @@ void bolt::affect_place_explosion_clouds()
(crawl_state.is_god_acting()) ? crawl_state.which_god_acting()
: GOD_NO_GOD;
const beh_type att =
- whose_kill() == KC_OTHER ? BEH_HOSTILE : BEH_FRIENDLY;
+ (whose_kill() == KC_OTHER ? BEH_HOSTILE : BEH_FRIENDLY);
mons_place(
mgen_data(MONS_FIRE_VORTEX, att, 2, SPELL_FIRE_STORM, p,
@@ -3384,7 +3386,7 @@ void bolt::tracer_affect_player()
apply_dmg_funcs(&you, dummy, messages);
- for (unsigned int i = 0; i < messages.size(); i++)
+ for (unsigned int i = 0; i < messages.size(); ++i)
mpr(messages[i].c_str(), MSGCH_WARN);
range_used += range_used_on_hit(&you);
@@ -3675,7 +3677,7 @@ void bolt::affect_player_enchantment()
break;
}
- mpr( "You convulse!" );
+ mpr("You convulse!");
if (aux_source.empty())
aux_source = "by dispel undead";
@@ -3952,7 +3954,7 @@ void bolt::affect_player()
if (hurted > 0)
{
- for (unsigned int i = 0; i < messages.size(); i++)
+ for (unsigned int i = 0; i < messages.size(); ++i)
mpr(messages[i].c_str(), MSGCH_WARN);
}
@@ -4048,7 +4050,7 @@ bool bolt::determine_damage(monsters* mon, int& preac, int& postac, int& final,
{
// The beam will pass overhead unless it's aimed at them.
if (!aimed_at_spot)
- return false;
+ return (false);
// Electricity is ineffective.
if (flavour == BEAM_ELECTRICITY)
@@ -4056,7 +4058,7 @@ bool bolt::determine_damage(monsters* mon, int& preac, int& postac, int& final,
if (!is_tracer && see_grid(mon->pos()))
mprf("The %s arcs harmlessly into the water.", name.c_str());
finish_beam();
- return false;
+ return (false);
}
// Otherwise, 1/3 damage reduction.
@@ -4085,8 +4087,8 @@ void bolt::handle_stop_attack_prompt(monsters* mon)
if ((thrower == KILL_YOU_MISSILE || thrower == KILL_YOU)
&& !is_harmless(mon))
{
- if ((friend_info.count == 1 && !friend_info.dont_stop)
- || (foe_info.count == 1 && !foe_info.dont_stop))
+ if (friend_info.count == 1 && !friend_info.dont_stop
+ || foe_info.count == 1 && !foe_info.dont_stop)
{
const bool on_target = (target == mon->pos());
if (stop_attack_prompt(mon, true, on_target))
@@ -4109,12 +4111,7 @@ void bolt::tracer_nonenchantment_affect_monster(monsters* mon)
{
std::vector<std::string> messages;
int preac, post, final;
- if ( !determine_damage(mon, preac, post, final, messages) )
- return;
-
- // Maybe the user wants to cancel at this point.
- handle_stop_attack_prompt(mon);
- if (beam_cancelled)
+ if (!determine_damage(mon, preac, post, final, messages))
return;
// Check only if actual damage.
@@ -4137,8 +4134,17 @@ void bolt::tracer_nonenchantment_affect_monster(monsters* mon)
friend_info.power += 2 * final * mons_power(mon->type) / preac;
friend_info.count++;
}
+ }
- for (unsigned int i = 0; i < messages.size(); i++)
+ // Maybe the user wants to cancel at this point.
+ handle_stop_attack_prompt(mon);
+ if (beam_cancelled)
+ return;
+
+ // Check only if actual damage.
+ if (final > 0)
+ {
+ for (unsigned int i = 0; i < messages.size(); ++i)
mpr(messages[i].c_str(), MSGCH_MONSTER_DAMAGE);
}
@@ -4542,7 +4548,7 @@ void bolt::affect_monster(monsters* mon)
if (final > 0)
{
- for (unsigned int i = 0; i < messages.size(); i++)
+ for (unsigned int i = 0; i < messages.size(); ++i)
mpr(messages[i].c_str(), MSGCH_MONSTER_DAMAGE);
}
@@ -5011,7 +5017,7 @@ int bolt::range_used_on_hit(const actor* victim) const
if (in_explosion_phase)
return (used);
- for (unsigned int i = 0; i < range_funcs.size(); i++)
+ for (unsigned int i = 0; i < range_funcs.size(); ++i)
{
if ( (*range_funcs[i])(*this, victim, used) )
break;
@@ -5143,7 +5149,7 @@ void bolt::refine_for_explosion()
if (seeMsg == NULL)
{
seeMsg = "The beam explodes into a cloud of software bugs!";
- hearMsg = "You hear the sound of one hand!";
+ hearMsg = "You hear the sound of one hand clapping!";
}
@@ -5320,9 +5326,8 @@ void bolt::explosion_draw_cell(const coord_def& p)
if (in_los_bounds(drawpos))
{
cgotoxy(drawpos.x, drawpos.y, GOTO_DNGN);
- put_colour_ch(
- colour == BLACK ? random_colour() : colour,
- dchar_glyph(DCHAR_EXPLOSION));
+ put_colour_ch(colour == BLACK ? random_colour() : colour,
+ dchar_glyph(DCHAR_EXPLOSION));
}
#endif
}
@@ -5381,7 +5386,7 @@ void bolt::determine_affected_cells(explosion_map& m, const coord_def& delta,
m(delta + centre) = std::min(count, m(delta + centre));
// Now recurse in every direction.
- for (int i = 0; i < 8; i++)
+ for (int i = 0; i < 8; ++i)
{
const coord_def new_delta = delta + Compass[i];
@@ -5614,78 +5619,78 @@ std::string beam_type_name(beam_type type)
{
switch (type)
{
- case BEAM_NONE: return("none");
- case BEAM_MISSILE: return("missile");
- case BEAM_MMISSILE: return("magic missile");
+ case BEAM_NONE: return("none");
+ case BEAM_MISSILE: return("missile");
+ case BEAM_MMISSILE: return("magic missile");
- case BEAM_POTION_FIRE:
- case BEAM_FIRE: return("fire");
+ case BEAM_POTION_FIRE: // fall through
+ case BEAM_FIRE: return("fire");
- case BEAM_POTION_COLD:
- case BEAM_COLD: return("cold");
+ case BEAM_POTION_COLD: // fall through
+ case BEAM_COLD: return("cold");
- case BEAM_MAGIC: return("magic");
- case BEAM_ELECTRICITY: return("electricity");
+ case BEAM_MAGIC: return("magic");
+ case BEAM_ELECTRICITY: return("electricity");
case BEAM_POTION_STINKING_CLOUD:
- case BEAM_POTION_POISON:
- case BEAM_POISON: return("poison");
-
- case BEAM_NEG: return("negative energy");
- case BEAM_ACID: return("acid");
-
- case BEAM_MIASMA:
- case BEAM_POTION_MIASMA: return("miasma");
-
- case BEAM_SPORE: return("spores");
- case BEAM_POISON_ARROW: return("poison arrow");
- case BEAM_HELLFIRE: return("hellfire");
- case BEAM_NAPALM: return("sticky fire");
-
- case BEAM_POTION_STEAM:
- case BEAM_STEAM: return("steam");
-
- case BEAM_ENERGY: return("energy");
- case BEAM_HOLY: return("holy energy");
- case BEAM_FRAG: return("fragments");
- case BEAM_LAVA: return("magma");
- case BEAM_ICE: return("ice");
- case BEAM_NUKE: return("nuke");
- case BEAM_RANDOM: return("random");
- case BEAM_CHAOS: return("chaos");
- case BEAM_SLOW: return("slow");
- case BEAM_HASTE: return("haste");
- case BEAM_HEALING: return("healing");
- case BEAM_PARALYSIS: return("paralysis");
- case BEAM_CONFUSION: return("confusion");
- case BEAM_INVISIBILITY: return("invisibility");
- case BEAM_DIGGING: return("digging");
- case BEAM_TELEPORT: return("teleportation");
- case BEAM_POLYMORPH: return("polymorph");
- case BEAM_CHARM: return("enslave");
- case BEAM_BANISH: return("banishment");
- case BEAM_DEGENERATE: return("degeneration");
- case BEAM_ENSLAVE_UNDEAD: return("enslave undead");
- case BEAM_ENSLAVE_SOUL: return("enslave soul");
- case BEAM_PAIN: return("pain");
- case BEAM_DISPEL_UNDEAD: return("dispel undead");
- case BEAM_DISINTEGRATION: return("disintegration");
- case BEAM_ENSLAVE_DEMON: return("enslave demon");
- case BEAM_BLINK: return("blink");
- case BEAM_PETRIFY: return("petrify");
- case BEAM_BACKLIGHT: return("backlight");
- case BEAM_SLEEP: return("sleep");
- case BEAM_POTION_BLACK_SMOKE: return("black smoke");
- case BEAM_POTION_GREY_SMOKE: return("grey smoke");
- case BEAM_POTION_BLUE_SMOKE: return("blue smoke");
- case BEAM_POTION_PURP_SMOKE: return("purple smoke");
- case BEAM_POTION_RANDOM: return("random potion");
- case BEAM_VISUAL: return ("visual effects");
- case BEAM_TORMENT_DAMAGE: return("torment damage");
- case BEAM_STEAL_FOOD: return("steal food");
- case NUM_BEAMS:
- DEBUGSTR("invalid beam type");
- return("INVALID");
+ case BEAM_POTION_POISON: // fall through
+ case BEAM_POISON: return("poison");
+
+ case BEAM_NEG: return("negative energy");
+ case BEAM_ACID: return("acid");
+
+ case BEAM_MIASMA: // fall through
+ case BEAM_POTION_MIASMA: return("miasma");
+
+ case BEAM_SPORE: return("spores");
+ case BEAM_POISON_ARROW: return("poison arrow");
+ case BEAM_HELLFIRE: return("hellfire");
+ case BEAM_NAPALM: return("sticky fire");
+
+ case BEAM_POTION_STEAM: // fall through
+ case BEAM_STEAM: return("steam");
+
+ case BEAM_ENERGY: return("energy");
+ case BEAM_HOLY: return("holy energy");
+ case BEAM_FRAG: return("fragments");
+ case BEAM_LAVA: return("magma");
+ case BEAM_ICE: return("ice");
+ case BEAM_NUKE: return("nuke");
+ case BEAM_RANDOM: return("random");
+ case BEAM_CHAOS: return("chaos");
+ case BEAM_SLOW: return("slow");
+ case BEAM_HASTE: return("haste");
+ case BEAM_HEALING: return("healing");
+ case BEAM_PARALYSIS: return("paralysis");
+ case BEAM_CONFUSION: return("confusion");
+ case BEAM_INVISIBILITY: return("invisibility");
+ case BEAM_DIGGING: return("digging");
+ case BEAM_TELEPORT: return("teleportation");
+ case BEAM_POLYMORPH: return("polymorph");
+ case BEAM_CHARM: return("enslave");
+ case BEAM_BANISH: return("banishment");
+ case BEAM_DEGENERATE: return("degeneration");
+ case BEAM_ENSLAVE_UNDEAD: return("enslave undead");
+ case BEAM_ENSLAVE_SOUL: return("enslave soul");
+ case BEAM_PAIN: return("pain");
+ case BEAM_DISPEL_UNDEAD: return("dispel undead");
+ case BEAM_DISINTEGRATION: return("disintegration");
+ case BEAM_ENSLAVE_DEMON: return("enslave demon");
+ case BEAM_BLINK: return("blink");
+ case BEAM_PETRIFY: return("petrify");
+ case BEAM_BACKLIGHT: return("backlight");
+ case BEAM_SLEEP: return("sleep");
+ case BEAM_POTION_BLACK_SMOKE: return("black smoke");
+ case BEAM_POTION_GREY_SMOKE: return("grey smoke");
+ case BEAM_POTION_BLUE_SMOKE: return("blue smoke");
+ case BEAM_POTION_PURP_SMOKE: return("purple smoke");
+ case BEAM_POTION_RANDOM: return("random potion");
+ case BEAM_VISUAL: return ("visual effects");
+ case BEAM_TORMENT_DAMAGE: return("torment damage");
+ case BEAM_STEAL_FOOD: return("steal food");
+
+ case NUM_BEAMS: DEBUGSTR("invalid beam type");
+ return("INVALID");
}
DEBUGSTR("unknown beam type");
return("UNKNOWN");