Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/include/extern.h b/include/extern.h
- index e8285c0..4e2af9a 100644
- --- a/include/extern.h
- +++ b/include/extern.h
- @@ -98,6 +98,7 @@ E void FDECL(retouch_equipment, (int));
- E void NDECL(mkot_trap_warn);
- E boolean FDECL(is_magic_key, (struct monst *, struct obj *));
- E struct obj *FDECL(has_magic_key, (struct monst *));
- +E void FDECL(empower_artifact, (struct obj *, struct monst *, BOOLEAN_P));
- /* ### attrib.c ### */
- diff --git a/src/artifact.c b/src/artifact.c
- index 03573fe..045d727 100644
- --- a/src/artifact.c
- +++ b/src/artifact.c
- @@ -2202,4 +2202,75 @@ struct monst *mon; /* if null, hero assumed */
- return (struct obj *) 0;
- }
- +/* Let some artifacts grow in power upon slaying a hated foe. */
- +void
- +empower_artifact(weapon, victim, silent)
- +struct obj *weapon;
- +struct monst *victim;
- +boolean silent;
- +{
- + int chance = 10, tries = 1;
- + const struct artifact *artifact = get_artifact(weapon);
- + if (!artifact || weapon->oclass != WEAPON_CLASS
- + || !bane_applies(artifact, victim))
- + return;
- + if (artifact->spfx & SPFX_DFLAG2) {
- + /* some artifacts have way too common victims -- balance */
- + switch (artifact->mtype) {
- + case M2_ELF:
- + /* somewhat common, moderate levels, mediocre artifact */
- + chance = 25;
- + break;
- + case M2_ORC:
- + /* very common, weak, both artifacts are mundane */
- + chance = 30;
- + break;
- + case M2_DEMON:
- + /* common in hell, can be strong, but artifact is
- + * hardly better than an ordinary silver saber */
- + chance = 40;
- + break;
- + case M2_UNDEAD:
- + /* very common, can be strong, artifact is actually useful */
- + chance = 60;
- + break;
- + default:
- + /* other banes have rare enough victims */
- + break;
- + }
- + } else if (artifact->spfx & SPFX_DALIGN) {
- + /* Sceptre of Might: really stretching it,
- + * but let's throw a bone to illiterate cavepeople */
- + chance = 1000; /* victims incredibly common, so make it rare */
- + }
- + if (victim->mrevived || victim->mcloned) {
- + /* penalize farming dragons/giants/etc. with turn undead */
- + int died = mvitals[monsndx(victim->data)].died;
- + int counter, step;
- + /* almost the same formula as for experience */
- + for (counter = 1, step = 0; step < died; counter++) {
- + chance += chance;
- + died -= step;
- + if (counter & 1)
- + step += 20;
- + }
- + } else if (victim->data->geno & G_UNIQ)
- + tries += rnd(3); /* up to +4 at once, but +2 more likely */
- + while (tries--) {
- + int plus = weapon->spe;
- + if (plus == 127)
- + break; /* not very likely, but let's not ruin anyone's game */
- + if (rn2(victim->m_lev + chance) < chance) /* level : chance odds */
- + continue;
- + /* penalize "unsafe" enchantments, with a discount for +6 -> +7 */
- + if (plus == 6 && rn2(2) || plus > 6 && rn2(5) || plus > 8 && rn2(plus))
- + continue;
- + if (!silent) {
- + pline("%s looks more powerful!", Yname2(weapon));
- + silent = TRUE;
- + }
- + weapon->spe++;
- + }
- +}
- +
- /*artifact.c*/
- diff --git a/src/mhitm.c b/src/mhitm.c
- index 5ebbd84..6ae64f8 100644
- --- a/src/mhitm.c
- +++ b/src/mhitm.c
- @@ -543,6 +543,7 @@ struct attack *mattk;
- silverhit = (weaponhit && otmp
- && objects[otmp->otyp].oc_material == SILVER),
- showit = FALSE;
- + int result;
- /* unhiding or unmimicking happens even if hero can't see it
- because the formerly concealed monster is now in action */
- @@ -637,7 +638,10 @@ struct attack *mattk;
- } else
- noises(magr, mattk);
- - return mdamagem(magr, mdef, mattk);
- + result = mdamagem(magr, mdef, mattk);
- + if (weaponhit && result & MM_DEF_DIED)
- + empower_artifact(otmp, mdef, !vis);
- + return result;
- }
- /* Returns the same values as mdamagem(). */
- diff --git a/src/uhitm.c b/src/uhitm.c
- index 2eedb18..7b72776 100644
- --- a/src/uhitm.c
- +++ b/src/uhitm.c
- @@ -1327,6 +1327,8 @@ int dieroll;
- pline("%s appears confused.", Monnam(mon));
- }
- }
- + if (destroyed)
- + empower_artifact(obj, mon, FALSE);
- if (unpoisonmsg)
- Your("%s %s no longer poisoned.", saved_oname,
- vtense(saved_oname, "are"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement