diff --git a/osx/Blades of Exile Char Editor/bladespced.rsrc b/osx/Blades of Exile Char Editor/bladespced.rsrc index b00aa23c..d491d1af 100644 Binary files a/osx/Blades of Exile Char Editor/bladespced.rsrc and b/osx/Blades of Exile Char Editor/bladespced.rsrc differ diff --git a/osx/Scenario Editor/BOEScen.rsrc b/osx/Scenario Editor/BOEScen.rsrc index 0850a69a..02101f66 100644 Binary files a/osx/Scenario Editor/BOEScen.rsrc and b/osx/Scenario Editor/BOEScen.rsrc differ diff --git a/osx/Scenario Editor/Blades of Exile Graphics b/osx/Scenario Editor/Blades of Exile Graphics index 7bc90005..1dc7f2d8 100644 Binary files a/osx/Scenario Editor/Blades of Exile Graphics and b/osx/Scenario Editor/Blades of Exile Graphics differ diff --git a/osx/Scenario Editor/scen.actions.cpp b/osx/Scenario Editor/scen.actions.cpp index 3243a109..f97f62e5 100644 --- a/osx/Scenario Editor/scen.actions.cpp +++ b/osx/Scenario Editor/scen.actions.cpp @@ -18,7 +18,7 @@ #include "scen.btnmg.h" - +extern Str255 current_string; Rect world_screen; // border rects order: top, left, bottom, right // Rect border_rect[4]; @@ -35,17 +35,17 @@ bool good_palette_buttons[2][6][10] = { { {1,1,1,1,1,1,1,1,0,0}, {1,1,1,1,1,1,0,1,0,0}, - {0,0,0,1,1,1,1,1,0,0}, + {0,0,1,1,1,1,1,1,0,0}, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0} }, { + {1,1,1,1,1,1,1,1,0,1}, + {1,1,1,1,1,1,0,0,0,1}, + {1,1,1,1,1,1,1,1,0,1}, + {1,1,1,0,1,1,1,1,0,1}, {1,1,1,1,1,1,1,1,0,0}, - {1,1,1,1,1,1,0,0,0,0}, - {1,1,1,1,1,1,1,1,0,0}, - {1,1,1,0,1,1,1,1,0,0}, - {1,1,1,1,1,1,0,1,0,0}, - {1,1,1,1,1,1,1,1,0,0} + {1,1,1,1,1,1,1,1,0,1} } }; cTown::cItem store_place_item = {loc(),-1,0,0,0,0,0}; @@ -85,18 +85,18 @@ short current_rs_top = 0; short out_buttons[6][10] = { {0, 1, 2, 3, 4, 5, 6, 7, -1,-1}, {10,11,12,13,14,15,-1,17,-1,-1}, - {-1,-1,-1,23,24,25,26,27,-1,-1}, + {-1,-1,46,23,24,25,26,27,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, }; short town_buttons[6][10] = { - {0, 1, 2, 3, 4, 5, 6, 7, -1,-1}, - {10,11,12,13,14,15,-1,-1,-1,-1}, - {20,21,22,23,24,25,26,27,-1,-1}, - {30,31,32,-1,34,35,36,37,-1,-1}, - {40,41,42,43,44,45,-1,47,-1,-1}, - {50,51,52,53,54,55,56,57,-1,-1}, + {0, 1, 2, 3, 4, 5, 6, 7, -1,9 }, + {10,11,12,13,14,15,-1,-1,-1,29}, + {20,21,22,23,24,25,26,27,-1,39}, + {30,31,32,-1,34,35,36,37,-1,49}, + {40,41,42,43,44,45,46,47,-1,-1}, + {50,51,52,53,54,55,56,57,-1,69}, }; cCreature last_placed_monst; @@ -429,17 +429,8 @@ bool handle_action(Point the_point,EventRecord event) { (spot_hit.y < 0) || (spot_hit.y > ((editing_town == true) ? town->max_dim() - 1 : 47))) ; else switch (overall_mode) { case MODE_DRAWING: - if (((mouse_button_held == false) && - (((editing_town == true) && (town->terrain(spot_hit.x,spot_hit.y) == current_terrain_type)) || - ((editing_town == false) && (current_terrain.terrain[spot_hit.x][spot_hit.y] == current_terrain_type)) || - ((is_mountain(spot_hit.x,spot_hit.y)) && (current_terrain_type >= 22) - && (current_terrain_type <= 35) && (current_terrain_type != 23)) || - ((is_erasable_water(spot_hit.x,spot_hit.y)) && (current_terrain_type >= 50)&& (current_terrain_type <= 62)) || - ((is_correctable_wall((short) spot_hit.x,(short) spot_hit.y)) - && (current_terrain_type >= 5) && (current_terrain_type <= 21) && (scenario.ter_types[current_terrain_type].blockage == 5)) || - ((is_hill(spot_hit.x,spot_hit.y)) && (current_terrain_type >= 36) && (current_terrain_type <= 49) - && (current_terrain_type != 37)))) || - ((mouse_button_held == true) && (erasing_mode == true))) { + if ((!mouse_button_held && terrain_matches(spot_hit.x,spot_hit.y,current_terrain_type)) || + (mouse_button_held && erasing_mode)) { set_terrain(spot_hit,current_ground); set_cursor(0); erasing_mode = true; @@ -529,11 +520,11 @@ bool handle_action(Point the_point,EventRecord event) { case 0: overall_mode = MODE_DRAWING; set_cursor(0); - set_string("Drawing mode",""); + set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str()); break; } break; - case MODE_TOGGLE_SPECIAL_DOT: + //case MODE_TOGGLE_SPECIAL_DOT: // town.special[spot_hit.x][spot_hit.y] = !town.special[spot_hit.x][spot_hit.y]; /*if (mouse_button_held == true) break; @@ -541,7 +532,7 @@ bool handle_action(Point the_point,EventRecord event) { take_special(spot_hit.x,spot_hit.y); else make_special(spot_hit.x,spot_hit.y); overall_mode = 0; */ - break; + //break; case MODE_LARGE_PAINTBRUSH: mouse_button_held = true; @@ -585,7 +576,7 @@ bool handle_action(Point the_point,EventRecord event) { overall_mode = MODE_DRAWING; set_cursor(0); - set_string("Drawing mode",""); + set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str()); break; case MODE_EDIT_ITEM: for (x = 0; x < 64; x++) @@ -693,6 +684,15 @@ bool handle_action(Point the_point,EventRecord event) { make_quickfire(spot_hit.x,spot_hit.y); overall_mode = MODE_DRAWING; break; + case MODE_TOGGLE_SPECIAL_DOT: + if(!editing_town){ + current_terrain.special_spot[spot_hit.x][spot_hit.y] = !current_terrain.special_spot[spot_hit.x][spot_hit.y]; + overall_mode = MODE_DRAWING; + break; + } + make_field_type(spot_hit.x, spot_hit.y, 1); + overall_mode = MODE_DRAWING; + break; case MODE_CLEAR_FIELDS: take_quickfire(spot_hit.x,spot_hit.y); take_force_barrier(spot_hit.x,spot_hit.y); @@ -700,6 +700,7 @@ bool handle_action(Point the_point,EventRecord event) { take_barrel(spot_hit.x,spot_hit.y); take_crate(spot_hit.x,spot_hit.y); take_web(spot_hit.x,spot_hit.y); + take_field_type(spot_hit.x, spot_hit.y, 1); for (i = 0; i < 8; i++) take_sfx(spot_hit.x,spot_hit.y,i); set_cursor(0); @@ -886,7 +887,7 @@ bool handle_action(Point the_point,EventRecord event) { break; } if ((overall_mode == MODE_DRAWING) && (old_mode != MODE_DRAWING)) - set_string("Drawing mode",""); + set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str()); draw_terrain(); } @@ -957,27 +958,27 @@ bool handle_action(Point the_point,EventRecord event) { flash_rect(temp_rect); switch (i + 100 * j) { case 0: - set_string("Drawing mode"," "); + set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str()); overall_mode = MODE_DRAWING; set_cursor(0); break; case 1: - set_string("Paintbrush (large)",""); + set_string("Paintbrush (large)",(char*)scenario.ter_types[current_terrain_type].name.c_str()); overall_mode = MODE_LARGE_PAINTBRUSH; set_cursor(2); break; case 2: - set_string("Paintbrush (small)",""); + set_string("Paintbrush (small)",(char*)scenario.ter_types[current_terrain_type].name.c_str()); set_cursor(2); overall_mode = MODE_SMALL_PAINTBRUSH; break; case 3: - set_string("Spraycan (large)",""); + set_string("Spraycan (large)",(char*)scenario.ter_types[current_terrain_type].name.c_str()); set_cursor(3); overall_mode = MODE_LARGE_SPRAYCAN; break; case 4: - set_string("Spraycan (small)",""); + set_string("Spraycan (small)",(char*)scenario.ter_types[current_terrain_type].name.c_str()); set_cursor(3); overall_mode = MODE_SMALL_SPRAYCAN; break; @@ -1054,7 +1055,10 @@ bool handle_action(Point the_point,EventRecord event) { break; case 202: if (editing_town == false) { - set_string("Edit placed item","Not while outdoors."); + //set_string("Edit placed item","Not while outdoors."); + set_string("Toggle special spot","Select location"); + overall_mode = MODE_TOGGLE_SPECIAL_DOT; + set_cursor(0); break; } set_string("Delete an item","Select item"); @@ -1154,6 +1158,11 @@ bool handle_action(Point the_point,EventRecord event) { overall_mode = MODE_PLACE_QUICKFIRE; set_cursor(0); break; + case 406: + set_string("Place special spot","Select location"); + overall_mode = MODE_TOGGLE_SPECIAL_DOT; + set_cursor(0); + break; case 407: set_string("Clear space","Select space to clear"); overall_mode = MODE_CLEAR_FIELDS; @@ -1267,10 +1276,13 @@ void swap_terrain() { void set_new_terrain(unsigned char selected_terrain) { current_terrain_type = selected_terrain; redraw_selected_ter(); - if (selected_terrain < 2) - current_ground = 0; - else if (selected_terrain < 5) - current_ground = 2; +// if (selected_terrain < 2) +// current_ground = 0; +// else if (selected_terrain < 5) +// current_ground = 2; + current_ground = get_ground_from_ter(selected_terrain); + p2cstr(current_string); + set_string((char*)current_string,(char*)scenario.ter_types[current_terrain_type].name.c_str()); } void handle_keystroke(char chr,char chr2,EventRecord event) { @@ -1803,9 +1815,50 @@ void unfrill_terrain() { draw_terrain(); } -void set_terrain(location l,unsigned char terrain_type) { +unsigned short find_object_part(unsigned char num, unsigned char x, unsigned char y, unsigned short fallback){ + for(int i = 0; i < 256; i++){ + if(scenario.ter_types[i].obj_num == num && + scenario.ter_types[i].obj_pos.x == x && + scenario.ter_types[i].obj_pos.y == y) + return i; + } + return fallback; +} + +unsigned short get_ground_from_ter(unsigned short ter){ + unsigned char ground = scenario.ter_types[ter].ground_type; + for(int i = 0; i < 256; i++) + if(scenario.ter_types[i].ground_type == ground) + return i; + return 0; +} + +bool terrain_matches(unsigned char x, unsigned char y, unsigned short ter){ + unsigned short ter2; + if(editing_town) ter2 = town->terrain(x,y); else ter2 = current_terrain.terrain[x][y]; + if(ter2 == ter) return true; + if(scenario.ter_types[ter2].ground_type != scenario.ter_types[ter].ground_type) + return false; + if(scenario.ter_types[ter].trim_type == TRIM_NONE && + scenario.ter_types[ter2].trim_type >= TRIM_S && + scenario.ter_types[ter2].trim_type <= TRIM_NW_INNER) + return ter == get_ground_from_ter(ter); + if(scenario.ter_types[ter2].trim_type == TRIM_NONE && + scenario.ter_types[ter].trim_type >= TRIM_S && + scenario.ter_types[ter].trim_type <= TRIM_NW_INNER) + return ter2 == get_ground_from_ter(ter2); + if(scenario.ter_types[ter2].trim_type >= TRIM_S && + scenario.ter_types[ter2].trim_type <= TRIM_NW_INNER && + scenario.ter_types[ter].trim_type >= TRIM_S && + scenario.ter_types[ter].trim_type <= TRIM_NW_INNER) + return true; + return false; +} + + +void set_terrain(location l,unsigned short terrain_type) { short i,j,which_sign = -1; - unsigned char ter; + unsigned short ter; location l2; i = l.x; @@ -1822,31 +1875,47 @@ void set_terrain(location l,unsigned char terrain_type) { else current_terrain.terrain[i][j] = terrain_type; l2 = l; - if (terrain_type == 85) { - l2.x++; - if (editing_town == true) - town->terrain(l2.x,l2.y) = 86; - else current_terrain.terrain[l2.x][l2.y] = 86; - } - if (terrain_type == 86) { - l2.x--; - if (editing_town == true) - town->terrain(l2.x,l2.y) = 85; - else current_terrain.terrain[l2.x][l2.y] = 85; - } - if (terrain_type == 88) { - l2.x++; - if (editing_town == true) - town->terrain(l2.x,l2.y) = 89; - else current_terrain.terrain[l2.x][l2.y] = 89; - } - if (terrain_type == 89) { - l2.x--; - if (editing_town == true) - town->terrain(l2.x,l2.y) = 88; - else current_terrain.terrain[l2.x][l2.y] = 88; + // Large objects (eg rubble) + if(scenario.ter_types[terrain_type].obj_num > 0){ + int q = scenario.ter_types[terrain_type].obj_num; + location obj_loc = scenario.ter_types[terrain_type].obj_pos; + location obj_dim = scenario.ter_types[terrain_type].obj_size; + while(obj_loc.x > 0) l2.x-- , obj_loc.x--; + while(obj_loc.y > 0) l2.y-- , obj_loc.y--; + for(i = 0; i < obj_dim.x; i++) + for(j = 0; j < obj_dim.y; j++){ + if (editing_town == true) + town->terrain(l2.x + i,l2.y + j) = find_object_part(q,i,j,terrain_type); + else current_terrain.terrain[l2.x + i][l2.y + j] = find_object_part(q,i,j,terrain_type); + } } + +// if (terrain_type == 85) { +// l2.x++; +// if (editing_town == true) +// town->terrain(l2.x,l2.y) = 86; +// else current_terrain.terrain[l2.x][l2.y] = 86; +// } +// if (terrain_type == 86) { +// l2.x--; +// if (editing_town == true) +// town->terrain(l2.x,l2.y) = 85; +// else current_terrain.terrain[l2.x][l2.y] = 85; +// } +// if (terrain_type == 88) { +// l2.x++; +// if (editing_town == true) +// town->terrain(l2.x,l2.y) = 89; +// else current_terrain.terrain[l2.x][l2.y] = 89; +// } +// if (terrain_type == 89) { +// l2.x--; +// if (editing_town == true) +// town->terrain(l2.x,l2.y) = 88; +// else current_terrain.terrain[l2.x][l2.y] = 88; +// } + // Correcting mountains? if (is_mountain(l.x,l.y)) for (i = l.x - 1; i < l.x + 2; i++) for (j = l.y - 1; j < l.y + 2; j++) { @@ -1880,7 +1949,7 @@ void set_terrain(location l,unsigned char terrain_type) { adjust_space(l); l.y--; - if ((scenario.ter_types[terrain_type].special == 11) && (editing_town == true)) { /// it's a sign + if ((scenario.ter_types[terrain_type].special == TER_SPEC_IS_A_SIGN) && (editing_town == true)) { /// it's a sign for (i = 0; i < 15; i++) if (which_sign < 0) { if ((town->sign_locs[i].x == l.x) && (town->sign_locs[i].y == l.y)) @@ -1892,7 +1961,7 @@ void set_terrain(location l,unsigned char terrain_type) { which_sign = i; else { ter = town->terrain(town->sign_locs[i].x,town->sign_locs[i].y); - if (scenario.ter_types[ter].special != 11) + if (scenario.ter_types[ter].special != TER_SPEC_IS_A_SIGN) which_sign = i; } } @@ -1910,7 +1979,7 @@ void set_terrain(location l,unsigned char terrain_type) { } mouse_button_held = false; } - if ((scenario.ter_types[terrain_type].special == 11) && (editing_town == false)) { /// it's a sign + if ((scenario.ter_types[terrain_type].special == TER_SPEC_IS_A_SIGN) && (editing_town == false)) { /// it's a sign if ((l.x == 0) || (l.x == 47) || (l.y == 0) || (l.y == 47)) { fancy_choice_dialog(870,0); mouse_button_held = false; @@ -1927,7 +1996,7 @@ void set_terrain(location l,unsigned char terrain_type) { which_sign = i; else { ter = current_terrain.terrain[current_terrain.sign_locs[i].x][current_terrain.sign_locs[i].y]; - if (scenario.ter_types[ter].special != 11) + if (scenario.ter_types[ter].special != TER_SPEC_IS_A_SIGN) which_sign = i; } } @@ -3003,7 +3072,7 @@ void town_entry(location spot_hit) { unsigned char ter; ter = current_terrain.terrain[spot_hit.x][spot_hit.y]; - if (scenario.ter_types[ter].special != 21) { + if (scenario.ter_types[ter].special != TER_SPEC_TOWN_ENTRANCE) { give_error("This space isn't a town entrance. Town entrances are marked by a small brown castle icon.","",0); return; } @@ -3011,7 +3080,7 @@ void town_entry(location spot_hit) { for (x = 0; x < 8; x++) if (current_terrain.exit_locs[x].x < 100) { ter = current_terrain.terrain[current_terrain.exit_locs[x].x][current_terrain.exit_locs[x].y]; - if (scenario.ter_types[ter].special != 21) + if (scenario.ter_types[ter].special != TER_SPEC_TOWN_ENTRANCE) current_terrain.exit_locs[x].x = 100; } y = -2; @@ -3112,7 +3181,7 @@ void start_town_edit() { DrawMenuBar(); HideControl(right_sbar); redraw_screen(); - set_string("Drawing mode",""); + set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str()); place_location(); copied_spec = -1; for (i = 0; i < town->max_dim(); i++) @@ -3143,7 +3212,7 @@ void start_out_edit() { shut_down_menus(1); DrawMenuBar(); redraw_screen(); - set_string("Drawing mode",""); + set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str()); place_location(); copied_spec = -1; for (i = 0; i < 48; i++) @@ -3479,7 +3548,7 @@ void update_item_menu() { DeleteMenuItem(item_menu[j],1); } for (i = 0; i < 80; i++) { - sprintf((char *) item_name, "%s",scenario.scen_items[i + j * 80].full_name); + sprintf((char *) item_name, "%s",scenario.scen_items[i + j * 80].full_name.c_str()); c2pstr((char*) item_name); AppendMenu(item_menu[j],item_name); } @@ -3491,7 +3560,7 @@ void update_item_menu() { DeleteMenuItem(mon_menu[j],1); } for (i = 0; i < 64; i++) { - sprintf((char *) item_name, "%s",scenario.scen_monsters[i + j * 64].m_name); + sprintf((char *) item_name, "%s",scenario.scen_monsters[i + j * 64].m_name.c_str()); c2pstr((char*) item_name); AppendMenu(mon_menu[j],item_name); } diff --git a/osx/Scenario Editor/scen.actions.h b/osx/Scenario Editor/scen.actions.h index 2fd44373..7bfbb755 100644 --- a/osx/Scenario Editor/scen.actions.h +++ b/osx/Scenario Editor/scen.actions.h @@ -28,7 +28,7 @@ void change_val_4 (unsigned char *val,short a,short b,short c,short d); void change_val (unsigned char *val,short a,short b); void frill_up_terrain(); void unfrill_terrain(); -void set_terrain(location l,unsigned char terrain_type); +void set_terrain(location l,unsigned short terrain_type); bool fix_rubble(location l); bool fix_cave(location l); bool fix_mountain(location l); @@ -67,3 +67,5 @@ void set_special(location spot_hit); bool save_check(short which_dlog); void update_item_menu(); +unsigned short get_ground_from_ter(unsigned short ter); +bool terrain_matches(unsigned char x, unsigned char y, unsigned short ter); diff --git a/osx/Scenario Editor/scen.core.cpp b/osx/Scenario Editor/scen.core.cpp index 292a7eb0..287c6905 100644 --- a/osx/Scenario Editor/scen.core.cpp +++ b/osx/Scenario Editor/scen.core.cpp @@ -863,7 +863,7 @@ void init_scenario() { for (i = 0; i < 256; i++) { scenario.ter_types[i].picture = ter_pics[i]; scenario.ter_types[i].blockage = ter_block[i]; - scenario.ter_types[i].special = (eTerSpec) ter_traits[i]; + scenario.ter_types[i].special = (eTerSpec) ter_traits[i]; // ???: What on earth is all this for? get_str(temp_str,1,i + 1); sprintf((char *)scenario.ter_types[i].name.c_str(), "%s", temp_str); @@ -940,22 +940,22 @@ bool save_ter_info() { store_ter.blockage = cd_get_led_range(813,19,24); store_ter.special = (eTerSpec) cd_get_led_range(813,32,55); i = CDGN(813,6); - if ((store_ter.special < 2) || (store_ter.special > 6)) { + /*if ((store_ter.special < 2) || (store_ter.special > 6)) { if (cre(i,0,256,"First special flag must be from 0 to 255.","",813) == true) return false; } - else if ((store_ter.special > 1) && (store_ter.special <= 4)) { + else*/ if (store_ter.special == TER_SPEC_DAMAGING) { if (cre(i,0,256,"First special flag must be from 0 to 100.","",813) == true) return false; } - else if ((store_ter.special > 4) && (store_ter.special <= 7)) { + else if (store_ter.special == TER_SPEC_DANGEROUS) { if (cre(i,0,256,"First special flag must be from 0 to 8.","",813) == true) return false; } store_ter.flag1 = CDGN(813,6); i = CDGN(813,7); - if ((store_ter.special == 21) || (store_ter.special == 1)) { + if (store_ter.special == TER_SPEC_TOWN_ENTRANCE) { if (cre(i,0,256,"Second special flag must be from 0 to 200.","",813) == true) return false; } - else if ((store_ter.special > 1) && (store_ter.special <= 7)) { + else if ((store_ter.special == TER_SPEC_DAMAGING) || (store_ter.special == TER_SPEC_DANGEROUS)) { if (cre(i,0,256,"Second special flag must be from 0 to 100.","",813) == true) return false; } store_ter.flag2 = CDGN(813,7); diff --git a/osx/Scenario Editor/scen.graphics.cpp b/osx/Scenario Editor/scen.graphics.cpp index d23a5ba9..dc823a5a 100644 --- a/osx/Scenario Editor/scen.graphics.cpp +++ b/osx/Scenario Editor/scen.graphics.cpp @@ -10,6 +10,7 @@ #include "scen.keydlgs.h" #include "soundtool.h" #include "mathutil.h" +#include "boe.consts.h" // TODO: Put these constants in a global file #include "scen.core.h" #include "scen.townout.h" @@ -78,12 +79,9 @@ GWorldPtr spec_scen_g = NULL; GWorldPtr ter_draw_gworld; GWorldPtr dlogpics_gworld; GWorldPtr talkfaces_gworld; +GWorldPtr roads_gworld; GWorldPtr mixed_gworld; PixPatHandle map_pat[25]; -short small_icons[24] = {0,23,37,38,39,35,33,34,30,0, - 30,26,0,0,36,0,27,28,29,20, -21,22,0,0}; - // begin new stuff Rect blue_button_from = {120,91,134,107}; @@ -218,6 +216,145 @@ void init_dialogs(){ //return tmp; } +short get_small_icon(unsigned short ter){ + short icon; + switch(scenario.ter_types[ter].special){ + case TER_SPEC_NONE: + icon = scenario.ter_types[ter].flag1; + break; + case TER_SPEC_CHANGE_WHEN_STEP_ON: + icon = 23; + break; + case TER_SPEC_DAMAGING: + switch(scenario.ter_types[ter].flag3){ + case DAMAGE_WEAPON: + icon = 40; + break; + case DAMAGE_FIRE: + icon = 37; + break; + case DAMAGE_POISON: + icon = 43; + break; + case DAMAGE_MAGIC: + icon = 39; + break; + case DAMAGE_UNBLOCKABLE: + icon = 39; + break; + case DAMAGE_COLD: + icon = 38; + break; + case DAMAGE_UNDEAD: + icon = 18; + break; + case DAMAGE_DEMON: + icon = 19; + break; + } + break; + case TER_SPEC_BRIDGE: + icon = 42; + break; + case TER_SPEC_BED: + icon = -1; + break; + case TER_SPEC_DANGEROUS: + switch(scenario.ter_types[ter].flag3){ + case STATUS_POISONED_WEAPON: // TODO: Do something here + break; + case STATUS_BLESS: // TODO: Do something here + break; + case STATUS_POISON: + icon = 35; + break; + case STATUS_HASTE: // TODO: Do something here + break; + case STATUS_INVULNERABLE: // TODO: Do something here + break; + case STATUS_MAGIC_RESISTANCE: // TODO: Do something here + break; + case STATUS_WEBS: // TODO: Do something here + break; + case STATUS_DISEASE: + icon = 33; + break; + case STATUS_INVISIBLE: // TODO: Do something here + break; + case STATUS_DUMB: // TODO: Do something here + break; + case STATUS_MARTYRS_SHIELD: // TODO: Do something here + break; + case STATUS_ASLEEP: + icon = 44; + break; + case STATUS_PARALYZED: // TODO: Do something here + break; + case STATUS_ACID: + icon = 41; + break; + case 14: // bless TODO: Do something here + break; + case 15: // haste TODO: Do something here + break; + } + break; + case TER_SPEC_CRUMBLING: + icon = 34; + break; + case TER_SPEC_LOCKABLE: + icon = 30; + break; + case TER_SPEC_UNLOCKABLE: + if (scenario.ter_types[ter].flag2 >= 5) + icon = (scenario.ter_types[ter].flag2 == 10) ? 32 : 31; + else icon = 30; + break; + case TER_SPEC_IS_A_SIGN: + icon = 26; + break; + case TER_SPEC_CALL_SPECIAL: + icon = scenario.ter_types[ter].flag3; + break; + case TER_SPEC_IS_A_CONTAINER: + icon = 36; + break; + case TER_SPEC_WATERFALL: + icon = -1; + break; + case TER_SPEC_CONVEYOR: + switch(scenario.ter_types[ter].flag1){ // TODO: Consider the other four possible directions + case DIR_N: + icon = 27; + break; + case DIR_E: + icon = 28; + break; + case DIR_S: + icon = 29; + break; + case DIR_W: + icon = 20; + break; + } + break; + case TER_SPEC_BLOCKED_TO_MONSTERS: + icon = 21; + break; + case TER_SPEC_TOWN_ENTRANCE: + icon = 22; + break; + case TER_SPEC_CHANGE_WHEN_USED: + icon = -1; + break; + case TER_SPEC_CALL_SPECIAL_WHEN_USED: + icon = scenario.ter_types[ter].flag3; + break; + } + if(icon == 255) icon = -1; + return icon; +} + void Set_up_win () { short i,j; for (i = 0; i < 70; i++){ @@ -294,6 +431,7 @@ void load_graphics(){ editor_mixed = load_pict(906); anim_gworld = load_pict(820); field_gworld = load_pict(821); + roads_gworld = load_pict(822); talkfaces_gworld = load_pict(860); items_gworld = load_pict(901); tiny_obj_gworld = load_pict(900); @@ -491,25 +629,20 @@ void set_up_terrain_buttons() { ter_from,terrain_buttons_gworld,terrain_rects[i],0,0); } - small_i = small_icons[scenario.ter_types[i].special]; - if ((small_i == 30) && (scenario.ter_types[i].flag2 >= 5)) - small_i = 31; - if ((small_i == 31) && (scenario.ter_types[i].flag2 == 10)) - small_i = 32; - if (i == 82) - small_i = 3; - if (i == 83) - small_i = 2; - if ((i == 7) || (i == 10) || (i == 13) || (i == 16)) - small_i = 23; + small_i = get_small_icon(i); +// if (i == 82) +// small_i = 3; +// if (i == 83) +// small_i = 2; +// if ((i == 7) || (i == 10) || (i == 13) || (i == 16)) +// small_i = 23; tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (small_i % 10),7 * (small_i / 10)); tiny_to = terrain_rects[i]; tiny_to.top = tiny_to.bottom - 7; tiny_to.left = tiny_to.right - 7; - if (small_i > 0) - rect_draw_some_item(editor_mixed, - tiny_from,terrain_buttons_gworld,tiny_to,0,0); + if (small_i > 0 && small_i < 255) + rect_draw_some_item(editor_mixed,tiny_from,terrain_buttons_gworld,tiny_to,0,0); } break; case DRAW_MONST: @@ -598,6 +731,11 @@ void draw_terrain(){ else t_to_draw = current_terrain.terrain[cen_x + q - 4][cen_y + r - 4]; } draw_one_terrain_spot(q,r,t_to_draw); + + if((editing_town && is_field_type(cen_x + q - 4,cen_y + r - 4, 1)) || + (!editing_town && current_terrain.special_spot[cen_x + q - 4][cen_y + r - 4])) + Draw_Some_Item(roads_gworld, calc_rect(6, 0), ter_draw_gworld, where_draw, 1, 0); + which_pt.x = cen_x + q - 4; which_pt.y =cen_y + r - 4; @@ -625,11 +763,7 @@ void draw_terrain(){ rect_draw_some_item(editor_mixed,from_rect,ter_draw_gworld,to_rect,0,0); OffsetRect(&tiny_to,0,-7); } - small_i = small_icons[scenario.ter_types[t_to_draw].special]; - if ((small_i == 30) && (scenario.ter_types[t_to_draw].flag2 >= 5)) - small_i = 31; - if ((small_i == 31) && (scenario.ter_types[t_to_draw].flag2 == 10)) - small_i = 32; + small_i = get_small_icon(t_to_draw); tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (small_i % 10),7 * (small_i / 10)); if (small_i > 0) { @@ -1133,6 +1267,11 @@ void place_location() { DrawString(draw_str); //draw_cur_string(); + MoveTo(260 ,terrain_rects[255].top + 26); + sprintf((char*)draw_str,"%i",current_terrain_type); + c2pstr((char*) draw_str); + DrawString(draw_str); + erase_rect.left = 2; erase_rect.right = RIGHT_AREA_WIDTH - 1; erase_rect.top = terrain_rects[255].bottom + 117; @@ -1172,7 +1311,15 @@ void place_location() { source_rect = get_template_rect(current_terrain_type); rect_draw_some_item(terrain_gworld[picture_wanted / 50],source_rect, terrain_buttons_gworld,draw_rect,0,0); - } + } + short small_i = get_small_icon(current_terrain_type); + Rect tiny_to = draw_rect; + tiny_to.top = tiny_to.bottom - 7; + tiny_to.left = tiny_to.right - 7; + Rect tiny_from = base_small_button_from; + OffsetRect(&tiny_from,7 * (small_i % 10),7 * (small_i / 10)); + if (small_i > 0 && small_i < 255) + rect_draw_some_item(editor_mixed,tiny_from,terrain_buttons_gworld,tiny_to,0,0); } draw_rect = terrain_buttons_rect; @@ -1283,7 +1430,7 @@ void sort_specials() { bool is_field_type(short i,short j,short field_type) { short k; - for (k = 0; k < 50; k++) + for (k = 0; k < town->preset_fields.size(); k++) if ((town->preset_fields[k].type == field_type) && (town->preset_fields[k].loc.x == i) && (town->preset_fields[k].loc.y == j)) @@ -1296,21 +1443,26 @@ void make_field_type(short i,short j,short field_type) { if (is_field_type(i,j,field_type) == true) return; - for (k = 0; k < 50; k++) + for (k = 0; k < town->preset_fields.size(); k++) if (town->preset_fields[k].type == 0) { town->preset_fields[k].loc.x = i; town->preset_fields[k].loc.y = j; town->preset_fields[k].type = field_type; return; } - give_error("Each town can have at most 50 fields and special effects (webs, barrels, blood stains, etc.). To place more, use the eraser first.","",0); + //give_error("Each town can have at most 50 fields and special effects (webs, barrels, blood stains, etc.). To place more, use the eraser first.","",0); + cTown::cField the_field; + the_field.loc.x = i; + the_field.loc.y = j; + the_field.type = field_type; + town->preset_fields.push_back(the_field); } void take_field_type(short i,short j,short field_type) { short k; - for (k = 0; k < 50; k++) + for (k = 0; k < town->preset_fields.size(); k++) if ((town->preset_fields[k].type == field_type) && (town->preset_fields[k].loc.x == i) && (town->preset_fields[k].loc.y == j)) { @@ -1399,7 +1551,7 @@ bool container_there(location l) { if (editing_town == false) return false; - if (scenario.ter_types[town->terrain(l.x,l.y)].special == 14) + if (scenario.ter_types[town->terrain(l.x,l.y)].special == TER_SPEC_IS_A_CONTAINER) return true; if (is_barrel(l.x,l.y) == true) return true; diff --git a/osx/Scenario Editor/scen.keydlgs.cpp b/osx/Scenario Editor/scen.keydlgs.cpp index c588838b..9d9ae4a8 100644 --- a/osx/Scenario Editor/scen.keydlgs.cpp +++ b/osx/Scenario Editor/scen.keydlgs.cpp @@ -1240,7 +1240,7 @@ void edit_scen_intro_event_filter (short item_hit) { switch (item_hit) { case 9: scenario.intro_pic = CDGN(804,8); - if ((scenario.intro_pic < 0) || (scenario.intro_pic > 29)) { + if (scenario.intro_pic > 29) { give_error("Intro picture number is out of range.","",804); break; } diff --git a/osx/Scenario Editor/scen.main.cpp b/osx/Scenario Editor/scen.main.cpp index c4fb710e..8e50060f 100644 --- a/osx/Scenario Editor/scen.main.cpp +++ b/osx/Scenario Editor/scen.main.cpp @@ -224,7 +224,7 @@ void check_for_intel(){ OSErr err; err = Gestalt(gestaltSysArchitecture,&response); if(err != noErr){ - printf("Gestalt error %i\n"); + printf("Gestalt error %i\n",err); exit(1); } if(response == gestaltIntel) mac_is_intel = true; diff --git a/osx/bladesofexile.rsrc b/osx/bladesofexile.rsrc index 72e4ef40..f8fdb279 100644 Binary files a/osx/bladesofexile.rsrc and b/osx/bladesofexile.rsrc differ diff --git a/osx/boe.actions.cpp b/osx/boe.actions.cpp index 0cefa796..6c0b98a4 100644 --- a/osx/boe.actions.cpp +++ b/osx/boe.actions.cpp @@ -487,7 +487,7 @@ bool handle_action(EventRecord event) add_string_to_buf("Rest: Not enough food. "); else if (nearest_monster() <= 3) add_string_to_buf("Rest: Monster too close. "); - else if ((scenario.ter_types[ter].special >= 2) && (scenario.ter_types[ter].special <= 6)) + else if ((scenario.ter_types[ter].special == TER_SPEC_DAMAGING) || (scenario.ter_types[ter].special == TER_SPEC_DANGEROUS)) add_string_to_buf("Rest: It's dangerous here.");//// else if (flying() == true) add_string_to_buf("Rest: Not while flying. "); @@ -626,7 +626,7 @@ bool handle_action(EventRecord event) } } else if (overall_mode == MODE_COMBAT) { - if (which_combat_type == MODE_OUTDOORS) { + if (which_combat_type == 0) { if (hit_end_c_button() == true) { end_town_mode(0,univ.town.p_loc); play_sound(93); @@ -701,7 +701,7 @@ bool handle_action(EventRecord event) add_string_to_buf("Pause."); for (k = 0; k < 6; k++) if ((ADVEN[k].main_status == 1) && (ADVEN[k].status[6] > 0)) { - sprintf((char *) str,"%s cleans webs.",ADVEN[k].name); + sprintf((char *) str,"%s cleans webs.",ADVEN[k].name.c_str()); add_string_to_buf((char *) str); ADVEN[k].status[6] = move_to_zero(ADVEN[k].status[6]); ADVEN[k].status[6] = move_to_zero(ADVEN[k].status[6]); @@ -787,7 +787,7 @@ bool handle_action(EventRecord event) else need_redraw = true; storage = univ.out[univ.party.p_loc.x][univ.party.p_loc.y]; - if (scenario.ter_types[storage].special == 21) {//// town entry + if (scenario.ter_types[storage].special == TER_SPEC_TOWN_ENTRANCE) {//// town entry if (univ.party.direction == 0) find_direction_from = 2; else if (univ.party.direction == 4) find_direction_from = 0; @@ -1053,19 +1053,19 @@ bool handle_action(EventRecord event) current_pc = i; set_stat_window (i); if (overall_mode == MODE_SHOPPING) - sprintf((char *) str,"Now shopping: %s",ADVEN[i].name); - else sprintf((char *) str,"Now active: %s",ADVEN[i].name); + sprintf((char *) str,"Now shopping: %s",ADVEN[i].name.c_str()); + else sprintf((char *) str,"Now active: %s",ADVEN[i].name.c_str()); add_string_to_buf((char *)str); adjust_spell_menus(); } break; case 1: - sprintf((char *) str,"%s has %d health out of %d.",ADVEN[i].name, + sprintf((char *) str,"%s has %d health out of %d.",ADVEN[i].name.c_str(), ADVEN[i].cur_health,ADVEN[i].max_health); add_string_to_buf((char *)str); break; case 2: - sprintf((char *) str,"%s has %d spell pts. out of %d.",ADVEN[i].name, + sprintf((char *) str,"%s has %d spell pts. out of %d.",ADVEN[i].name.c_str(), ADVEN[i].cur_sp,ADVEN[i].max_sp); add_string_to_buf((char *)str); break; @@ -1115,7 +1115,7 @@ bool handle_action(EventRecord event) add_string_to_buf("Set active: PC must be here & active."); else { current_pc = i; - sprintf((char *) str,"Now active: %s",ADVEN[i].name); + sprintf((char *) str,"Now active: %s",ADVEN[i].name.c_str()); add_string_to_buf((char *)str); adjust_spell_menus(); } @@ -2314,7 +2314,7 @@ void handle_cave_lore()//// for (i = 0; i < 6; i++) if ((ADVEN[i].main_status == 1) && (ADVEN[i].traits[4] > 0) && (get_ran(1,0,12) == 5) && (((pic >= 0) && (pic <= 1)) || ((pic >= 70) && (pic <= 76))) ) { - sprintf((char *)str,"%s hunts.",ADVEN[i].name); + sprintf((char *)str,"%s hunts.",ADVEN[i].name.c_str()); univ.party.food += get_ran(2,1,6); add_string_to_buf((char *)str); put_pc_screen(); @@ -2323,7 +2323,7 @@ void handle_cave_lore()//// if ( (ADVEN[i].main_status == 1) && (ADVEN[i].traits[5] > 0) && (get_ran(1,0,12) == 5) && (((pic >= 2) && (pic <= 4)) || ((pic >= 79) && (pic <= 84)))) { - sprintf((char *)str,"%s hunts.",ADVEN[i].name); + sprintf((char *)str,"%s hunts.",ADVEN[i].name.c_str()); univ.party.food += get_ran(2,1,6); add_string_to_buf((char *)str); put_pc_screen(); @@ -2577,7 +2577,7 @@ bool outd_move_party(location destination,bool forced) // not in towns && ((scenario.ter_types[ter].boat_over == false) || ((real_dest.x != univ.party.p_loc.x) && (real_dest.y != univ.party.p_loc.y))) - && (scenario.ter_types[ter].special != 21)) { + && (scenario.ter_types[ter].special != TER_SPEC_TOWN_ENTRANCE)) { add_string_to_buf("You leave the boat."); univ.party.in_boat = -1; } @@ -2586,7 +2586,7 @@ bool outd_move_party(location destination,bool forced) return false; else if ((outd_is_blocked(real_dest) == false) && (scenario.ter_types[ter].boat_over == true) - && (scenario.ter_types[ter].special != 21)) { + && (scenario.ter_types[ter].special != TER_SPEC_TOWN_ENTRANCE)) { if ((fancy_choice_dialog(1086,0)) == 1) forced = true; else { @@ -2624,7 +2624,7 @@ bool outd_move_party(location destination,bool forced) add_string_to_buf("Land before mounting horses."); return false; } - if ((scenario.ter_types[ter].special >= 2) && (scenario.ter_types[ter].special <= 4)) { + if (scenario.ter_types[ter].special == TER_SPEC_DAMAGING) { ASB("Your horses quite sensibly refuse."); return false; } @@ -2652,7 +2652,7 @@ bool outd_move_party(location destination,bool forced) (scenario.ter_types[ter].fly_over == true)) ) { univ.party.direction = set_direction(univ.party.p_loc, destination); - if ((flying() == true) && (scenario.ter_types[ter].special == 21)) { + if ((flying() == true) && (scenario.ter_types[ter].special == TER_SPEC_TOWN_ENTRANCE)) { add_string_to_buf("Moved: You have to land first. "); return false; } @@ -2668,7 +2668,7 @@ bool outd_move_party(location destination,bool forced) num_out_moves++; if (univ.party.in_boat >= 0) { // Waterfall!!! - while (scenario.ter_types[univ.out[univ.party.p_loc.x][univ.party.p_loc.y + 1]].special == 15) { + while (scenario.ter_types[univ.out[univ.party.p_loc.x][univ.party.p_loc.y + 1]].special == TER_SPEC_WATERFALL) { // TODO: Implement the 7 other possible directions add_string_to_buf(" Waterfall! "); univ.party.p_loc.y += 2; univ.party.loc_in_sec.y += 2; @@ -2755,33 +2755,33 @@ bool town_move_party(location destination,short forced)//// if (keep_going == true) { if (univ.party.in_boat >= 0) { - if ((is_blocked(destination) == false) && (is_special(destination) == false) - // If to bridge, exit if heading diagonal, keep going is head horiz or vert - && ( (scenario.ter_types[ter].boat_over == false) - || ((destination.x != univ.town.p_loc.x) && (destination.y != univ.town.p_loc.y)))) { - add_string_to_buf("You leave the boat. "); - univ.party.in_boat = -1; - } - else if ((destination.x != univ.town.p_loc.x) && (destination.y != univ.town.p_loc.y)) - return false; - // Crossing bridge: land or go through - else if ((is_blocked(destination) == false) && (scenario.ter_types[ter].boat_over == true)) { - if ((fancy_choice_dialog(1086,0)) == 1) - forced = true; - else if (is_blocked(destination) == false) { - add_string_to_buf("You leave the boat. "); - univ.party.in_boat = -1; - } - } - // boat in destination - else if (town_boat_there(destination) < 30) { - add_string_to_buf(" Boat there already. "); - return false; - } - // water or lava - else if (scenario.ter_types[ter].boat_over == true) - forced = true; + if ((!is_blocked(destination)) && (!is_special(destination)) + // If to bridge, exit if heading diagonal, keep going if heading horiz or vert + && ( (!scenario.ter_types[ter].boat_over) + || ((destination.x != univ.town.p_loc.x) && (destination.y != univ.town.p_loc.y)))) { + add_string_to_buf("You leave the boat. "); + univ.party.in_boat = -1; } + else if ((destination.x != univ.town.p_loc.x) && (destination.y != univ.town.p_loc.y)) + return false; + // Crossing bridge: land or go through + else if ((!is_blocked(destination)) && (scenario.ter_types[ter].boat_over) && (scenario.ter_types[ter].special == TER_SPEC_BRIDGE)) { + if ((fancy_choice_dialog(1086,0)) == 1) + forced = true; + else if (is_blocked(destination) == false) { + add_string_to_buf("You leave the boat. "); + univ.party.in_boat = -1; + } + } + // boat in destination + else if (town_boat_there(destination) < 30) { + add_string_to_buf(" Boat there already. "); + return false; + } + // water or lava + else if (scenario.ter_types[ter].boat_over == true) + forced = true; + } if (((boat_there = town_boat_there(destination)) < 30) && (univ.party.in_boat < 0)) { if (univ.party.boats[boat_there].property == true) { @@ -2816,7 +2816,7 @@ bool town_move_party(location destination,short forced)//// } else if ((is_blocked(destination) == false) || (forced == 1)) { if (univ.party.in_horse >= 0) { - if ((scenario.ter_types[ter].special >= 2) && (scenario.ter_types[ter].special <= 4)) { + if (scenario.ter_types[ter].special == TER_SPEC_DAMAGING) { ASB("Your horses quite sensibly refuse."); return false; } @@ -2840,7 +2840,7 @@ bool town_move_party(location destination,short forced)//// if (univ.party.in_boat >= 0) { // Waterfall!!! - while (scenario.ter_types[univ.town->terrain(destination.x,destination.y + 1)].special == 15) { + while (scenario.ter_types[univ.town->terrain(destination.x,destination.y + 1)].special == TER_SPEC_WATERFALL) { // TODO: Implement the other 7 possible directions add_string_to_buf(" Waterfall! "); destination.y += 2; univ.town.p_loc.y += 2; @@ -2942,7 +2942,7 @@ short count_walls(location loc) bool is_sign(unsigned char ter) { - if (scenario.ter_types[ter].special == 11) + if (scenario.ter_types[ter].special == TER_SPEC_IS_A_SIGN) return true; return false; } diff --git a/osx/boe.combat.cpp b/osx/boe.combat.cpp index 0ed3ea8d..d6a86a88 100644 --- a/osx/boe.combat.cpp +++ b/osx/boe.combat.cpp @@ -1607,7 +1607,7 @@ bool combat_next_step() if ((combat_active_pc == 6) && (current_pc != store_pc)) { sprintf((char *)create_line, "Active: %s (#%d, %d ap.) ", - ADVEN[current_pc].name,current_pc + 1,ADVEN[current_pc].ap); + ADVEN[current_pc].name.c_str(),current_pc + 1,ADVEN[current_pc].ap); add_string_to_buf((char *)create_line); print_buf(); } diff --git a/osx/boe.consts.h b/osx/boe.consts.h index 8f066156..143ccb70 100644 --- a/osx/boe.consts.h +++ b/osx/boe.consts.h @@ -159,6 +159,16 @@ enum eGameMode { #define STATUS_PARALYZED 12 #define STATUS_ACID 13 +// Directions! +#define DIR_N 0 +#define DIR_NE 1 +#define DIR_E 2 +#define DIR_SE 3 +#define DIR_S 4 +#define DIR_SW 5 +#define DIR_W 6 +#define DIR_NW 7 + /* damage type*/ /* used as parameter to some functions */ enum eDamageType { diff --git a/osx/boe.fileio.cpp b/osx/boe.fileio.cpp index 811599ac..d45c069e 100644 --- a/osx/boe.fileio.cpp +++ b/osx/boe.fileio.cpp @@ -244,8 +244,7 @@ void finish_load_party(){ force_barrier = true; if (univ.town.is_quickfire(j,k) == true) quickfire = true; - if ((scenario.ter_types[univ.town->terrain(j,k)].special >= 16) && - (scenario.ter_types[univ.town->terrain(j,k)].special <= 19)) + if ((scenario.ter_types[univ.town->terrain(j,k)].special == TER_SPEC_CONVEYOR)) belt_present = true; } force_wall = true; @@ -543,7 +542,7 @@ void init_town(){ // formerly part of load_town if (univ.town->special_locs[i].x < 100){ univ.town.set_special(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); } - for (i = 0; i < 50; i++) { + for (i = 0; i < univ.town->preset_fields.size(); i++) { switch(univ.town->preset_fields[i].type){ case 1: // currently unused univ.town.set_spot(univ.town->preset_fields[i].loc.x,univ.town->preset_fields[i].loc.y,true); @@ -1226,11 +1225,13 @@ void build_scen_headers() // data_store->scen_names[cur_entry][i - last_colon - 1] = scen_name[i]; // data_store->scen_names[cur_entry][strlen((char *) scen_name) - last_colon - 1] = 0; // cur_entry++; - std::string curScenarioName((char*) files[cur_entry].name); - for(unsigned i = 0; i < curScenarioName.length(); i++) - if(curScenarioName[i] == ':') - last_colon = i; - curScenarioName.erase(0,last_colon + 1); + p2cstr(files[cur_entry].name); + std::string curScenarioName((char*)files[cur_entry].name); + c2pstr((char*)files[cur_entry].name); +// for(unsigned i = 0; i < curScenarioName.length(); i++) +// if(curScenarioName[i] == ':') +// last_colon = i; +// curScenarioName.erase(0,last_colon + 1); scen_names.push_back(curScenarioName); } cur_entry++; diff --git a/osx/boe.graphics.cpp b/osx/boe.graphics.cpp index ac1ba046..5da9ee33 100644 --- a/osx/boe.graphics.cpp +++ b/osx/boe.graphics.cpp @@ -141,6 +141,7 @@ GWorldPtr party_template_gworld; GWorldPtr items_gworld; GWorldPtr tiny_obj_gworld; GWorldPtr fields_gworld; +GWorldPtr roads_gworld; GWorldPtr map_gworld; GWorldPtr tiny_map_graphics; GWorldPtr missiles_gworld; @@ -810,6 +811,7 @@ void Set_up_win () items_gworld = load_pict(901); tiny_obj_gworld = load_pict(900); fields_gworld = load_pict(821); + roads_gworld = load_pict(822); missiles_gworld = load_pict(880); dlogpics_gworld = load_pict(850); @@ -1748,31 +1750,39 @@ GWorldPtr load_pict(short picture_to_get) // this is used for determinign whether to round off walkway corners // right now, trying a restrictive rule (just cave floor and grass, mainly) -bool is_nature(char x, char y) +bool is_nature(char x, char y, unsigned char ground_t) { short pic; unsigned char ter_type; ter_type = coord_to_ter((short) x,(short) y); - pic = scenario.ter_types[ter_type].picture; - if ((pic >= 0) && (pic <= 45)) - return true; - if ((pic >= 67) && (pic <= 73)) - return true; - if ((pic >= 75) && (pic <= 87)) - return true; - if ((pic >= 121) && (pic <= 122)) - return true; - if ((pic >= 179) && (pic <= 208)) - return true; - if ((pic >= 211) && (pic <= 212)) - return true; - if ((pic >= 217) && (pic <= 246)) - return true; - - return false; + return ground_t == scenario.ter_types[ter_type].ground_type; +// pic = scenario.ter_types[ter_type].picture; +// if ((pic >= 0) && (pic <= 45)) +// return true; +// if ((pic >= 67) && (pic <= 73)) +// return true; +// if ((pic >= 75) && (pic <= 87)) +// return true; +// if ((pic >= 121) && (pic <= 122)) +// return true; +// if ((pic >= 179) && (pic <= 208)) +// return true; +// if ((pic >= 211) && (pic <= 212)) +// return true; +// if ((pic >= 217) && (pic <= 246)) +// return true; +// +// return false; } +unsigned short get_ground_from_ter(unsigned short ter){ + unsigned char ground = scenario.ter_types[ter].ground_type; + for(int i = 0; i < 256; i++) + if(scenario.ter_types[i].ground_type == ground) + return i; + return 0; +} void draw_terrain(short mode) //mode ... if 1, don't place on screen after redoing @@ -1782,9 +1792,9 @@ void draw_terrain(short mode) location where_draw; location sector_p_in,view_loc; char can_draw; - unsigned char spec_terrain; + unsigned short spec_terrain; bool off_terrain = false,draw_trim = true; - short i,j,short_spec_terrain; + short i,j; GrafPtr old_port; if(overall_mode == MODE_TALKING || overall_mode == MODE_SHOPPING || overall_mode == MODE_STARTUP) @@ -1816,7 +1826,8 @@ void draw_terrain(short mode) for (i = 0; i < 13; i++) for (j = 0; j < 13; j++) { - light_area[i][j] = 0;unexplored_area[i][j] = 0; + light_area[i][j] = 0; + unexplored_area[i][j] = 0; } @@ -1906,101 +1917,119 @@ void draw_terrain(short mode) anim_ticks = 0; } - short_spec_terrain = spec_terrain; + eTrimType trim = scenario.ter_types[spec_terrain].trim_type; - // Finally, draw this terrain spot - switch (short_spec_terrain) { //// all draw_one_terrain_spot - case 82: // cave wway - if (loc_off_act_area(where_draw) == false) { - if ((is_nature(where_draw.x - 1,where_draw.y)) && - (is_nature(where_draw.x,where_draw.y - 1) )) - short_spec_terrain = 10219; - if ((is_nature(where_draw.x + 1,where_draw.y) ) && - (is_nature(where_draw.x,where_draw.y - 1) )) - short_spec_terrain = 10220; - if ((is_nature(where_draw.x + 1,where_draw.y) ) && - (is_nature(where_draw.x,where_draw.y + 1) )) - short_spec_terrain = 10221; - if ((is_nature(where_draw.x - 1,where_draw.y) ) && - (is_nature(where_draw.x,where_draw.y + 1) )) - short_spec_terrain = 10218; - } - draw_one_terrain_spot(q,r,short_spec_terrain,0); - break; - case 83: // ground wway - if (loc_off_act_area(where_draw) == false) { - if ((is_nature(where_draw.x - 1,where_draw.y)) && - (is_nature(where_draw.x,where_draw.y - 1)) ) - short_spec_terrain = 10223; - if ((is_nature(where_draw.x + 1,where_draw.y) ) && - (is_nature(where_draw.x,where_draw.y - 1) )) - short_spec_terrain = 10224; - if ((is_nature(where_draw.x + 1,where_draw.y) ) && - (is_nature(where_draw.x,where_draw.y + 1) )) - short_spec_terrain = 10225; - if ((is_nature(where_draw.x - 1,where_draw.y) ) && - (is_nature(where_draw.x,where_draw.y + 1) )) - short_spec_terrain = 10222; - } - draw_one_terrain_spot(q,r,short_spec_terrain,0); - break; - - case 79: case 80: case 81: - if ((short_spec_terrain == 81) - && ((univ.out[where_draw.x][where_draw.y - 1] == 80) || (univ.out[where_draw.x][where_draw.y - 1] == 79))) - short_spec_terrain = 42; - if ((short_spec_terrain == 81) - && ((univ.out[where_draw.x][where_draw.y + 1] == 80) || (univ.out[where_draw.x][where_draw.y + 1] == 79))) - short_spec_terrain = 38; - if ((short_spec_terrain == 81) - && ((univ.out[where_draw.x - 1][where_draw.y] == 80) || (univ.out[where_draw.x - 1][where_draw.y] == 79))) - short_spec_terrain = 44; - if ((short_spec_terrain == 81) - && ((univ.out[where_draw.x + 1][where_draw.y ] == 80) || (univ.out[where_draw.x + 1][where_draw.y] == 79))) - short_spec_terrain = 40; - /*if ((short_spec_terrain == 81) - && ((univ.out[where_draw.x][where_draw.y - 1] != 234) && (univ.out[where_draw.x][where_draw.y - 1] != 81) && - ((univ.out[where_draw.x][where_draw.y - 1] < 36) || (univ.out[where_draw.x][where_draw.y - 1] > 49)))) - short_spec_terrain = 42; - if ((short_spec_terrain == 81) - && ((univ.out[where_draw.x][where_draw.y + 1] != 234) && (univ.out[where_draw.x][where_draw.y + 1] != 81) && - ((univ.out[where_draw.x][where_draw.y + 1] < 36) || (univ.out[where_draw.x][where_draw.y + 1] > 49)))) - short_spec_terrain = 38; - if ((short_spec_terrain == 81) - && ((univ.out[where_draw.x - 1][where_draw.y] != 234) &&(univ.out[where_draw.x - 1][where_draw.y] != 81) && - ((univ.out[where_draw.x - 1][where_draw.y] < 36) || (univ.out[where_draw.x - 1][where_draw.y] > 49)))) - short_spec_terrain = 44; - if ((short_spec_terrain == 81) - && ((univ.out[where_draw.x + 1][where_draw.y] != 234) && (univ.out[where_draw.x + 1][where_draw.y] != 81) && - ((univ.out[where_draw.x + 1][where_draw.y] < 36) || (univ.out[where_draw.x + 1][where_draw.y] > 49)))) - short_spec_terrain = 40;*/ - draw_one_terrain_spot(q,r,short_spec_terrain,0); - place_road(q,r,where_draw); - break; - case 90: - draw_one_terrain_spot(q,r,-1,0); - break; - default: - if (short_spec_terrain < 2) - current_ground = 0; - if ((short_spec_terrain == 2) || ( - (short_spec_terrain >= 22) && (short_spec_terrain <= 49))) - current_ground = 2; - draw_one_terrain_spot(q,r,short_spec_terrain,0); - break; - } - } - else { // Can't see. Place darkness. + // Finally, draw this terrain spot TODO: Alter walkway drawing +// if(short_spec_terrain == 82) { // cave wway +// if (loc_off_act_area(where_draw) == false) { +// if ((is_nature(where_draw.x - 1,where_draw.y)) && +// (is_nature(where_draw.x,where_draw.y - 1) )) +// short_spec_terrain = 10219; +// if ((is_nature(where_draw.x + 1,where_draw.y) ) && +// (is_nature(where_draw.x,where_draw.y - 1) )) +// short_spec_terrain = 10220; +// if ((is_nature(where_draw.x + 1,where_draw.y) ) && +// (is_nature(where_draw.x,where_draw.y + 1) )) +// short_spec_terrain = 10221; +// if ((is_nature(where_draw.x - 1,where_draw.y) ) && +// (is_nature(where_draw.x,where_draw.y + 1) )) +// short_spec_terrain = 10218; +// } +// draw_one_terrain_spot(q,r,short_spec_terrain,0); +// }else if(short_spec_terrain == 83) { // ground wway +// if (loc_off_act_area(where_draw) == false) { +// if ((is_nature(where_draw.x - 1,where_draw.y)) && +// (is_nature(where_draw.x,where_draw.y - 1)) ) +// short_spec_terrain = 10223; +// if ((is_nature(where_draw.x + 1,where_draw.y) ) && +// (is_nature(where_draw.x,where_draw.y - 1) )) +// short_spec_terrain = 10224; +// if ((is_nature(where_draw.x + 1,where_draw.y) ) && +// (is_nature(where_draw.x,where_draw.y + 1) )) +// short_spec_terrain = 10225; +// if ((is_nature(where_draw.x - 1,where_draw.y) ) && +// (is_nature(where_draw.x,where_draw.y + 1) )) +// short_spec_terrain = 10222; +// } +// draw_one_terrain_spot(q,r,short_spec_terrain,0); + if(trim == TRIM_WALKWAY){ + int corner = -1; + unsigned short ground_ter = get_ground_from_ter(spec_terrain); + unsigned char ground_t = scenario.ter_types[spec_terrain].trim_ter; + if (!loc_off_act_area(where_draw)) { + if ((is_nature(where_draw.x - 1,where_draw.y,ground_t)) && + (is_nature(where_draw.x,where_draw.y - 1,ground_t))) + corner = 1; + if ((is_nature(where_draw.x + 1,where_draw.y,ground_t)) && + (is_nature(where_draw.x,where_draw.y - 1,ground_t))) + corner = 2; + if ((is_nature(where_draw.x + 1,where_draw.y,ground_t)) && + (is_nature(where_draw.x,where_draw.y + 1,ground_t))) + corner = 3; + if ((is_nature(where_draw.x - 1,where_draw.y,ground_t)) && + (is_nature(where_draw.x,where_draw.y + 1,ground_t))) + corner = 0; + } + draw_one_terrain_spot(q,r,corner < 0 ? spec_terrain : ground_ter,0); + if(corner >= 0) + Draw_Some_Item(roads_gworld, calc_rect(corner,0), terrain_screen_gworld, loc(q,r), 1, 0); + }else if(trim == TRIM_ROAD) { // TODO: Alter road handling +// if ((short_spec_terrain == 81) +// && ((univ.out[where_draw.x][where_draw.y - 1] == 80) || (univ.out[where_draw.x][where_draw.y - 1] == 79))) +// short_spec_terrain = 42; +// if ((short_spec_terrain == 81) +// && ((univ.out[where_draw.x][where_draw.y + 1] == 80) || (univ.out[where_draw.x][where_draw.y + 1] == 79))) +// short_spec_terrain = 38; +// if ((short_spec_terrain == 81) +// && ((univ.out[where_draw.x - 1][where_draw.y] == 80) || (univ.out[where_draw.x - 1][where_draw.y] == 79))) +// short_spec_terrain = 44; +// if ((short_spec_terrain == 81) +// && ((univ.out[where_draw.x + 1][where_draw.y ] == 80) || (univ.out[where_draw.x + 1][where_draw.y] == 79))) +// short_spec_terrain = 40; + /*if ((short_spec_terrain == 81) + && ((univ.out[where_draw.x][where_draw.y - 1] != 234) && (univ.out[where_draw.x][where_draw.y - 1] != 81) && + ((univ.out[where_draw.x][where_draw.y - 1] < 36) || (univ.out[where_draw.x][where_draw.y - 1] > 49)))) + short_spec_terrain = 42; + if ((short_spec_terrain == 81) + && ((univ.out[where_draw.x][where_draw.y + 1] != 234) && (univ.out[where_draw.x][where_draw.y + 1] != 81) && + ((univ.out[where_draw.x][where_draw.y + 1] < 36) || (univ.out[where_draw.x][where_draw.y + 1] > 49)))) + short_spec_terrain = 38; + if ((short_spec_terrain == 81) + && ((univ.out[where_draw.x - 1][where_draw.y] != 234) &&(univ.out[where_draw.x - 1][where_draw.y] != 81) && + ((univ.out[where_draw.x - 1][where_draw.y] < 36) || (univ.out[where_draw.x - 1][where_draw.y] > 49)))) + short_spec_terrain = 44; + if ((short_spec_terrain == 81) + && ((univ.out[where_draw.x + 1][where_draw.y] != 234) && (univ.out[where_draw.x + 1][where_draw.y] != 81) && + ((univ.out[where_draw.x + 1][where_draw.y] < 36) || (univ.out[where_draw.x + 1][where_draw.y] > 49)))) + short_spec_terrain = 40;*/ + draw_one_terrain_spot(q,r,spec_terrain,0); + place_road(q,r,where_draw); + }else if(spec_terrain == 65535) { draw_one_terrain_spot(q,r,-1,0); - } + }else{ +// if (spec_terrain < 2) +// current_ground = 0; +// if ((spec_terrain == 2) || ( +// (spec_terrain >= 22) && (spec_terrain <= 49))) +// current_ground = 2; + current_ground = get_ground_from_ter(spec_terrain); + draw_one_terrain_spot(q,r,spec_terrain,0); + } + } + else { // Can't see. Place darkness. + draw_one_terrain_spot(q,r,-1,0); + } if ((can_draw != 0) && (overall_mode != MODE_RESTING) && (frills_on == true) - && (draw_trim == true) && (cartoon_happening == false)) { // Place the trim + && (draw_trim == true) && (cartoon_happening == false)) { // Place the trim TODO: Alter trim place_trim((short) q,(short) r,where_draw,spec_terrain); - } + } + if((is_town() && univ.town.is_spot(where_draw.x,where_draw.y)) || + (is_out() && univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].special_spot[where_draw.x][where_draw.y])) + Draw_Some_Item(roads_gworld, calc_rect(6, 0), terrain_screen_gworld, where_draw, 1, 0); } - } - + } + if ((overall_mode != MODE_RESTING) && (!is_out())) draw_sfx(); @@ -2240,18 +2269,23 @@ void draw_trim(short q,short r,short which_trim,short which_mode) } -bool extend_road_terrain(unsigned char ter) +bool extend_road_terrain(unsigned short ter) { - short i; - short extend_pics[39] = {61,62,63,64,65, 66,401,402,406,202, - 203,204,215,216,90, 91,92,93,102,103, - 104,105,112,113,114, 115,187,188,189,190, - 192,193,194,195,196, 197,191,200,201}; - - for (i = 0; i < 39; i++) - if (scenario.ter_types[ter].picture == extend_pics[i]) - return true; - return false; + unsigned short trim = scenario.ter_types[ter].trim_type; + unsigned short spec = scenario.ter_types[ter].special; + unsigned short flag = scenario.ter_types[ter].flag1; + if(trim == TRIM_ROAD || trim == TRIM_CITY || trim == TRIM_WALKWAY) + return true; + if(spec == TER_SPEC_BRIDGE) + return true; + if(spec == TER_SPEC_TOWN_ENTRANCE && trim != TRIM_NONE) + return true; // cave entrance, most likely + if(spec == TER_SPEC_UNLOCKABLE || spec == TER_SPEC_CHANGE_WHEN_STEP_ON) + return true; // closed door, possibly locked; or closed portcullis + if(spec == TER_SPEC_CHANGE_WHEN_USED && scenario.ter_types[flag].special == TER_SPEC_CHANGE_WHEN_STEP_ON && scenario.ter_types[flag].flag1 == ter) + return true; // open door (I think) TODO: Verify this works + if(spec == TER_SPEC_LOCKABLE) + return true; // open portcullis (most likely) } void place_road(short q,short r,location where) @@ -2259,46 +2293,99 @@ void place_road(short q,short r,location where) location draw_loc; unsigned char ter; Rect to_rect; - Rect road_rects[2] = {{76,112,80,125},{72,144,90,148}}; // 0 - rl partial 1 - ud partial - Rect road_dest_rects[4] = {{0,12,18,16},{16,15,20,28},{18,12,36,16},{16,0,20,13}}; // top right bottom left + //Rect road_rects[2] = {{76,112,80,125},{72,144,90,148}}; // 0 - rl partial 1 - ud partial + Rect road_rects[4] = { + {4,112,8,125}, // horizontal partial + {0,144,18,148}, // vertical partial + {0,112,4,140}, // horizontal full + {0,140,36,144}, // vertical full + }; + //Rect road_dest_rects[4] = {{0,12,18,16},{16,15,20,28},{18,12,36,16},{16,0,20,13}}; // top right bottom left + Rect road_dest_rects[6] = { + {0,12,18,16}, // top + {16,15,20,28}, // right + {18,12,36,16}, // bottom + {16,0,20,13}, // left + {0,12,36,16}, // top + bottom + {16,0,20,28}, // right + left + }; draw_loc.x = q; draw_loc.y = r; - terrain_there[q][r] = -1; - + terrain_there[q][r] = -1; // TODO: Test the new road-handling code on a hills boundary. + if (where.y > 0) ter = coord_to_ter(where.x,where.y - 1); - if ((where.y == 0) || (extend_road_terrain(ter) == true)) { + if ((where.y == 0) || (extend_road_terrain(ter))) { to_rect = road_dest_rects[0]; OffsetRect(&to_rect,13 + q * 28,13 + r * 36); - rect_draw_some_item (fields_gworld, road_rects[1], terrain_screen_gworld, to_rect, 0, 0); + rect_draw_some_item (roads_gworld, road_rects[1], terrain_screen_gworld, to_rect, 0, 0); + }else{ + ter = coord_to_ter(where.x,where.y - 2); + if(extend_road_terrain(ter)){ + to_rect = road_dest_rects[0]; + OffsetRect(&to_rect,13 + q * 28,13 + r * 36); + rect_draw_some_item (roads_gworld, road_rects[1], terrain_screen_gworld, to_rect, 0, 0); + to_rect = road_dest_rects[4]; + OffsetRect(&to_rect,13 + q * 28,13 + (r - 1) * 36); + rect_draw_some_item (roads_gworld, road_rects[3], terrain_screen_gworld, to_rect, 0, 0); } - + } + if (((is_out()) && (where.x < 96)) || (!(is_out()) && (where.x < univ.town->max_dim() - 1))) ter = coord_to_ter(where.x + 1,where.y); if (((is_out()) && (where.x == 96)) || (!(is_out()) && (where.x == univ.town->max_dim() - 1)) - || (extend_road_terrain(ter) == true)) { + || (extend_road_terrain(ter) == true)) { to_rect = road_dest_rects[1]; OffsetRect(&to_rect,13 + q * 28,13 + r * 36); - rect_draw_some_item (fields_gworld, road_rects[0], terrain_screen_gworld, to_rect, 0, 0); + rect_draw_some_item (roads_gworld, road_rects[0], terrain_screen_gworld, to_rect, 0, 0); + }else{ + ter = coord_to_ter(where.x + 1,where.y); + if(extend_road_terrain(ter)){ + to_rect = road_dest_rects[1]; + OffsetRect(&to_rect,13 + q * 28,13 + r * 36); + rect_draw_some_item (roads_gworld, road_rects[1], terrain_screen_gworld, to_rect, 0, 0); + to_rect = road_dest_rects[5]; + OffsetRect(&to_rect,13 + (q + 1) * 28,13 + r * 36); + rect_draw_some_item (roads_gworld, road_rects[3], terrain_screen_gworld, to_rect, 0, 0); } - + } + if (((is_out()) && (where.y < 96)) || (!(is_out()) && (where.y < univ.town->max_dim() - 1))) ter = coord_to_ter(where.x,where.y + 1); if (((is_out()) && (where.y == 96)) || (!(is_out()) && (where.y == univ.town->max_dim() - 1)) - || (extend_road_terrain(ter) == true)) { + || (extend_road_terrain(ter) == true)) { to_rect = road_dest_rects[2]; OffsetRect(&to_rect,13 + q * 28,13 + r * 36); - rect_draw_some_item (fields_gworld, road_rects[1], terrain_screen_gworld, to_rect, 0, 0); + rect_draw_some_item (roads_gworld, road_rects[1], terrain_screen_gworld, to_rect, 0, 0); + }else{ + ter = coord_to_ter(where.x,where.y + 2); + if(extend_road_terrain(ter)){ + to_rect = road_dest_rects[2]; + OffsetRect(&to_rect,13 + q * 28,13 + r * 36); + rect_draw_some_item (roads_gworld, road_rects[1], terrain_screen_gworld, to_rect, 0, 0); + to_rect = road_dest_rects[4]; + OffsetRect(&to_rect,13 + q * 28,13 + (r + 1) * 36); + rect_draw_some_item (roads_gworld, road_rects[3], terrain_screen_gworld, to_rect, 0, 0); } - + } + if (where.x > 0) ter = coord_to_ter(where.x - 1,where.y); if ((where.x == 0) || (extend_road_terrain(ter) == true)) { to_rect = road_dest_rects[3]; OffsetRect(&to_rect,13 + q * 28,13 + r * 36); - rect_draw_some_item (fields_gworld, road_rects[0], terrain_screen_gworld, to_rect, 0, 0); + rect_draw_some_item (roads_gworld, road_rects[0], terrain_screen_gworld, to_rect, 0, 0); + }else{ + ter = coord_to_ter(where.x - 1,where.y); + if(extend_road_terrain(ter)){ + to_rect = road_dest_rects[3]; + OffsetRect(&to_rect,13 + q * 28,13 + r * 36); + rect_draw_some_item (roads_gworld, road_rects[1], terrain_screen_gworld, to_rect, 0, 0); + to_rect = road_dest_rects[5]; + OffsetRect(&to_rect,13 + (q - 1) * 28,13 + r * 36); + rect_draw_some_item (roads_gworld, road_rects[3], terrain_screen_gworld, to_rect, 0, 0); } - + } } void draw_rest_screen() diff --git a/osx/boe.graphics.h b/osx/boe.graphics.h index e8edffcd..964a13d0 100644 --- a/osx/boe.graphics.h +++ b/osx/boe.graphics.h @@ -42,7 +42,7 @@ void put_graphics_in_template(); void draw_terrain(short mode = 0); void place_trim(short q,short r,location where,unsigned char ter_type); void draw_trim(short q,short r,short which_trim,short which_mode); -bool extend_road_terrain(unsigned char ter); +bool extend_road_terrain(unsigned short ter); void place_road(short q,short r,location where); void draw_rest_screen(); void boom_space(location where,short mode,short type,short damage,short sound); @@ -57,7 +57,7 @@ bool party_toast(); void redraw_partial_terrain(Rect redraw_rect); void dump_gworld(); //void final_process_dialog(short which_dlog); -bool is_nature(char i, char j); +bool is_nature(char i, char j, unsigned char ground_t); void put_dialog_graphic(short graphic_num,short spec_g,Rect draw_rect); void draw_startup_stats(); void HideMenuBar( void ); diff --git a/osx/boe.graphutil.cpp b/osx/boe.graphutil.cpp index b7720fca..5bde393e 100644 --- a/osx/boe.graphutil.cpp +++ b/osx/boe.graphutil.cpp @@ -229,9 +229,7 @@ void draw_one_terrain_spot (short i,short j,short terrain_to_draw,short dest) // anim_onscreen = true; } - if (dest == 0) - rect_draw_some_item(source_gworld, source_rect, terrain_screen_gworld, where_draw, (unsigned char) 0, 0); - else rect_draw_some_item(source_gworld, source_rect, terrain_screen_gworld, where_draw, (unsigned char) 0, 1); + rect_draw_some_item(source_gworld, source_rect, terrain_screen_gworld, where_draw, (unsigned char) 0, dest); } void draw_monsters() //// @@ -317,12 +315,12 @@ void draw_monsters() //// ter = univ.town->terrain(univ.town.monst.dudes[i].cur_loc.x,univ.town.monst.dudes[i].cur_loc.y); // in bed? if ((store_loc.x >= 0) && (store_loc.x < 9) && (store_loc.y >= 0) && (store_loc.y < 9) && - (scenario.ter_types[ter].picture == 143) && + (scenario.ter_types[ter].special == TER_SPEC_BED) && ((univ.town.monst.dudes[i].m_d.m_type < 7) && (univ.town.monst.dudes[i].m_d.m_type != 1) && (univ.town.monst.dudes[i].m_d.m_type != 2)) && ((univ.town.monst.dudes[i].active == 1) || (univ.town.monst.dudes[i].target == 6)) && (width == 1) && (height == 1)) //// - draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10230,0); + draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + scenario.ter_types[ter].flag1,0); else Draw_Some_Item(storage_gworld, source_rect, terrain_screen_gworld, store_loc, 1, 0); } } @@ -354,12 +352,12 @@ void draw_monsters() //// ,k); ter = univ.town->terrain(univ.town.monst.dudes[i].cur_loc.x,univ.town.monst.dudes[i].cur_loc.y); if ((store_loc.x >= 0) && (store_loc.x < 9) && (store_loc.y >= 0) && (store_loc.y < 9) && - (scenario.ter_types[ter].picture == 143) && + (scenario.ter_types[ter].special == TER_SPEC_BED) && ((univ.town.monst.dudes[i].m_d.m_type < 7) && (univ.town.monst.dudes[i].m_d.m_type != 1) && (univ.town.monst.dudes[i].m_d.m_type != 2)) && ((univ.town.monst.dudes[i].active == 1) || (univ.town.monst.dudes[i].target == 6)) && (width == 1) && (height == 1)) - draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10230,0); //// + draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + scenario.ter_types[ter].flag1,0); //// else Draw_Some_Item(storage_gworld, source_rect, terrain_screen_gworld, store_loc, 1, 0); } } @@ -691,10 +689,10 @@ void draw_party_symbol(short mode,location center) if ((univ.party.in_boat < 0) && (univ.party.in_horse < 0)) {//// i = first_active_pc(); source_rect = get_party_template_rect(i,(univ.party.direction < 4) ? 0 : 1); - + unsigned short ter = univ.town->terrain(univ.town.p_loc.x,univ.town.p_loc.y); // now wedge in bed graphic - if ((is_town()) && (scenario.ter_types[univ.town->terrain(univ.town.p_loc.x,univ.town.p_loc.y)].picture == 143)) - draw_one_terrain_spot((short) target.x,(short) target.y,10230,0); //// + if ((is_town()) && (scenario.ter_types[ter].special == TER_SPEC_BED)) + draw_one_terrain_spot((short) target.x,(short) target.y,10000 + scenario.ter_types[ter].flag1,0); //// else Draw_Some_Item(party_template_gworld, source_rect, terrain_screen_gworld, target, 1, 0); } else if (univ.party.in_boat >= 0) { @@ -825,11 +823,10 @@ unsigned char get_t_t(char x,char y) // returns terrain type at where // Is this is subterranean fluid that gets shore plopped down on it? bool is_fluid(unsigned char ter_type)//// { - - if (((ter_type >= 71) && (ter_type <= 76)) || (ter_type == 90)) - return true; - - return false; +// if (((ter_type >= 71) && (ter_type <= 76)) || (ter_type == 90)) +// return true; +// return false; + return scenario.ter_types[ter_type].trim_type == TRIM_FRILLS; } // Is this is subterranean beach that gets shore plopped down next to it? @@ -837,10 +834,12 @@ bool is_shore(unsigned char ter_type)//// { if (is_fluid(ter_type) == true) return false; - if (ter_type == 77) - return false; - if (ter_type == 90) + if(scenario.ter_types[ter_type].trim_type = TRIM_WATERFALL) return false; +// if (ter_type == 77) +// return false; +// if (ter_type == 90) +// return false; /* if (ter_type == 240) return false; if ((ter_type >= 117) && (ter_type <= 131)) @@ -1042,7 +1041,7 @@ void adjust_monst_menu() for (i = 0; i < 256; i++) if (on_monst_menu[i] >= 0) { //GetIndString(monst_name, 2,on_monst_menu[i]); - sprintf((char *) monst_name,"%s",scenario.scen_monsters[on_monst_menu[i]].m_name); + sprintf((char *) monst_name,"%s",scenario.scen_monsters[on_monst_menu[i]].m_name.c_str()); c2pstr((char*)monst_name); AppendMenu(monst_menu,monst_name); } diff --git a/osx/boe.infodlg.cpp b/osx/boe.infodlg.cpp index 310ac436..236c9ab3 100644 --- a/osx/boe.infodlg.cpp +++ b/osx/boe.infodlg.cpp @@ -810,7 +810,7 @@ void display_pc_info() store = pc_carry_weight(pc); i = amount_pc_can_carry(pc); - sprintf ((char *) to_draw, "%s is carrying %d stones out of %d.",ADVEN[pc].name,store,i); + sprintf ((char *) to_draw, "%s is carrying %d stones out of %d.",ADVEN[pc].name.c_str(),store,i); csit(1019,69,(char *) to_draw); sprintf((char *) str,"%d out of %d.", diff --git a/osx/boe.items.cpp b/osx/boe.items.cpp index b3ad5f94..04f3fa35 100644 --- a/osx/boe.items.cpp +++ b/osx/boe.items.cpp @@ -149,8 +149,8 @@ bool give_to_pc(short pc_num,cItemRec item,short print_result) } if (in_startup_mode == false) { if (item.is_ident() == 0) - sprintf((char *) announce_string," %s gets %s.",ADVEN[pc_num].name,item.name); - else sprintf((char *) announce_string," %s gets %s.",ADVEN[pc_num].name,item.full_name); + sprintf((char *) announce_string," %s gets %s.",ADVEN[pc_num].name.c_str(),item.name.c_str()); + else sprintf((char *) announce_string," %s gets %s.",ADVEN[pc_num].name.c_str(),item.full_name.c_str()); if (print_result == true) add_string_to_buf((char *)announce_string); } @@ -180,8 +180,8 @@ bool forced_give(short item_num,eItemAbil abil) //// ADVEN[i].items[j] = item; if (item.is_ident() == 0) - sprintf((char *) announce_string," %s gets %s.",ADVEN[i].name,item.name); - else sprintf((char *) announce_string," %s gets %s.",ADVEN[i].name,item.full_name); + sprintf((char *) announce_string," %s gets %s.",ADVEN[i].name.c_str(),item.name.c_str()); + else sprintf((char *) announce_string," %s gets %s.",ADVEN[i].name.c_str(),item.full_name.c_str()); add_string_to_buf((char *)announce_string); combine_things(i); sort_pc_items(i); @@ -449,39 +449,39 @@ void enchant_weapon(short pc_num,short item_hit,short enchant_type,short new_val ADVEN[pc_num].items[item_hit].set_enchanted(true); switch (enchant_type) { case 0: - sprintf((char *)store_name,"%s (+1)",ADVEN[pc_num].items[item_hit].full_name); + sprintf((char *)store_name,"%s (+1)",ADVEN[pc_num].items[item_hit].full_name.c_str()); ADVEN[pc_num].items[item_hit].bonus++; ADVEN[pc_num].items[item_hit].value = new_val; break; case 1: - sprintf((char *)store_name,"%s (+2)",ADVEN[pc_num].items[item_hit].full_name); + sprintf((char *)store_name,"%s (+2)",ADVEN[pc_num].items[item_hit].full_name.c_str()); ADVEN[pc_num].items[item_hit].bonus += 2; ADVEN[pc_num].items[item_hit].value = new_val; break; case 2: - sprintf((char *)store_name,"%s (+3)",ADVEN[pc_num].items[item_hit].full_name); + sprintf((char *)store_name,"%s (+3)",ADVEN[pc_num].items[item_hit].full_name.c_str()); ADVEN[pc_num].items[item_hit].bonus += 3; ADVEN[pc_num].items[item_hit].value = new_val; break; case 3: - sprintf((char *)store_name,"%s (F)",ADVEN[pc_num].items[item_hit].full_name); + sprintf((char *)store_name,"%s (F)",ADVEN[pc_num].items[item_hit].full_name.c_str()); ADVEN[pc_num].items[item_hit].ability = ITEM_SPELL_FLAME; ADVEN[pc_num].items[item_hit].ability_strength = 5; ADVEN[pc_num].items[item_hit].charges = 8; break; case 4: - sprintf((char *)store_name,"%s (F!)",ADVEN[pc_num].items[item_hit].full_name); + sprintf((char *)store_name,"%s (F!)",ADVEN[pc_num].items[item_hit].full_name.c_str()); ADVEN[pc_num].items[item_hit].value = new_val; ADVEN[pc_num].items[item_hit].ability = ITEM_FLAMING_WEAPON; ADVEN[pc_num].items[item_hit].ability_strength = 5; break; case 5: - sprintf((char *)store_name,"%s (+5)",ADVEN[pc_num].items[item_hit].full_name); + sprintf((char *)store_name,"%s (+5)",ADVEN[pc_num].items[item_hit].full_name.c_str()); ADVEN[pc_num].items[item_hit].value = new_val; ADVEN[pc_num].items[item_hit].bonus += 5; break; case 6: - sprintf((char *)store_name,"%s (B)",ADVEN[pc_num].items[item_hit].full_name); + sprintf((char *)store_name,"%s (B)",ADVEN[pc_num].items[item_hit].full_name.c_str()); ADVEN[pc_num].items[item_hit].bonus++; ADVEN[pc_num].items[item_hit].ability = ITEM_BLESS_CURSE; ADVEN[pc_num].items[item_hit].ability_strength = 5; @@ -925,7 +925,7 @@ void put_item_graphics() if (current_getting_pc < 6) { i = amount_pc_can_carry(current_getting_pc); storage = pc_carry_weight(current_getting_pc); - sprintf ((char *) message, "%s is carrying %d out of %d.",ADVEN[current_getting_pc].name,storage,i); + sprintf ((char *) message, "%s is carrying %d out of %d.",ADVEN[current_getting_pc].name.c_str(),storage,i); csit(987,52,(char *) message); } diff --git a/osx/boe.locutils.cpp b/osx/boe.locutils.cpp index 106afb45..6b24682b 100644 --- a/osx/boe.locutils.cpp +++ b/osx/boe.locutils.cpp @@ -77,20 +77,20 @@ short set_direction (location old_pt, location new_pt) { if (old_pt.x == new_pt.x) if (old_pt.y > new_pt.y) - return 0; - else return 4; + return DIR_N; + else return DIR_S; if (old_pt.x > new_pt.x) { if (old_pt.y > new_pt.y) - return 7; + return DIR_NW; if (old_pt.y < new_pt.y) - return 5; - return 6; - } + return DIR_SW; + return DIR_W; + } if (old_pt.y > new_pt.y) - return 1; + return DIR_NE; if (old_pt.y < new_pt.y) - return 3; - return 2; + return DIR_SE; + return DIR_E; } location global_to_local(location global) @@ -322,7 +322,7 @@ bool is_container(location loc) if ((univ.town.is_barrel(loc.x,loc.y)) || (univ.town.is_crate(loc.x,loc.y))) return true; ter = coord_to_ter(loc.x,loc.y); - if (scenario.ter_types[ter].special == 14) + if (scenario.ter_types[ter].special == TER_SPEC_IS_A_CONTAINER) return true; return false; } @@ -393,10 +393,10 @@ bool is_blocked(location to_check) } // Keep away from marked specials during combat - if ((is_combat()) && (gr <= 212) && (gr >= 207)) + if ((is_combat()) && univ.town.is_spot(to_check.x, to_check.y)) return true; if ((is_combat()) && (gr == 406)) - return true; + return true; // TODO: Replace gr == 406 with a blockage == clear/special && is_special() check // Party there? if (is_town()) @@ -755,8 +755,7 @@ void alter_space(short i,short j,unsigned char ter) else { univ.town->terrain(i,j) = ter; combat_terrain[i][j] = ter; - if ((scenario.ter_types[univ.town->terrain(i,j)].special >= 16) && - (scenario.ter_types[univ.town->terrain(i,j)].special <= 19)) - belt_present = true; + if (scenario.ter_types[univ.town->terrain(i,j)].special == TER_SPEC_CONVEYOR) + belt_present = true; } } diff --git a/osx/boe.main.cpp b/osx/boe.main.cpp index 723ae802..ea2d0cc4 100644 --- a/osx/boe.main.cpp +++ b/osx/boe.main.cpp @@ -1330,7 +1330,7 @@ void move_sound(unsigned char ter,short step){ }else on_swamp = false; if ((monsters_going == false) && (overall_mode < MODE_COMBAT) && (univ.party.in_boat >= 0)) {// is on boat ? - if (spec == 21) //town entrance ? + if (spec == TER_SPEC_TOWN_ENTRANCE) //town entrance ? return; play_sound(48); //play boat sound } diff --git a/osx/boe.monster.cpp b/osx/boe.monster.cpp index c31b0609..883efa9f 100644 --- a/osx/boe.monster.cpp +++ b/osx/boe.monster.cpp @@ -1018,13 +1018,12 @@ bool monst_check_special_terrain(location where_check,short mode,short which_mon which_m = &univ.town.monst.dudes[which_monst]; ter_abil = scenario.ter_types[ter].special; - if ((mode > 0) && (ter_abil >= 16) && - (ter_abil <= 19)) { + if ((mode > 0) && (ter_abil == TER_SPEC_CONVEYOR)) { if ( - ((ter_abil == 16) && (where_check.y > from_loc.y)) || - ((ter_abil == 17) && (where_check.x < from_loc.x)) || - ((ter_abil == 18) && (where_check.y < from_loc.y)) || - ((ter_abil == 19) && (where_check.x > from_loc.x)) ) { + ((ter_abil == DIR_N) && (where_check.y > from_loc.y)) || + ((ter_abil == DIR_E) && (where_check.x < from_loc.x)) || + ((ter_abil == DIR_S) && (where_check.y < from_loc.y)) || + ((ter_abil == DIR_W) && (where_check.x > from_loc.x)) ) { return false; } } @@ -1119,10 +1118,10 @@ bool monst_check_special_terrain(location where_check,short mode,short which_mon } } - if (monster_placid(which_monst) && // monstyers don't hop into bed when things are calm - (scenario.ter_types[ter].picture == 143)) + if (monster_placid(which_monst) && // monsters don't hop into bed when things are calm + (scenario.ter_types[ter].special == TER_SPEC_BED)) can_enter = false; - if ((scenario.ter_types[ter].picture <= 212) && (scenario.ter_types[ter].picture >= 207)) + if (mode == 1 && univ.town.is_spot(where_check.x, where_check.y)) can_enter = false; if (ter == 90) { if ((is_combat()) && (which_combat_type == 0)) { diff --git a/osx/boe.newgraph.cpp b/osx/boe.newgraph.cpp index 5a5b51fe..7e5ac1a7 100644 --- a/osx/boe.newgraph.cpp +++ b/osx/boe.newgraph.cpp @@ -839,12 +839,12 @@ char *cost_strs[] = {"Extremely Cheap","Very Reasonable","Pretty Average","Somew RGBForeColor(&c[3]); switch (store_shop_type) { - case 3: sprintf(cur_name,"Healing for %s.",ADVEN[current_pc].name); break; - case 10: sprintf(cur_name,"Mage Spells for %s.",ADVEN[current_pc].name);break; - case 11: sprintf(cur_name,"Priest Spells for %s.",ADVEN[current_pc].name); break; + case 3: sprintf(cur_name,"Healing for %s.",ADVEN[current_pc].name.c_str()); break; + case 10: sprintf(cur_name,"Mage Spells for %s.",ADVEN[current_pc].name.c_str());break; + case 11: sprintf(cur_name,"Priest Spells for %s.",ADVEN[current_pc].name.c_str()); break; case 12: sprintf(cur_name,"Buying Alchemy.");break; case 4: sprintf(cur_name,"Buying Food.");break; - default:sprintf(cur_name,"Shopping for %s.",ADVEN[current_pc].name); break; + default:sprintf(cur_name,"Shopping for %s.",ADVEN[current_pc].name.c_str()); break; } char_port_draw_string( talk_gworld,shopper_name,cur_name,2,18,false); diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index f5ba2ebb..1fa68094 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -663,16 +663,20 @@ void cure_party(short amt) } +// if how_much < 0, bless void curse_pc(short which_pc,short how_much) { if (ADVEN[which_pc].main_status != 1) return; if (ADVEN[which_pc].main_status == 1) { - ADVEN[which_pc].status[1] = max(ADVEN[which_pc].status[1] - how_much,-8); - sprintf ((char *) c_line, " %s cursed.",(char *) ADVEN[which_pc].name.c_str()); + ADVEN[which_pc].status[1] = minmax(-8,8,ADVEN[which_pc].status[1] - how_much); + if(how_much < 0) + sprintf ((char *) c_line, " %s blessed.",(char *) ADVEN[which_pc].name.c_str()); + else sprintf ((char *) c_line, " %s cursed.",(char *) ADVEN[which_pc].name.c_str()); add_string_to_buf((char *) c_line); } put_pc_screen(); + if (how_much < 0) give_help(59,0,0); } @@ -1403,7 +1407,7 @@ void give_party_spell(short which) //// if (ADVEN[i].mage_spells[which] == false) { ADVEN[i].mage_spells[which] = true; if (ADVEN[i].main_status == 1) - sprintf((char *) str,"%s learns spell.",ADVEN[i].name); + sprintf((char *) str,"%s learns spell.",ADVEN[i].name.c_str()); give_help(41,0,0); if (sound_done == false) {sound_done = true; play_sound(62);}; } @@ -1412,7 +1416,7 @@ void give_party_spell(short which) //// if (ADVEN[i].priest_spells[which - 100] == false) { ADVEN[i].priest_spells[which - 100] = true; if (ADVEN[i].main_status == 1) - sprintf((char *) str,"%s learns spell.",ADVEN[i].name); + sprintf((char *) str,"%s learns spell.",ADVEN[i].name.c_str()); give_help(41,0,0); if (sound_done == false) {sound_done = true; play_sound(62);}; } @@ -1588,7 +1592,7 @@ void do_mage_spell(short pc_num,short spell_num) } if ((spell_num == 29) && (target < 6)) { ADVEN[target].status[5] += 2 + stat_adj(pc_num,2) + get_ran(2,1,2); - sprintf ((char *) c_line, " %s protected.",ADVEN[target].name); + sprintf ((char *) c_line, " %s protected.",ADVEN[target].name.c_str()); } add_string_to_buf((char *) c_line); break; @@ -2072,27 +2076,24 @@ void cast_town_spell(location where) //// break; case 20: - switch (scenario.ter_types[ter].special) { //// - case 9: case 10: + if (scenario.ter_types[ter].special == TER_SPEC_UNLOCKABLE){ + if (scenario.ter_types[ter].flag2 == 10) + r1 = 10000; + else{ r1 = get_ran(1,1,100) - 5 * stat_adj(who_cast,2) + 5 * univ.town.difficulty; r1 += scenario.ter_types[ter].flag2 * 7; - if (scenario.ter_types[ter].flag2 == 10) - r1 = 10000; - if (r1 < (135 - combat_percent[min(19,ADVEN[who_cast].level)])) { - add_string_to_buf(" Door unlocked. "); - play_sound(9); - univ.town->terrain(where.x,where.y) = scenario.ter_types[ter].flag1; - } - else { - play_sound(41); - add_string_to_buf(" Didn't work. "); - } - break; - - default: - add_string_to_buf(" Wrong terrain type. "); - break; } + if (r1 < (135 - combat_percent[min(19,ADVEN[who_cast].level)])) { + add_string_to_buf(" Door unlocked. "); + play_sound(9); + univ.town->terrain(where.x,where.y) = scenario.ter_types[ter].flag1; + } + else { + play_sound(41); + add_string_to_buf(" Didn't work. "); + } + }else + add_string_to_buf(" Wrong terrain type. "); break; case 41: @@ -2135,14 +2136,14 @@ void sanctify_space(location where) add_string_to_buf(" Nothing happens."); } -void crumble_wall(location where) +void crumble_wall(location where) // TODO: Add something like this to the spreading quickfire function { unsigned char ter; if (loc_off_act_area(where) == true) return; ter = univ.town->terrain(where.x,where.y); - if (scenario.ter_types[ter].special == 7) { + if (scenario.ter_types[ter].special == TER_SPEC_CRUMBLING && scenario.ter_types[ter].flag3 < 2) { play_sound(60); univ.town->terrain(where.x,where.y) = scenario.ter_types[ter].flag1; add_string_to_buf(" Barrier crumbles."); @@ -2169,16 +2170,16 @@ void do_mindduel(short pc_num,cCreature *monst) r1 += 5 * balance; r2 = get_ran(1,1,6); if (r1 < 30) { - sprintf((char *)c_line, " %s is drained %d.",ADVEN[pc_num].name,r2); + sprintf((char *)c_line, " %s is drained %d.",ADVEN[pc_num].name.c_str(),r2); add_string_to_buf((char *) c_line); monst->m_d.mp += r2; balance++; if (ADVEN[pc_num].cur_sp == 0) { ADVEN[pc_num].status[9] += 2; - sprintf((char *) c_line," %s is dumbfounded.",ADVEN[pc_num].name); + sprintf((char *) c_line," %s is dumbfounded.",ADVEN[pc_num].name.c_str()); add_string_to_buf((char *) c_line); if (ADVEN[pc_num].status[9] > 7) { - sprintf((char *) c_line," %s is killed!",ADVEN[pc_num].name); + sprintf((char *) c_line," %s is killed!",ADVEN[pc_num].name.c_str()); add_string_to_buf((char *) c_line); kill_pc(pc_num,MAIN_STATUS_DEAD); } @@ -2189,7 +2190,7 @@ void do_mindduel(short pc_num,cCreature *monst) } } if (r1 > 70) { - sprintf((char *)c_line, " %s drains %d.",ADVEN[pc_num].name,r2); + sprintf((char *)c_line, " %s drains %d.",ADVEN[pc_num].name.c_str(),r2); add_string_to_buf((char *) c_line); ADVEN[pc_num].cur_sp += r2; balance--; @@ -2960,7 +2961,7 @@ short alch_choice(short pc_num) cd_activate_item(1047,9 + i * 2,0); } sprintf((char *) get_text, "%s (skill %d)", - ADVEN[pc_num].name,ADVEN[pc_num].skills[12]); + ADVEN[pc_num].name.c_str(),ADVEN[pc_num].skills[12]); cd_set_item_text(1047,4,get_text); if (univ.party.help_received[20] == 0) { cd_initial_draw(1047); @@ -3479,7 +3480,7 @@ void set_pc_moves() else { // do webs ADVEN[i].ap = max(0,ADVEN[i].ap - ADVEN[i].status[6] / 2); if (ADVEN[i].ap == 0) { - sprintf((char *) c_line,"%s must clean webs.",ADVEN[i].name); + sprintf((char *) c_line,"%s must clean webs.",ADVEN[i].name.c_str()); add_string_to_buf((char *) c_line); ADVEN[i].status[6] = max(0,ADVEN[i].status[6] - 3); } diff --git a/osx/boe.specials.cpp b/osx/boe.specials.cpp index 5b52fc3c..60f3d128 100644 --- a/osx/boe.specials.cpp +++ b/osx/boe.specials.cpp @@ -145,7 +145,7 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short // sets forced to true if definitely can enter { unsigned short ter; - short r1,i,choice,door_pc,ter_special,ter_flag1,ter_flag2,pic_type = 0,ter_pic = 0; + short r1,i,choice,door_pc,ter_special,ter_flag1,ter_flag2,ter_flag3,pic_type = 0,ter_pic = 0; eDamageType dam_type = DAMAGE_WEAPON; bool can_enter = true; location out_where,from_loc,to_loc; @@ -171,15 +171,15 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short ter_special = scenario.ter_types[ter].special; ter_flag1 = scenario.ter_types[ter].flag1; ter_flag2 = scenario.ter_types[ter].flag2; + ter_flag3 = scenario.ter_types[ter].flag3; ter_pic = scenario.ter_types[ter].picture; - if ((mode > 0) && (ter_special >= 16) && - (ter_special <= 19)) { + if ((mode > 0) && (ter_special == TER_SPEC_CONVEYOR)) { if ( - ((ter_special == 16) && (where_check.y > from_loc.y)) || - ((ter_special == 17) && (where_check.x < from_loc.x)) || - ((ter_special == 18) && (where_check.y < from_loc.y)) || - ((ter_special == 19) && (where_check.x > from_loc.x)) ) { + ((ter_flag3 == DIR_N) && (where_check.y > from_loc.y)) || + ((ter_flag3 == DIR_E) && (where_check.x < from_loc.x)) || + ((ter_flag3 == DIR_S) && (where_check.y < from_loc.y)) || + ((ter_flag3 == DIR_W) && (where_check.x > from_loc.x)) ) { ASB("The moving floor prevents you."); return false; } @@ -202,11 +202,11 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short put_pc_screen(); put_item_screen(stat_window,0); } - } + } - if ((is_combat()) && (((ter_pic <= 207) && (ter_pic >= 212)) || (ter_pic == 406))) { + if ((is_combat()) && (univ.town.is_spot(where_check.x, where_check.y) || (ter_pic == 406))) { ASB("Move: Can't trigger this special in combat."); - return false; + return false; // TODO: Replace ter_pic == 406 with a blockage == clear/special && is_special() check } if (((mode == 1) || ((mode == 2) && (which_combat_type == 1))) @@ -221,8 +221,8 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short *forced = true; } *spec_num = univ.town->spec_id[i]; - if ((is_blocked(where_check) == false) || (ter_special == 1) - || (ter_special == 12) || (ter_special == 13)) { + if ((is_blocked(where_check) == false) || (ter_special == TER_SPEC_CHANGE_WHEN_STEP_ON) + || (ter_special == TER_SPEC_CALL_SPECIAL)) { give_help(54,0,0); run_special(mode,2,univ.town->spec_id[i],where_check,&s1,&s2,&s3); if (s1 > 0) @@ -231,59 +231,58 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short } put_pc_screen(); put_item_screen(stat_window,0); - } + } if (can_enter == false) return false; if ((!is_out()) && (overall_mode < MODE_TALKING)) { - check_fields(where_check,mode,which_pc); - - if (univ.town.is_web(where_check.x,where_check.y)) { - add_string_to_buf(" Webs! "); - if (mode < 2) { - suppress_stat_screen = true; - for (i = 0; i < 6; i++) { - r1 = get_ran(1,2,3); - web_pc(i,r1); + check_fields(where_check,mode,which_pc); + + if (univ.town.is_web(where_check.x,where_check.y)) { + add_string_to_buf(" Webs! "); + if (mode < 2) { + suppress_stat_screen = true; + for (i = 0; i < 6; i++) { + r1 = get_ran(1,2,3); + web_pc(i,r1); } - suppress_stat_screen = true; - put_pc_screen(); + suppress_stat_screen = true; + put_pc_screen(); } else web_pc(current_pc,get_ran(1,2,3)); - univ.town.set_web(where_check.x,where_check.y,false); + univ.town.set_web(where_check.x,where_check.y,false); } - if (univ.town.is_force_barr(where_check.x,where_check.y)) { - add_string_to_buf(" Magic barrier! "); - can_enter = false; + if (univ.town.is_force_barr(where_check.x,where_check.y)) { + add_string_to_buf(" Magic barrier! "); + can_enter = false; } - if (univ.town.is_crate(where_check.x,where_check.y)) { - add_string_to_buf(" You push the crate."); - to_loc = push_loc(from_loc,where_check); - univ.town.set_crate((short) where_check.x,(short) where_check.y,false); - if (to_loc.x > 0) - univ.town.set_crate((short) to_loc.x,(short) to_loc.y,true); - for (i = 0; i < NUM_TOWN_ITEMS; i++) - if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) - && (univ.town.items[i].is_contained() == true)) - univ.town.items[i].item_loc = to_loc; + if (univ.town.is_crate(where_check.x,where_check.y)) { + add_string_to_buf(" You push the crate."); + to_loc = push_loc(from_loc,where_check); + univ.town.set_crate((short) where_check.x,(short) where_check.y,false); + if (to_loc.x > 0) + univ.town.set_crate((short) to_loc.x,(short) to_loc.y,true); + for (i = 0; i < NUM_TOWN_ITEMS; i++) + if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) + && (univ.town.items[i].is_contained() == true)) + univ.town.items[i].item_loc = to_loc; } - if (univ.town.is_barrel(where_check.x,where_check.y)) { - add_string_to_buf(" You push the barrel."); - to_loc = push_loc(from_loc,where_check); - univ.town.set_barrel((short) where_check.x,(short) where_check.y,false); - if (to_loc.x > 0) - univ.town.set_barrel((short) to_loc.x,(short) to_loc.y,false); - for (i = 0; i < NUM_TOWN_ITEMS; i++) - if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) - && (univ.town.items[i].is_contained())) - univ.town.items[i].item_loc = to_loc; + if (univ.town.is_barrel(where_check.x,where_check.y)) { + add_string_to_buf(" You push the barrel."); + to_loc = push_loc(from_loc,where_check); + univ.town.set_barrel((short) where_check.x,(short) where_check.y,false); + if (to_loc.x > 0) + univ.town.set_barrel((short) to_loc.x,(short) to_loc.y,false); + for (i = 0; i < NUM_TOWN_ITEMS; i++) + if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) + && (univ.town.items[i].is_contained())) + univ.town.items[i].item_loc = to_loc; } - } - + } switch (ter_special) { - case 1: + case TER_SPEC_CHANGE_WHEN_STEP_ON: alter_space(where_check.x,where_check.y,ter_flag1); if (ter_flag2 < 200) { play_sound(-1 * ter_flag2); @@ -292,25 +291,38 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short if (scenario.ter_types[ter].blockage > 2) can_enter = false; break; - case 2: case 3:case 4: + case TER_SPEC_DAMAGING: if (flying()) break; - if (ter_special == 2) { - add_string_to_buf(" It's hot!"); - dam_type = DAMAGE_FIRE; pic_type = 0; - if (PSD[SDF_PARTY_FIREWALK] > 0) { - add_string_to_buf(" It doesn't affect you."); - break; + if(ter_flag3 > 0 && ter_flag3 < 8) + dam_type = (eDamageType) ter_flag3; + else dam_type = DAMAGE_WEAPON; + switch(dam_type){ + case DAMAGE_FIRE: + add_string_to_buf(" It's hot!"); + pic_type = 0; + if (PSD[SDF_PARTY_FIREWALK] > 0) { + add_string_to_buf(" It doesn't affect you."); + goto LBL_NO_DAMAGE; } - } - if (ter_special == 3) { - add_string_to_buf(" You feel cold!"); - dam_type = DAMAGE_COLD; pic_type = 4; - } - if (ter_special == 4) { - add_string_to_buf(" Something shocks you!"); - dam_type = DAMAGE_MAGIC; pic_type = 1; - } + case DAMAGE_COLD: + add_string_to_buf(" You feel cold!"); + pic_type = 4; + case DAMAGE_MAGIC: + case DAMAGE_UNBLOCKABLE: + add_string_to_buf(" Something shocks you!"); + pic_type = 1; + case DAMAGE_WEAPON: + add_string_to_buf(" You feel pain!"); + pic_type = 3; + case DAMAGE_POISON: + add_string_to_buf(" You suddenly feel very ill for a moment..."); + pic_type = 2; + case DAMAGE_UNDEAD: + case DAMAGE_DEMON: + add_string_to_buf(" A dark wind blows through you!"); + pic_type = 1; // TODO: Verify that this is correct + } r1 = get_ran(ter_flag2,dam_type,ter_flag1); if (mode < 2) hit_party(r1,dam_type); @@ -320,47 +332,96 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short if (overall_mode < MODE_COMBAT) boom_space(univ.party.p_loc,overall_mode,pic_type,r1,12); fast_bang = 0; - break; - case 5: case 6: + LBL_NO_DAMAGE: break; + case TER_SPEC_DANGEROUS: if (flying()) break; if (univ.party.in_boat >= 0) return true; //one_sound(17); - if (mode < 2) { - for (i = 0; i < 6; i++) - if (ADVEN[i].main_status == 1) - { - if (get_ran(1,1,100) <= ter_flag2) { - if (ter_special == 5) + if (mode == 2) i = which_pc; else i = 0; + for ( ; i < 6; i++) + if (ADVEN[i].main_status == 1) { + if (get_ran(1,1,100) <= ter_flag2) { + switch(ter_flag3){ + case STATUS_POISONED_WEAPON: // TODO: Do something here + break; + case STATUS_BLESS: + curse_pc(i,ter_flag1); + break; + case STATUS_POISON: poison_pc(i,ter_flag1); - else disease_pc(i,ter_flag1); - } + break; + case STATUS_HASTE: + slow_pc(i,ter_flag1); + break; + case STATUS_INVULNERABLE: // TODO: Do something here + break; + case STATUS_MAGIC_RESISTANCE: // TODO: Do something here + break; + case STATUS_WEBS: + web_pc(i,ter_flag1); + break; + case STATUS_DISEASE: + disease_pc(i,ter_flag1); + break; + case STATUS_INVISIBLE: + void_sanctuary(i); + break; + case STATUS_DUMB: + dumbfound_pc(i,ter_flag1); + break; + case STATUS_MARTYRS_SHIELD: // TODO: Do something here + break; + case STATUS_ASLEEP: + sleep_pc(i,ter_flag1,STATUS_ASLEEP,ter_flag1); + break; + case STATUS_PARALYZED: // TODO: Do something here + break; + case STATUS_ACID: + acid_pc(i,ter_flag1); + break; + case 14: // bless + curse_pc(i,-ter_flag1); + break; + case 15: // haste + slow_pc(i,-ter_flag1); + break; } + if(mode == 2) break; // only damage once in combat! + } } //print_nums(1,which_pc,current_pc); - if (mode == 2) { - if (get_ran(1,1,100) <= ter_flag2){ - if (ter_special == 5) - poison_pc(which_pc,ter_flag1); - else disease_pc(which_pc,ter_flag1); - } - } +// if (mode == 2) { +// if (get_ran(1,1,100) <= ter_flag2){ +// if (ter_special == 5) +// poison_pc(which_pc,ter_flag1); +// else disease_pc(which_pc,ter_flag1); +// } +// } break; - case 12: // local special - run_special(mode,2,ter_flag1,where_check,&s1,&s2,&s3); - if (s1 > 0) - can_enter = false; - break; - case 13: // global special - run_special(mode,0,ter_flag1,where_check,&s1,&s2,&s3); + case TER_SPEC_CALL_SPECIAL:{ + short spec_type = 0; + if(ter_flag2 == 3){ + if(mode == 1 || (mode == 2 && which_combat_type == 1)) spec_type = 2; else spec_type = 1; + }else if(ter_flag2 == 2 && (mode == 0 || (mode == 2 && which_combat_type == 0))) + spec_type = 1; + else if(ter_flag2 == 1 && (mode == 1 || (mode == 2 && which_combat_type == 1))) + spec_type = 2; + run_special(mode,spec_type,ter_flag1,where_check,&s1,&s2,&s3); if (s1 > 0) can_enter = false; break; + } +// case 13: // global special +// run_special(mode,0,ter_flag1,where_check,&s1,&s2,&s3); +// if (s1 > 0) +// can_enter = false; +// break; // Locked doors - case 9: case 10: + case TER_SPEC_UNLOCKABLE: if (is_combat()) { // No lockpicking in combat add_string_to_buf(" Can't enter: It's locked."); break; @@ -561,8 +622,8 @@ effect_pat_type s = {{{0,0,0,0,0,0,0,0,0}, } if (take_charge == true) { if (!ADVEN[pc].items[item].is_ident()) - sprintf((char *) to_draw, "Use: %s",ADVEN[pc].items[item].name); - else sprintf((char *) to_draw, "Use: %s",ADVEN[pc].items[item].full_name); + sprintf((char *) to_draw, "Use: %s",ADVEN[pc].items[item].name.c_str()); + else sprintf((char *) to_draw, "Use: %s",ADVEN[pc].items[item].full_name.c_str()); add_string_to_buf((char *) to_draw); if ((ADVEN[pc].items[item].variety == 7) && @@ -956,7 +1017,7 @@ bool use_space(location where) univ.town.items[i].item_loc = to_loc; } - if (scenario.ter_types[ter].special == 22) { + if (scenario.ter_types[ter].special == TER_SPEC_CHANGE_WHEN_USED) { if (where == from_loc) { add_string_to_buf(" Not while on space."); return false; @@ -965,8 +1026,16 @@ bool use_space(location where) alter_space(where.x,where.y,scenario.ter_types[ter].flag1); play_sound(scenario.ter_types[ter].flag2); return true; - }else if (scenario.ter_types[ter].special == 23) // call special - run_special(17,0,scenario.ter_types[ter].flag1,where,&i,&i,&i); + }else if (scenario.ter_types[ter].special == TER_SPEC_CALL_SPECIAL_WHEN_USED){ // call special + short spec_type = 0; + if(scenario.ter_types[ter].flag2 == 3){ + if((is_town() || (is_combat() && which_combat_type == 1))) spec_type = 2; else spec_type = 1; + }else if(scenario.ter_types[ter].flag2 == 1 && (is_town() || (is_combat() && which_combat_type == 1))) + spec_type = 2; + else if(scenario.ter_types[ter].flag2 == 2 && (is_out() || (is_combat() && which_combat_type == 1))) + spec_type = 1; + run_special(17,spec_type,scenario.ter_types[ter].flag1,where,&i,&i,&i); + } add_string_to_buf(" Nothing to use."); return false; @@ -1428,7 +1497,7 @@ void push_things()//// unsigned char ter; location l; - if (is_out()) + if (is_out()) // TODO: Make these work outdoors return; if (belt_present == false) return; @@ -1437,11 +1506,11 @@ void push_things()//// if (univ.town.monst.dudes[i].active > 0) { l = univ.town.monst.dudes[i].cur_loc; ter = univ.town->terrain(l.x,l.y); - switch (scenario.ter_types[ter].special) { - case 16: l.y--; break; - case 17: l.x++; break; - case 18: l.y++; break; - case 19: l.x--; break; + switch (scenario.ter_types[ter].flag1) { // TODO: Implement the other 4 possible directions + case DIR_N: l.y--; break; + case DIR_E: l.x++; break; + case DIR_S: l.y++; break; + case DIR_W: l.x--; break; } if (l != univ.town.monst.dudes[i].cur_loc) { univ.town.monst.dudes[i].cur_loc = l; @@ -1454,11 +1523,11 @@ void push_things()//// if (univ.town.items[i].variety > 0) { l = univ.town.items[i].item_loc; ter = univ.town->terrain(l.x,l.y); - switch (scenario.ter_types[ter].special) { - case 16: l.y--; break; - case 17: l.x++; break; - case 18: l.y++; break; - case 19: l.x--; break; + switch (scenario.ter_types[ter].flag1) { // TODO: Implement the other 4 possible directions + case DIR_N: l.y--; break; + case DIR_E: l.x++; break; + case DIR_S: l.y++; break; + case DIR_W: l.x--; break; } if (l != univ.town.items[i].item_loc) { univ.town.items[i].item_loc = l; @@ -1471,15 +1540,15 @@ void push_things()//// if (is_town()) { ter = univ.town->terrain(univ.town.p_loc.x,univ.town.p_loc.y); l = univ.town.p_loc; - switch (scenario.ter_types[ter].special) { - case 16: l.y--; break; - case 17: l.x++; break; - case 18: l.y++; break; - case 19: l.x--; break; + switch (scenario.ter_types[ter].flag1) { // TODO: Implement the other 4 possible directions + case DIR_N: l.y--; break; + case DIR_E: l.x++; break; + case DIR_S: l.y++; break; + case DIR_W: l.x--; break; } if (l != univ.town.p_loc) { ASB("You get pushed."); - if (scenario.ter_types[ter].special >= 16) + if (scenario.ter_types[ter].special == TER_SPEC_CONVEYOR) draw_terrain(0); center = l; univ.town.p_loc = l; @@ -1506,16 +1575,16 @@ void push_things()//// if (ADVEN[i].main_status == 1) { ter = univ.town->terrain(pc_pos[i].x,pc_pos[i].y); l = pc_pos[i]; - switch (scenario.ter_types[ter].special) { - case 16: l.y--; break; - case 17: l.x++; break; - case 18: l.y++; break; - case 19: l.x--; break; + switch (scenario.ter_types[ter].flag1) { // TODO: Implement the other 4 possible directions + case DIR_N: l.y--; break; + case DIR_E: l.x++; break; + case DIR_S: l.y++; break; + case DIR_W: l.x--; break; } if (l != pc_pos[i]) { ASB("Someone gets pushed."); ter = univ.town->terrain(l.x,l.y); - if (scenario.ter_types[ter].special >= 16) + if (scenario.ter_types[ter].special == TER_SPEC_CONVEYOR) draw_terrain(0); pc_pos[i] = l; update_explored(l); @@ -2490,7 +2559,7 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type, break; case 171: set_terrain(l,spec.ex2a); - if(scenario.ter_types[spec.ex2a].special >= 16 && scenario.ter_types[spec.ex2a].special <=19) + if(scenario.ter_types[spec.ex2a].special == TER_SPEC_CONVEYOR) belt_present = true; *redraw = true; draw_map(modeless_dialogs[5],10); @@ -2498,12 +2567,12 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type, case 172: if (coord_to_ter(spec.ex1a,spec.ex1b) == spec.ex2a){ set_terrain(l,spec.ex2b); - if(scenario.ter_types[spec.ex2a].special >= 16 && scenario.ter_types[spec.ex2a].special <=19) + if(scenario.ter_types[spec.ex2a].special == TER_SPEC_CONVEYOR) belt_present = true; } else if (coord_to_ter(spec.ex1a,spec.ex1b) == spec.ex2b){ set_terrain(l,spec.ex2a); - if(scenario.ter_types[spec.ex2a].special >= 16 && scenario.ter_types[spec.ex2a].special <=19) + if(scenario.ter_types[spec.ex2a].special == TER_SPEC_CONVEYOR) belt_present = true; } *redraw = 1; @@ -2512,7 +2581,7 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type, case 173: ter = coord_to_ter(spec.ex1a,spec.ex1b); set_terrain(l,scenario.ter_types[ter].trans_to_what); - if(scenario.ter_types[spec.ex2a].special >= 16 && scenario.ter_types[spec.ex2a].special <=19) + if(scenario.ter_types[spec.ex2a].special == TER_SPEC_CONVEYOR) belt_present = true; *redraw = 1; draw_map(modeless_dialogs[5],10); @@ -2547,13 +2616,13 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type, break; case 177: ter = coord_to_ter(spec.ex1a,spec.ex1b); - if (scenario.ter_types[ter].special == 8) + if (scenario.ter_types[ter].special == TER_SPEC_LOCKABLE) set_terrain(l,scenario.ter_types[ter].flag1); *redraw = 1; break; case 178: ter = coord_to_ter(spec.ex1a,spec.ex1b); - if ((scenario.ter_types[ter].special == 9) || (scenario.ter_types[ter].special == 10)) + if (scenario.ter_types[ter].special == TER_SPEC_UNLOCKABLE) set_terrain(l,scenario.ter_types[ter].flag1); *redraw = 1; break; @@ -2884,7 +2953,7 @@ void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type, case 214: if (get_ran(1,1,100) <= spec.sd2){ set_terrain(l,spec.sd1); - if(scenario.ter_types[spec.sd1].special >= 16 && scenario.ter_types[spec.sd1].special <=19) + if(scenario.ter_types[spec.sd1].special == TER_SPEC_CONVEYOR) belt_present = true; *redraw = true; draw_map(modeless_dialogs[5],10); @@ -2893,14 +2962,14 @@ void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type, case 215: if (coord_to_ter(i,j) == spec.sd1){ set_terrain(l,spec.sd2); - if(scenario.ter_types[spec.sd2].special >= 16 && scenario.ter_types[spec.sd2].special <=19) + if(scenario.ter_types[spec.sd2].special == TER_SPEC_CONVEYOR) belt_present = true; *redraw = true; draw_map(modeless_dialogs[5],10); } else if (coord_to_ter(i,j) == spec.sd2){ set_terrain(l,spec.sd1); - if(scenario.ter_types[spec.sd1].special >= 16 && scenario.ter_types[spec.sd1].special <=19) + if(scenario.ter_types[spec.sd1].special == TER_SPEC_CONVEYOR) belt_present = true; *redraw = true; draw_map(modeless_dialogs[5],10); @@ -2909,7 +2978,7 @@ void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type, case 216: ter = coord_to_ter(i,j); set_terrain(l,scenario.ter_types[ter].trans_to_what); - if(scenario.ter_types[scenario.ter_types[ter].trans_to_what].special >= 16 && scenario.ter_types[scenario.ter_types[ter].trans_to_what].special <=19) + if(scenario.ter_types[scenario.ter_types[ter].trans_to_what].special == TER_SPEC_CONVEYOR) belt_present = true; *redraw = true; draw_map(modeless_dialogs[5],10); @@ -2918,7 +2987,7 @@ void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type, ter = coord_to_ter(i,j); if (scenario.ter_types[ter].special == 8){ set_terrain(l,scenario.ter_types[ter].flag1); - if(scenario.ter_types[scenario.ter_types[ter].trans_to_what].special >= 16 && scenario.ter_types[scenario.ter_types[ter].trans_to_what].special <=19) + if(scenario.ter_types[scenario.ter_types[ter].trans_to_what].special == TER_SPEC_CONVEYOR) belt_present = true; *redraw = true; draw_map(modeless_dialogs[5],10); @@ -2926,9 +2995,9 @@ void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type, break; case 218: ter = coord_to_ter(i,j); - if ((scenario.ter_types[ter].special == 9) || (scenario.ter_types[ter].special == 10)){ + if (scenario.ter_types[ter].special == TER_SPEC_UNLOCKABLE){ set_terrain(l,scenario.ter_types[ter].flag1); - if(scenario.ter_types[scenario.ter_types[ter].trans_to_what].special >= 16 && scenario.ter_types[scenario.ter_types[ter].trans_to_what].special <=19) + if(scenario.ter_types[scenario.ter_types[ter].trans_to_what].special == TER_SPEC_CONVEYOR) belt_present = true; *redraw = true; draw_map(modeless_dialogs[5],10); diff --git a/osx/boe.text.cpp b/osx/boe.text.cpp index 465963f4..182248a6 100644 --- a/osx/boe.text.cpp +++ b/osx/boe.text.cpp @@ -355,12 +355,12 @@ void put_item_screen(short screen_num,short suppress_buttons) //// if (!ADVEN[pc].items[i_num].is_ident()) - sprintf((char *) to_draw, "%s ",ADVEN[pc].items[i_num].name); + sprintf((char *) to_draw, "%s ",ADVEN[pc].items[i_num].name.c_str()); else { /// Don't place # of charges when Sell button up and space tight if ((ADVEN[pc].items[i_num].charges > 0) && (ADVEN[pc].items[i_num].type != 2) && (stat_screen_mode <= 1)) - sprintf((char *) to_draw, "%s (%d)",ADVEN[pc].items[i_num].full_name,ADVEN[pc].items[i_num].charges); - else sprintf((char *) to_draw, "%s",ADVEN[pc].items[i_num].full_name); + sprintf((char *) to_draw, "%s (%d)",ADVEN[pc].items[i_num].full_name.c_str(),ADVEN[pc].items[i_num].charges); + else sprintf((char *) to_draw, "%s",ADVEN[pc].items[i_num].full_name.c_str()); } dest_rect.left -= 2; win_draw_string( item_stats_gworld,dest_rect,to_draw,0,10,false); diff --git a/osx/boe.town.cpp b/osx/boe.town.cpp index f20ae816..ad0316b9 100644 --- a/osx/boe.town.cpp +++ b/osx/boe.town.cpp @@ -216,9 +216,8 @@ void start_town_mode(short which_town, short entry_dir) current_ground = 0; else if (univ.town->terrain(i,j) == 2) current_ground = 2; - if ((scenario.ter_types[univ.town->terrain(i,j)].special >= 16) && - (scenario.ter_types[univ.town->terrain(i,j)].special <= 19)) - belt_present = true; + if (scenario.ter_types[univ.town->terrain(i,j)].special == TER_SPEC_CONVEYOR) + belt_present = true; } univ.town.hostile = 0; @@ -907,45 +906,13 @@ void create_out_combat_terrain(short type,short num_walls,short spec_code) // spec_code is encounter's spec_code { short i,j,k,r1,ter_type; - // 0 grass 1 cave 2 mntn 3 bridge 4 cave bridge 5 rubble cave 6 cave tree 7 cave mush - // 8 cave swamp 9 surfac eorcks 10 surf swamp 11 surface woods 12 s. shrub 13 stalags - static const short general_types[260] = { - 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, // 0 - grassy field - 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, // 1 - ordinary cave - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 2 - mountain - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 3 - surface bridge - 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, // 4 - cave bridge - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 50 */ // 5 - rubble-strewn cave - 0, 3, 3, 3, 3, 3, 3, 5, 5, 5, // 6 - cave tree forest - 6, 6, 7, 7, 1, 1, 8, 9, 10,11, // 7 - cave mushrooms - 10,11,12,13,13,9, 9, 9, 1, 1, // 8 - cave swamp - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - surface rocks - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 100 */ // 10 - surface swamp - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 11 - surface woods - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 12 - shrubbery - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 13 - stalagmites - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 14 - cave road (proposed) - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 150 */ // 15 - surface road (proposed) - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 16 - hills road (proposed) - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 17 - crops (proposed) - 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, // 18 - cave fumarole (proposed) - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, // 19 - surface fumarole (proposed) - 0, 0, 1, 0, 2, 0, 0, 1, 1, 1,/* 200 */ // (note: fumaroles would have lava.) - 1, 0, 2, 1, 1, 0, 1, 1, 1, 1, // the numbers in this array are indices into the other arrays - 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, // (ter_base, ground_type, and terrain_odds first index) - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 /* 250 */ + static const short ter_base[16] = { + 2,0,36,50,71,0,0,0, + 0,2,2, 2, 2, 0,0,36 }; - static const short ter_base[14] = { - 2,0,36,50,71, - 0,0,0,0,2, - 2,2,2,0 - }; - static const short ground_type[14] = { - 2,0,36,50,71, - 0,0,0,0,2, - 2,2,2,0 + static const short ground_type[16] = { + 2,0,36,50,71,0,0,0, + 0,2,2, 2, 2, 0,0,36 }; static const location special_ter_locs[15] = { loc(11,10),loc(11,14),loc(10,20),loc(11,26),loc(9,30), @@ -976,7 +943,19 @@ void create_out_combat_terrain(short type,short num_walls,short spec_code) {71,71,71,96}, {71,71,71,96} }; - static const short terrain_odds[14][10] = { + static const unsigned char surf_fume[4][4] = { + {75,75,75,36}, + {75,75,75,75}, + {75,75,75,75}, + {36,37,75,75} + }; + static const unsigned char cave_fume[4][4] = { + {98,0 ,75,75}, + {0 ,75,75,75}, + {75,75,75,0 }, + {75,75,75,0 } + }; + static const short terrain_odds[16][10] = { {3,80,4,40,115,20,114,10,112,1}, {1,50,93,25,94,5,98,10,95,1}, {37,20,0,0,0,0,0,0,0,0}, @@ -990,14 +969,18 @@ void create_out_combat_terrain(short type,short num_walls,short spec_code) {3,200,4,400,111,250,0,0,0,0}, {3,200,4,300,112,50,113,60,114,100}, {3,100,4,250,115,120,114,30,112,2}, - {1,25,84,15,98,300,97,280,0,0} + {1,25,76,15,98,300,97,280,75,5}, + {37,20,76,20,75,5,0,0,0,0} }; // ter then odds then ter then odds ... location stuff_ul; - ter_type = scenario.ter_types[type].picture; - if (ter_type > 260) - ter_type = 1; - else ter_type = general_types[ter_type]; +// ter_type = scenario.ter_types[type].picture; +// if (ter_type > 260) +// ter_type = 1; +// else ter_type = general_types[ter_type]; + ter_type = scenario.ter_types[type].combat_arena; + if(ter_type >= 1000) ter_type = 1; // TODO: load town ter_type - 1000 as the combat arena + // TODO: Also implement the roads and crops arenas for (i = 0; i < 48; i++) for (j = 0; j < 48; j++) { @@ -1062,7 +1045,23 @@ void create_out_combat_terrain(short type,short num_walls,short spec_code) for (j = 0; j < 4; j++) for (k = 0; k < 4; k++) univ.town->terrain(stuff_ul.x + j,stuff_ul.y + k) = surf_lake[k][j]; - } + } + if (ter_type == 14) + for (i = 0; i < 15; i++) + if (get_ran(1,0,5) == 1) { + stuff_ul = special_ter_locs[i]; + for (j = 0; j < 4; j++) + for (k = 0; k < 4; k++) + univ.town->terrain(stuff_ul.x + j,stuff_ul.y + k) = cave_fume[k][j]; + } + if (ter_type == 15) + for (i = 0; i < 15; i++) + if (get_ran(1,0,5) == 1) { + stuff_ul = special_ter_locs[i]; + for (j = 0; j < 4; j++) + for (k = 0; k < 4; k++) + univ.town->terrain(stuff_ul.x + j,stuff_ul.y + k) = surf_fume[k][j]; + } if (ground_type[ter_type] == 0) { @@ -1200,7 +1199,7 @@ void pick_lock(location where,short pc_num) if (pc_has_abil_equip(pc_num,42) < 24) r1 = r1 - 12; - if ((scenario.ter_types[terrain].special < 9) || (scenario.ter_types[terrain].special > 10)) { + if (scenario.ter_types[terrain].special != TER_SPEC_UNLOCKABLE) { add_string_to_buf(" Wrong terrain type. "); return; } @@ -1228,13 +1227,13 @@ void bash_door(location where,short pc_num) //// terrain = univ.town->terrain(where.x,where.y); r1 = get_ran(1,1,100) - 15 * stat_adj(pc_num,0) + univ.town.difficulty * 4; - if ((scenario.ter_types[terrain].special < 9) || (scenario.ter_types[terrain].special > 10)) { + if (scenario.ter_types[terrain].special != TER_SPEC_UNLOCKABLE) { add_string_to_buf(" Wrong terrain type. "); return; } unlock_adjust = scenario.ter_types[terrain].flag2; - if ((unlock_adjust >= 5) || (r1 > (unlock_adjust * 15 + 40)) || (scenario.ter_types[terrain].special != 10)) { + if ((unlock_adjust >= 5) || (r1 > (unlock_adjust * 15 + 40)) || (scenario.ter_types[terrain].flag3 != 1)) { add_string_to_buf(" Didn't work. "); damage_pc(pc_num,get_ran(1,1,4),DAMAGE_UNBLOCKABLE,MONSTER_TYPE_UNKNOWN,0); } @@ -1271,14 +1270,15 @@ void erase_specials()//// } if (where.x != 100) { - switch (scenario.ter_types[univ.town->terrain(where.x,where.y)].picture) { - case 207: univ.town->terrain(where.x,where.y) = 0; break; - case 208: univ.town->terrain(where.x,where.y) = 170; break; - case 209: univ.town->terrain(where.x,where.y) = 210; break; - case 210: univ.town->terrain(where.x,where.y) = 217; break; - case 211: univ.town->terrain(where.x,where.y) = 2; break; - case 212: univ.town->terrain(where.x,where.y) = 36; break; - } +// switch (scenario.ter_types[univ.town->terrain(where.x,where.y)].picture) { +// case 207: univ.town->terrain(where.x,where.y) = 0; break; +// case 208: univ.town->terrain(where.x,where.y) = 170; break; +// case 209: univ.town->terrain(where.x,where.y) = 210; break; +// case 210: univ.town->terrain(where.x,where.y) = 217; break; +// case 211: univ.town->terrain(where.x,where.y) = 2; break; +// case 212: univ.town->terrain(where.x,where.y) = 36; break; + // } + univ.town.set_spot(where.x,where.y,false); univ.town.set_special(where.x,where.y,false); } } @@ -1336,16 +1336,17 @@ void erase_out_specials() univ.out.outdoors[i][j].special_locs[k].x = 100; } - switch (scenario.ter_types[univ.out.outdoors[i][j].terrain[where.x][where.y]].picture) { - case 207: univ.out[48 * i + where.x][48 * j + where.y] = 0; break; - case 208: univ.out[48 * i + where.x][48 * j + where.y] = 170; break; - case 209: univ.out[48 * i + where.x][48 * j + where.y] = 210; break; - case 210: univ.out[48 * i + where.x][48 * j + where.y] = 217; break; - case 211: univ.out[48 * i + where.x][48 * j + where.y] = 2; break; - case 212: univ.out[48 * i + where.x][48 * j + where.y] = 36; break; - } - } +// switch (scenario.ter_types[univ.out.outdoors[i][j].terrain[where.x][where.y]].picture) { +// case 207: univ.out[48 * i + where.x][48 * j + where.y] = 0; break; +// case 208: univ.out[48 * i + where.x][48 * j + where.y] = 170; break; +// case 209: univ.out[48 * i + where.x][48 * j + where.y] = 210; break; +// case 210: univ.out[48 * i + where.x][48 * j + where.y] = 217; break; +// case 211: univ.out[48 * i + where.x][48 * j + where.y] = 2; break; +// case 212: univ.out[48 * i + where.x][48 * j + where.y] = 36; break; +// } } + univ.out.outdoors[i][j].special_spot[where.x][where.y] = false; + } //} @@ -1764,9 +1765,8 @@ pascal void draw_map (DialogPtr the_dialog, short the_item) bool is_door(location destination) { - if ((scenario.ter_types[univ.town->terrain(destination.x,destination.y)].special == 9) || - (scenario.ter_types[univ.town->terrain(destination.x,destination.y)].special == 1) || - (scenario.ter_types[univ.town->terrain(destination.x,destination.y)].special == 10)) + if ((scenario.ter_types[univ.town->terrain(destination.x,destination.y)].special == TER_SPEC_UNLOCKABLE) || + (scenario.ter_types[univ.town->terrain(destination.x,destination.y)].special == TER_SPEC_CHANGE_WHEN_STEP_ON)) return true; return false; } diff --git a/osx/classes.h b/osx/classes.h index 3b18ba05..78a1c6ae 100644 --- a/osx/classes.h +++ b/osx/classes.h @@ -9,6 +9,7 @@ */ #include +#include #include using namespace std; diff --git a/osx/classes/outdoors.cpp b/osx/classes/outdoors.cpp index 174f0d19..3c542c20 100644 --- a/osx/classes/outdoors.cpp +++ b/osx/classes/outdoors.cpp @@ -9,12 +9,18 @@ #include "classes.h" #include "oldstructs.h" +extern cScenario scenario; + __attribute__((deprecated)) cOutdoors& cOutdoors::operator = (legacy::outdoor_record_type& old){ int i,j; for(i = 0; i < 48; i++) - for(j = 0; j < 48; j++) + for(j = 0; j < 48; j++){ terrain[i][j] = old.terrain[i][j]; + if(scenario.ter_types[terrain[i][j]].i == 3000) // marker to indicate it used to be a special spot + special_spot[i][j] = true; + else special_spot[i][j] = false; + } for(i = 0; i < 18; i++){ special_locs[i].x = old.special_locs[i].x; special_locs[i].y = old.special_locs[i].y; diff --git a/osx/classes/outdoors.h b/osx/classes/outdoors.h index 031470a5..86abe883 100644 --- a/osx/classes/outdoors.h +++ b/osx/classes/outdoors.h @@ -54,6 +54,7 @@ public: char spec_strs[90][256]; char sign_strs[8][256]; char(& out_strs(short i))[256]; + bool special_spot[48][48]; cOutdoors(); cOutdoors& operator = (legacy::outdoor_record_type& old); diff --git a/osx/classes/regtown.cpp b/osx/classes/regtown.cpp index 9ae0f39e..b5e10cf4 100644 --- a/osx/classes/regtown.cpp +++ b/osx/classes/regtown.cpp @@ -9,13 +9,22 @@ #include "classes.h" #include "oldstructs.h" +extern cScenario scenario; + __attribute__((deprecated)) void cTinyTown::append(legacy::tiny_tr_type& old){ int i,j; + cField the_field; + the_field.type = 1; for (i = 0; i < 32; i++) for (j = 0; j < 32; j++) { _terrain[i][j] = old.terrain[i][j]; - _lighting[i / 8][j] = old.lighting[i / 8][j]; + _lighting[i / 8][j] = old.lighting[i / 8][j]; + if(scenario.ter_types[_terrain[i][j]].i == 3000) { // marker to indicate it used to be a special spot + the_field.loc.x = i; + the_field.loc.y = j; + preset_fields.push_back(the_field); + } } for (i = 0; i < 16; i++) { _room_rect[i].top = old.room_rect[i].top; @@ -47,10 +56,17 @@ void cTinyTown::append(legacy::tiny_tr_type& old){ __attribute__((deprecated)) void cMedTown::append(legacy::ave_tr_type& old){ int i,j; + cField the_field; + the_field.type = 1; for (i = 0; i < 48; i++) for (j = 0; j < 48; j++) { _terrain[i][j] = old.terrain[i][j]; - _lighting[i / 8][j] = old.lighting[i / 8][j]; + _lighting[i / 8][j] = old.lighting[i / 8][j]; + if(scenario.ter_types[_terrain[i][j]].i == 3000) { // marker to indicate it used to be a special spot + the_field.loc.x = i; + the_field.loc.y = j; + preset_fields.push_back(the_field); + } } for (i = 0; i < 16; i++) { _room_rect[i].top = old.room_rect[i].top; @@ -82,10 +98,17 @@ void cMedTown::append(legacy::ave_tr_type& old){ __attribute__((deprecated)) void cBigTown::append(legacy::big_tr_type& old){ int i,j; + cField the_field; + the_field.type = 1; for (i = 0; i < 64; i++) for (j = 0; j < 64; j++) { _terrain[i][j] = old.terrain[i][j]; - _lighting[i / 8][j] = old.lighting[i / 8][j]; + _lighting[i / 8][j] = old.lighting[i / 8][j]; + if(scenario.ter_types[_terrain[i][j]].i == 3000) { // marker to indicate it used to be a special spot + the_field.loc.x = i; + the_field.loc.y = j; + preset_fields.push_back(the_field); + } } for (i = 0; i < 16; i++) { _room_rect[i].top = old.room_rect[i].top; diff --git a/osx/classes/scenario.cpp b/osx/classes/scenario.cpp index 5335098a..d01a15c6 100644 --- a/osx/classes/scenario.cpp +++ b/osx/classes/scenario.cpp @@ -72,7 +72,10 @@ cScenario& cScenario::operator = (legacy::scenario_data_type& old){ for(i = 0; i < 30; i++) boats[i] = old.scen_boats[i]; for(i = 0; i < 30; i++) horses[i] = old.scen_horses[i]; flag_g = old.flag_g; - for(i = 0; i < 256; i++) ter_types[i] = old.ter_types[i]; + for(i = 0; i < 256; i++){ + ter_types[i].i = i; + ter_types[i] = old.ter_types[i]; + } for(i = 0; i < 20; i++) scenario_timer_times[i] = old.scenario_timer_times[i]; for(i = 0; i < 20; i++) scenario_timer_specs[i] = old.scenario_timer_specs[i]; flag_h = old.flag_h; diff --git a/osx/classes/terrain.cpp b/osx/classes/terrain.cpp index 6a409fb9..ed240414 100644 --- a/osx/classes/terrain.cpp +++ b/osx/classes/terrain.cpp @@ -8,14 +8,221 @@ #include "classes.h" #include "oldstructs.h" +#include "boe.consts.h" // TODO: Put these constants in a global file __attribute__((deprecated)) cTerrain& cTerrain::operator = (legacy::terrain_type_type& old){ + static const short arenas[260] = { + 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, // 0 - grassy field + 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, // 1 - ordinary cave + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 2 - mountain + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 3 - surface bridge + 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, // 4 - cave bridge + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 50 */ // 5 - rubble-strewn cave + 0, 3, 3, 3, 3, 3, 3, 5, 5, 5, // 6 - cave tree forest + 6, 6, 7, 7, 1, 1, 8, 9, 10,11, // 7 - cave mushrooms + 10,11,12,13,13,9, 9, 9, 1, 1, // 8 - cave swamp + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - surface rocks + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 100 */ // 10 - surface swamp + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 11 - surface woods + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 12 - shrubbery + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 13 - stalagmites + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 14 - cave fumarole (proposed) + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 150 */ // 15 - surface fumarole (proposed) + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 101 - cave road (proposed) + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 102 - surface road (proposed) + 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, // 103 - hills road (proposed) + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, // 104 - crops (proposed) + 0, 0, 1, 0, 2, 0, 0, 1, 1, 1,/* 200 */ // (note: fumaroles would have lava.) + 1, 0, 2, 1, 1, 0, 1, 1, 1, 1, // the numbers in this array are indices into the other arrays + 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, // (ter_base, ground_type, and terrain_odds first index) + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 /* 250 */ + }; + static const short ground[274] = { + 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 1, 1, 1, + 1, 1, 1, 0, 0, 1, 1, 1, 10,10, 10,10,10,10,10,10,10,10,10,10, + 11,11,11,11,11,11,11,11,11,11, 12,12,12,12,12,12,12,12,12,12, + 12,0, 0, 13,13,13,13,13,13,13, 13,13,13,13,13,13,13,13,13,13, + 13,13,13,13,13,13,13,13,13,13, 13,13,13,13,13,13,13,14,14,14, + 14,14,14,15,15,15,15,15,15,15, 15,15,15,15,15,15,15,15,0, 0, + 0, 16,0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1, + 1, 1, 0, 1, 4, 1, 1, 0, 13,14, 15,1, 4, 13,13,17,17,0, 17,17, + 17,17,17,17,17,17,0, 1, 18,19, 13,20,0, 13,0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 0, 0, 15,15,15,15, 15,13,13,1, 1, 1, 1, 1, 1, 4, + 6, 6, 6, 6, 7, 6, 0, 21,22,23, 24,0, 13,13 + }; + static const short trims[274] = { + 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,1, 1, + 2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12,13,0, 0, 2, 3, 4, 5, 6, 7, + 8, 9, 10,11,12,13,0, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,0, + 0, 8, 0, 4, 6, 0, 2, 0, 0, 0, 0, 0, 0, 0, 14,0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 18,18,18, 18,18,6, 4, 2, 8, 18,18,0, 0, + 18,18,15,15,15,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,16,0, 16,16, + 16,16,16,16,16,16,0, 0, 0, 0, 0, 0, 18,0, 0, 0, 18,18,18,18, + 2, 4, 6, 8, 18,18,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 14,14,14,14,14,17,18,0, 0, 0, 0, 0, 0, 0, + }; + static const short trim_ters[274] = { + 99,99,99,99,99,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99,99, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 99,99,1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 99,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 99, + 99,1, 99,1, 1, 99,1, 99,99,99, 99,99,99,99,99,99,99,99,99,99, + 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, + 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, + 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, + 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, + 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, + 99,99,99,99,99,99,99,99,99,99, 99,99,4, 4, 4, 4, 99,99,99,99, + 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,0, 1, 99,0, 0, + 0, 0, 1, 1, 1, 1, 99,99,99,99, 99,99,99,99,99,99,99,99,99,99, + 0, 0, 0, 0, 99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, + 99,99,99,99,99,2, 99,99,99,99, 99,99,99,99, + }; picture = old.picture; blockage = old.blockage; flag1 = old.flag1; flag2 = old.flag2; - special = (eTerSpec) old.special; + switch(old.special){ + case 0: + if(i == 7 || i == 10 || i == 13 || i == 16){ + special = TER_SPEC_NONE; + flag1 = 23; + flag2 = flag3 = 0; + }else if(picture == 215){ + special = TER_SPEC_NONE; + flag1 = 3; + flag2 = flag3 = 0; + }else if(picture == 216){ + special = TER_SPEC_NONE; + flag1 = 2; + flag2 = flag3 = 0; + }else if(picture == 143) { + special = TER_SPEC_BED; + flag1 = 230; + flag2 = flag3 = 0; + }else if((picture >= 61 && picture <= 66) || picture == 401 || picture == 402){ + special = TER_SPEC_BRIDGE; + flag1 = flag2 = flag3 = 0; + break; + }else{ + special = TER_SPEC_NONE; + flag1 = 255; + flag2 = flag3 = 0; + } + break; + case 1: + special = TER_SPEC_CHANGE_WHEN_STEP_ON; + flag3 = 0; + break; + case 2: + special = TER_SPEC_DAMAGING; + flag3 = DAMAGE_FIRE; + break; + case 3: + special = TER_SPEC_DAMAGING; + flag3 = DAMAGE_COLD; + break; + case 4: + special = TER_SPEC_DAMAGING; + flag3 = DAMAGE_MAGIC; + break; + case 5: + special = TER_SPEC_DANGEROUS; + flag3 = STATUS_POISON; + break; + case 6: + special = TER_SPEC_DANGEROUS; + flag3 = STATUS_DISEASE; + break; + case 7: + special = TER_SPEC_CRUMBLING; + flag2 = 0; // ???: may change this + flag3 = 1; // destroyed by Move Mountains but not by quickfire; 0 = both, 2 = quickfire only + break; + case 8: + special = TER_SPEC_LOCKABLE; + flag3 = 0; + break; + case 9: + special = TER_SPEC_UNLOCKABLE; + flag3 = false; // can't bash + break; + case 10: + special = TER_SPEC_UNLOCKABLE; + flag3 = true; // can bash + break; + case 11: + special = TER_SPEC_IS_A_SIGN; + flag3 = 0; + break; + case 12: + special = TER_SPEC_CALL_SPECIAL; + flag2 = 0; // local special, always (1 would be local if in town, global if outdoors) + flag3 = 255; + break; + case 13: + special = TER_SPEC_CALL_SPECIAL; + flag2 = 3; // global special, always (2 would be local if outdoors, global if in town) + flag3 = 255; + break; + case 14: + special = TER_SPEC_IS_A_CONTAINER; + flag3 = 0; + break; + case 15: + special = TER_SPEC_WATERFALL; + flag1 = DIR_S; + flag3 = 0; + break; + case 16: + special = TER_SPEC_CONVEYOR; + flag1 = DIR_N; + flag3 = 0; + break; + case 17: + special = TER_SPEC_CONVEYOR; + flag1 = DIR_E; + flag3 = 0; + break; + case 18: + special = TER_SPEC_CONVEYOR; + flag1 = DIR_S; + flag3 = 0; + break; + case 19: + special = TER_SPEC_CONVEYOR; + flag1 = DIR_W; + flag3 = 0; + break; + case 20: + special = TER_SPEC_BLOCKED_TO_MONSTERS; + flag3 = 0; + break; + case 21: + special = TER_SPEC_TOWN_ENTRANCE; + flag3 = 0; + break; + case 22: + special = TER_SPEC_CHANGE_WHEN_USED; + flag2 = 3; + flag3 = 0; + break; + case 23: + special = TER_SPEC_CALL_SPECIAL_WHEN_USED; + flag2 = 0; + flag3 = 255; + break; + } trans_to_what = old.trans_to_what; fly_over = old.fly_over; boat_over = old.boat_over; @@ -23,5 +230,108 @@ cTerrain& cTerrain::operator = (legacy::terrain_type_type& old){ light_radius = old.light_radius; step_sound = old.step_sound; shortcut_key = old.shortcut_key; + if(picture >= 260) combat_arena = 1; + else combat_arena = arenas[picture]; + if(picture < 260){ + ground_type = ground[picture]; + trim_type = (eTrimType) trims[picture]; + trim_ter = trim_ters[picture]; + }else if(picture >= 400 && picture < 1000){ + ground_type = ground[picture - 140]; + trim_type = (eTrimType) trims[picture - 140]; + trim_ter = trim_ters[picture - 140]; + }else{ // TODO: Implement new-style road and walkway handling, and deprecate picture 216. + ground_type = 255; + trim_type = TRIM_NONE; + trim_ter = 0; + } + if(trim_ter == 99) trim_ter = 0; + switch(picture){ + // Rubbles, plus pentagram as a bonus + case 68: + obj_num = 1; + obj_pos.x = 0; + obj_pos.y = 0; + obj_size.x = 2; + obj_size.y = 1; + break; + case 69: + obj_num = 1; + obj_pos.x = 1; + obj_pos.y = 0; + obj_size.x = 2; + obj_size.y = 1; + break; + case 86: + obj_num = 2; + obj_pos.x = 0; + obj_pos.y = 0; + obj_size.x = 2; + obj_size.y = 1; + break; + case 87: + obj_num = 2; + obj_pos.x = 1; + obj_pos.y = 0; + obj_size.x = 2; + obj_size.y = 1; + break; + case 233: + picture = 137; + break; + case 247: + obj_num = 3; + obj_pos.x = 0; + obj_pos.y = 0; + obj_size.x = 2; + obj_size.y = 2; + break; + case 248: + obj_num = 3; + obj_pos.x = 1; + obj_pos.y = 0; + obj_size.x = 2; + obj_size.y = 2; + break; + case 249: + obj_num = 3; + obj_pos.x = 0; + obj_pos.y = 1; + obj_size.x = 2; + obj_size.y = 2; + break; + case 250: + obj_num = 3; + obj_pos.x = 1; + obj_pos.y = 1; + obj_size.x = 2; + obj_size.y = 2; + break; + // Special spaces + case 207: + picture = 0; + i = 3000; + break; + case 208: + picture = 123; + i = 3000; + break; + case 209: + picture = 157; + i = 3000; + break; + case 210: + picture = 163; + i = 3000; + break; + case 211: + picture = 2; + i = 3000; + break; + case 212: + picture = 32; + i = 3000; + break; + }; return *this; } diff --git a/osx/classes/terrain.h b/osx/classes/terrain.h index 163cee75..e645bcac 100644 --- a/osx/classes/terrain.h +++ b/osx/classes/terrain.h @@ -11,30 +11,90 @@ namespace legacy { struct terrain_type_type; }; /* Terrains Specials Properties : scenario.ter_types[i].special */ //complete enum eTerSpec { +// TER_SPEC_NONE = 0, +// TER_SPEC_CHANGE_WHEN_STEP_ON = 1, +// TER_SPEC_DOES_FIRE_DAMAGE = 2, +// TER_SPEC_DOES_COLD_DAMAGE = 3, +// TER_SPEC_DOES_MAGIC_DAMAGE = 4, +// TER_SPEC_POISON_LAND = 5, +// TER_SPEC_DISEASED_LAND = 6, +// TER_SPEC_CRUMBLING_TERRAIN = 7, +// TER_SPEC_LOCKABLE_TERRAIN = 8, +// TER_SPEC_UNLOCKABLE_TERRAIN = 9, +// TER_SPEC_UNLOCKABLE_BASHABLE = 10, +// TER_SPEC_IS_A_SIGN = 11, +// TER_SPEC_CALL_LOCAL_SPECIAL = 12, +// TER_SPEC_CALL_SCENARIO_SPECIAL = 13, +// TER_SPEC_IS_A_CONTAINER = 14, +// TER_SPEC_WATERFALL = 15, +// TER_SPEC_CONVEYOR_NORTH = 16, +// TER_SPEC_CONVEYOR_EAST = 17, +// TER_SPEC_CONVEYOR_SOUTH = 18, +// TER_SPEC_CONVEYOR_WEST = 19, +// TER_SPEC_BLOCKED_TO_MONSTERS = 20, +// TER_SPEC_TOWN_ENTRANCE = 21, +// TER_SPEC_CHANGE_WHEN_USED = 22, +// TER_SPEC_CALL_SPECIAL_WHEN_USED = 23, TER_SPEC_NONE = 0, TER_SPEC_CHANGE_WHEN_STEP_ON = 1, - TER_SPEC_DOES_FIRE_DAMAGE = 2, - TER_SPEC_DOES_COLD_DAMAGE = 3, - TER_SPEC_DOES_MAGIC_DAMAGE = 4, - TER_SPEC_POISON_LAND = 5, - TER_SPEC_DISEASED_LAND = 6, - TER_SPEC_CRUMBLING_TERRAIN = 7, - TER_SPEC_LOCKABLE_TERRAIN = 8, - TER_SPEC_UNLOCKABLE_TERRAIN = 9, - TER_SPEC_UNLOCKABLE_BASHABLE = 10, + TER_SPEC_DAMAGING = 2, + TER_SPEC_BRIDGE = 3, // new + TER_SPEC_BED = 4, // new + TER_SPEC_DANGEROUS = 5, + TER_SPEC_UNUSED1 = 6, + TER_SPEC_CRUMBLING = 7, + TER_SPEC_LOCKABLE = 8, + TER_SPEC_UNLOCKABLE = 9, + TER_SPEC_UNUSED2 = 10, TER_SPEC_IS_A_SIGN = 11, - TER_SPEC_CALL_LOCAL_SPECIAL = 12, - TER_SPEC_CALL_SCENARIO_SPECIAL = 13, + TER_SPEC_CALL_SPECIAL = 12, + TER_SPEC_UNUSED3 = 13, TER_SPEC_IS_A_CONTAINER = 14, TER_SPEC_WATERFALL = 15, - TER_SPEC_CONVEYOR_NORTH = 16, - TER_SPEC_CONVEYOR_EAST = 17, - TER_SPEC_CONVEYOR_SOUTH = 18, - TER_SPEC_CONVEYOR_WEST = 19, + TER_SPEC_CONVEYOR = 16, + TER_SPEC_UNUSED4 = 17, + TER_SPEC_UNUSED5 = 18, + TER_SPEC_UNUSED6 = 19, TER_SPEC_BLOCKED_TO_MONSTERS = 20, TER_SPEC_TOWN_ENTRANCE = 21, TER_SPEC_CHANGE_WHEN_USED = 22, TER_SPEC_CALL_SPECIAL_WHEN_USED = 23, +// 1. Change when step on (What to change to, number of sound, Unused) +// 2. Damaging terrain; can't rest here (Amount of damage done, multiplier, damage type) +// 3. Reserved +// 4. Reserved +// 5. Dangerous land; can't rest here; percentage chance may be 0 (Strength, Percentage chance, status type) +// 6. Reserved +// 7. Crumbling terrain (Terrain to change to, strength?, destroyed by what - quickfire, shatter/move mountains, or both) +// 8. Lockable terrain (Terrain to change to when locked, Unused, Unused) +// 9. Unlockable terrain (Terrain to change to when locked, Difficulty, can be bashed) +// 10. Reserved +// 11. Sign (Unused, Unused, Unused) +// 12. Call special (Special to call, local or scenario?, Unused) +// 13. Reserved +// 14. Container (Unused, Unused, Unused) +// 15. Waterfall (Direction, Unused, Unused) +// 16. Conveyor Belt (Direction, Unused, Unused) +// 17. Reserved +// 18. Reserved +// 19. Reserved +// 20. Blocked to Monsters (Unused, Unused, Unused) +// 21. Town entrance (Terrain type if hidden, Unused, Unused) +// 22. Change when Used (Terrain to change to when used, Number of sound, Unused) +// 23. Call special when used (Special to call, local or scenario?, Unused) +// 24. Bridge - if the party boats over it, they get the option to land. (Unused, Unused, Unused) +}; + +enum eTrimType { + TRIM_NONE = 0, + TRIM_WALL = 1, // not a trim, but trims will conform to it as if it's the same ground type (eg stone wall) + TRIM_S, TRIM_SE, TRIM_E, TRIM_NE, TRIM_N, TRIM_NW, TRIM_W, TRIM_SW, + TRIM_NE_INNER, TRIM_SE_INNER, TRIM_SW_INNER, TRIM_NW_INNER, + TRIM_FRILLS = 14, // like on lava and underground water; no trim_ter required + TRIM_ROAD = 15, // the game will treat it like a road space and draw roads; no trim_ter required + TRIM_WALKWAY = 16, // the game will draw walkway corners; trim_ter is base terrain to draw on + TRIM_WATERFALL = 17, // special case for waterfalls + TRIM_CITY = 18, // the game will join roads up to this space but not draw roads on the space }; class cTerrain { @@ -44,6 +104,7 @@ public: unsigned char blockage; unsigned char flag1; unsigned char flag2; + unsigned char flag3; // new additional flag for special properties eTerSpec special; unsigned char trans_to_what; unsigned char fly_over; @@ -54,10 +115,12 @@ public: unsigned char shortcut_key; // for editor use only unsigned char obj_num; // ditto (formerly res1) unsigned char ground_type; // ditto (formerly res2) - unsigned char trim_type; // ditto, mostly (formerly res3) + eTrimType trim_type; // ditto, mostly (formerly res3) unsigned short trim_ter; // ditto unsigned short combat_arena; location obj_pos; // editor use only + location obj_size; // editor use only + unsigned short i; // for temporary use in porting cTerrain& operator = (legacy::terrain_type_type& old); void writeTo(ostream& file); diff --git a/osx/classes/town.cpp b/osx/classes/town.cpp index 5696a6f1..02fe3eeb 100644 --- a/osx/classes/town.cpp +++ b/osx/classes/town.cpp @@ -29,6 +29,8 @@ cTown& cTown::operator = (legacy::town_record_type& old){ exit_specs[i] = old.exit_specs[i]; wandering[i] = old.wandering[i]; } + preset_fields.clear(); + preset_fields.reserve(50); for(i = 0; i < 50; i++){ special_locs[i].x = old.special_locs[i].x; special_locs[i].y = old.special_locs[i].y; @@ -36,7 +38,9 @@ cTown& cTown::operator = (legacy::town_record_type& old){ // preset_fields[i].loc.x = old.preset_fields[i].field_loc.x; // preset_fields[i].loc.y = old.preset_fields[i].field_loc.y; // preset_fields[i].type = old.preset_fields[i].field_type; - preset_fields[i] = old.preset_fields[i]; + cField temp; + temp = old.preset_fields[i]; + preset_fields.push_back(temp); } for(i = 0; i < 15; i++){ sign_locs[i].x = old.sign_locs[i].x; @@ -119,8 +123,8 @@ cTown::cTown(short size){ for (i = 0; i < 64; i++) preset_items[i] = null_item; max_num_monst = 30000; - for (i = 0; i < 50; i++) - preset_fields[i].type = 0; +// for (i = 0; i < 50; i++) +// preset_fields[i].type = 0; spec_on_entry = -1; spec_on_entry_if_dead = -1; for (i = 0; i < 15; i++) { diff --git a/osx/classes/town.h b/osx/classes/town.h index 1e28e2e5..f77baa76 100644 --- a/osx/classes/town.h +++ b/osx/classes/town.h @@ -68,7 +68,7 @@ public: rectangle in_town_rect; cItem preset_items[64]; short max_num_monst; - cField preset_fields[50]; + vector preset_fields; short spec_on_entry,spec_on_entry_if_dead; short timer_spec_times[8]; short timer_specs[8]; diff --git a/osx/tools/dlgutil.cpp b/osx/tools/dlgutil.cpp index ce9c55ea..26d88fbf 100644 --- a/osx/tools/dlgutil.cpp +++ b/osx/tools/dlgutil.cpp @@ -195,13 +195,13 @@ short cd_create_custom_dialog(WindowPtr parent, Str255 strs[6],short pic_num,sho void oops_error(short error, short code, short mode){ // mode is 0 for scened, 1 for game, 2 for pced Str255 error_str1, error_str2; - static const char* progname[] = {"the scenario editor", "Blades of Exile", "the PC editor"}; - static const char* filetname[] = {"scenario", "game", "game"}; + static const char* progname[3] = {"the scenario editor", "Blades of Exile", "the PC editor"}; + static const char* filetname[3] = {"scenario", "game", "game"}; SysBeep(50); SysBeep(50); SysBeep(50); - sprintf("The program encountered an error while loading/saving/creating the %s. To prevent future problems, the program will now terminate. Trying again may solve the problem.", filetname[mode]); + sprintf((char*)error_str1,"The program encountered an error while loading/saving/creating the %s. To prevent future problems, the program will now terminate. Trying again may solve the problem.", filetname[mode]); sprintf((char *) error_str2,"Giving %s more memory might also help. Be sure to back your %s up often. Error number: %d.",progname[mode],filetname[mode],error); if(code != 0) sprintf((char*) error_str2,"%s Result code: %i.",error_str2,code); diff --git a/osx/tools/fileio.cpp b/osx/tools/fileio.cpp index 1ccb8ea7..f9916f5a 100644 --- a/osx/tools/fileio.cpp +++ b/osx/tools/fileio.cpp @@ -263,8 +263,8 @@ header_posix_ustar generateTarHeader(const std::string& fileName, unsigned long sprintf(header.mode,"%07o",0600); //leave uid filled with NULs //leave gid filled with NULs - sprintf(header.size,"%011o",fileSize); - sprintf(header.mtime,"%011o",time(NULL)); + sprintf(header.size,"%011llo",fileSize); + sprintf(header.mtime,"%011lo",time(NULL)); memset(header.checksum,' ',8); header.typeflag[0]=directory?'5':'0'; //leave linkname filled with NULs @@ -1390,7 +1390,7 @@ bool load_party_v2(FSSpec file_to_load, bool town_restore, bool in_scen, bool ma /* Split the tar archive into its component files */ while(!gzeof(party_file)){ gzread(party_file, &header, sizeof(header)); - sscanf(header.size, "%o", &tar_size); + sscanf(header.size, "%lo", &tar_size); tar_name = header.name; buf = new char[tar_size]; gzread(party_file, buf, tar_size);