All auto-generated monsters in ice caves should start with cold immunity.

This commit is contained in:
Rob Pearce 2016-07-23 11:33:18 +10:00
parent e698875655
commit 6a7175a8d3
4 changed files with 65 additions and 1 deletions

1
defs.h
View File

@ -4964,6 +4964,7 @@ typedef struct habitat_s {
enum OBTYPE upstairtype, downstairtype; enum OBTYPE upstairtype, downstairtype;
int stairsinrooms; int stairsinrooms;
enum CELLTYPE emptycelltype,solidcelltype; enum CELLTYPE emptycelltype,solidcelltype;
struct flagpile_s *monflags; // random monsters in this habitat get these
struct habitat_s *next, *prev; struct habitat_s *next, *prev;
} habitat_t; } habitat_t;

61
map.c
View File

@ -648,6 +648,10 @@ int addrandomthing(cell_t *c, int obchance, int *nadded) {
lf = addmonster(c, R_RANDOM, NULL, B_TRUE, 1, B_TRUE, B_ALLOWEXTRA, nadded); lf = addmonster(c, R_RANDOM, NULL, B_TRUE, 1, B_TRUE, B_ALLOWEXTRA, nadded);
if (lf) { if (lf) {
rv = TT_MONSTER; rv = TT_MONSTER;
if (c->habitat) {
// ensure it has proper resistances
copyflags(lf->flags, c->habitat->monflags, NA);
}
} }
//if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging //if (gamemode == GM_GAMESTARTED) checkallflags(player->cell->map); // debugging
} }
@ -5866,6 +5870,31 @@ void killcell(cell_t **c) {
// } // }
} }
void killbranch(branch_t *b) {
branch_t *nextone, *lastone;
// free mem
free(b->name);
// remove from list
nextone = b->next;
if (nextone != NULL) {
nextone->prev = b->prev;
} else { /* last */
lastbranch = b->prev;
}
if (b->prev == NULL) {
/* first */
nextone = b->next;
free(firstbranch);
firstbranch = nextone;
} else {
lastone = b->prev;
free (lastone->next );
lastone->next = nextone;
}
}
void killcelltype(celltype_t *ct) { void killcelltype(celltype_t *ct) {
celltype_t *nextone, *lastone; celltype_t *nextone, *lastone;
if (ct->name) free(ct->name); if (ct->name) free(ct->name);
@ -5896,6 +5925,33 @@ void killfakes(map_t *map, cell_t *cell) {
free(map->name); free(map->name);
} }
void killhabitat(habitat_t *h) {
habitat_t *nextone, *lastone;
// free mem
free(h->name);
killflagpile(h->monflags);
h->monflags = NULL;
// remove from list
nextone = h->next;
if (nextone != NULL) {
nextone->prev = h->prev;
} else { /* last */
lasthabitat = h->prev;
}
if (h->prev == NULL) {
/* first */
nextone = h->next;
free(firsthabitat);
firsthabitat = nextone;
} else {
lastone = h->prev;
free (lastone->next );
lastone->next = nextone;
}
}
void killmap(map_t *m) { void killmap(map_t *m) {
map_t *nextone, *lastone; map_t *nextone, *lastone;
int i; int i;
@ -8812,10 +8868,12 @@ object_t *hastrailof(obpile_t *op, lifeform_t *lf, int oid, flag_t **tflag, life
void initmap(void) { void initmap(void) {
habitat_t *h;
// habitats // habitats
// thingchance, obchance, vaultchance, maxvisrange, upstiartype, downstairtype, stairs_in_rooms,temp // thingchance, obchance, vaultchance, maxvisrange, upstiartype, downstairtype, stairs_in_rooms,temp
addhabitat(H_DUNGEON, "dungeon", CT_CORRIDOR, CT_WALL, 5, 60, 40, 6, OT_STAIRSUP, OT_STAIRSDOWN, B_TRUE, T_NORMAL); addhabitat(H_DUNGEON, "dungeon", CT_CORRIDOR, CT_WALL, 5, 60, 40, 6, OT_STAIRSUP, OT_STAIRSDOWN, B_TRUE, T_NORMAL);
addhabitat(H_ICECAVE, "ice cavern", CT_CORRIDOR, CT_WALLICE, 10, 45, 20, 6, OT_ICESTAIRSUP, OT_ICESTAIRSDOWN, B_FALSE, T_COLD); h = addhabitat(H_ICECAVE, "ice cavern", CT_CORRIDOR, CT_WALLICE, 10, 45, 20, 6, OT_ICESTAIRSUP, OT_ICESTAIRSDOWN, B_FALSE, T_COLD);
addflag(h->monflags, F_DTIMMUNE, DT_COLD, B_TRUE, NA, NULL);
addhabitat(H_CAVE, "cave", CT_DIRT, CT_WALLDIRT, 5, 45, 20, 6, OT_TUNNELUP, OT_TUNNELDOWN, B_FALSE, T_NORMAL); addhabitat(H_CAVE, "cave", CT_DIRT, CT_WALLDIRT, 5, 45, 20, 6, OT_TUNNELUP, OT_TUNNELDOWN, B_FALSE, T_NORMAL);
addhabitat(H_FOREST, "forest", CT_GRASS, CT_WALLTREE, 5, 75, 0, MAXVISRANGE, OT_TREEUP, OT_TREEDOWN, B_FALSE, T_NORMAL); addhabitat(H_FOREST, "forest", CT_GRASS, CT_WALLTREE, 5, 75, 0, MAXVISRANGE, OT_TREEUP, OT_TREEDOWN, B_FALSE, T_NORMAL);
addhabitat(H_HEAVEN, "heaven", CT_CORRIDOR, CT_WALLGLASS, 5, 0, 0, MAXVISRANGE, OT_NONE, OT_NONE, B_FALSE, T_NORMAL); addhabitat(H_HEAVEN, "heaven", CT_CORRIDOR, CT_WALLGLASS, 5, 0, 0, MAXVISRANGE, OT_NONE, OT_NONE, B_FALSE, T_NORMAL);
@ -8874,6 +8932,7 @@ void initmap(void) {
addbranch(BH_WOODS, "The Sylvan Woods", B_TRUE, H_FOREST, 3, 3, D_DOWN, B_TRUE, 1, B_FALSE); addbranch(BH_WOODS, "The Sylvan Woods", B_TRUE, H_FOREST, 3, 3, D_DOWN, B_TRUE, 1, B_FALSE);
addbranch(BH_MASTERVAULTS, "The Master Vaults", B_TRUE, H_MASTERVAULTS, 3, 1, D_DOWN, B_TRUE, 5, B_TRUE); addbranch(BH_MASTERVAULTS, "The Master Vaults", B_TRUE, H_MASTERVAULTS, 3, 1, D_DOWN, B_TRUE, 5, B_TRUE);
addbranch(BH_ICECAVERNS, "The Ice Caverns", B_TRUE, H_ICECAVE, 1, 1, D_DOWN, B_TRUE, 10, B_FALSE); addbranch(BH_ICECAVERNS, "The Ice Caverns", B_TRUE, H_ICECAVE, 1, 1, D_DOWN, B_TRUE, 10, B_FALSE);
// minor branches // minor branches
addbranch(BH_PIT, "A Pit", B_FALSE, H_PIT, 1, 1, D_DOWN, B_FALSE, 0, B_TRUE); addbranch(BH_PIT, "A Pit", B_FALSE, H_PIT, 1, 1, D_DOWN, B_FALSE, 0, B_TRUE);
addbranch(BH_SEWER, "A Sewer", B_FALSE, H_SEWER, 1, 0, D_NONE, B_FALSE, 2, B_TRUE); addbranch(BH_SEWER, "A Sewer", B_FALSE, H_SEWER, 1, 0, D_NONE, B_FALSE, 2, B_TRUE);

2
map.h
View File

@ -185,9 +185,11 @@ int isoutdoors(map_t *m);
int isroom(cell_t *c); int isroom(cell_t *c);
int issolid(cell_t *c); int issolid(cell_t *c);
int iswallindir(cell_t *cell, int dir); int iswallindir(cell_t *cell, int dir);
void killbranch(branch_t *b);
void killcell(cell_t **c); void killcell(cell_t **c);
void killcelltype(celltype_t *ct); void killcelltype(celltype_t *ct);
void killfakes(map_t *map, cell_t *cell); void killfakes(map_t *map, cell_t *cell);
void killhabitat(habitat_t *h);
void killmap(map_t *m); void killmap(map_t *m);
void killregion(region_t *r); void killregion(region_t *r);
int linkexit(cell_t *c, int wantfilled, int *ncellsadded); int linkexit(cell_t *c, int wantfilled, int *ncellsadded);

View File

@ -914,6 +914,8 @@ void cleanup(void) {
while (firstoption) killoption(firstoption); while (firstoption) killoption(firstoption);
// free maps (this will kill its lifeforms & obs & cells too) // free maps (this will kill its lifeforms & obs & cells too)
while (firstmap) killmap(firstmap); while (firstmap) killmap(firstmap);
// free branches
while (firstbranch) killbranch(firstbranch);
// free knowledge // free knowledge
while (knowledge) killknowledge(knowledge); while (knowledge) killknowledge(knowledge);
// free brands // free brands