Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ lib/user/*.prf
.new
*~
*.DS_Store
sil.INI
src/sil.res
11 changes: 5 additions & 6 deletions src/Makefile.cyg
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

CC = gcc
WRES = windres
LIBS = -s -mno-cygwin -mwindows -e _mainCRTStartup -lwinmm
CFLAGS = -Wall -mno-cygwin -O2 -fno-strength-reduce -DWINDOWS
LIBS = -s -mwindows -e _mainCRTStartup -lwinmm
CFLAGS = -Wall -O2 -fno-strength-reduce -DWINDOWS

EXOBJS = \
sil.res \
Expand Down Expand Up @@ -158,7 +158,7 @@ generate.o: generate.c $(INCS)
init1.o: init1.c $(INCS) init.h
$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

init2.o: init2.c $(INCS) init.h
init2.o: init2.c $(INCS) init.h
$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

load.o: load.c $(INCS) init.h
Expand Down Expand Up @@ -226,13 +226,13 @@ variable.o: variable.c $(INCS)
wizard1.o: wizard1.c $(INCS)
$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

wizard2.o: wizard2.c $(INCS)
wizard2.o: wizard2.c $(INCS)
$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

squelch.o: squelch.c $(INCS)
$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

xtra1.o: xtra1.c $(INCS)
xtra1.o: xtra1.c $(INCS)
$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

xtra2.o: xtra2.c $(INCS)
Expand All @@ -258,4 +258,3 @@ z-virt.o: z-virt.c $(HDRS) z-virt.h z-util.h

.c.o:
$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

109 changes: 69 additions & 40 deletions src/cmd4.c
Original file line number Diff line number Diff line change
Expand Up @@ -2561,6 +2561,22 @@ void dif_mod(int value, int positive_base, int *dif_inc)
}
}

/*
* Determines the difficulty modifier for pvals, with the possibility of a negative one.
*
* It uses dif_mod (see above) and applies to the increment or the decrement as appropiate.
*/
void neg_dif_mod(int value, int base, int *dif_inc, int *dif_dec)
{
int mod = 0;

dif_mod(ABS(value), base, &mod);

if (value > 0)
*dif_inc += mod;
else
*dif_dec += mod / 2;
}

