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.
This commit is contained in:
John "Elwin" Edwards 2016-05-01 19:39:56 -04:00
parent 718c807339
commit ca1c442db2
10 changed files with 42 additions and 17 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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" } },

View file

@ -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;

View file

@ -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;

View file

@ -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" } },

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;
}