summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-27 09:58:49 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-27 09:58:49 +0000
commit7aa3305f41d2f073710d9a732bd29572b704bc49 (patch)
tree374aa17118ecb68bc4c237176506dbaf9aafb0b7 /crawl-ref/source/fight.cc
parent3cc681e30ac236f7b88adece29f194cb30138ec8 (diff)
downloadcrawl-ref-7aa3305f41d2f073710d9a732bd29572b704bc49.tar.gz
crawl-ref-7aa3305f41d2f073710d9a732bd29572b704bc49.zip
* Moved most hard-coded non-standard unrandart behaviour to art-func.h,
specifically code for equipping, unequpping, an equipped unrandart doing something every time world_reacts() is called (special wield effects), melee hit effects, and evoking. Left hardcoded outside of art-func.h: * Sword of Cerebov temproarily downgrading the defender's fire resistance. * Staff of Olgreb boosting poison spells, as if it were a staff of poison. * Vampire's Tooth always getting maximal vampiric drain. * Mace of Variablity's initial pluses being chosen at creation time. * Since what used to be special wield effects is now handled very differently, noisy weapons and the lantern of shadows effects are handled with player attributes rather than SPWLD_NOISES and SPWLD_SHADOW. * Unrandarts can now have an elemental colour for their colour (currently only used for the Mace of Variability). * Unrandarts' value modification, being special, and being evil are now handled in art-data.txt rather than being hardcoded. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10055 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc75
1 files changed, 20 insertions, 55 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 5b74a77724..4f7e94b236 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -347,9 +347,8 @@ melee_attack::melee_attack(actor *attk, actor *defn,
to_hit(0), base_damage(0), potential_damage(0), damage_done(0),
special_damage(0), aux_damage(0), stab_attempt(false), stab_bonus(0),
weapon(NULL), damage_brand(SPWPN_NORMAL),
- wpn_skill(SK_UNARMED_COMBAT), hands(HANDS_ONE),
- spwld(SPWLD_NONE), hand_half_bonus(false),
- art_props(0), attack_verb("bug"), verb_degree(),
+ wpn_skill(SK_UNARMED_COMBAT), hands(HANDS_ONE), hand_half_bonus(false),
+ art_props(0), unrand_entry(NULL), attack_verb("bug"), verb_degree(),
no_damage_message(), special_damage_message(), unarmed_attack(),
shield(NULL), defender_shield(NULL),
heavy_armour_penalty(0), can_do_unarmed(false),
@@ -378,14 +377,13 @@ void melee_attack::init_attack()
&& is_artefact( *weapon ))
{
artefact_wpn_properties( *weapon, art_props );
+ if (is_unrandom_artefact( *weapon ))
+ unrand_entry = get_unrand_entry(weapon->special);
}
wpn_skill = weapon ? weapon_skill( *weapon ) : SK_UNARMED_COMBAT;
if (weapon)
- {
hands = hands_reqd( *weapon, attacker->body_size() );
- spwld = item_special_wield_effect( *weapon );
- }
shield = attacker->shield();
if (defender)
@@ -536,25 +534,15 @@ void melee_attack::check_autoberserk()
}
}
-void melee_attack::check_special_wield_effects()
+bool melee_attack::check_unrand_effects(bool mondied)
{
- switch (spwld)
+ if (unrand_entry && unrand_entry->melee_effects_func)
{
- case SPWLD_TROG:
- if (coinflip())
- attacker->go_berserk(false);
- break;
-
- case SPWLD_WUCAD_MU:
- if (one_chance_in(9))
- {
- MiscastEffect(attacker, MELEE_MISCAST, SPTYP_DIVINATION,
- random2(9), random2(70), "the Staff of Wucad Mu");
- }
- break;
- default:
- break;
+ unrand_entry->melee_effects_func(weapon, attacker, defender, mondied);
+ return (!defender->alive());
}
+
+ return (false);
}
void melee_attack::identify_mimic(actor *act)
@@ -597,8 +585,6 @@ bool melee_attack::attack()
// The attacker loses nutrition.
attacker->make_hungry(3, true);
- check_special_wield_effects();
-
// Xom thinks fumbles are funny...
if (attacker->fumbles_attack())
{
@@ -1864,38 +1850,12 @@ void melee_attack::player_exercise_combat_skills()
void melee_attack::player_check_weapon_effects()
{
- if (spwld == SPWLD_TORMENT && coinflip())
- {
- torment(TORMENT_SPWLD, you.pos());
- did_god_conduct(DID_UNHOLY, 5);
- }
-
- if (spwld == SPWLD_ZONGULDROK || spwld == SPWLD_CURSE)
- did_god_conduct(DID_NECROMANCY, 3);
-
- if (weapon)
+ if (weapon && weapon->base_type == OBJ_WEAPONS)
{
- if (weapon->base_type == OBJ_WEAPONS)
- {
- if (is_holy_item(*weapon))
- did_god_conduct(DID_HOLY, 1);
- else if (is_demonic(*weapon))
- did_god_conduct(DID_UNHOLY, 1);
- }
-
- if (is_unrandom_artefact(*weapon))
- {
- switch (weapon->special)
- {
- case UNRAND_ASMODEUS:
- case UNRAND_DISPATER:
- case UNRAND_CEREBOV:
- did_god_conduct(DID_UNHOLY, 3);
- break;
- default:
- break;
- }
- }
+ if (is_holy_item(*weapon))
+ did_god_conduct(DID_HOLY, 1);
+ else if (is_demonic(*weapon))
+ did_god_conduct(DID_UNHOLY, 1);
}
}
@@ -1904,6 +1864,8 @@ bool melee_attack::player_monattk_hit_effects(bool mondied)
{
player_check_weapon_effects();
+ mondied = check_unrand_effects(mondied) || mondied;
+
// Thirsty vampires will try to use a stabbing situation to draw blood.
if (you.species == SP_VAMPIRE && you.hunger_state < HS_SATIATED
&& mondied && stab_attempt && stab_bonus > 0
@@ -4867,6 +4829,9 @@ void melee_attack::mons_perform_attack_rounds()
}
}
+ if (check_unrand_effects())
+ break;
+
if (damage_done < 1 && this_round_hit && !shield_blocked)
mons_announce_dud_hit(attk);