/*
* Determines the difficulty of a given object.
Expand All @@ -2578,6 +2594,7 @@ int object_difficulty(object_type *o_ptr)
int brands = 0;
int dif_mult = 100;
int cat = 0; // default to soothe compilation warnings
bool smithing_gear = FALSE;

// reset smithing costs
smithing_cost.str = 0;
Expand Down Expand Up @@ -2695,29 +2712,47 @@ int object_difficulty(object_type *o_ptr)
dif_mod(x, 10, &dif_inc);
smithing_cost.str += (x > 0) ? x : 0;
}

// Abilities
for (i = 0; i < o_ptr->abilities; i++)
{
dif_inc += 5 + (&b_info[ability_index(o_ptr->skilltype[i],o_ptr->abilitynum[i])])->level / 2;
smithing_cost.exp += 500;
// if it has a smithing ability, flag it as smithing gear
if (o_ptr->skilltype[i] == S_SMT) smithing_gear = TRUE;
}

if (o_ptr->pval != 0)
{
x = (o_ptr->pval > 0) ? o_ptr->pval : 0;
x = o_ptr->pval;

if (f1 & TR1_DAMAGE_SIDES) { dif_mod(x, 15, &dif_inc); smithing_cost.str += x; }
if (f1 & TR1_STR) { dif_mod(x, 12, &dif_inc); smithing_cost.str += x; }
if (f1 & TR1_DEX) { dif_mod(x, 12, &dif_inc); smithing_cost.dex += x; }
if (f1 & TR1_CON) { dif_mod(x, 12, &dif_inc); smithing_cost.con += x; }
if (f1 & TR1_GRA) { dif_mod(x, 12, &dif_inc); smithing_cost.gra += x; }
if (f1 & TR1_MEL) { dif_mod(x, 4, &dif_inc); smithing_cost.exp += x*100; }
if (f1 & TR1_ARC) { dif_mod(x, 4, &dif_inc); smithing_cost.exp += x*100; }
if (f1 & TR1_STL) { dif_mod(x, 4, &dif_inc); smithing_cost.exp += x*100; }
if (f1 & TR1_PER) { dif_mod(x, 4, &dif_inc); smithing_cost.exp += x*100; }
if (f1 & TR1_WIL) { dif_mod(x, 4, &dif_inc); smithing_cost.exp += x*100; }
if (f1 & TR1_SMT) { dif_mod(x, 4, &dif_inc); smithing_cost.exp += x*100; }
if (f1 & TR1_SNG) { dif_mod(x, 4, &dif_inc); smithing_cost.exp += x*100; }

x = (o_ptr->pval < 0) ? o_ptr->pval : 0;
// if it has a smithing skill modifier
if (f1 & TR1_SMT)
{
// flag it as smithing gear
smithing_gear = TRUE;
dif_mod(x, 4, &dif_inc);
if (x > 0) smithing_cost.exp += x*100;
}

if (smithing_gear) x = (x > 0) ? x : 0; // do not allow negative difficulty modifiers if it is smithing gear

if (f1 & TR1_DAMAGE_SIDES) { neg_dif_mod(x, 15, &dif_inc, &dif_dec); smithing_cost.str += x; }
if (f1 & TR1_STR) { neg_dif_mod(x, 12, &dif_inc, &dif_dec); smithing_cost.str += x; }
if (f1 & TR1_DEX) { neg_dif_mod(x, 12, &dif_inc, &dif_dec); smithing_cost.dex += x; }
if (f1 & TR1_CON) { neg_dif_mod(x, 12, &dif_inc, &dif_dec); smithing_cost.con += x; }
if (f1 & TR1_GRA) { neg_dif_mod(x, 12, &dif_inc, &dif_dec); smithing_cost.gra += x; }
if (f1 & TR1_MEL) { neg_dif_mod(x, 4, &dif_inc, &dif_dec); smithing_cost.exp += x*100; }
if (f1 & TR1_ARC) { neg_dif_mod(x, 4, &dif_inc, &dif_dec); smithing_cost.exp += x*100; }
if (f1 & TR1_STL) { neg_dif_mod(x, 4, &dif_inc, &dif_dec); smithing_cost.exp += x*100; }
if (f1 & TR1_PER) { neg_dif_mod(x, 4, &dif_inc, &dif_dec); smithing_cost.exp += x*100; }
if (f1 & TR1_WIL) { neg_dif_mod(x, 4, &dif_inc, &dif_dec); smithing_cost.exp += x*100; }
if (f1 & TR1_SNG) { neg_dif_mod(x, 4, &dif_inc, &dif_dec); smithing_cost.exp += x*100; }

if (f1 & TR1_NEG_STR) { dif_mod(-x, 12, &dif_inc); smithing_cost.str -= x; }
if (f1 & TR1_NEG_DEX) { dif_mod(-x, 12, &dif_inc); smithing_cost.dex -= x; }
if (f1 & TR1_NEG_CON) { dif_mod(-x, 12, &dif_inc); smithing_cost.con -= x; }
if (f1 & TR1_NEG_GRA) { dif_mod(-x, 12, &dif_inc); smithing_cost.gra -= x; }
if (f1 & TR1_NEG_STR) { neg_dif_mod(-x, 12, &dif_inc, &dif_dec); smithing_cost.str -= x; }
if (f1 & TR1_NEG_DEX) { neg_dif_mod(-x, 12, &dif_inc, &dif_dec); smithing_cost.dex -= x; }
if (f1 & TR1_NEG_CON) { neg_dif_mod(-x, 12, &dif_inc, &dif_dec); smithing_cost.con -= x; }
if (f1 & TR1_NEG_GRA) { neg_dif_mod(-x, 12, &dif_inc, &dif_dec); smithing_cost.gra -= x; }
}

// Sustains
Expand Down Expand Up @@ -2749,32 +2784,26 @@ int object_difficulty(object_type *o_ptr)
if (f2 & TR2_RES_HALLU) { dif_inc += 3; }

// Penalty Flags
if (f2 & TR2_FEAR) { dif_dec += 0; }
if (f2 & TR2_HUNGER) { dif_dec += 0; }
if (f2 & TR2_DARKNESS) { dif_dec += 0; }
if (f2 & TR2_DANGER) { dif_dec += 5; } // only Danger counts
if (f2 & TR2_AGGRAVATE) { dif_dec += 0; }
if (f2 & TR2_HAUNTED) { dif_dec += 0; }
if (f2 & TR2_VUL_COLD) { dif_dec += 0; }
if (f2 & TR2_VUL_FIRE) { dif_dec += 0; }
if (f2 & TR2_VUL_POIS) { dif_dec += 0; }


// Abilities
for (i = 0; i < o_ptr->abilities; i++)
{
dif_inc += 5 + (&b_info[ability_index(o_ptr->skilltype[i],o_ptr->abilitynum[i])])->level / 2;
smithing_cost.exp += 500;
}

// Mithirl
if (f2 & TR2_FEAR) { if (!smithing_gear) dif_dec += 1; }
if (f2 & TR2_HUNGER) { dif_dec += 2; }
if (f2 & TR2_DARKNESS) { if (!smithing_gear) dif_dec += 4; }
if (f2 & TR2_DANGER) { dif_dec += 8; }
if (f2 & TR2_AGGRAVATE) { if (!smithing_gear) dif_dec += 1; }
if (f2 & TR2_HAUNTED) { dif_dec += 6; }
if (f2 & TR2_VUL_COLD) { if (!smithing_gear) dif_dec += 4; }
if (f2 & TR2_VUL_FIRE) { if (!smithing_gear) dif_dec += 4; }
if (f2 & TR2_VUL_POIS) { if (!smithing_gear) dif_dec += 4; }
if (f2 & TR2_VUL_POIS) { if (!smithing_gear) dif_dec += 4; }
if (f3 & TR3_LIGHT_CURSE) { dif_dec += 4; /* representative of the 4 points in will necessary to break it */ }

// Mithril
if (k_ptr->flags3 & TR3_MITHRIL) { smithing_cost.mithril += o_ptr->weight; }

// Penalty for being an artefact
if (o_ptr->name1) { smithing_cost.uses += 2; }

// Cap the difficulty reduction at 8
if (dif_dec > 8) dif_dec = 8;
// Cap the difficulty reduction at half of the current difficulty
dif_dec = MIN(dif_inc / 2, dif_dec);

// Set the overall difficulty
dif = dif_inc - dif_dec;
Expand Down