Unify ad_sgld
This commit is contained in:
@@ -2764,6 +2764,7 @@ E void FDECL(mhitm_ad_fire, (struct monst *, struct attack *, struct monst *, st
|
|||||||
E void FDECL(mhitm_ad_cold, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
|
E void FDECL(mhitm_ad_cold, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
|
||||||
E void FDECL(mhitm_ad_elec, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
|
E void FDECL(mhitm_ad_elec, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
|
||||||
E void FDECL(mhitm_ad_acid, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
|
E void FDECL(mhitm_ad_acid, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
|
||||||
|
E void FDECL(mhitm_ad_sgld, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
|
||||||
E int FDECL(damageum, (struct monst *, struct attack *, int));
|
E int FDECL(damageum, (struct monst *, struct attack *, int));
|
||||||
E void FDECL(missum, (struct monst *, struct attack *, BOOLEAN_P));
|
E void FDECL(missum, (struct monst *, struct attack *, BOOLEAN_P));
|
||||||
E int FDECL(passive, (struct monst *, struct obj *, BOOLEAN_P, int,
|
E int FDECL(passive, (struct monst *, struct obj *, BOOLEAN_P, int,
|
||||||
|
|||||||
29
src/mhitm.c
29
src/mhitm.c
@@ -1193,32 +1193,9 @@ int dieroll;
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AD_SGLD:
|
case AD_SGLD:
|
||||||
mhm.damage = 0;
|
mhitm_ad_sgld(magr, mattk, mdef, &mhm);
|
||||||
if (magr->mcan)
|
if (mhm.done)
|
||||||
break;
|
return mhm.hitflags;
|
||||||
/* technically incorrect; no check for stealing gold from
|
|
||||||
* between mdef's feet...
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
struct obj *gold = findgold(mdef->minvent);
|
|
||||||
|
|
||||||
if (!gold)
|
|
||||||
break;
|
|
||||||
obj_extract_self(gold);
|
|
||||||
add_to_minv(magr, gold);
|
|
||||||
}
|
|
||||||
mdef->mstrategy &= ~STRAT_WAITFORU;
|
|
||||||
if (g.vis && canseemon(mdef)) {
|
|
||||||
Strcpy(buf, Monnam(magr));
|
|
||||||
pline("%s steals some gold from %s.", buf, mon_nam(mdef));
|
|
||||||
}
|
|
||||||
if (!tele_restrict(magr)) {
|
|
||||||
boolean couldspot = canspotmon(magr);
|
|
||||||
|
|
||||||
(void) rloc(magr, TRUE);
|
|
||||||
if (g.vis && couldspot && !canspotmon(magr))
|
|
||||||
pline("%s suddenly disappears!", buf);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case AD_DRLI: /* drain life */
|
case AD_DRLI: /* drain life */
|
||||||
mhitm_ad_drli(magr, mattk, mdef, &mhm);
|
mhitm_ad_drli(magr, mattk, mdef, &mhm);
|
||||||
|
|||||||
@@ -1330,11 +1330,9 @@ register struct attack *mattk;
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AD_SGLD:
|
case AD_SGLD:
|
||||||
hitmsg(mtmp, mattk);
|
mhitm_ad_sgld(mtmp, mattk, &g.youmonst, &mhm);
|
||||||
if (g.youmonst.data->mlet == mdat->mlet)
|
if (mhm.done)
|
||||||
break;
|
return mhm.hitflags;
|
||||||
if (!mtmp->mcan)
|
|
||||||
stealgold(mtmp);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AD_SSEX:
|
case AD_SSEX:
|
||||||
|
|||||||
88
src/uhitm.c
88
src/uhitm.c
@@ -2262,6 +2262,74 @@ struct mhitm_data *mhm;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mhitm_ad_sgld(magr, mattk, mdef, mhm)
|
||||||
|
struct monst *magr;
|
||||||
|
struct attack *mattk;
|
||||||
|
struct monst *mdef;
|
||||||
|
struct mhitm_data *mhm;
|
||||||
|
{
|
||||||
|
struct permonst *pa = magr->data;
|
||||||
|
struct permonst *pd = mdef->data;
|
||||||
|
|
||||||
|
if (magr == &g.youmonst) {
|
||||||
|
/* uhitm */
|
||||||
|
struct obj *mongold = findgold(mdef->minvent);
|
||||||
|
|
||||||
|
if (mongold) {
|
||||||
|
obj_extract_self(mongold);
|
||||||
|
if (merge_choice(g.invent, mongold) || inv_cnt(FALSE) < 52) {
|
||||||
|
addinv(mongold);
|
||||||
|
Your("purse feels heavier.");
|
||||||
|
} else {
|
||||||
|
You("grab %s's gold, but find no room in your knapsack.",
|
||||||
|
mon_nam(mdef));
|
||||||
|
dropy(mongold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exercise(A_DEX, TRUE);
|
||||||
|
mhm->damage = 0;
|
||||||
|
} else if (mdef == &g.youmonst) {
|
||||||
|
/* mhitu */
|
||||||
|
hitmsg(magr, mattk);
|
||||||
|
if (pd->mlet == pa->mlet)
|
||||||
|
return;
|
||||||
|
if (!magr->mcan)
|
||||||
|
stealgold(magr);
|
||||||
|
} else {
|
||||||
|
/* mhitm */
|
||||||
|
char buf[BUFSZ];
|
||||||
|
|
||||||
|
mhm->damage = 0;
|
||||||
|
if (magr->mcan)
|
||||||
|
return;
|
||||||
|
/* technically incorrect; no check for stealing gold from
|
||||||
|
* between mdef's feet...
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
struct obj *gold = findgold(mdef->minvent);
|
||||||
|
|
||||||
|
if (!gold)
|
||||||
|
return;
|
||||||
|
obj_extract_self(gold);
|
||||||
|
add_to_minv(magr, gold);
|
||||||
|
}
|
||||||
|
mdef->mstrategy &= ~STRAT_WAITFORU;
|
||||||
|
if (g.vis && canseemon(mdef)) {
|
||||||
|
Strcpy(buf, Monnam(magr));
|
||||||
|
pline("%s steals some gold from %s.", buf, mon_nam(mdef));
|
||||||
|
}
|
||||||
|
if (!tele_restrict(magr)) {
|
||||||
|
boolean couldspot = canspotmon(magr);
|
||||||
|
|
||||||
|
(void) rloc(magr, TRUE);
|
||||||
|
if (g.vis && couldspot && !canspotmon(magr))
|
||||||
|
pline("%s suddenly disappears!", buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Template for monster hits monster for AD_FOO.
|
/* Template for monster hits monster for AD_FOO.
|
||||||
- replace "break" with return
|
- replace "break" with return
|
||||||
@@ -2297,7 +2365,6 @@ int specialdmg; /* blessed and/or silver bonus against various things */
|
|||||||
register struct permonst *pd = mdef->data;
|
register struct permonst *pd = mdef->data;
|
||||||
int armpro;
|
int armpro;
|
||||||
boolean negated;
|
boolean negated;
|
||||||
struct obj *mongold;
|
|
||||||
struct mhitm_data mhm;
|
struct mhitm_data mhm;
|
||||||
mhm.damage = d((int) mattk->damn, (int) mattk->damd);
|
mhm.damage = d((int) mattk->damn, (int) mattk->damd);
|
||||||
mhm.hitflags = MM_MISS;
|
mhm.hitflags = MM_MISS;
|
||||||
@@ -2394,22 +2461,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */
|
|||||||
mhm.damage = 0;
|
mhm.damage = 0;
|
||||||
break;
|
break;
|
||||||
case AD_SGLD:
|
case AD_SGLD:
|
||||||
/* This you as a leprechaun, so steal
|
mhitm_ad_sgld(&g.youmonst, mattk, mdef, &mhm);
|
||||||
real gold only, no lesser coins */
|
if (mhm.done)
|
||||||
mongold = findgold(mdef->minvent);
|
return mhm.hitflags;
|
||||||
if (mongold) {
|
|
||||||
obj_extract_self(mongold);
|
|
||||||
if (merge_choice(g.invent, mongold) || inv_cnt(FALSE) < 52) {
|
|
||||||
addinv(mongold);
|
|
||||||
Your("purse feels heavier.");
|
|
||||||
} else {
|
|
||||||
You("grab %s's gold, but find no room in your knapsack.",
|
|
||||||
mon_nam(mdef));
|
|
||||||
dropy(mongold);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exercise(A_DEX, TRUE);
|
|
||||||
mhm.damage = 0;
|
|
||||||
break;
|
break;
|
||||||
case AD_TLPT:
|
case AD_TLPT:
|
||||||
if (mhm.damage <= 0)
|
if (mhm.damage <= 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user