Remove the victim argument to rust_dmg().

The argument can be calculated from `otmp`.
This commit is contained in:
Sean Hunt
2015-03-02 12:49:57 -05:00
parent 5ffd5a3000
commit 9c4b0113aa
6 changed files with 39 additions and 38 deletions
+1 -1
View File
@@ -2203,7 +2203,7 @@ E coord *FDECL(gettrack, (int,int));
/* ### trap.c ### */ /* ### trap.c ### */
E boolean FDECL(burnarmor,(struct monst *)); E boolean FDECL(burnarmor,(struct monst *));
E boolean FDECL(rust_dmg, (struct obj *,const char *,int,BOOLEAN_P,struct monst *)); E boolean FDECL(rust_dmg, (struct obj *,const char *,int,BOOLEAN_P));
E void FDECL(grease_protect, (struct obj *,const char *,struct monst *)); E void FDECL(grease_protect, (struct obj *,const char *,struct monst *));
E struct trap *FDECL(maketrap, (int,int,int)); E struct trap *FDECL(maketrap, (int,int,int));
E void FDECL(fall_through, (BOOLEAN_P)); E void FDECL(fall_through, (BOOLEAN_P));
+1 -1
View File
@@ -983,7 +983,7 @@ dokick()
if(!rn2(3)) goto ouch; if(!rn2(3)) goto ouch;
/* make metal boots rust */ /* make metal boots rust */
if(uarmf && rn2(3)) if(uarmf && rn2(3))
if (!rust_dmg(uarmf, "metal boots", 1, FALSE, &youmonst)) { if (!rust_dmg(uarmf, "metal boots", 1, FALSE)) {
Your("boots get wet."); Your("boots get wet.");
/* could cause short-lived fumbling here */ /* could cause short-lived fumbling here */
} }
+7 -7
View File
@@ -740,12 +740,12 @@ int attk;
while (1) { while (1) {
switch(rn2(5)) { switch(rn2(5)) {
case 0: case 0:
if (!uarmh || !rust_dmg(uarmh, xname(uarmh), hurt, FALSE, &youmonst)) if (!uarmh || !rust_dmg(uarmh, xname(uarmh), hurt, FALSE))
continue; continue;
break; break;
case 1: case 1:
if (uarmc) { if (uarmc) {
(void)rust_dmg(uarmc, xname(uarmc), hurt, TRUE, &youmonst); (void)rust_dmg(uarmc, xname(uarmc), hurt, TRUE);
break; break;
} }
/* Note the difference between break and continue; /* Note the difference between break and continue;
@@ -754,20 +754,20 @@ int attk;
* something else did. * something else did.
*/ */
if (uarm) if (uarm)
(void)rust_dmg(uarm, xname(uarm), hurt, TRUE, &youmonst); (void)rust_dmg(uarm, xname(uarm), hurt, TRUE);
else if (uarmu) else if (uarmu)
(void)rust_dmg(uarmu, xname(uarmu), hurt, TRUE, &youmonst); (void)rust_dmg(uarmu, xname(uarmu), hurt, TRUE);
break; break;
case 2: case 2:
if (!uarms || !rust_dmg(uarms, xname(uarms), hurt, FALSE, &youmonst)) if (!uarms || !rust_dmg(uarms, xname(uarms), hurt, FALSE))
continue; continue;
break; break;
case 3: case 3:
if (!uarmg || !rust_dmg(uarmg, xname(uarmg), hurt, FALSE, &youmonst)) if (!uarmg || !rust_dmg(uarmg, xname(uarmg), hurt, FALSE))
continue; continue;
break; break;
case 4: case 4:
if (!uarmf || !rust_dmg(uarmf, xname(uarmf), hurt, FALSE, &youmonst)) if (!uarmf || !rust_dmg(uarmf, xname(uarmf), hurt, FALSE))
continue; continue;
break; break;
} }
+2 -2
View File
@@ -113,9 +113,9 @@ dosit()
in_water: in_water:
You("sit in the water."); You("sit in the water.");
if (!rn2(10) && uarm) if (!rn2(10) && uarm)
(void) rust_dmg(uarm, "armor", 1, TRUE, &youmonst); (void) rust_dmg(uarm, "armor", 1, TRUE);
if (!rn2(10) && uarmf && uarmf->otyp != WATER_WALKING_BOOTS) if (!rn2(10) && uarmf && uarmf->otyp != WATER_WALKING_BOOTS)
(void) rust_dmg(uarm, "armor", 1, TRUE, &youmonst); (void) rust_dmg(uarm, "armor", 1, TRUE);
} else if(IS_SINK(typ)) { } else if(IS_SINK(typ)) {
You(sit_message, defsyms[S_sink].explanation); You(sit_message, defsyms[S_sink].explanation);
Your("%s gets wet.", humanoid(youmonst.data) ? "rump" : "underside"); Your("%s gets wet.", humanoid(youmonst.data) ? "rump" : "underside");
+17 -16
View File
@@ -55,7 +55,7 @@ struct monst *victim;
int mat_idx; int mat_idx;
if (!victim) return 0; if (!victim) return 0;
#define burn_dmg(obj,descr) rust_dmg(obj, descr, 0, FALSE, victim) #define burn_dmg(obj,descr) rust_dmg(obj, descr, 0, FALSE)
while (1) { while (1) {
switch (rn2(5)) { switch (rn2(5)) {
case 0: case 0:
@@ -107,20 +107,21 @@ struct monst *victim;
* returned only for rustable items. * returned only for rustable items.
*/ */
boolean boolean
rust_dmg(otmp, ostr, type, print, victim) rust_dmg(otmp, ostr, type, print)
register struct obj *otmp; register struct obj *otmp;
register const char *ostr; register const char *ostr;
int type; int type;
boolean print; boolean print;
struct monst *victim;
{ {
static NEARDATA const char * const action[] = { "smoulder", "rust", "rot", "corrode" }; static NEARDATA const char * const action[] = { "smoulder", "rust", "rot", "corrode" };
static NEARDATA const char * const msg[] = { "burnt", "rusted", "rotten", "corroded" }; static NEARDATA const char * const msg[] = { "burnt", "rusted", "rotten", "corroded" };
boolean vulnerable = FALSE; boolean vulnerable = FALSE;
boolean grprot = FALSE; boolean grprot = FALSE;
boolean is_primary = TRUE; boolean is_primary = TRUE;
boolean vismon = (victim != &youmonst) && canseemon(victim);
int erosion; int erosion;
struct monst *victim =
carried(otmp) ? &youmonst : mcarried(otmp) ? otmp->ocarry : NULL;
boolean vismon = (victim != &youmonst) && canseemon(victim);
if (!otmp) return(FALSE); if (!otmp) return(FALSE);
switch(type) { switch(type) {
@@ -920,17 +921,17 @@ unsigned trflags;
pline("%s you on the %s!", A_gush_of_water_hits, pline("%s you on the %s!", A_gush_of_water_hits,
body_part(HEAD)); body_part(HEAD));
(void) rust_dmg(uarmh, helm_simple_name(uarmh), (void) rust_dmg(uarmh, helm_simple_name(uarmh),
1, TRUE, &youmonst); 1, TRUE);
break; break;
case 1: case 1:
pline("%s your left %s!", A_gush_of_water_hits, pline("%s your left %s!", A_gush_of_water_hits,
body_part(ARM)); body_part(ARM));
if (rust_dmg(uarms, "shield", 1, TRUE, &youmonst)) if (rust_dmg(uarms, "shield", 1, TRUE))
break; break;
if (u.twoweap || (uwep && bimanual(uwep))) if (u.twoweap || (uwep && bimanual(uwep)))
(void) erode_obj(u.twoweap ? uswapwep : uwep, (void) erode_obj(u.twoweap ? uswapwep : uwep,
1, TRUE, FALSE); 1, TRUE, FALSE);
glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst); glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE);
/* Not "metal gauntlets" since it gets called /* Not "metal gauntlets" since it gets called
* even if it's leather for the message * even if it's leather for the message
*/ */
@@ -948,11 +949,11 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst);
(void) snuff_lit(otmp); (void) snuff_lit(otmp);
if (uarmc) if (uarmc)
(void) rust_dmg(uarmc, cloak_simple_name(uarmc), (void) rust_dmg(uarmc, cloak_simple_name(uarmc),
1, TRUE, &youmonst); 1, TRUE);
else if (uarm) else if (uarm)
(void) rust_dmg(uarm, "armor", 1, TRUE, &youmonst); (void) rust_dmg(uarm, "armor", 1, TRUE);
else if (uarmu) else if (uarmu)
(void) rust_dmg(uarmu, "shirt", 1, TRUE, &youmonst); (void) rust_dmg(uarmu, "shirt", 1, TRUE);
} }
update_inventory(); update_inventory();
break; break;
@@ -2051,20 +2052,20 @@ register struct monst *mtmp;
mon_nam(mtmp), mbodypart(mtmp, HEAD)); mon_nam(mtmp), mbodypart(mtmp, HEAD));
target = which_armor(mtmp, W_ARMH); target = which_armor(mtmp, W_ARMH);
(void) rust_dmg(target, helm_simple_name(target), (void) rust_dmg(target, helm_simple_name(target),
1, TRUE, mtmp); 1, TRUE);
break; break;
case 1: case 1:
if (in_sight) if (in_sight)
pline("%s %s's left %s!", A_gush_of_water_hits, pline("%s %s's left %s!", A_gush_of_water_hits,
mon_nam(mtmp), mbodypart(mtmp, ARM)); mon_nam(mtmp), mbodypart(mtmp, ARM));
target = which_armor(mtmp, W_ARMS); target = which_armor(mtmp, W_ARMS);
if (rust_dmg(target, "shield", 1, TRUE, mtmp)) if (rust_dmg(target, "shield", 1, TRUE))
break; break;
target = MON_WEP(mtmp); target = MON_WEP(mtmp);
if (target && bimanual(target)) if (target && bimanual(target))
(void) erode_obj(target, 1, TRUE, FALSE); (void) erode_obj(target, 1, TRUE, FALSE);
glovecheck: target = which_armor(mtmp, W_ARMG); glovecheck: target = which_armor(mtmp, W_ARMG);
(void) rust_dmg(target, "gauntlets", 1, TRUE, mtmp); (void) rust_dmg(target, "gauntlets", 1, TRUE);
break; break;
case 2: case 2:
if (in_sight) if (in_sight)
@@ -2083,11 +2084,11 @@ glovecheck: target = which_armor(mtmp, W_ARMG);
if ((target = which_armor(mtmp, W_ARMC)) != 0) if ((target = which_armor(mtmp, W_ARMC)) != 0)
(void) rust_dmg(target, (void) rust_dmg(target,
cloak_simple_name(target), cloak_simple_name(target),
1, TRUE, mtmp); 1, TRUE);
else if ((target = which_armor(mtmp, W_ARM)) != 0) else if ((target = which_armor(mtmp, W_ARM)) != 0)
(void) rust_dmg(target, "armor", 1, TRUE, mtmp); (void) rust_dmg(target, "armor", 1, TRUE);
else if ((target = which_armor(mtmp, W_ARMU)) != 0) else if ((target = which_armor(mtmp, W_ARMU)) != 0)
(void) rust_dmg(target, "shirt", 1, TRUE, mtmp); (void) rust_dmg(target, "shirt", 1, TRUE);
} }
if (mptr == &mons[PM_IRON_GOLEM]) { if (mptr == &mons[PM_IRON_GOLEM]) {
+11 -11
View File
@@ -56,34 +56,34 @@ int attk;
switch(rn2(5)) { switch(rn2(5)) {
case 0: case 0:
target = which_armor(mdef, W_ARMH); target = which_armor(mdef, W_ARMH);
if (!target || !rust_dmg(target, xname(target), hurt, FALSE, mdef)) if (!target || !rust_dmg(target, xname(target), hurt, FALSE))
continue; continue;
break; break;
case 1: case 1:
target = which_armor(mdef, W_ARMC); target = which_armor(mdef, W_ARMC);
if (target) { if (target) {
(void)rust_dmg(target, xname(target), hurt, TRUE, mdef); (void)rust_dmg(target, xname(target), hurt, TRUE);
break; break;
} }
if ((target = which_armor(mdef, W_ARM)) != (struct obj *)0) { if ((target = which_armor(mdef, W_ARM)) != (struct obj *)0) {
(void)rust_dmg(target, xname(target), hurt, TRUE, mdef); (void)rust_dmg(target, xname(target), hurt, TRUE);
} else if ((target = which_armor(mdef, W_ARMU)) != (struct obj *)0) { } else if ((target = which_armor(mdef, W_ARMU)) != (struct obj *)0) {
(void)rust_dmg(target, xname(target), hurt, TRUE, mdef); (void)rust_dmg(target, xname(target), hurt, TRUE);
} }
break; break;
case 2: case 2:
target = which_armor(mdef, W_ARMS); target = which_armor(mdef, W_ARMS);
if (!target || !rust_dmg(target, xname(target), hurt, FALSE, mdef)) if (!target || !rust_dmg(target, xname(target), hurt, FALSE))
continue; continue;
break; break;
case 3: case 3:
target = which_armor(mdef, W_ARMG); target = which_armor(mdef, W_ARMG);
if (!target || !rust_dmg(target, xname(target), hurt, FALSE, mdef)) if (!target || !rust_dmg(target, xname(target), hurt, FALSE))
continue; continue;
break; break;
case 4: case 4:
target = which_armor(mdef, W_ARMF); target = which_armor(mdef, W_ARMF);
if (!target || !rust_dmg(target, xname(target), hurt, FALSE, mdef)) if (!target || !rust_dmg(target, xname(target), hurt, FALSE))
continue; continue;
break; break;
} }
@@ -2231,7 +2231,7 @@ boolean wep_was_destroyed;
if(mhit && !mon->mcan) { if(mhit && !mon->mcan) {
if (aatyp == AT_KICK) { if (aatyp == AT_KICK) {
if (uarmf && !rn2(6)) if (uarmf && !rn2(6))
(void)rust_dmg(uarmf, xname(uarmf), 0, TRUE, &youmonst); (void)rust_dmg(uarmf, xname(uarmf), 0, TRUE);
} else if (aatyp == AT_WEAP || aatyp == AT_CLAW || } else if (aatyp == AT_WEAP || aatyp == AT_CLAW ||
aatyp == AT_MAGC || aatyp == AT_TUCH) aatyp == AT_MAGC || aatyp == AT_TUCH)
passive_obj(mon, (struct obj*)0, &(ptr->mattk[i])); passive_obj(mon, (struct obj*)0, &(ptr->mattk[i]));
@@ -2251,7 +2251,7 @@ boolean wep_was_destroyed;
if (mhit) { if (mhit) {
if (aatyp == AT_KICK) { if (aatyp == AT_KICK) {
if (uarmf && !rn2(6)) if (uarmf && !rn2(6))
(void)rust_dmg(uarmf, xname(uarmf), 3, TRUE, &youmonst); (void)rust_dmg(uarmf, xname(uarmf), 3, TRUE);
} else if (aatyp == AT_WEAP || aatyp == AT_CLAW || } else if (aatyp == AT_WEAP || aatyp == AT_CLAW ||
aatyp == AT_MAGC || aatyp == AT_TUCH) aatyp == AT_MAGC || aatyp == AT_TUCH)
passive_obj(mon, (struct obj*)0, &(ptr->mattk[i])); passive_obj(mon, (struct obj*)0, &(ptr->mattk[i]));
@@ -2284,7 +2284,7 @@ boolean wep_was_destroyed;
if(mhit && !mon->mcan) { if(mhit && !mon->mcan) {
if (aatyp == AT_KICK) { if (aatyp == AT_KICK) {
if (uarmf) if (uarmf)
(void)rust_dmg(uarmf, xname(uarmf), 1, TRUE, &youmonst); (void)rust_dmg(uarmf, xname(uarmf), 1, TRUE);
} else if (aatyp == AT_WEAP || aatyp == AT_CLAW || } else if (aatyp == AT_WEAP || aatyp == AT_CLAW ||
aatyp == AT_MAGC || aatyp == AT_TUCH) aatyp == AT_MAGC || aatyp == AT_TUCH)
passive_obj(mon, (struct obj*)0, &(ptr->mattk[i])); passive_obj(mon, (struct obj*)0, &(ptr->mattk[i]));
@@ -2294,7 +2294,7 @@ boolean wep_was_destroyed;
if(mhit && !mon->mcan) { if(mhit && !mon->mcan) {
if (aatyp == AT_KICK) { if (aatyp == AT_KICK) {
if (uarmf) if (uarmf)
(void)rust_dmg(uarmf, xname(uarmf), 3, TRUE, &youmonst); (void)rust_dmg(uarmf, xname(uarmf), 3, TRUE);
} else if (aatyp == AT_WEAP || aatyp == AT_CLAW || } else if (aatyp == AT_WEAP || aatyp == AT_CLAW ||
aatyp == AT_MAGC || aatyp == AT_TUCH) aatyp == AT_MAGC || aatyp == AT_TUCH)
passive_obj(mon, (struct obj*)0, &(ptr->mattk[i])); passive_obj(mon, (struct obj*)0, &(ptr->mattk[i]));