diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-07-21 04:10:52 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-07-21 04:10:52 +0000 |
commit | a17368df4fcbdf37e3452c6bc4935ba4372aabd8 (patch) | |
tree | 05c1e1c8d83dfb48b191543e158c03e79d270729 /crawl-ref/source/item_use.cc | |
parent | c2aad9d53735d0ac859227b27cd44733a28b31cf (diff) | |
download | crawl-ref-a17368df4fcbdf37e3452c6bc4935ba4372aabd8.tar.gz crawl-ref-a17368df4fcbdf37e3452c6bc4935ba4372aabd8.zip |
Allow unrandart launchers to modify the beam of the missile they fire.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10363 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/item_use.cc')
-rw-r--r-- | crawl-ref/source/item_use.cc | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 5a0ed0af1e..0edf5d15a0 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1849,7 +1849,7 @@ static bool _dispersal_hit_victim(bolt& beam, actor* victim, int dmg, return (true); } -void setup_missile_beam(const actor *agent, bolt &beam, item_def &item, +bool setup_missile_beam(const actor *agent, bolt &beam, item_def &item, std::string &ammo_name, bool &returning) { dungeon_char_type zapsym = DCHAR_SPACE; @@ -1901,10 +1901,30 @@ void setup_missile_beam(const actor *agent, bolt &beam, item_def &item, beam.can_see_invis = agent->can_see_invisible(); - const item_def *launcher = const_cast<actor*>(agent)->weapon(0); + item_def *launcher = const_cast<actor*>(agent)->weapon(0); if (launcher && !item.launched_by(*launcher)) launcher = NULL; + const unrandart_entry* entry = launcher && is_unrandom_artefact(*launcher) + ? get_unrand_entry(launcher->special) : NULL; + + if (entry && entry->fight_func.launch) + { + setup_missile_type sm = + entry->fight_func.launch(launcher, &beam, &ammo_name, + &returning); + + switch(sm) + { + case SM_CONTINUE: + break; + case SM_FINISHED: + return (false); + case SM_CANCEL: + return (true); + } + } + int bow_brand = SPWPN_NORMAL; if (launcher != NULL) bow_brand = get_weapon_brand(*launcher); @@ -2073,6 +2093,8 @@ void setup_missile_beam(const actor *agent, bolt &beam, item_def &item, ammo_name = article_a(ammo_name, true); else ammo_name = "the " + ammo_name; + + return (false); } // XXX This is a bit too generous, as it lets the player determine @@ -2228,7 +2250,12 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, } std::string ammo_name; - setup_missile_beam(&you, pbolt, item, ammo_name, returning); + + if (setup_missile_beam(&you, pbolt, item, ammo_name, returning)) + { + you.turn_is_over = false; + return (false); + } // Did we know the ammo's brand before throwing it? const bool ammo_brand_known = item_type_known(thrown); |