Skip to content

Commit

Permalink
Fix curse timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
NickMcConnell committed Oct 22, 2016
1 parent 51c8e1f commit c27e08d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/gamedata/curse.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ type:amulet
type:ring
effect:TIMED_INC:STONESKIN
dice:20+1d20
time:1d1000
desc:periodically turns your skin to stone

name:anti-teleportation
Expand Down
9 changes: 8 additions & 1 deletion src/obj-curse.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ int lookup_curse(const char *name)
* \param source the curses being copied
* \param randomise whether some values on the curse object need randomising
*/
void copy_curse(struct curse **dest, struct curse *source, bool randomise)
void copy_curse(struct curse **dest, struct curse *source, bool randomise,
bool new)
{
struct curse *c = source;

Expand Down Expand Up @@ -100,6 +101,11 @@ void copy_curse(struct curse **dest, struct curse *source, bool randomise)
}
}
}

/* Timeouts need to be set for new objects */
if (new) {
new_c->obj->timeout = randcalc(new_c->obj->time, 0, RANDOMISE);
}
}
new_c->next = *dest;
*dest = new_c;
Expand Down Expand Up @@ -228,5 +234,6 @@ bool do_curse_effect(struct curse *curse)
msgt(MSG_GENERIC, curse->obj->effect_msg);
}
effect_do(effect, NULL, &ident, was_aware, dir, 0, 0);
curse->obj->timeout = randcalc(curse->obj->time, 0, RANDOMISE);
return !was_aware && ident;
}
3 changes: 2 additions & 1 deletion src/obj-curse.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ struct curse {
extern struct curse *curses;

int lookup_curse(const char *name);
void copy_curse(struct curse **dest, struct curse *src, bool randomise);
void copy_curse(struct curse **dest, struct curse *src, bool randomise,
bool new);
void free_curse(struct curse *source, bool complete);
bool curses_are_equal(struct curse *curse1, struct curse *curse2);
bool append_curse(struct curse **current, int pick, int power);
Expand Down
8 changes: 4 additions & 4 deletions src/obj-make.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void ego_apply_magic(struct object *obj, int level)
/* Add slays, brands and curses */
copy_slay(&obj->slays, obj->ego->slays);
copy_brand(&obj->brands, obj->ego->brands);
copy_curse(&obj->curses, obj->ego->curses, true);
copy_curse(&obj->curses, obj->ego->curses, true, true);

/* Add resists */
for (i = 0; i < ELEM_MAX; i++) {
Expand Down Expand Up @@ -483,7 +483,7 @@ void copy_artifact_data(struct object *obj, const struct artifact *art)
of_union(obj->flags, art->flags);
copy_slay(&obj->slays, art->slays);
copy_brand(&obj->brands, art->brands);
copy_curse(&obj->curses, art->curses, false);
copy_curse(&obj->curses, art->curses, false, true);
for (i = 0; i < ELEM_MAX; i++) {
/* Take the larger of artifact and base object resist levels */
obj->el_info[i].res_level =
Expand Down Expand Up @@ -794,7 +794,7 @@ void object_prep(struct object *obj, struct object_kind *k, int lev,
/* Default slays, brands and curses */
copy_slay(&obj->slays, k->slays);
copy_brand(&obj->brands, k->brands);
copy_curse(&obj->curses, k->curses, true);
copy_curse(&obj->curses, k->curses, true, true);

/* Default resists */
for (i = 0; i < ELEM_MAX; i++) {
Expand All @@ -808,7 +808,7 @@ void object_prep(struct object *obj, struct object_kind *k, int lev,
* Attempt to apply curses to an object, with a corresponding increase in
* generation level of the object
*/
void apply_curse(struct object *obj, int *lev)
static void apply_curse(struct object *obj, int *lev)
{
int pick = randint1(z_info->curse_max - 1);
int power = 10 * m_bonus(9, *lev);
Expand Down
2 changes: 1 addition & 1 deletion src/obj-pile.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void object_copy(struct object *dest, const struct object *src)

copy_slay(&dest->slays, src->slays);
copy_brand(&dest->brands, src->brands);
copy_curse(&dest->curses, src->curses, false);
copy_curse(&dest->curses, src->curses, false, false);

/* Detach from any pile */
dest->prev = NULL;
Expand Down

0 comments on commit c27e08d

Please sign in to comment.