From ca1c442db221aa5ac3e6e6fcd1eff852f0d82bc2 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Sun, 1 May 2016 19:39:56 -0400 Subject: [PATCH] Rogue V[345], Super-Rogue: Fix violet fungi/venus flytraps. Violet fungi (renamed venus flytraps in Rogue V5) do an increasing amount of damage each time they hit. If they miss, you still suffer the same number of HP. This worked by keeping a counter and printing new damage strings into monsters[5].m_stats.s_dmg, which is the "prototype" of that particular monster. Each individual monster has its own damage string. Apparently these were once char *, pointing to the same string as the prototype. When the s_dmg member was changed to be an internal char array, changing the prototype's damage string no longer had any effect on actual monsters. As a result, flytraps did no damage on a hit, or only one point in V5. The mechanism for doing damage on a miss continued to work. This has been fixed by overwriting the individual monster's damage string instead of the prototype's. It is now no longer necessary to reset the damage string when the flytrap is killed. The method for resetting it when the hero teleports away had to be modified. Comments referencing the long-unused xstr have been removed. --- rogue3/fight.c | 5 +++-- rogue3/wizard.c | 9 ++++++++- rogue4/extern.c | 4 +--- rogue4/fight.c | 5 +++-- rogue4/wizard.c | 7 ++++++- rogue5/extern.c | 4 +--- rogue5/fight.c | 5 +++-- rogue5/wizard.c | 7 ++++++- srogue/fight.c | 4 +++- srogue/monsters.c | 9 ++++++++- 10 files changed, 42 insertions(+), 17 deletions(-) diff --git a/rogue3/fight.c b/rogue3/fight.c index a2ff0cb..c88df9c 100644 --- a/rogue3/fight.c +++ b/rogue3/fight.c @@ -108,6 +108,8 @@ attack(struct thing *mp) */ running = FALSE; quiet = 0; + if (mp->t_type == 'F') + fung_hit = atoi(mp->t_stats.s_dmg); if (mp->t_type == 'M' && off(player, ISBLIND)) mp->t_disguise = 'M'; if (on(player, ISBLIND)) @@ -200,7 +202,7 @@ attack(struct thing *mp) * Violet fungi stops the poor guy from moving */ player.t_flags |= ISHELD; - sprintf(monsters['F'-'A'].m_stats.s_dmg,"%dd1",++fung_hit); + sprintf(mp->t_stats.s_dmg, "%dd1", ++fung_hit); when 'L': { /* @@ -693,7 +695,6 @@ killed(struct linked_list *item, int pr) case 'F': player.t_flags &= ~ISHELD; fung_hit = 0; - strcpy(monsters['F'-'A'].m_stats.s_dmg, "000d0"); when 'L': { struct room *rp; diff --git a/rogue3/wizard.c b/rogue3/wizard.c index 132befe..efe7e09 100644 --- a/rogue3/wizard.c +++ b/rogue3/wizard.c @@ -166,9 +166,16 @@ teleport() * a Fungi */ if (on(player, ISHELD)) { + struct linked_list *item; + struct thing *mon; + player.t_flags &= ~ISHELD; fung_hit = 0; - strcpy(monsters['F'-'A'].m_stats.s_dmg, "000d0"); + for (item = mlist; item != NULL; item = next(item)) { + mon = (struct thing *) ldata(item); + if (mon->t_type == 'F') + strcpy(mon->t_stats.s_dmg, "000d0"); + } } count = 0; running = FALSE; diff --git a/rogue4/extern.c b/rogue4/extern.c index 017180c..6fe070b 100644 --- a/rogue4/extern.c +++ b/rogue4/extern.c @@ -170,9 +170,7 @@ struct monster monsters[26] = { "centaur", 15, 0, { XX, 15, 4, 4, ___, "1d6/1d6" } }, { "dragon", 100, ISMEAN, { XX,6800, 10, -1, ___, "1d8/1d8/3d10" } }, { "floating eye",0, 0, { XX, 5, 1, 9, ___, "0d0" } }, - /* NOTE: the damage is %%% so that xstr won't merge this */ - /* string with others, since it is written on in the program */ - { "violet fungi",0, ISMEAN, { XX, 80, 8, 3, ___, "%%%d0" } }, + { "violet fungi",0, ISMEAN, { XX, 80, 8, 3, ___, "0d0" } }, { "gnome", 10, 0, { XX, 7, 1, 5, ___, "1d6" } }, { "hobgoblin", 0, ISMEAN, { XX, 3, 1, 5, ___, "1d8" } }, { "invisible stalker",0,ISINVIS,{ XX,120, 8, 3, ___, "4d4" } }, diff --git a/rogue4/fight.c b/rogue4/fight.c index c7ed6df..e66e6f3 100644 --- a/rogue4/fight.c +++ b/rogue4/fight.c @@ -113,6 +113,8 @@ attack(THING *mp) */ running = FALSE; count = quiet = 0; + if (mp->t_type == 'F') + fung_hit = atoi(mp->t_stats.s_dmg); if (mp->t_type == 'M' && !on(player, ISBLIND)) mp->t_disguise = 'M'; if (on(player, ISBLIND)) @@ -216,7 +218,7 @@ attack(THING *mp) * Violet fungi stops the poor guy from moving */ player.t_flags |= ISHELD; - sprintf(monsters['F'-'A'].m_stats.s_dmg,"%dd1",++fung_hit); + sprintf(mp->t_stats.s_dmg,"%dd1",++fung_hit); when 'L': { /* @@ -695,7 +697,6 @@ killed(THING *tp, bool pr) case 'F': player.t_flags &= ~ISHELD; fung_hit = 0; - strcpy(monsters['F'-'A'].m_stats.s_dmg, "000d0"); when 'L': { register THING *gold; diff --git a/rogue4/wizard.c b/rogue4/wizard.c index 18827ae..40fdda5 100644 --- a/rogue4/wizard.c +++ b/rogue4/wizard.c @@ -180,9 +180,14 @@ teleport(void) * a Fungi */ if (on(player, ISHELD)) { + THING *mon; + player.t_flags &= ~ISHELD; fung_hit = 0; - strcpy(monsters['F'-'A'].m_stats.s_dmg, "000d0"); + for (mon = mlist; mon != NULL; mon = next(mon)) { + if (mon->t_type == 'F') + strcpy(mon->t_stats.s_dmg, "0d0"); + } } no_move = 0; count = 0; diff --git a/rogue5/extern.c b/rogue5/extern.c index 390b762..8351d9c 100644 --- a/rogue5/extern.c +++ b/rogue5/extern.c @@ -197,9 +197,7 @@ struct monster monsters[26] = { "centaur", 15, 0, { XX, 17, 4, 4, ___, "1x2/1x5/1x5" } }, { "dragon", 100, ISMEAN, { XX,5000, 10, -1, ___, "1x8/1x8/3x10" } }, { "emu", 0, ISMEAN, { XX, 2, 1, 7, ___, "1x2" } }, -{ "venus flytrap", 0, ISMEAN, { XX, 80, 8, 3, ___, "%%%x0" } }, - /* NOTE: the damage is %%% so that xstr won't merge this */ - /* string with others, since it is written on in the program */ +{ "venus flytrap", 0, ISMEAN, { XX, 80, 8, 3, ___, "0x0" } }, { "griffin", 20, ISMEAN|ISFLY|ISREGEN, { XX,2000, 13, 2, ___, "4x3/3x5" } }, { "hobgoblin", 0, ISMEAN, { XX, 3, 1, 5, ___, "1x8" } }, { "ice monster", 0, 0, { XX, 5, 1, 9, ___, "0x0" } }, diff --git a/rogue5/fight.c b/rogue5/fight.c index b88d875..6a00497 100644 --- a/rogue5/fight.c +++ b/rogue5/fight.c @@ -156,6 +156,8 @@ attack(THING *mp) to_death = FALSE; kamikaze = FALSE; } + if (mp->t_type == 'F') + vf_hit = atoi(mp->t_stats.s_dmg); if (mp->t_type == 'X' && mp->t_disguise != 'X' && !on(player, ISBLIND)) { mp->t_disguise = 'X'; @@ -269,7 +271,7 @@ attack(THING *mp) * Venus Flytrap stops the poor guy from moving */ player.t_flags |= ISHELD; - sprintf(monsters['F'-'A'].m_stats.s_dmg,"%dx1", ++vf_hit); + sprintf(mp->t_stats.s_dmg,"%dx1", ++vf_hit); if (--pstats.s_hpt <= 0) death('F'); when 'L': @@ -641,7 +643,6 @@ killed(THING *tp, int pr) case 'F': player.t_flags &= ~ISHELD; vf_hit = 0; - strcpy(monsters['F'-'A'].m_stats.s_dmg, "000x0"); when 'L': { THING *gold; diff --git a/rogue5/wizard.c b/rogue5/wizard.c index 29434f3..20169e1 100644 --- a/rogue5/wizard.c +++ b/rogue5/wizard.c @@ -220,9 +220,14 @@ teleport(void) * a Flytrap */ if (on(player, ISHELD)) { + THING *mp; + player.t_flags &= ~ISHELD; vf_hit = 0; - strcpy(monsters['F'-'A'].m_stats.s_dmg, "000x0"); + for (mp = mlist; mp != NULL; mp = next(mp)) { + if (mp->t_type == 'F') + strcpy(mp->t_stats.s_dmg, "0x0"); + } } no_move = 0; count = 0; diff --git a/srogue/fight.c b/srogue/fight.c index 6f80372..c463a20 100644 --- a/srogue/fight.c +++ b/srogue/fight.c @@ -142,6 +142,8 @@ attack(struct thing *mp) running = FALSE; quiet = 0; isfight = TRUE; + if (mp->t_type == 'F') + fung_hit = atoi(mp->t_stats.s_dmg); if (mp->t_type == 'M' && pl_off(ISBLIND)) mp->t_disguise = 'M'; if (pl_on(ISBLIND)) @@ -206,7 +208,7 @@ attack(struct thing *mp) } when 'F': player.t_flags |= ISHELD; - sprintf(monsters[midx('F')].m_stats.s_dmg,"%dd1",++fung_hit); + sprintf(mp->t_stats.s_dmg,"%dd1",++fung_hit); when 'L': { long lastpurse; struct linked_list *lep; diff --git a/srogue/monsters.c b/srogue/monsters.c index 1acccfb..77337f3 100644 --- a/srogue/monsters.c +++ b/srogue/monsters.c @@ -334,10 +334,17 @@ tryagain: void unhold(char whichmon) { + struct linked_list *item; + struct thing *mon; + switch (whichmon) { case 'F': fung_hit = 0; - strcpy(monsters[midx('F')].m_stats.s_dmg, "000d0"); + for (item = mlist; item != NULL; item = next(item)) { + mon = THINGPTR(item); + if (mon->t_type == 'F') + strcpy(mon->t_stats.s_dmg, "000d0"); + } case 'd': player.t_flags &= ~ISHELD; }