/* "Half-Life Automap - .map Generation Utility" v1.0 written by SuperJer superjer@superjer.com Legal Rights: You may use this code for any purpose as long as the original author is recognized and no money is made. Notes: All the program code is in this one file, that's the way I like it ok - I don't like dealing with multiple files. This code is very poorly commented. And that's just too bad, isn't it? GWA HA HA HA HA! mer... */ #include #include #include #include #include const char q = char(34); const char TNT = char(219); const int NUM_WALLS = 128; const int DIM_X = 64; const int DIM_Y = 64; const int HORIZ = 0; const int VERT = 1; const int MAX_LOOK_FOR_ATTACH = 6; // max distance a wall will look before deciding direction const int EXTRA_WALL_FILLS = 8; const int CRATE_FREQUENCY = 20; const int CRATE_CLUSTERING = 95; // percent chance of throwing out crate due to no neighboring crates const int MAX_HOLES = 50; const int WALL_KNOCKS = 500; const int MAX_BOX_ROOMS = 20; const int MAX_LIGHTING = 100000; const int MAX_BRUSH_ENTS = 398; // DO NOT CHANGE - HALF-LIFE LIMTATION! const int MAX_MONSTERS_PER_ROOM = 4; const int MAX_INDOOR_ROOM_AREA = 110; int monsterlimit; int alien_grunts; int alien_slaves; int barnacles; int barneys; int bullchickens; int headcrabs; int houndeyes; int human_grunts; int human_assassins; int ichthyosaurs; int leechs; int sentrys; int zombies; int weaponfrequency; int w_357; //0 none >0 allowed <0 disabled int w_9mmAR; int w_9mmhandgun; int w_crossbow; int w_egon; int w_gauss; int w_handgrenade; int w_hornetgun; int w_rpg; int w_satchel; int w_shotgun; int w_snark; int w_tripmine; int suck_number(char* line) { int i = 0; int total = -1; while(line[i] >= '0' && line[i] <= '9') { if(total == -1) total = 0; total *= 10; total += line[i] - '0'; i++; } return total; } void load_dofile(char* wad_file) { char line[100]; ifstream f; f.open("dofile.txt"); if(!f.eof()) f.getline(line, 99, '\n'); // throw out first line if(!f.eof()) f.getline(wad_file, 299, '\n'); // throw out first line if(!f.eof()) f.getline(line, 99, '\n'); monsterlimit = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); alien_grunts = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); alien_slaves = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); barnacles = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); barneys = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); bullchickens = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); headcrabs = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); houndeyes = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); human_grunts = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); human_assassins = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); ichthyosaurs = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); leechs = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); sentrys = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); zombies = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); weaponfrequency = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_357 = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_9mmAR = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_9mmhandgun = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_crossbow = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_egon = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_gauss = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_handgrenade = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_hornetgun = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_rpg = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_satchel = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_shotgun = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_snark = suck_number(line); if(!f.eof()) f.getline(line, 99, '\n'); w_tripmine = suck_number(line); f.close(); if(w_tripmine == -1) { cout << "Error in dofile.txt, using defaults where necessary." << endl; system("pause"); } return; } struct block { int x1; int x2; int y1; int y2; int z1; int z2; }; struct face { int u1; int u2; int u3; int x_off; int v1; int v2; int v3; int y_off; int rot; double x_scale; double y_scale; char tex[20]; }; struct position { int x; int y; }; struct door_obj { int room1; int room2; void reset() { room1 = 0; room2 = 0; } }; class room_obj { public: int crumble; int powerups; int lit; int special; // 1 = start, 2 = finish int visited; int monsters; int area; char gunned; char style; char pref_monster; int sunk; int ceiling; void reset() { ceiling = 0; sunk = 0; crumble = 0; powerups = 0; lit = 0; style = 0; special = 0; visited = 0; pref_monster = 0; gunned = 0; monsters = 0; area = 0; } }; class block_textures { public: face top; face bottom; face west; face east; face north; face south; void to_default(); void set_all_textures(const char *tex); }; void block_textures::to_default() { top.u1 = 1; top.u2 = 0; top.u3 = 0; top.x_off = 0; top.v1 = 0; top.v2 = -1; top.v3 = 0; top.y_off = 0; top.rot = 0; top.x_scale = 1; top.y_scale = 1; bottom.u1 = 1; bottom.u2 = 0; bottom.u3 = 0; bottom.x_off = 0; bottom.v1 = 0; bottom.v2 = -1; bottom.v3 = 0; bottom.y_off = 0; bottom.rot = 0; bottom.x_scale = 1; bottom.y_scale = 1; west.u1 = 0; west.u2 = 1; west.u3 = 0; west.x_off = 0; west.v1 = 0; west.v2 = 0; west.v3 = -1; west.y_off = 0; west.rot = 0; west.x_scale = 1; west.y_scale = 1; east.u1 = 0; east.u2 = 1; east.u3 = 0; east.x_off = 0; east.v1 = 0; east.v2 = 0; east.v3 = -1; east.y_off = 0; east.rot = 0; east.x_scale = 1; east.y_scale = 1; north.u1 = 1; north.u2 = 0; north.u3 = 0; north.x_off = 0; north.v1 = 0; north.v2 = 0; north.v3 = -1; north.y_off = 0; north.rot = 0; north.x_scale = 1; north.y_scale = 1; south.u1 = 1; south.u2 = 0; south.u3 = 0; south.x_off = 0; south.v1 = 0; south.v2 = 0; south.v3 = -1; south.y_off = 0; south.rot = 0; south.x_scale = 1; south.y_scale = 1; } void block_textures::set_all_textures(const char *tex) { strcpy(north.tex, tex); strcpy(south.tex, tex); strcpy(west.tex, tex); strcpy(east.tex, tex); strcpy(top.tex, tex); strcpy(bottom.tex, tex); } void writeblock_specific(ofstream &f, block b, block_textures bt) { f << "{\n"; f << "( " << b.x1 << ' ' << b.y2 << ' ' << b.z2 << " ) ( " << b.x2 << ' ' << b.y2 << ' ' << b.z2 << " ) ( " << b.x2 << ' ' << b.y1 << ' ' << b.z2 << " ) " << bt.top.tex << " [ " << bt.top.u1 << ' ' << bt.top.u2 << ' ' << bt.top.u3 << ' ' << bt.top.x_off << " ] [ " << bt.top.v1 << ' ' << bt.top.v2 << ' ' << bt.top.v3 << ' ' << bt.top.y_off << " ] " << bt.top.rot << ' ' << bt.top.x_scale << ' ' << bt.top.y_scale << endl << "( " << b.x1 << ' ' << b.y1 << ' ' << b.z1 << " ) ( " << b.x2 << ' ' << b.y1 << ' ' << b.z1 << " ) ( " << b.x2 << ' ' << b.y2 << ' ' << b.z1 << " ) " << bt.bottom.tex << " [ " << bt.bottom.u1 << ' ' << bt.bottom.u2 << ' ' << bt.bottom.u3 << ' ' << bt.bottom.x_off << " ] [ " << bt.bottom.v1 << ' ' << bt.bottom.v2 << ' ' << bt.bottom.v3 << ' ' << bt.bottom.y_off << " ] " << bt.bottom.rot << ' ' << bt.bottom.x_scale << ' ' << bt.bottom.y_scale << endl << "( " << b.x1 << ' ' << b.y2 << ' ' << b.z2 << " ) ( " << b.x1 << ' ' << b.y1 << ' ' << b.z2 << " ) ( " << b.x1 << ' ' << b.y1 << ' ' << b.z1 << " ) " << bt.west.tex << " [ " << bt.west.u1 << ' ' << bt.west.u2 << ' ' << bt.west.u3 << ' ' << bt.west.x_off << " ] [ " << bt.west.v1 << ' ' << bt.west.v2 << ' ' << bt.west.v3 << ' ' << bt.west.y_off << " ] " << bt.west.rot << ' ' << bt.west.x_scale << ' ' << bt.west.y_scale << endl << "( " << b.x2 << ' ' << b.y2 << ' ' << b.z1 << " ) ( " << b.x2 << ' ' << b.y1 << ' ' << b.z1 << " ) ( " << b.x2 << ' ' << b.y1 << ' ' << b.z2 << " ) " << bt.east.tex << " [ " << bt.east.u1 << ' ' << bt.east.u2 << ' ' << bt.east.u3 << ' ' << bt.east.x_off << " ] [ " << bt.east.v1 << ' ' << bt.east.v2 << ' ' << bt.east.v3 << ' ' << bt.east.y_off << " ] " << bt.east.rot << ' ' << bt.east.x_scale << ' ' << bt.east.y_scale << endl << "( " << b.x2 << ' ' << b.y2 << ' ' << b.z2 << " ) ( " << b.x1 << ' ' << b.y2 << ' ' << b.z2 << " ) ( " << b.x1 << ' ' << b.y2 << ' ' << b.z1 << " ) " << bt.north.tex << " [ " << bt.north.u1 << ' ' << bt.north.u2 << ' ' << bt.north.u3 << ' ' << bt.north.x_off << " ] [ " << bt.north.v1 << ' ' << bt.north.v2 << ' ' << bt.north.v3 << ' ' << bt.north.y_off << " ] " << bt.north.rot << ' ' << bt.north.x_scale << ' ' << bt.north.y_scale << endl << "( " << b.x2 << ' ' << b.y1 << ' ' << b.z1 << " ) ( " << b.x1 << ' ' << b.y1 << ' ' << b.z1 << " ) ( " << b.x1 << ' ' << b.y1 << ' ' << b.z2 << " ) " << bt.south.tex << " [ " << bt.south.u1 << ' ' << bt.south.u2 << ' ' << bt.south.u3 << ' ' << bt.south.x_off << " ] [ " << bt.south.v1 << ' ' << bt.south.v2 << ' ' << bt.south.v3 << ' ' << bt.south.y_off << " ] " << bt.south.rot << ' ' << bt.south.x_scale << ' ' << bt.south.y_scale << endl; f << "}\n"; return; } void writeblock(ofstream &f, block b, const char *tex) { block_textures deftex; deftex.to_default(); deftex.set_all_textures(tex); writeblock_specific(f, b, deftex); } void swipswap(int &x, int &y) { int temp = x; x = y; y = temp; return; } // OHMYGOD! -- ITS A RECURSIVE FUNCTION! int wallfill(char a_read[][DIM_X], char a_write[][DIM_X], int y, int x, const char with, const char stop) { if(y < 0 || y >= DIM_Y || x < 0 || x >= DIM_X) return 0; if(a_read[y][x] != stop && a_write[y][x] != with) { a_write[y][x] = with; void(wallfill(a_read, a_write, y - 1, x, with, stop)); void(wallfill(a_read, a_write, y + 1, x, with, stop)); void(wallfill(a_read, a_write, y, x - 1, with, stop)); void(wallfill(a_read, a_write, y, x + 1, with, stop)); return 1; } return 0; } int searchfill(char a_read[][DIM_X], char a_write[][DIM_X], int y, int x, const char with, const char stop, const char victory) { int found_home = 0; if(y < 0 || y >= DIM_Y || x < 0 || x >= DIM_X) return 0; if(a_write[y][x] == victory) return 1; if(a_read[y][x] != stop && a_write[y][x] != with) { a_write[y][x] = with; found_home += searchfill(a_read, a_write, y - 1, x, with, stop, victory); found_home += searchfill(a_read, a_write, y + 1, x, with, stop, victory); found_home += searchfill(a_read, a_write, y, x - 1, with, stop, victory); found_home += searchfill(a_read, a_write, y, x + 1, with, stop, victory); return found_home; } return 0; } // find number of exits (doors and vents) from a room: void count_doors_and_vents(char a_read[][DIM_X], char a_visit[][DIM_X], int y, int x, int &doors, int &vents) { if(y < 0 || y >= DIM_Y || x < 0 || x >= DIM_X || a_visit[y][x] == '.') return; if(a_read[y][x] == '^') { doors++; return; } if(a_read[y][x] == '-' || a_read[y][x] == '|' || a_read[y][x] == '+') { vents++; return; } a_visit[y][x] = '.'; if(a_read[y][x] != TNT) { count_doors_and_vents(a_read, a_visit, y - 1, x, doors, vents); count_doors_and_vents(a_read, a_visit, y + 1, x, doors, vents); count_doors_and_vents(a_read, a_visit, y, x - 1, doors, vents); count_doors_and_vents(a_read, a_visit, y, x + 1, doors, vents); } return; } int countexits(char a_read[][DIM_X], int y, int x, int &doors, int &vents) { char a[DIM_Y][DIM_X]; int i, j; for(i = 0; i < DIM_Y; i++) for(j = 0; j < DIM_X; j++) a[i][j] = '\0'; doors = 0; vents = 0; count_doors_and_vents(a_read, a, y, x, doors, vents); return doors + vents; } void check_boxfill_helped(char a_read[][DIM_X], char a_visit[][DIM_X], int y, int x, int &exits) { if(y < 0 || y >= DIM_Y || x < 0 || x >= DIM_X || a_visit[y][x] == '.') return; a_visit[y][x] = '.'; if(a_read[y][x] == '^' || a_read[y][x] == '-' || a_read[y][x] == '|' || a_read[y][x] == '+') { exits++; return; } if(a_read[y][x] == '\0') { check_boxfill_helped(a_read, a_visit, y - 1, x, exits); check_boxfill_helped(a_read, a_visit, y + 1, x, exits); check_boxfill_helped(a_read, a_visit, y, x - 1, exits); check_boxfill_helped(a_read, a_visit, y, x + 1, exits); } return; } int check_boxfill(char a_read[][DIM_X], int y, int x) { char a_visit[DIM_Y][DIM_X] = { '\0' }; int exits = 0; check_boxfill_helped(a_read, a_visit, y, x, exits); return exits; } void bridge(char wall[][DIM_X], int doory, int doorx, int y, int x) { int i, j; int stop_minus, stop_plus; if(doory - y == 1) // up { j = 1; stop_minus = 0; stop_plus = 0; while(stop_minus == 0 || stop_plus == 0) // is the other door on this same wall? { if(stop_minus == 0 && wall[y][x - j] == 'o' && wall[doory][x - j] != TNT) // spotted a door { for(; j >= 0; j--) { wall[y][x - j] = '#'; } return; } else if(wall[y][x - j] != 'o') { stop_minus = 1; } if(stop_plus == 0 && wall[y][x + j] == 'o' && wall[doory][x + j] != TNT) // spotted a door { for(; j >= 0; j--) { wall[y][x + j] = '#'; } return; } else if(wall[y][x + j] != 'o') { stop_plus = 1; } j++; } // NO? oh well, build a bridge: for(i = y; i > 0; i--) { if(wall[i][x] == TNT) // hit a wall { i++; // back that ass up j = 1; stop_minus = 0; stop_plus = 0; while(true) { if(stop_minus == 0 && wall[i][x - j] == 'o' && wall[i - 1][x - j] != TNT) // spotted a door { for(; j > 0; j--) { wall[i][x - j] = '#'; } return; } else if(wall[i][x - j] != 'o') { stop_minus = 1; } if(stop_plus == 0 && wall[i][x + j] == 'o' && wall[i - 1][x + j] != TNT) // spotted a door { for(; j > 0; j--) { wall[i][x + j] = '#'; } return; } else if(wall[i][x + j] != 'o') { stop_plus = 1; } j++; } } if(wall[i][x] != 'o') // hit a door return; wall[i][x] = '#'; j = 1; stop_minus = 0; stop_plus = 0; while(stop_minus == 0 || stop_plus == 0) { if(wall[i][x - j] != 'o' && wall[i][x - j] != TNT && stop_minus == 0) // spotted a door { for(j--; j > 0; j--) { wall[i][x - j] = '#'; } return; } else if(wall[i][x - j] != 'o') { stop_minus = 1; } if(wall[i][x + j] != 'o' && wall[i][x + j] != TNT && stop_plus == 0) // spotted a door { for(j--; j > 0; j--) { wall[i][x + j] = '#'; } return; } else if(wall[i][x + j] != 'o') { stop_plus = 1; } j++; } } } else if(y - doory == 1) // down; { //-------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> j = 1; stop_minus = 0; stop_plus = 0; while(stop_minus == 0 || stop_plus == 0) // is the other door on this same wall? { if(stop_minus == 0 && wall[y][x - j] == 'o' && wall[doory][x - j] != TNT) // spotted a door { for(; j >= 0; j--) { wall[y][x - j] = '#'; } return; } else if(wall[y][x - j] != 'o') { stop_minus = 1; } if(stop_plus == 0 && wall[y][x + j] == 'o' && wall[doory][x + j] != TNT) // spotted a door { for(; j >= 0; j--) { wall[y][x + j] = '#'; } return; } else if(wall[y][x + j] != 'o') { stop_plus = 1; } j++; } // NO? oh well, build a bridge: for(i = y; i < DIM_Y; i++) { if(wall[i][x] == TNT) // hit a wall, run along it until we find a door { i--; // back that ass up (reverse of the for) j = 1; stop_minus = 0; stop_plus = 0; while(true) { if(stop_minus == 0 && wall[i][x - j] == 'o' && wall[i + 1][x - j] != TNT) // spotted a door { for(; j > 0; j--) { wall[i][x - j] = '#'; } return; } else if(wall[i][x - j] != 'o') { stop_minus = 1; } if(stop_plus == 0 && wall[i][x + j] == 'o' && wall[i + 1][x + j] != TNT) // spotted a door { for(; j > 0; j--) { wall[i][x + j] = '#'; } return; } else if(wall[i][x + j] != 'o') { stop_plus = 1; } j++; } } if(wall[i][x] != 'o') // hit a door return; wall[i][x] = '#'; j = 1; stop_minus = 0; stop_plus = 0; while(stop_minus == 0 || stop_plus == 0) // look for a door to both sides { if(wall[i][x - j] != 'o' && wall[i][x - j] != TNT && stop_minus == 0) // spotted a door { for(j--; j > 0; j--) { wall[i][x - j] = '#'; } return; } else if(wall[i][x - j] != 'o') { stop_minus = 1; } if(wall[i][x + j] != 'o' && wall[i][x + j] != TNT && stop_plus == 0) // spotted a door { for(j--; j > 0; j--) { wall[i][x + j] = '#'; } return; } else if(wall[i][x + j] != 'o') { stop_plus = 1; } j++; } } } else if(doorx - x == 1) // left; { //--------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> j = 1; stop_minus = 0; stop_plus = 0; while(stop_minus == 0 || stop_plus == 0) // is the other door on this same wall? { if(stop_minus == 0 && wall[y - j][x] == 'o' && wall[y - j][doorx] != TNT) // spotted a door { for(; j >= 0; j--) { wall[y - j][x] = '#'; } return; } else if(wall[y - j][x] != 'o') { stop_minus = 1; } if(stop_plus == 0 && wall[y + j][x] == 'o' && wall[y + j][doorx] != TNT) // spotted a door { for(; j >= 0; j--) { wall[y + j][x] = '#'; } return; } else if(wall[y + j][x] != 'o') { stop_plus = 1; } j++; } // NO? oh well, build a bridge: for(i = x; i > 0; i--) { if(wall[y][i] == TNT) // hit a wall, run along it until we find a door { i++; // back that ass up (reverse of the for) j = 1; stop_minus = 0; stop_plus = 0; while(true) { if(stop_minus == 0 && wall[y - j][i] == 'o' && wall[y - j][i - 1] != TNT) // spotted a door { for(; j > 0; j--) { wall[y - j][i] = '#'; } return; } else if(wall[y - j][i] != 'o') { stop_minus = 1; } if(stop_plus == 0 && wall[y + j][i] == 'o' && wall[y + j][i - 1] != TNT) // spotted a door { for(; j > 0; j--) { wall[y + j][i] = '#'; } return; } else if(wall[y + j][i] != 'o') { stop_plus = 1; } j++; } } if(wall[y][i] != 'o') // hit a door return; wall[y][i] = '#'; j = 1; stop_minus = 0; stop_plus = 0; while(stop_minus == 0 || stop_plus == 0) // look for a door to both sides { if(wall[y - j][i] != 'o' && wall[y - j][i] != TNT && stop_minus == 0) // spotted a door { for(j--; j > 0; j--) { wall[y - j][i] = '#'; } return; } else if(wall[y - j][i] != 'o') { stop_minus = 1; } if(wall[y + j][i] != 'o' && wall[y + j][i] != TNT && stop_plus == 0) // spotted a door { for(j--; j > 0; j--) { wall[y + j][i] = '#'; } return; } else if(wall[y + j][i] != 'o') { stop_plus = 1; } j++; } } } else if(x - doorx == 1) // right; { //-------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> j = 1; stop_minus = 0; stop_plus = 0; while(stop_minus == 0 || stop_plus == 0) // is the other door on this same wall? { if(stop_minus == 0 && wall[y - j][x] == 'o' && wall[y - j][doorx] != TNT) // spotted a door { for(; j >= 0; j--) { wall[y - j][x] = '#'; } return; } else if(wall[y - j][x] != 'o') { stop_minus = 1; } if(stop_plus == 0 && wall[y + j][x] == 'o' && wall[y + j][doorx] != TNT) // spotted a door { for(; j >= 0; j--) { wall[y + j][x] = '#'; } return; } else if(wall[y + j][x] != 'o') { stop_plus = 1; } j++; } // NO? oh well, build a bridge: for(i = x; i < DIM_X; i++) { if(wall[y][i] == TNT) // hit a wall, run along it until we find a door { i--; // back that ass up (reverse of the for) j = 1; stop_minus = 0; stop_plus = 0; while(true) { if(stop_minus == 0 && wall[y - j][i] == 'o' && wall[y - j][i + 1] != TNT) // spotted a door { for(; j > 0; j--) { wall[y - j][i] = '#'; } return; } else if(wall[y - j][i] != 'o') { stop_minus = 1; } if(stop_plus == 0 && wall[y + j][i] == 'o' && wall[y + j][i + 1] != TNT) // spotted a door { for(; j > 0; j--) { wall[y + j][i] = '#'; } return; } else if(wall[y + j][i] != 'o') { stop_plus = 1; } j++; } } if(wall[y][i] != 'o') // hit a door return; wall[y][i] = '#'; j = 1; stop_minus = 0; stop_plus = 0; while(stop_minus == 0 || stop_plus == 0) // look for a door to both sides { if(wall[y - j][i] != 'o' && wall[y - j][i] != TNT && stop_minus == 0) // spotted a door { for(j--; j > 0; j--) { wall[y - j][i] = '#'; } return; } else if(wall[y - j][i] != 'o') { stop_minus = 1; } if(wall[y + j][i] != 'o' && wall[y + j][i] != TNT && stop_plus == 0) // spotted a door { for(j--; j > 0; j--) { wall[y + j][i] = '#'; } return; } else if(wall[y + j][i] != 'o') { stop_plus = 1; } j++; } } } return; } void sink_n_bridge(char wall[][DIM_X], char exits[][DIM_X], int y, int x) { int oldx, oldy; int i = 0; if(y < 0 || y >= DIM_Y || x < 0 || x >= DIM_X || exits[y][x] != 2 || wall[y][x] == 'o') //only works on rooms with 2 doors return; wallfill(exits, wall, y, x, 'o', 0); while(true) { oldx = x; oldy = y; switch(rand() % 4) { case 0: x++; break; case 1: x--; break; case 2: y++; break; case 3: y--; break; } if(wall[y][x] == '^' || wall[y][x] == '-' || wall[y][x] == '|' || wall[y][x] == '+') { bridge(wall, y, x, oldy, oldx); return; } else if(wall[y][x] != 'o') { x = oldx; y = oldy; } i++; } } int smear(char a[][DIM_X], int y, int x, const char sym) { if(y - 1 >=0 && a[y - 1][x] == sym) { a[y][x] = sym; return 1; } if(y + 1 < DIM_Y && a[y + 1][x] == sym) { a[y][x] = sym; return 1; } if(x - 1 >=0 && a[y][x - 1] == sym) { a[y][x] = sym; return 1; } if(x + 1 < DIM_X && a[y][x + 1] == sym) { a[y][x] = sym; return 1; } return 0; } void exchange(char a[][DIM_X], const char from, const char to) { int i = 0; int j; while(i < DIM_Y) { j = 0; while(j < DIM_X) { if(a[i][j] == from) a[i][j] = to; j++; } i++; } return; } int count(char a[][DIM_X], const char sym) { int i = 0; int j; int dracula = 0; while(i < DIM_Y) { j = 0; while(j < DIM_X) { if(a[i][j] == sym) dracula++; j++; } i++; } return dracula; } int grabsome(char a[][DIM_X], int &goty, int &gotx, int &toy, int &tox, const char c) { int locky, lockx, i, j; gotx = -1; i = 0; while(i < DIM_Y) { j = 0; while(j < DIM_X) { if(a[i][j] == c) { gotx = j; goty = i; break; } j++; } if(gotx != -1) break; i++; } if(gotx == -1) return 1; tox = gotx; toy = goty; lockx = 0; locky = 0; while(true) { if(tox + 1 >= DIM_X) lockx = 1; else { for(i = goty; i <= toy; i++) { if(a[i][tox + 1] != c) { lockx = 1; break; } } if(lockx == 0) tox++; } if(toy + 1 >= DIM_Y) locky = 1; else { for(i = gotx; i <= tox; i++) { if(a[toy + 1][i] != c) { locky = 1; break; } } if(locky == 0) toy++; } if(lockx && locky) break; } for(i = goty; i <= toy; i++) for(j = gotx; j <= tox; j++) a[i][j] = '`'; return 0; } void write_kill_zone(ofstream f) { f << q << "classname" << q << ' ' << q << "trigger_hurt" << q << endl << q << "dmg" << q << ' ' << q << "999" << q << endl << q << "damagetype" << q << ' ' << q << "32" << q << endl; return; } void write_end_zone(ofstream f) { f << q << "classname" << q << ' ' << q << "trigger_endsection" << q << endl << q << "section" << q << ' ' << q << "_oem_end_logo" << q << endl << q << "spawnflags" << q << ' ' << q << "1" << q << endl << q << "targetname" << q << ' ' << q << "quit_to_menu" << q << endl; return; } void write_end_trigger(ofstream f) { f << q << "classname" << q << ' ' << q << "trigger_once" << q << endl << q << "target" << q << ' ' << q << "end_man" << q << endl; return; } void write_crate_ent(ofstream f) { int content = 0; int cap = weaponfrequency; if(cap > 100) cap = 100; //pick an item to be inside: if(rand() % 200 < cap) { if(rand() % 2 == 1) { content = rand() % 2 + 1; // health or battery } else { switch(rand() % 12) { case 0: if(w_357) content = 13; break; case 1: if(w_9mmAR) content = 6; break; case 2: if(w_9mmAR) content = 7; break; case 3: if(w_9mmhandgun) content = 4; break; case 4: if(w_crossbow) content = 11; break; case 5: if(w_egon) content = 16; break; case 6: if(w_gauss) content = 16; break; case 7: if(w_rpg) content = 15; break; case 8: if(w_shotgun) content = 9; break; case 9: if(w_handgrenade) content = 17; break; case 10: if(w_tripmine) content = 18; break; case 11: if(w_satchel) content = 19; break; } } } f << q << "classname" << q << ' ' << q << "func_pushable" << q << endl << q << "spawnflags" << q << ' ' << q << "128" << q << endl << q << "health" << q << ' ' << q << "25" << q << endl << q << "material" << q << ' ' << q << "1" << q << endl << q << "explosion" << q << ' ' << q << "1" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "size" << q << ' ' << q << "2" << q << endl << q << "friction" << q << ' ' << q << "180" << q << endl << q << "buoyancy" << q << ' ' << q << "30" << q << endl << q << "spawnobject" << q << ' ' << q << content << q << endl; return; } void write_explosive_crate_ent(ofstream f, int num, int x, int y, int z) { f << q << "classname" << q << ' ' << q << "env_explosion" << q << endl << q << "targetname" << q << ' ' << q << num << q << endl << q << "iMagnitude" << q << ' ' << q << "150" << q << endl << q << "origin" << q << ' ' << q << x << ' ' << y << ' ' << z << q << endl << "}\n{\n" << q << "classname" << q << ' ' << q << "env_shooter" << q << endl << q << "targetname" << q << ' ' << q << num << q << endl << q << "m_iGibs" << q << ' ' << q << "10" << q << endl << q << "m_flVelocity" << q << ' ' << q << "400" << q << endl << q << "m_flVariance" << q << ' ' << q << "0.55" << q << endl << q << "m_flGibLife" << q << ' ' << q << "1" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "shootmodel" << q << ' ' << q << "models/woodgibs.mdl" << q << endl << q << "shootsounds" << q << ' ' << q << "1" << q << endl << q << "scale" << q << ' ' << q << "100" << q << endl << q << "angles" << q << ' ' << q << "-90 0 0" << q << endl << q << "origin" << q << ' ' << q << x << ' ' << y << ' ' << z << q << endl << "}\n{\n" << q << "classname" << q << ' ' << q << "func_breakable" << q << endl << q << "health" << q << ' ' << q << "30" << q << endl << q << "material" << q << ' ' << q << "1" << q << endl << q << "target" << q << ' ' << q << num << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl; return; } int neighbors(const char a[][DIM_X], const int y, const int x, const char test) { int count = 0; if(y - 1 >= 0 && a[y - 1][x] == test) count++; if(y + 1 < DIM_Y && a[y + 1][x] == test) count++; if(x - 1 >= 0 && a[y][x - 1] == test) count++; if(x + 1 >= 0 && a[y][x + 1] == test) count++; return count; } void write_255_func_wall(ofstream f) { f << q << "classname" << q << ' ' << q << "func_wall" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "rendermode" << q << ' ' << q << "4" << q << endl << q << "renderamt" << q << ' ' << q << "255" << q << endl; return; } void write_255_metal_breakable(ofstream f) { f << q << "classname" << q << ' ' << q << "func_breakable" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "rendermode" << q << ' ' << q << "4" << q << endl << q << "renderamt" << q << ' ' << q << "255" << q << endl << q << "health" << q << ' ' << q << "10" << q << endl << q << "material" << q << ' ' << q << "2" << q << endl; return; } int rooms_around(char r[][DIM_X], int i, int j, int &room1, int &room2) { int found_a_room = 0; if(r[i - 1][j] != '\0') // if not un-numbered in room array { room1 = r[i - 1][j]; found_a_room++; } if(r[i + 1][j] != '\0') // if not un-numbered in room array { if(found_a_room == 0) room1 = r[i + 1][j]; else room2 = r[i + 1][j]; found_a_room++; } if(r[i][j - 1] != '\0') // if not un-numbered in room array { if(found_a_room == 0) room1 = r[i][j - 1]; else room2 = r[i][j - 1]; found_a_room++; } if(r[i][j + 1] != '\0') // if not un-numbered in room array { if(found_a_room == 0) room1 = r[i][j + 1]; else room2 = r[i][j + 1]; found_a_room++; } return found_a_room; } void knock_down(char walls[][DIM_X], char e[][DIM_X], const char room_nums[][DIM_X], int room1, int room2) // knocks down a wall between room1 and room2 { if(room1 == room2) return; int i, j; for(i = 1; i < DIM_Y - 1; i++) for(j = 1; j < DIM_X - 1; j++) if(neighbors(room_nums, i, j, room1) == 1 && neighbors(room_nums, i, j, room2) == 1) { if(walls[i][j] != '^') walls[i][j] = '\0'; if(neighbors(e, i, j, 'k') + neighbors(e, i, j, 'K') > 1) e[i][j] = 'k'; } return; } void electrician(char l[][DIM_X], int y, int x, int oldy = -1, int oldx = -1) { int i; if(x == oldx) { if(oldy < y) swipswap(y, oldy); for(i = y + 1; i < oldy; i++) l[i][x] = '['; } else if(y == oldy) { if(oldx < x) swipswap(x, oldx); for(i = x + 1; i < oldx; i++) l[y][i] = '_'; } return; } int try_light(char r[][DIM_X], char w[][DIM_X], char l[][DIM_X], int y, int x, int oldy = -1, int oldx = -1) { int order; int i; if(x >= 0 && y >= 0 && x < DIM_X && y < DIM_Y) if(oldy == -1 || r[y][x] == r[oldy][oldx]) if((w[y][x] == '\0' || w[y][x] == '#') && l[y][x] == 0) { l[y][x] = 'L'; if(oldx != -1) electrician(l, y, x, oldy, oldx); order = rand() % 4; i = order; while(i < order + 3) { switch(i % 4) { case 0: try_light(r, w, l, y - 4, x, y, x); break; case 1: try_light(r, w, l, y, x - 4, y, x); break; case 2: try_light(r, w, l, y + 4, x, y, x); break; case 3: try_light(r, w, l, y, x - 4, y, x); break; } i++; } return 1; } return 0; } int calculate_room_degrees(room_obj room[], door_obj door[], int last_room, int last_door, int startroom) { room[startroom].visited = 1; int i, j; int newroom = 1; int rec_room; j = 2; while(newroom == 1) // repeat until no new rooms encountered. { newroom = 0; for(i = 1; i <= last_door; i++) // cycle through all doors { if(room[door[i].room1].visited == j - 1) { if(room[door[i].room2].visited == 0) { room[door[i].room2].visited = j; newroom = 1; rec_room = door[i].room2; // farthest room so far } } if(room[door[i].room2].visited == j - 1) { if(room[door[i].room1].visited == 0) { room[door[i].room1].visited = j; newroom = 1; rec_room = door[i].room1; // farthest room so far } } } j++; cout << j << endl; } return rec_room; } // draws a line of '?'s across an array. DECOMMISSIONED! void draw_line(char w[][DIM_X], int y1, int x1, int y2, int x2) { double finey = y1; double finex = x1; double incy = (y2 - y1) / ((double)DIM_Y); double incx = (x2 - x1) / ((double)DIM_X); while(int(finey) != y2 || int(finex) != x2) { finey += incy; finex += incx; w[int(finey)][int(finex)] = '?'; } return; } // counts how many walls are between two points by straight line int how_many_walls_between(char w[][DIM_X], int y1, int x1, int y2, int x2) { int count = 0; int lasty = y1; int lastx = x1; double finey = y1; double finex = x1; double incy = (y2 - y1) / ((double)DIM_Y); double incx = (x2 - x1) / ((double)DIM_X); while(int(finey) != y2 || int(finex) != x2) { lasty = int(finey); lastx = int(finex); finey += incy; finex += incx; if((lasty != int(finey) || lastx != int(finex)) && w[int(finey)][int(finex)] == TNT) count++; } return count; } char random_monster() { int i; for(i = 0; i < 50; i++) { switch(rand() % 11) { case 0: if(alien_grunts) { alien_grunts--; return 'f'; } break; case 1: if(alien_slaves) { alien_slaves--; return 's'; } break; case 2: if(barnacles) { barnacles--; return 'b'; } break; case 3: if(barneys) { barneys--; return 'r'; } break; case 4: if(bullchickens) { bullchickens--; return 'q'; } break; case 5: if(headcrabs) { headcrabs--; return 'c'; } break; case 6: if(houndeyes) { houndeyes--; return 'h'; } break; case 7: if(human_grunts) { human_grunts--; return 'g'; } break; case 8: if(human_assassins) { human_assassins--; return 'a'; } break; case 9: if(sentrys) { sentrys--; return 'm'; } break; case 10: if(zombies) { zombies--; return 'z'; } break; } } return '\0'; // all out of stock } char pick_weapon(int kind) // 0 any, 1 starting, 2 common, 3 good, 4 great { int i; while(true) { i = 0; while(i < 60) { switch(rand() % 13) { case 0: if(0 < w_357 && kind < 3) { if(rand() % 5 == 1) w_357 = -1; return 'A'; } break; case 1: if(0 < w_9mmAR && (kind > 1 || kind == 0)) { if(rand() % 3 == 1) w_9mmAR = -1; return 'M'; } break; case 2: if(0 < w_9mmhandgun && kind < 3) { if(rand() % 8 == 1) w_9mmhandgun = -1; return 'P'; } break; case 3: if(0 < w_crossbow && (kind > 2 || kind == 0)) { if(rand() % 3 == 1) w_crossbow = -1; return 'C'; } break; case 4: if(0 < w_egon && (kind == 4 || kind == 0)) { w_egon = -1; return 'E'; } break; case 5: if(0 < w_gauss && (kind == 4 || kind == 0)) { if(rand() % 2 == 1) w_gauss = -1; return 'U'; } break; case 6: if(0 < w_handgrenade && kind < 3) { if(rand() % 3 == 1) w_handgrenade = -1; return 'G'; } break; case 7: if(0 < w_hornetgun && (kind == 4 || kind == 0)) { if(rand() % 2 == 1) w_hornetgun = -1; return 'H'; } break; case 8: if(0 < w_rpg && (kind == 4 || kind == 0)) { if(rand() % 2 == 1) w_rpg = -1; return 'R'; } break; case 9: if(0 < w_satchel && (kind > 1 || kind == 0)) { if(rand() % 3 == 1) w_satchel = -1; return 'L'; } break; case 10: if(0 < w_shotgun) { if(rand() % 4 == 1) w_shotgun = -1; return 'S'; } break; case 11: if(0 < w_snark && (kind == 4 || kind == 0)) { if(rand() % 3 == 1) w_snark = -1; return 'K'; } break; case 12: if(0 < w_tripmine && (kind == 3 || kind == 0)) { if(rand() % 3 == 1) w_tripmine = -1; return 'T'; } break; } i++; } if(kind == 4) kind = 3; else if(kind == 3 || kind == 1) kind = 0; else return '\0'; } } char ammo_of(char gun) { switch(gun) { case 'A': return '1'; case 'M': return '2'; case 'P': return '2'; case 'C': return '3'; case 'E': return '4'; case 'U': return '4'; case 'H': return '\0'; case 'R': return '5'; case 'S': return '6'; case 'K': return '\0'; } return gun; } position farthest_from(position point, char w[][DIM_X], char v[][DIM_X], char e[][DIM_X]) { int i, j; int count = 1; int stayinalive = 1; position record; v[point.y][point.x] = count; while(stayinalive) { stayinalive = 0; count++; for(i = 1; i < DIM_Y - 1; i++) { for(j = 1; j < DIM_X - 1; j++) { if(w[i][j] != TNT && w[i][j] != 'o' && e[i][j] != 'k' && e[i][j] != 'K' && v[i][j] == 0) // if not wall and not visited { if(v[i + 1][j] == count - 1 || v[i - 1][j] == count - 1 || v[i][j + 1] == count - 1 || v[i][j - 1] == count - 1) // if any neighbor visited { record.y = i; record.x = j; v[i][j] = count; stayinalive = 1; } } } } if(count == 100) count = 1; //system("cls"); for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(count == 1 && v[i][j] > 0) v[i][j] = 1; //if(v[i][j] != 0) // cout << '%'; //else if(e[i][j] != 0) // cout << e[i][j]; //else // cout << w[i][j]; } //cout << endl; } //cout << count << endl; //system("pause"); } return record; } void main(int argc, char *argv[]) { ofstream f; block brush; char w[DIM_Y][DIM_X]; //walls char exits[DIM_Y][DIM_X]; //exits out of a room char e[DIM_Y][DIM_X]; //entities char v[DIM_Y][DIM_X]; //visitation char r[DIM_Y][DIM_X]; //room number char d[DIM_Y][DIM_X]; //door number char l[DIM_Y][DIM_X]; //lights char m[DIM_Y][DIM_X]; //monsters char c[DIM_Y][DIM_X]; //ceiling char g[DIM_Y][DIM_X]; //ground height char h[DIM_Y][DIM_X]; //height from floor to ceiling char n[DIM_Y][DIM_X]; //nodes room_obj room[100]; door_obj door[100]; int w_dir, w_startx, w_starty, dstop; int i, j; int strand; int made_start; // player start int x, y; int failcount; // random tracebacks int found_a_way_home, found_a_wall; int door_dracula, door_guess, door_badger; int gotx, goty; // write it down int tox,toy; int exp; int doors, vents; // count exits char r_num; int last_door, last_room; int room1, room2; unsigned int map_number; block_textures btex; int tries, more_tries; unsigned int input = 1; position startpos; position endpos; int brush_ents; int z_boost; char mapname[30]; unsigned int seed; unsigned long longy; char wad_file[300]; //while(input != 0) //{ strand = 1000; made_start = 0; failcount = 0; brush_ents = 0; load_dofile(wad_file); for(i = 0; i < DIM_Y; i++) for(j = 0; j< DIM_X; j++) { w[i][j] = 0; v[i][j] = 0; e[i][j] = 0; exits[i][j] = 0; r[i][j] = 0; d[i][j] = 0; l[i][j] = 0; m[i][j] = 0; c[i][j] = 0; n[i][j] = 0; g[i][j] = 0; h[i][j] = 0; } for(i = 0; i < 100; i++) { room[i].reset(); door[i].reset(); } map_number = 0; i = 0; while(argc > 1 && argv[1][i] != '\0') { map_number *= 10; map_number += argv[1][i] - 48; i++; } if(map_number == 0) map_number = (unsigned)time(0); srand(map_number); // SEED! for(i = 0; i < NUM_WALLS; i++) { w_startx = rand() % DIM_X; w_starty = rand() % DIM_Y; j = 1; w_dir = rand() % 2; dstop = 0; while(dstop == 0 && j < MAX_LOOK_FOR_ATTACH) { if(w_dir == HORIZ) { if(w_startx + j < DIM_X && w[w_starty][w_startx + j] == TNT) dstop = 1; if(w_startx - j >= 0 && w[w_starty][w_startx - j] == TNT) dstop = 1; if(dstop == 0) w_dir = VERT; } if(w_dir == VERT) { if(w_starty + j < DIM_Y && w[w_starty + j][w_startx] == TNT) dstop = 1; if(w_starty - j >= 0 && w[w_starty - j][w_startx] == TNT) dstop = 1; if(dstop == 0) w_dir = HORIZ; } j++; } if(j >= MAX_LOOK_FOR_ATTACH) w_dir = rand() % 2; if(w_dir == HORIZ) { j = w_startx; while(j < DIM_X) { if((j != w_startx) && (w[w_starty][j] != '\0')) break; else w[w_starty][j] = TNT; j++; } j = w_startx; while(j >= 0) { if((j != w_startx) && (w[w_starty][j] != '\0')) break; else w[w_starty][j] = TNT; j--; } } else { j = w_starty; while(j < DIM_Y) { if((j != w_starty) && (w[j][w_startx] != '\0')) break; else w[j][w_startx] = TNT; j++; } j = w_starty; while(j >= 0) { if((j != w_starty) && (w[j][w_startx] != '\0')) break; else w[j][w_startx] = TNT; j--; } } } for(i = 0; i < DIM_X; i++) { if(w[0][i] == '\0') void(wallfill(w, w, 0, i, TNT, TNT)); if(w[DIM_Y-1][i] == '\0') void(wallfill(w, w, DIM_Y-1, i, TNT, TNT)); } for(i = 0; i < DIM_Y; i++) { if(w[i][0] == '\0') void(wallfill(w, w, i, 0, TNT, TNT)); if(w[i][DIM_X-1] == '\0') void(wallfill(w, w, i, DIM_X-1, TNT, TNT)); } while(j < EXTRA_WALL_FILLS * 10) { if(wallfill(w, w, rand() % (DIM_Y / 2) + (DIM_Y / 4), rand() % (DIM_X / 2) + (DIM_X / 4), TNT, TNT) == 1) j += 10; else j++; } //player start for(i = 15; i < DIM_Y; i++) { for(j = 0; j <= i; j++) { if(w[i - j][j] == '\0') { y = i - j; x = j; made_start = 1; break; } } if(made_start) break; } e[y][x] = 's'; startpos.x = x; startpos.y = y; if(wallfill(w, v, y, x, '.', TNT) == 0) // make starting pad { cout << "FATAL ERROR!" << "FATAL ERROR!" << "FATAL ERROR!" << "Failed to generate homing zone!\n\n\n"; return; } //random tracebacks while(failcount < 20) { x = rand() % DIM_X; y = rand() % DIM_Y; if(w[y][x] == '\0') { found_a_way_home = 0; while(found_a_way_home == 0) { exchange(v, '!', '\0'); if(searchfill(w, v, y, x, '!', TNT, '.') != 0) { found_a_way_home = 1; exchange(v, '!', '.'); } else { found_a_wall = 0; while(found_a_wall == 0) { door_guess = rand() % count(v, '!'); x = 0; y = 0; for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(v[i][j] == '!') { if(door_guess == 0) { y = i; x = j; break; } else door_guess--; } } if(x != 0 && y != 0) break; } door_dracula = rand() % 64; for(i = 0; i < 4; i++) { door_badger = 0; switch(door_dracula % 4) { case 0: if(x + 1 < DIM_X - 1) if(w[y][x + 1] == TNT) if(w[y][x + 2] != TNT && v[y][x + 2] != '!') { found_a_wall = 1; x++; } else if(rand() % 16 == 7) { for(j = x + 3; j < DIM_X; j++) { if(w[y][j] != TNT && v[y][j] != '!') { door_badger = j; found_a_wall = -1; break; } else if(w[y][j] != TNT || (w[y - 1][j] != TNT && w[y + 1][j] != TNT)) break; } if(door_badger) for(j = x + 1; j < door_badger; j++) { w[y][j] = '-'; // badger part of a door } } break; case 1: if(x - 1 > 0) if(w[y][x - 1] == TNT) if(w[y][x - 2] != TNT && v[y][x - 2] != '!') { found_a_wall = 1; x--; } else if(rand() % 16 == 7) { for(j = x - 3; j > 0; j--) { if(w[y][j] != TNT && v[y][j] != '!') { door_badger = j; found_a_wall = -1; break; } else if(w[y][j] != TNT || (w[y - 1][j] != TNT && w[y + 1][j] != TNT)) break; } if(door_badger) for(j = x - 1; j > door_badger; j--) { w[y][j] = '-'; // badger part of a door } } break; case 2: if(y + 1 < DIM_Y - 1) if(w[y + 1][x] == TNT) if(w[y + 2][x] != TNT && v[y + 2][x] != '!') { found_a_wall = 1; y++; } else if(rand() % 16 == 7) { for(j = y + 3; j < DIM_Y; j++) { if(w[j][x] != TNT && v[j][x] != '!') { door_badger = j; found_a_wall = -1; break; } else if(w[j][x] != TNT || (w[j][x - 1] != TNT && w[j][x + 1] != TNT)) break; } if(door_badger) for(j = y + 1; j < door_badger; j++) { w[j][x] = '|'; // badger part of a door } } break; case 3: if(y - 1 > 0) if(w[y - 1][x] == TNT) if(w[y - 2][x] != TNT && v[y - 2][x] != '!') { found_a_wall = 1; y--; } else if(rand() % 16 == 7) { for(j = y - 3; j > 0; j--) // -> BUG WAS HERE 'y + 3' { if(w[j][x] != TNT && v[j][x] != '!') { door_badger = j; found_a_wall = -1; break; } else if(w[j][x] != TNT || (w[j][x - 1] != TNT && w[j][x + 1] != TNT)) break; } if(door_badger) for(j = y - 1; j > door_badger; j--) { w[j][x] = '|'; // badger part of a door } } break; } if(found_a_wall) break; else door_dracula++; } } if(found_a_wall == 1) w[y][x] = '^'; // make a door! } } } else failcount++; } // find connected vents for(j = 1; j < DIM_Y - 1; j++) { for(i = 1; i < DIM_X - 1; i++) { if(w[j][i] == '-' && (w[j - 1][i] == '|' || w[j + 1][i] == '|')) w[j][i] = '+'; if(w[j][i] == '|' && (w[j][i - 1] == '-' || w[j][i + 1] == '-')) w[j][i] = '+'; if(w[j][i] == '-' && (w[j - 1][i] == '\0' || w[j + 1][i] == '\0')) w[j][i] = '\0'; if(w[j][i] == '|' && (w[j][i - 1] == '\0' || w[j][i + 1] == '\0')) w[j][i] = '\0'; if(w[j][i] == '-' && (w[j - 1][i] == '^' || w[j + 1][i] == '^')) w[j][i] = '+'; if(w[j][i] == '|' && (w[j][i - 1] == '^' || w[j][i + 1] == '^')) w[j][i] = '+'; } } // fill in unused rooms for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(v[i][j] == '\0' && w[i][j] == '\0') wallfill(w, w, i, j, TNT, TNT); } } // kill idiotic hallways for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(w[i][j] == '\0' && neighbors(w, i, j, '^') != 0) // if open space & 1 or more door neighbors, put a 'd' in its visit { v[i][j] = 'd'; } } } for(i = 1; i < DIM_Y - 1; i++) { for(j = 1; j < DIM_X - 1; j++) { if(w[i][j] == '\0' && neighbors(w, i, j, TNT) == 3 && neighbors(w, i, j, '\0') == 1 && neighbors(v, i, j, 'd') == 0) // if open & has 3 wall neighbors, 1 open space neighbor, and 0 'd' neighbors { if(e[i][j] != 's') w[i][j] = TNT; } } } for(i = DIM_Y - 2; i > 0; i--) // now in reverse { for(j = DIM_X - 2; j > 0; j--) { if(w[i][j] == '\0' && neighbors(w, i, j, TNT) == 3 && neighbors(w, i, j, '\0') == 1 && neighbors(v, i, j, 'd') == 0) // if open & has 3 wall neighbors, 1 open space neighbor, and 0 'd' neighbors { if(e[i][j] != 's') w[i][j] = TNT; } } } // count all rooms' doors & vents (exits) for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(w[i][j] == '\0' && exits[i][j] == 0) exits[i][j] = countexits(w, i, j, doors, vents); } } //number off all the rooms r_num = char(1); for(i = DIM_Y - 1; i >= 0; i--) { for(j = 0; j < DIM_X; j++) { if(r[i][j] == '\0' && exits[i][j] != 0) { if (wallfill(exits, r, i, j, r_num, '\0')) r_num = r_num + 1; } } } last_room = r_num - 1; room[r[startpos.y][startpos.x]].special = 1; // startroom //number off all the doors r_num = char(1); for(i = DIM_Y - 2; i > 0; i--) { for(j = 1; j < DIM_X - 1; j++) { if(w[i][j] == '^') { d[i][j] = r_num; rooms_around(r, i, j, door[r_num].room1, door[r_num].room2); r_num = r_num + 1; } } } last_door = r_num - 1; // dig a hole(s) i = 0; while(i < MAX_HOLES) { x = rand() % DIM_X; y = rand() % DIM_Y; if(room[r[y][x]].crumble != 1 && room[r[y][x]].special != 1) sink_n_bridge(w, exits, y, x); i++; } // and connect holes for(j = 1; j < DIM_Y - 1; j++) for(i = 1; i < DIM_X - 1; i++) if(w[j][i] == TNT && ( ((w[j - 1][i] == 'o' || w[j - 1][i] == '#') && (w[j + 1][i] == 'o' || w[j + 1][i] == '#')) || ((w[j][i - 1] == 'o' || w[j][i - 1] == '#') && (w[j][i + 1] == 'o' || w[j][i + 1] == '#')) ) && neighbors(w, j, i, '^') == 0 && neighbors(w, j, i, '-') == 0 && neighbors(w, j, i, '|') == 0 && neighbors(w, j, i, '+') == 0) { w[j][i] = 'o'; } //boxfill more_tries = 0; while(more_tries < MAX_BOX_ROOMS) { x = rand() % (DIM_X - 2) + 1; y = rand() % (DIM_Y - 2) + 1; if(room[r[y][x]].special == 1) { y = startpos.y; x = startpos.x; } if(exits[y][x] > 0 && w[y][x] == '\0') // is a room (exits used to have to be greater than 1) { failcount = 0; for(i = 1; i < DIM_Y - 1 && failcount == 0; i++) for(j = 1; j < DIM_X - 1 && failcount == 0; j++) if(r[y][x] == r[i][j]) { goty = i; gotx = j; failcount = 1; } tries = 0; room[r[y][x]].style = 'B'; // Box filled room while(tries < 500) { failcount = rand() % count(r, r[goty][gotx]); for(i = goty; i < DIM_Y - 1; i++) { for(j = gotx; j < DIM_X - 1; j++) { if(r[i][j] == r[y][x]) { if(failcount-- == 0) { w[i][j] = 'K'; if(check_boxfill(w, y, x) != exits[i][j]) { w[i][j] = '\0'; } } } } } tries++; } } more_tries++; } // replace K's with boxes for(i = 0; i < DIM_Y; i++) for(j = 0; j < DIM_X; j++) { if(w[i][j] == 'K') //&& neighbors(w, i, j, '\0') < 2) { if(rand() % 2 == 1) e[i][j] = 'k'; else e[i][j] = 'K'; } } for(i = 0; i < DIM_Y; i++) for(j = 0; j < DIM_X; j++) { if(w[i][j] == 'K') { w[i][j] = '\0'; } } for(i = 0; i < DIM_Y; i++) for(j = 0; j < DIM_X; j++) { if(w[i][j] == '\0') { if(neighbors(e, i, j, 'K') + neighbors(e, i, j, 'k') > 0) { if(neighbors(e, i, j, 'k') + neighbors(e, i, j, 'K') + neighbors(w, i, j, TNT) >= 3 && e[i][j] == 0) e[i][j] = 'v'; } } } for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(w[i][j] == '\0' && room[r[i][j]].style == 'B' && neighbors(e, i, j, 'K') + neighbors(e, i, j, 'k') + neighbors(e, i, j, 'v') + neighbors(w, i, j, TNT) == 2 && (e[i - 1][j] != e[i + 1][j] || w[i - 1][j] != w[i + 1][j]) && (e[i][j - 1] != e[i][j + 1] || w[i][j - 1] != w[i][j + 1])) { n[i][j] = 'n'; } if(w[i][j] == '\0' && room[r[i][j]].style == 'B' && neighbors(e, i, j, 'K') + neighbors(e, i, j, 'k') + neighbors(e, i, j, 'v') + neighbors(w, i, j, TNT) == 1) { n[i][j] = 'n'; } } } //knock down some walls i = 0; tries = 0; while(i < WALL_KNOCKS) { x = rand() % (DIM_X - 2) + 1; y = rand() % (DIM_Y - 2) + 1; if(w[y][x] == TNT && rooms_around(r, y, x, room1, room2) == 2 && neighbors(w, y, x, 'o') == 0 && neighbors(w, y, x, '#') == 0) // if wall with two rooms around it { failcount = 0; for(j = 1; j <= last_door; j++) { if(door[j].room1 == room1 && door[j].room2 == room2) // if theres already a door in this wall failcount = 1; } if(failcount == 0) { tries++; knock_down(w, e, r, room1, room2); room[room1].crumble = 1; room[room2].crumble = 1; } } i++; } // count all rooms' doors & vents (exits) for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(w[i][j] == '\0' && exits[i][j] == 0) exits[i][j] = countexits(w, i, j, doors, vents); } } // throw in some crates i = 0; while(i < CRATE_FREQUENCY * CRATE_CLUSTERING && CRATE_CLUSTERING < 99) // if crate_clusterin >= 99 this will infloop { x = rand() % (DIM_X - 2) + 1; y = rand() % (DIM_Y - 2) + 1; if((room[r[y][x]].style != 'B' || e[y][x] == '1') && w[y][x] == '\0' || w[y][x] == '^') // this is a crateable square { if((e[y][x] == '1' || e[y - 1][x] == '1' || e[y - 1][x] == '2' || e[y + 1][x] == '1' || e[y + 1][x] == '2' || e[y][x - 1] == '1' || e[y][x - 1] == '2' || e[y][x + 1] == '1' || e[y][x + 1] == '2') || rand() % 100 > CRATE_CLUSTERING) { if(e[y][x] == '\0') e[y][x] = '1'; else if(e[y][x] == '1') e[y][x] = '2'; } else // failure due to clustering parameters should not result in increment i--; } i++; } for(i = 0; i < 100; i++) { room[i].reset(); door[i].reset(); } for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { r[i][j] = '\0'; } } //number off all the rooms _AGAIN_ now that walls were knocked down r_num = char(1); for(i = DIM_Y - 1; i >= 0; i--) { for(j = 0; j < DIM_X; j++) { if(r[i][j] == '\0' && exits[i][j] != 0) { if (wallfill(exits, r, i, j, r_num, '\0')) r_num = r_num + 1; } } } last_room = r_num - 1; room[r[startpos.y][startpos.x]].special = 1; // startroom //number off all the doors _AGAIN_ r_num = char(1); for(i = DIM_Y - 2; i > 0; i--) { for(j = 1; j < DIM_X - 1; j++) { if(w[i][j] == '^') { d[i][j] = r_num; rooms_around(r, i, j, door[r_num].room1, door[r_num].room2); r_num = r_num + 1; } } } last_door = r_num - 1; for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(e[i][j] == 'k' || e[i][j] == 'K' || e[i][j] == 'v') room[r[i][j]].style = 'B'; //boxfill if(w[i][j] == 'o' || e[i][j] == '#') room[r[i][j]].style = 'P'; //pit if(c[i][j] == '/') room[r[i][j]].style = 'O'; //outside } } //find area of each room for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(r[i][j] > 0) { room[r[i][j]].area++; } } } // THIS IS TOO CRASHY AS OF YET: /*x = calculate_room_degrees(room, door, last_room, last_door, r[startpos.y][startpos.x]); for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(r[i][j] == x) e[i][j] = '$'; } }*/ // plug in some lights i = 0; while(i < MAX_LIGHTING) { x = rand() % (DIM_X - 2) + 1; y = rand() % (DIM_Y - 2) + 1; if(room[r[y][x]].lit == 0) { room[r[y][x]].lit = try_light(r, w, l, y, x); } i++; } // sky for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(room[r[i][j]].area > MAX_INDOOR_ROOM_AREA) { c[i][j] = '/'; l[i][j] = 0; } } } // nodes for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if((w[i][j] == '\0' || w[i][j] == '#') && neighbors(w, i, j, '^') > 0) { n[i][j] = 'n'; } if(w[i][j] == '#' && neighbors(w, i, j, '#') == 2 && w[i - 1][j] != w[i + 1][j] && w[i][j - 1] != w[i][j + 1]) { n[i][j] = 'n'; } } } for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_Y; j++) { v[i][j] = 0; } } /*made_start = 0; // end in this case for(i = DIM_Y - 15; i > 0; i--) { for(j = DIM_X; i + (DIM_X - j) < DIM_Y; j--) { if(w[i + (DIM_X - j)][j] == '\0' && e[i + (DIM_X - j)][j] == '\0') { y = i + (DIM_X - j); x = j; made_start = 1; break; } } if(made_start) break; }*/ endpos = farthest_from(startpos, w, v, e); e[endpos.y][endpos.x] = 'e'; /*int sunkified; //DIFFERENT FLOOR HEIGHTS i = 0; while(i < 20) { sunkified = (rand() % 8 + 1) * 16; j = rand() % last_room + 1; while(!room[j].sunk && !room[j].style) { room[j].sunk = sunkified; } }*/ //draw_line(w, startpos.y, startpos.x, startpos.y, rand() % DIM_X); //mark possible monster spots /*for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(w[i][j] == '\0') if(how_many_walls_between(w, startpos.y, startpos.x, i, j) > 1) v[i][j] = '@'; } }*/ // INSERT MONSTERS! i = 0; j = 0; while(i < monsterlimit && j < 4000) { x = rand() % DIM_X; y = rand() % DIM_Y; if(m[y][x] == 0 && ( w[y][x] == '\0' || w[y][x] == '#') && room[r[y][x]].lit == 0 && room[r[y][x]].pref_monster == 0 && e[y][x] != 'K' && e[y][x] != 'e' && e[y][x] != '1' && e[y][x] != '2' && e[y][x] != 'v' && e[y][x] != 'k' && zombies) { m[y][x] = 'z'; room[r[y][x]].pref_monster = 'z'; i++; zombies--; } else if(m[y][x] == 0 && ( w[y][x] == '-' || w[y][x] == '|' || w[y][x] == '+') && headcrabs && rand() % 2 == 1) { m[y][x] = 'c'; i++; headcrabs--; } else if(m[y][x] == 0 && (w[y][x] == '\0' || w[y][x] == '#') && room[r[y][x]].monsters < MAX_MONSTERS_PER_ROOM && how_many_walls_between(w, startpos.y, startpos.x, y, x) > 4 && e[y][x] != 'K' && e[y][x] != 'e' && e[y][x] != '1' && e[y][x] != '2' && e[y][x] != 'v' && (e[y][x] != 'k' || rand() % 2 == 1)) { if(room[r[y][x]].pref_monster == 0) { m[y][x] = random_monster(); if(m[y][x] == 'f' || m[y][x] == 'q') // big monsters { if(w[y + 1][x] == '\0' && w[y + 1][x + 1] == '\0' && w[y][x + 1] == '\0' && e[y + 1][x] == '\0' && e[y + 1][x + 1] == '\0' && e[y][x + 1] == '\0' && m[y + 1][x] == '\0' && m[y + 1][x + 1] == '\0' && m[y][x + 1] == '\0') { m[y + 1][x] = 'x'; m[y + 1][x + 1] = 'x'; m[y][x + 1] = 'x'; } else { m[y][x] = 0; i--; room[r[y][x]].monsters--; } } else if((m[y][x] == 'b' && (c[y][x] == '/' || l[y][x] == 'L')) || (m[y][x] == 'a' && how_many_walls_between(w, y, x, startpos.y, startpos.x) < 8)) { m[y][x] = 0; i--; room[r[y][x]].monsters--; } room[r[y][x]].pref_monster = m[y][x]; i++; room[r[y][x]].monsters++; } else if(rand() % 4 == 1) { m[y][x] = room[r[y][x]].pref_monster; switch(m[y][x]) { case 'f': if(!alien_slaves) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } else { if(w[y + 1][x] == '\0' && w[y + 1][x + 1] == '\0' && w[y][x + 1] == '\0' && e[y + 1][x] == '\0' && e[y + 1][x + 1] == '\0' && e[y][x + 1] == '\0' && m[y + 1][x] == '\0' && m[y + 1][x + 1] == '\0' && m[y][x + 1] == '\0') { m[y + 1][x] = 'x'; m[y + 1][x + 1] = 'x'; m[y][x + 1] = 'x'; i++; alien_grunts--; room[r[y][x]].monsters++; } else { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } } break; case 's': if(!alien_slaves) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } else { i++; alien_slaves--; room[r[y][x]].monsters++; } break; case 'b': if(!barnacles || (c[y][x] != '/' || l[y][x] == 'L')) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } else { i++; barnacles--; //room[r[y][x]].monsters++; } break; case 'r': if(!barneys) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; room[r[y][x]].monsters += 10; // don't put other monsters in after barneys } else { i++; barneys--; room[r[y][x]].monsters++; } break; case 'q': if(!bullchickens) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } else { if(w[y + 1][x] == '\0' && w[y + 1][x + 1] == '\0' && w[y][x + 1] == '\0' && e[y + 1][x] == '\0' && e[y + 1][x + 1] == '\0' && e[y][x + 1] == '\0' && m[y + 1][x] == '\0' && m[y + 1][x + 1] == '\0' && m[y][x + 1] == '\0') { m[y + 1][x] = 'x'; m[y + 1][x + 1] = 'x'; m[y][x + 1] = 'x'; i++; bullchickens--; room[r[y][x]].monsters++; } else { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } } break; case 'c': if(!headcrabs) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } else { i++; headcrabs--; room[r[y][x]].monsters++; } break; case 'h': if(!houndeyes) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } else { i++; houndeyes--; room[r[y][x]].monsters++; } break; case 'g': if(!human_grunts) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } else { i++; human_grunts--; room[r[y][x]].monsters++; } break; case 'a': if(!human_assassins || how_many_walls_between(w, y, x, startpos.y, startpos.x) < 8) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } else { i++; human_assassins--; room[r[y][x]].monsters += 2; } break; case 'm': if(!sentrys) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; room[r[y][x]].monsters += 10; // no other monsters after sentrys } else { i++; sentrys--; room[r[y][x]].monsters++; } break; case 'z': if(!zombies) { m[y][x] = 0; room[r[y][x]].pref_monster = 0; } else { i++; zombies--; room[r[y][x]].monsters++; } break; } } } j++; } // put in weapons/ammo j = 0; while(j < 20 * weaponfrequency && j < 2000) { x = rand() % DIM_X; y = rand() % DIM_Y; if((room[r[y][x]].powerups < 3 || rand() % 10 == 1) && w[y][x] == '\0' && m[y][x] == 0 && (e[y][x] == 0 || e[y][x] == 'k') && neighbors(w, y, x, '^') == 0 && neighbors(w, y, x, TNT) + neighbors(e, y, x, '2') + neighbors(e, y, x, '1') + neighbors(e, y, x, 'k') + neighbors(e, y, x, 'K') != 0) { if(room[r[y][x]].special == 1 && room[r[y][x]].gunned == 0) { m[y][x] = pick_weapon(1); // starting room[r[y][x]].gunned = ammo_of(m[y][x]); room[r[y][x]].powerups++; } else if(exits[y][x] == 1) // do something special { if(room[r[y][x]].gunned == 0) { m[y][x] = pick_weapon(4); // great, 3 = good room[r[y][x]].gunned = ammo_of(m[y][x]); room[r[y][x]].powerups++; } else { m[y][x] = room[r[y][x]].gunned; room[r[y][x]].powerups++; } } else { if(rand() % 7 < 2) { if(room[r[y][x]].gunned == 0) { m[y][x] = pick_weapon(2); // common room[r[y][x]].powerups++; } } else { m[y][x] = room[r[y][x]].gunned; room[r[y][x]].powerups++; } } } j++; } if(argc > 2 && argv[2][1] != '\0') strcpy(mapname, argv[2]); // if output filename supplied at command line, use it else // otherwise name it "gen" + seed + ".map" { mapname[0] = 'g'; mapname[1] = 'e'; mapname[2] = 'n'; seed = map_number; longy = 10; while(longy < seed) { longy *= 10; } i = 3; while(longy > 1) { longy /= 10; mapname[i] = '0' + seed / longy; seed %= longy; i++; } mapname[i++] = '.'; mapname[i++] = 'm'; mapname[i++] = 'a'; mapname[i++] = 'p'; mapname[i] = '\0'; } // output to screen for(i = DIM_Y - 1; i >= 0; i--) { for(j = 0; j < DIM_X; j++) { if(w[i][j] == 'o') cout << '.'; else if(w[i][j] == '#') cout << '#'; else if(e[i][j] != 0) cout << e[i][j]; else if(c[i][j] != 0) cout << c[i][j]; else cout << w[i][j]; } for(j = 0; j < DIM_X; j++) { if(d[i][j] != 0) { //cout << ' ' << door[d[i][j]].room1 << ',' << door[d[i][j]].room2; } } cout << endl; } // output to file f.open("map_prev.txt"); f << mapname << endl; f << "seed: " << map_number << endl; for(i = DIM_Y - 1; i >= 0; i--) { for(j = 0; j < DIM_X; j++) { if(e[i][j] != 0) f << e[i][j]; else { if(w[i][j] == 'o') f << '.'; else if(w[i][j] == '#') f << '#'; else if(e[i][j] != 0) f << e[i][j]; else if(c[i][j] != 0) f << c[i][j]; else f << w[i][j]; } } f << endl; } f.close(); // *************************************** // done thinking up map, now write it down // *************************************** for(i = 0; i < DIM_Y; i++) for(j = 0; j < DIM_X; j++) v[i][j] = w[i][j]; // back up the array that we're about to screw over completely f.open(mapname); f << '{' << endl << q << "classname" << q << ' ' << q << "worldspawn" << q << endl << q << "MaxRange" << q << ' ' << q << "4096" << q << endl << q << "mapversion" << q << ' ' << q << "220" << q << endl << q << "message" << q << ' ' << q << "Generated by Automap 1.0" << q << endl << q << "skyname" << q << ' ' << q << "desert" << q << endl << q << "chaptertitle" << q << ' ' << q << "Seed: " << map_number << q << endl << q << "wad" << q << ' ' << q << wad_file << q << endl; while(true) // walls (Two-NineTeens) TNT { if(grabsome(w, goty, gotx, toy, tox, TNT)) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 0; brush.z2 = 192; writeblock(f, brush, "C2A1_W1"); } exchange(w, '`', TNT); // change back written walls. while(true) // catwalk '#' { if(grabsome(w, goty, gotx, toy, tox, '#')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = -8; brush.z2 = 0; writeblock(f, brush, "GENERIC015P"); } exchange(w, '`', 'o'); // change back written catwalks TO LOWEST FLOORS. while(true) // doors '^' { if(grabsome(w, goty, gotx, toy, tox, '^')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 128; brush.z2 = 192; writeblock(f, brush, "C2A1_W1"); } exchange(w, '`', TNT); // change back written doors. while(true) // vent NS { if(grabsome(w, goty, gotx, toy, tox, '|')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 96; brush.z2 = 192; btex.to_default(); btex.set_all_textures("C2A1_W1"); strcpy(btex.bottom.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); brush.z1 = 0; brush.z2 = 48; strcpy(btex.bottom.tex, "C2A1_W1"); strcpy(btex.top.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); brush.z1 = 48; brush.z2 = 96; brush.x2 = brush.x1 + 8; btex.east.u2 = 0; btex.east.u3 = -1; btex.east.x_off = -24; btex.east.v2 = -1; btex.east.v3 = 0; btex.east.rot = 90; strcpy(btex.top.tex, "C2A1_W1"); strcpy(btex.east.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); brush.x1 += 56; brush.x2 += 56; btex.to_default(); btex.west.u2 = 0; btex.west.u3 = -1; btex.west.x_off = -24; btex.west.v2 = -1; btex.west.v3 = 0; btex.west.rot = 90; strcpy(btex.east.tex, "C2A1_W1"); strcpy(btex.west.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); } exchange(w, '`', TNT); // change back written vents. while(true) // vent EW { if(grabsome(w, goty, gotx, toy, tox, '-')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 96; brush.z2 = 192; btex.to_default(); btex.bottom.u1 = 0; btex.bottom.u2 = -1; btex.bottom.v1 = -1; btex.bottom.v2 = 0; btex.bottom.rot = 90; btex.set_all_textures("C2A1_W1"); strcpy(btex.bottom.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); brush.z1 = 0; brush.z2 = 48; btex.to_default(); btex.top.u1 = 0; btex.top.u2 = -1; btex.top.v1 = -1; btex.top.v2 = 0; btex.top.rot = 90; strcpy(btex.bottom.tex, "C2A1_W1"); strcpy(btex.top.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); brush.z1 = 48; brush.z2 = 96; brush.y2 = brush.y1 + 8; btex.to_default(); btex.north.u1 = 0; //btex.north.u2 = 0; btex.north.u3 = -1; btex.north.x_off = -24; btex.north.v1 = -1; //btex.north.v2 = 0; btex.north.v3 = 0; btex.north.rot = 90; strcpy(btex.top.tex, "C2A1_W1"); strcpy(btex.north.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); brush.y1 += 56; brush.y2 += 56; btex.to_default(); btex.south.u1 = 0; //btex.south.u2 = 0; btex.south.u3 = -1; btex.south.x_off = -24; btex.south.v1 = -1; //btex.south.v2 = 0; btex.south.v3 = 0; btex.south.rot = 90; strcpy(btex.north.tex, "C2A1_W1"); strcpy(btex.south.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); } exchange(w, '`', TNT); // change back written vents. for(i = 1; i < DIM_Y - 1; i++) // vent EWNS for(j = 1; j < DIM_X - 1; j++) { if(w[i][j] == '+') { brush.x1 = j * 64 - DIM_X * 32; brush.x2 = (j + 1) * 64 - DIM_X * 32; brush.y1 = i * 64 - DIM_Y * 32; brush.y2 = (i + 1) * 64 - DIM_Y * 32; brush.z1 = 96; brush.z2 = 192; btex.to_default(); btex.set_all_textures("C2A1_W1"); strcpy(btex.bottom.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); brush.z1 = 0; brush.z2 = 48; strcpy(btex.bottom.tex, "C2A1_W1"); strcpy(btex.top.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); brush.z1 = 48; brush.z2 = 96; brush.x2 = brush.x1 + 8; brush.y1 = brush.y2 - 8; btex.east.u2 = 0; btex.east.u3 = -1; btex.east.x_off = -24; btex.east.v2 = -1; btex.east.v3 = 0; btex.east.rot = 90; btex.south.u1 = 0; //btex.south.u2 = 0; btex.south.u3 = -1; btex.south.x_off = -24; btex.south.v1 = -1; //btex.south.v2 = 0; btex.south.v3 = 0; btex.south.rot = 90; strcpy(btex.top.tex, "C2A1_W1"); strcpy(btex.east.tex, "DUCT_WALL03"); strcpy(btex.south.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); // NW CORNER brush.y1 -= 56; brush.y2 -= 56; btex.south.u1 = 1; //btex.south.u2 = 0; btex.south.u3 = 0; btex.south.x_off = 0; btex.south.v1 = 0; //btex.south.v2 = 0; btex.south.v3 = -1; btex.south.rot = 0; btex.north.u1 = 0; //btex.north.u2 = 0; btex.north.u3 = -1; btex.north.x_off = -24; btex.north.v1 = -1; //btex.north.v2 = 0; btex.north.v3 = 0; btex.north.rot = 90; strcpy(btex.south.tex, "C2A1_W1"); strcpy(btex.north.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); // SW CORNER brush.x1 += 56; brush.x2 += 56; btex.east.u2 = 1; btex.east.u3 = 0; btex.east.x_off = 0; btex.east.v2 = 0; btex.east.v3 = -1; btex.east.rot = 0; btex.west.u2 = 0; btex.west.u3 = -1; btex.west.x_off = -24; btex.west.v2 = -1; btex.west.v3 = 0; btex.west.rot = 90; strcpy(btex.east.tex, "C2A1_W1"); strcpy(btex.west.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); // SE CORNER brush.y1 += 56; brush.y2 += 56; btex.south.u1 = 0; //btex.south.u2 = 0; btex.south.u3 = -1; btex.south.x_off = -24; btex.south.v1 = -1; //btex.south.v2 = 0; btex.south.v3 = 0; btex.south.rot = 90; btex.north.u1 = 1; //btex.north.u2 = 0; btex.north.u3 = 0; btex.north.x_off = -24; btex.north.v1 = 0; //btex.north.v2 = 0; btex.north.v3 = -1; btex.north.rot = 90; strcpy(btex.north.tex, "C2A1_W1"); strcpy(btex.south.tex, "DUCT_WALL03"); writeblock_specific(f, brush, btex); // NE CORNER } } exchange(w, '`', TNT); // change back written vents. for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(neighbors(w, i, j, 'o') > 0 && w[i][j] != 'o') w[i][j] = 'T'; } } for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(neighbors(w, i, j, 'T') > 1 && w[i][j] != '\0' && w[i][j] != 'o') // if has more than 1 sub wall neighbor and is not empty and is not lowest floor w[i][j] = 'T'; // become a sub wall, too } } while(true) // sub walls 'T' { if(grabsome(w, goty, gotx, toy, tox, 'T')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = -512; brush.z2 = 0; btex.to_default(); btex.north.x_scale = 2; btex.north.y_scale = -2; btex.south.x_scale = 2; btex.south.y_scale = -2; btex.west.x_scale = 2; btex.west.y_scale = -2; btex.east.x_scale = 2; btex.east.y_scale = -2; btex.north.y_off = 1; btex.south.y_off = 1; btex.west.y_off = 1; btex.east.y_off = 1; btex.set_all_textures("C1A4_SILO2"); strcpy(btex.top.tex, "GENERIC015P"); strcpy(btex.bottom.tex, "GENERIC015P"); writeblock_specific(f, brush, btex); } exchange(w, '`', 'o'); // change back written sub walls to lowest floors. while(true) // lowest floor 'o' { if(grabsome(w, goty, gotx, toy, tox, 'o')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = -544; brush.z2 = -512; writeblock(f, brush, "BLACK"); } exchange(w, '`', 'o'); // change back written lowest floors. exchange(w, TNT, '\0'); // simplify floors for(i = 0; i < DIM_Y; i++) { for(j = 0; j < DIM_X; j++) { if(w[i][j] == '\0' && c[i][j] == '/') { w[i][j] = 's'; } } } while(true) // outdoor sandy floors 's' { if(grabsome(w, goty, gotx, toy, tox, 's')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = -32; brush.z2 = 0; writeblock(f, brush, "OUT_SND2C"); } // no changebacks! while(true) // floors '\0' { if(grabsome(w, goty, gotx, toy, tox, '\0')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = -32; brush.z2 = 0; writeblock(f, brush, "CRETE3_FLR05"); } exchange(w, '`', '\0'); // change back written floors. while(true) // immobile crates stacked 'K' { if(grabsome(e, goty, gotx, toy, tox, 'K')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 0; brush.z2 = 128; writeblock(f, brush, "XCRATE11B"); } exchange(e, '`', 'K'); // change back immobile crates stacked. while(true) // immobile crates single 'k' { if(grabsome(e, goty, gotx, toy, tox, 'k')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 0; brush.z2 = 64; writeblock(f, brush, "XCRATE11B"); } exchange(e, '`', 'k'); // change back immobile crates single. while(true) // immobile crates 48 'v' { if(grabsome(e, goty, gotx, toy, tox, 'v')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 0; brush.z2 = 48; btex.to_default(); btex.set_all_textures("XCRATE11A"); strcpy(btex.top.tex, "XCRATE11B"); writeblock_specific(f, brush, btex); } exchange(e, '`', 'v'); // change back immobile crates 48. while(true) // regular ceiling '\0' { if(grabsome(c, goty, gotx, toy, tox, '\0')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 192; brush.z2 = 216; writeblock(f, brush, "C1A2_C1"); } while(true) // sky '\0' { if(grabsome(c, goty, gotx, toy, tox, '/')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 208; brush.z2 = 216; writeblock(f, brush, "SKY"); } while(true) // lights 'L' in l[][] { if(grabsome(l, goty, gotx, toy, tox, 'L')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 188; brush.z2 = 192; btex.to_default(); btex.set_all_textures("GENERIC027"); strcpy(btex.bottom.tex, "LITEPANEL1"); writeblock_specific(f, brush, btex); } while(true) // light wiring '_' in l[][] { if(grabsome(l, goty, gotx, toy, tox, '_')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = brush.y1 + 2; brush.z1 = 190; brush.z2 = 192; writeblock(f, brush, "GENERIC027"); } while(true) // light wiring '[' in l[][] { if(grabsome(l, goty, gotx, toy, tox, '[')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = brush.x1 + 2; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 190; brush.z2 = 192; writeblock(f, brush, "GENERIC027"); } while(true) // end zone 'e' in e[][] { if(grabsome(e, goty, gotx, toy, tox, 'e')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = 0; brush.z2 = 8; btex.to_default(); btex.set_all_textures("GENERIC027"); strcpy(btex.top.tex, "C3A2_TELEPAD"); writeblock_specific(f, brush, btex); } exchange(e, '`', 'e'); // change back end zone. f << "}\n"; //****************** // END WORLDSPAWN... //-------------- // BEGIN ENTITIES... //****************** for(i = 0; i < DIM_Y; i++) // find/define Death zones { for(j = 0; j < DIM_X; j++) { if(v[i][j] == 'o' || v[i][j] == '#') w[i][j] = 'D'; } } while(true) // Death zones 'D' { if(grabsome(w, goty, gotx, toy, tox, 'D')) break; brush.x1 = gotx * 64 - DIM_X * 32; brush.x2 = (tox + 1) * 64 - DIM_X * 32; brush.y1 = goty * 64 - DIM_Y * 32; brush.y2 = (toy + 1) * 64 - DIM_Y * 32; brush.z1 = -512; brush.z2 = -480; f << "{\n"; write_kill_zone(f); writeblock(f, brush, "AAATRIGGER"); f << "}\n"; } while(true) // end zone 'e' { if(grabsome(e, goty, gotx, toy, tox, 'e')) break; brush.x1 = gotx * 64 - DIM_X * 32 + 24; brush.x2 = (tox + 1) * 64 - DIM_X * 32 - 24; brush.y1 = goty * 64 - DIM_Y * 32 + 24; brush.y2 = (toy + 1) * 64 - DIM_Y * 32 - 24; brush.z1 = 32; brush.z2 = 64; f << "{\n"; write_end_trigger(f); writeblock(f, brush, "AAATRIGGER"); f << "}\n"; brush.z1 = 128; brush.z2 = 144; f << "{\n"; write_end_zone(f); writeblock(f, brush, "AAATRIGGER"); f << "}\n"; } exchange(e, '`', 'e'); // change back e for(i = 1; i < DIM_Y - 1; i++) for(j = 1; j < DIM_X - 1; j++) { if((v[i - 1][j] == '|' || v[i - 1][j] == '+') && (v[i][j] == '\0' || v[i][j] == '#' || v[i][j] == '^')) // if end of a vent, lets put a grate on it { brush_ents++; f << "{\n"; write_255_metal_breakable(f); brush.x1 = j * 64 - DIM_X * 32 + 8; brush.x2 = brush.x1 + 48; brush.y1 = i * 64 - DIM_Y * 32 - 1; brush.y2 = brush.y1 + 1; brush.z1 = 48; brush.z2 = 96; btex.to_default(); btex.north.x_off = 53 - ((j - DIM_X / 2) % 3) * 22; btex.north.x_scale = 0.75; btex.south.x_off = 53 - ((j - DIM_X / 2) % 3) * 22; btex.south.x_scale = 0.75; btex.set_all_textures("{DUCT_VNT"); writeblock_specific(f, brush, btex); f << "}\n"; } if((v[i + 1][j] == '|' || v[i + 1][j] == '+') && (v[i][j] == '\0' || v[i][j] == '#' || v[i][j] == '^')) // if end of a vent, lets put a grate on it { brush_ents++; f << "{\n"; write_255_metal_breakable(f); brush.x1 = j * 64 - DIM_X * 32 + 8; brush.x2 = brush.x1 + 48; brush.y1 = i * 64 - DIM_Y * 32 + 64; brush.y2 = brush.y1 + 1; brush.z1 = 48; brush.z2 = 96; btex.to_default(); btex.north.x_off = 53 - ((j - DIM_X / 2) % 3) * 22; btex.north.x_scale = 0.75; btex.south.x_off = 53 - ((j - DIM_X / 2) % 3) * 22; btex.south.x_scale = 0.75; btex.set_all_textures("{DUCT_VNT"); writeblock_specific(f, brush, btex); f << "}\n"; } if((v[i][j - 1] == '-' || v[i][j - 1] == '+') && (v[i][j] == '\0' || v[i][j] == '#' || v[i][j] == '^')) // if end of a vent, lets put a grate on it { brush_ents++; f << "{\n"; write_255_metal_breakable(f); brush.x1 = j * 64 - DIM_X * 32 - 1; brush.x2 = brush.x1 + 1; brush.y1 = i * 64 - DIM_Y * 32 + 8; brush.y2 = brush.y1 + 48; brush.z1 = 48; brush.z2 = 96; btex.to_default(); btex.west.x_off = 53 - ((i - DIM_Y / 2) % 3) * 22; btex.west.x_scale = 0.75; btex.east.x_off = 53 - ((i - DIM_Y / 2) % 3) * 22; btex.east.x_scale = 0.75; btex.set_all_textures("{DUCT_VNT"); writeblock_specific(f, brush, btex); f << "}\n"; } if((v[i][j + 1] == '-' || v[i][j + 1] == '+') && (v[i][j] == '\0' || v[i][j] == '#' || v[i][j] == '^')) // if end of a vent, lets put a grate on it { brush_ents++; f << "{\n"; write_255_metal_breakable(f); brush.x1 = j * 64 - DIM_X * 32 + 64; brush.x2 = brush.x1 + 1; brush.y1 = i * 64 - DIM_Y * 32 + 8; brush.y2 = brush.y1 + 48; brush.z1 = 48; brush.z2 = 96; btex.to_default(); btex.west.x_off = 53 - ((i - DIM_Y / 2) % 3) * 22; btex.west.x_scale = 0.75; btex.east.x_off = 53 - ((i - DIM_Y / 2) % 3) * 22; btex.east.x_scale = 0.75; btex.set_all_textures("{DUCT_VNT"); writeblock_specific(f, brush, btex); f << "}\n"; } if(v[i][j] == '#') // make railings for the catwalks { if(v[i - 1][j] == 'o') { brush_ents++; f << "{\n"; write_255_func_wall(f); brush.x1 = j * 64 - DIM_X * 32; brush.x2 = brush.x1 + 64; brush.y1 = i * 64 - DIM_Y * 32; brush.y2 = brush.y1 + 1; brush.z1 = 0; brush.z2 = 32; btex.to_default(); btex.set_all_textures("{RAIL1"); strcpy(btex.top.tex, "GENERIC99C"); strcpy(btex.west.tex, "{BLUE"); strcpy(btex.east.tex, "{BLUE"); writeblock_specific(f, brush, btex); f << "}\n"; } if(v[i + 1][j] == 'o') { brush_ents++; f << "{\n"; write_255_func_wall(f); brush.x1 = j * 64 - DIM_X * 32; brush.x2 = brush.x1 + 64; brush.y1 = i * 64 - DIM_Y * 32 + 63; brush.y2 = brush.y1 + 1; brush.z1 = 0; brush.z2 = 32; btex.to_default(); btex.set_all_textures("{RAIL1"); strcpy(btex.top.tex, "GENERIC99C"); strcpy(btex.west.tex, "{BLUE"); strcpy(btex.east.tex, "{BLUE"); writeblock_specific(f, brush, btex); f << "}\n"; } if(v[i][j - 1] == 'o') { brush_ents++; f << "{\n"; write_255_func_wall(f); brush.x1 = j * 64 - DIM_X * 32; brush.x2 = brush.x1 + 1; brush.y1 = i * 64 - DIM_Y * 32; brush.y2 = brush.y1 + 64; brush.z1 = 0; brush.z2 = 32; btex.to_default(); btex.set_all_textures("{RAIL1"); strcpy(btex.top.tex, "GENERIC99C"); strcpy(btex.north.tex, "{BLUE"); strcpy(btex.south.tex, "{BLUE"); writeblock_specific(f, brush, btex); f << "}\n"; } if(v[i][j + 1] == 'o') { brush_ents++; f << "{\n"; write_255_func_wall(f); brush.x1 = j * 64 - DIM_X * 32 + 63; brush.x2 = brush.x1 + 1; brush.y1 = i * 64 - DIM_Y * 32; brush.y2 = brush.y1 + 64; brush.z1 = 0; brush.z2 = 32; btex.to_default(); btex.set_all_textures("{RAIL1"); strcpy(btex.top.tex, "GENERIC99C"); strcpy(btex.north.tex, "{BLUE"); strcpy(btex.south.tex, "{BLUE"); writeblock_specific(f, brush, btex); f << "}\n"; } } switch(e[i][j]) { case 's': // player start f << "{\n"; f << q << "classname" << q << ' ' << q << "info_player_start" << q << endl << q << "angles" << q << ' ' << q << "0 0 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 48" << q << endl; f << "}\n"; f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_crowbar" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 48" << q << endl; f << "}\n"; f << "{\n"; f << q << "classname" << q << ' ' << q << "item_suit" << q << endl << q << "spawnflags" << q << ' ' << q << "1" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 48" << q << endl; f << "}\n"; f << "{\n"; f << q << "classname" << q << ' ' << q << "light_environment" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "_light" << q << ' ' << q << "255 255 255 80" << q << endl << q << "pitch" << q << ' ' << q << (-30 - (rand() % 50)) << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 128" << q << endl; f << "}\n"; break; case 'e': // end zone sprite f << "{\n"; f << q << "classname" << q << ' ' << q << "env_sprite" << q << endl << q << "renderamt" << q << ' ' << q << "100" << q << endl << q << "framerate" << q << ' ' << q << "10.0" << q << endl << q << "model" << q << ' ' << q << "sprites/tele1.spr" << q << endl << q << "scale" << q << ' ' << q << "1" << q << endl << q << "rendermode" << q << ' ' << q<< "5" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 48" << q << endl; f << "}\n"; f << "{\n"; f << q << "classname" << q << ' ' << q << "multi_manager" << q << endl << q << "targetname" << q << ' ' << q << "end_man" << q << endl << q << "fade_out" << q << ' ' << q << "0" << q << endl << q << "quit_to_menu" << q << ' ' << q << "1" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 96" << q << endl; f << "}\n"; f << "{\n"; f << q << "classname" << q << ' ' << q << "env_fade" << q << endl << q << "duration" << q << ' ' << q << "1" << q << endl << q << "renderamt" << q << ' ' << q << "255" << q << endl << q << "rendercolor" << q << ' ' << q << "84 91 34" << q << endl << q << "targetname" << q << ' ' << q << "fade_out" << q << endl << q << "holdtime" << q << ' ' << q << "20" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 80" << q << endl; f << "}\n"; f << "{\n"; f << q << "classname" << q << ' ' << q << "env_funnel" << q << endl << q << "targetname" << q << ' ' << q << "fade_out" << q << endl << q << "spawnflags" << q << ' ' << q << "1" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 48" << q << endl; f << "}\n"; f << "{\n"; f << q << "classname" << q << ' ' << q << "ambient_generic" << q << endl << q << "spawnflags" << q << ' ' << q << "56" << q << endl << q << "health" << q << ' ' << q << "10" << q << endl << q << "message" << q << ' ' << q << "debris/beamstart1.wav" << q << endl << q << "targetname" << q << ' ' << q << "fade_out" << q << endl << q << "pitch" << q << ' ' << q << "125" << q << endl << q << "pitchstart" << q << ' ' << q << "125" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 64" << q << endl; f << "}\n"; break; case '2': // crates brush_ents++; f << "{\n"; exp = 0; if(rand() % 10 == 0) { write_explosive_crate_ent(f, strand++, j * 64 - (DIM_X - 1) * 32, i * 64 - (DIM_Y - 1) * 32, 96); exp = 1; } else write_crate_ent(f); brush.x1 = j * 64 - DIM_X * 32 + 1; brush.x2 = brush.x1 + 62; brush.y1 = i * 64 - DIM_Y * 32 + 1; brush.y2 = brush.y1 + 62; brush.z1 = 64; brush.z2 = 128; if(exp == 0) writeblock(f, brush, "BCRATE02"); else { switch(rand() % 3) { case 0: writeblock(f, brush, "BCRATE09A"); break; case 1: writeblock(f, brush, "BCRATE09B"); break; case 2: writeblock(f, brush, "BCRATE09C"); break; } } f << "}\n"; // (no break!) case '1': // crate brush_ents++; f << "{\n"; exp = 0; if(rand() % 10 == 0) { write_explosive_crate_ent(f, strand++, j * 64 - (DIM_X - 1) * 32, i * 64 - (DIM_Y - 1) * 32, 32); exp = 1; } else write_crate_ent(f); brush.x1 = j * 64 - DIM_X * 32 + 1; brush.x2 = brush.x1 + 62; brush.y1 = i * 64 - DIM_Y * 32 + 1; brush.y2 = brush.y1 + 62; brush.z1 = 0; brush.z2 = 64; if(exp == 0) writeblock(f, brush, "BCRATE02"); else { switch(rand() % 3) { case 0: writeblock(f, brush, "BCRATE09A"); break; case 1: writeblock(f, brush, "BCRATE09B"); break; case 2: writeblock(f, brush, "BCRATE09C"); break; } } f << "}\n"; break; } if(n[i][j] == 'n') { f << "{\n"; f << q << "classname" << q << ' ' << q << "info_node" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 8" << q << endl; f << "}\n"; } if(e[i][j] == 'k') z_boost = 64; else if(v[i][j] == '-' || v[i][j] == '|' || v[i][j] == '+') z_boost = 48; else z_boost = 0; switch(m[i][j]) { case 'A': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_357" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'M': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_9mmAR" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'P': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_9mmhandgun" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'C': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_crossbow" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'E': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_egon" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'U': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_gauss" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'G': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_handgrenade" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'H': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_hornetgun" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'R': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_rpg" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'L': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_satchel" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'S': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_shotgun" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'K': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_snark" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'T': f << "{\n"; f << q << "classname" << q << ' ' << q << "weapon_tripmine" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case '1': f << "{\n"; f << q << "classname" << q << ' ' << q << "ammo_357" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case '2': if(rand() % 2 == 1) { f << "{\n"; f << q << "classname" << q << ' ' << q << "ammo_9mmclip" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; } else { f << "{\n"; f << q << "classname" << q << ' ' << q << "ammo_9mmAR" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; } case '3': f << "{\n"; f << q << "classname" << q << ' ' << q << "ammo_crossbow" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case '4': f << "{\n"; f << q << "classname" << q << ' ' << q << "ammo_gaussclip" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case '5': f << "{\n"; f << q << "classname" << q << ' ' << q << "ammo_rpgclip" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case '6': f << "{\n"; f << q << "classname" << q << ' ' << q << "ammo_buckshot" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; // DONE WEAPONS - NOW MONSTERS: case 'f': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_alien_grunt" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 + 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 + 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 's': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_alien_slave" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'b': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_barnacle" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << " 192" << q << endl; f << "}\n"; break; case 'c': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_headcrab" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'r': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_barney" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'q': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_bullchicken" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 + 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 + 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'h': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_houndeye" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'g': if(rand() % 3 == 1) { x = 8 + 2 * ((rand() % 3) % 2); // 8 or 10 or 8 } else { x = 1 + 2 * ((rand() % 4) % 3); // 1 or 3 or 5 or 1 } f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_human_grunt" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "weapons" << q << ' ' << q << x << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'a': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_human_assassin" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'm': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_sentry" << q << endl << q << "targetname" << q << ' ' << q << "sentry" << int(r[i][j]) << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; case 'z': f << "{\n"; f << q << "classname" << q << ' ' << q << "monster_zombie" << q << endl << q << "rendercolor" << q << ' ' << q << "0 0 0" << q << endl << q << "angles" << q << ' ' << q << "0 " << rand() % 360 << " 0" << q << endl << q << "origin" << q << ' ' << q << j * 64 - (DIM_X - 1) * 32 << ' ' << i * 64 - (DIM_Y - 1) * 32 << ' ' << z_boost << q << endl; f << "}\n"; break; } } //cout << "brush_ents = " << brush_ents << endl; f.close(); if(argc > 3) system("pause"); return; }