Esempio n. 1
0
bool cCurTown::set_crate(short x, short y, bool b){
	if(x > record()->max_dim() || y > record()->max_dim()) return false;
	if(b){ // If certain things are on the space, there's no room for a crate.
		if(is_fire_barr(x,y) || is_force_barr(x,y) || is_quickfire(x,y) || is_barrel(x,y))
			return false;
		fields[x][y]  |=  OBJECT_CRATE;
	}
	else fields[x][y] &= ~OBJECT_CRATE;
	return true;
}
Esempio n. 2
0
Boolean container_there(location l)
{

	if (editing_town == FALSE)
		return FALSE;
	if (scenario.ter_types[t_d.terrain[l.x][l.y]].special == 14)
		return TRUE;
	if (is_barrel(l.x,l.y) == TRUE)
		return TRUE;
	if (is_crate(l.x,l.y) == TRUE)
		return TRUE;
	return 0;
}
Esempio n. 3
0
bool cCurTown::set_force_wall(short x, short y, bool b){
	if(x > record()->max_dim() || y > record()->max_dim()) return false;
	if(b){ // If certain things are on space, there's no room for field.
		if(is_impassable(x,y))
			return false;
		if(is_antimagic(x,y) || is_blade_wall(x,y) || is_quickfire(x,y))
			return false;
		if(is_crate(x,y) || is_barrel(x,y) || is_fire_barr(x,y) || is_force_barr(x,y))
			return false;
		set_web(x,y,false);
		set_fire_wall(x,y,false);
		fields[x][y]  |=  WALL_FORCE;
	}
	else fields[x][y] &= ~WALL_FORCE;
	return true;
}
Esempio n. 4
0
bool cCurTown::set_force_barr(short x, short y, bool b){
	if(x > record()->max_dim() || y > record()->max_dim()) return false;
	if(b){ // If certain things are on the space, there's no room for a barrier.
		if(is_fire_barr(x,y) || is_barrel(x,y) || is_quickfire(x,y) || is_crate(x,y))
			return false;
		if(is_antimagic(x,y) && get_ran(1,0,2) < 2)
			return false;
		// Cancel out fields
		set_web(x,y,false);
		set_force_wall(x,y,false);
		set_fire_wall(x,y,false);
		set_antimagic(x,y,false);
		set_scloud(x,y,false);
		set_ice_wall(x,y,false);
		set_blade_wall(x,y,false);
		set_sleep_cloud(x,y,false);
		fields[x][y]  |=  BARRIER_FORCE;
	}
	else fields[x][y] &= ~BARRIER_FORCE;
	return true;
}
Esempio n. 5
0
void draw_terrain()
{
	short q,r,x,i,small_i;
	location which_pt,where_draw;
	RECT draw_rect,clipping_rect = {8,8,260,332};
	unsigned char t_to_draw;
	RECT tiny_to,tiny_to_base = {29,37,36,44},tiny_from,from_rect,to_rect;
	HBITMAP store_bmp;
	COLORREF gray = RGB(128,128,128);
	COLORREF red = RGB(255,0,0);
	COLORREF white = RGB(255,255,255);

	HBRUSH new_brush;
	HDC hdc;
	HPEN old_pen;

	if (overall_mode >= 60)
		return;

	if (cur_viewing_mode == 0) {
		paint_pattern(ter_draw_gworld,0,terrain_rect,1);
		}
	hdc = CreateCompatibleDC(main_dc);

	SetBkMode(hdc,TRANSPARENT);
	SelectObject(hdc,small_bold_font);
	store_bmp = (HBITMAP)SelectObject(hdc,ter_draw_gworld);


	new_brush = CreateSolidBrush(gray);
	FrameRect(hdc,&terrain_rect,new_brush);
	DeleteObject(new_brush);
	old_pen = (HPEN)SelectObject(hdc,GetStockObject(NULL_PEN));
	SelectObject(hdc,store_bmp);

	if (cur_viewing_mode == 0) {
	for (q = 0; q < 9; q++)
		for (r = 0; r < 9; r++)
			{
			where_draw.x = q; where_draw.y = r;
			if (editing_town == TRUE) {
				t_to_draw = t_d.terrain[cen_x + q - 4][cen_y + r - 4];
				}
				else {
					if (cen_x + q - 4 == -1)
						t_to_draw = borders[3][cen_y + r - 4];
					else if (cen_x + q - 4 == 48)
						t_to_draw = borders[1][cen_y + r - 4];
					else if (cen_y + r - 4 == -1)
						t_to_draw = borders[0][cen_x + q - 4];
					else if (cen_y + r - 4 == 48)
						t_to_draw = borders[2][cen_x + q - 4];
					else t_to_draw = current_terrain.terrain[cen_x + q - 4][cen_y + r - 4];
					}
			draw_one_terrain_spot(q,r,t_to_draw);
			which_pt.x = cen_x + q - 4;
			which_pt.y =cen_y + r - 4;

			tiny_to = tiny_to_base;
			OffsetRect(&tiny_to,28 * q, 36 * r);

			// draw start icon, if starting point
			if ((editing_town == TRUE) &&
				(cur_town == scenario.which_town_start) && (scenario.where_start.x == cen_x + q - 4)
				&& (scenario.where_start.y == cen_y + r - 4)) {
				from_rect = start_button_from;
				to_rect = tiny_to;
				to_rect.left -= 14;
				rect_draw_some_item(editor_mixed,from_rect,ter_draw_gworld,to_rect,0,0);
				OffsetRect(&tiny_to,0,-7);
				}
			if ((editing_town == FALSE)
				&& (scenario.out_sec_start.x == cur_out.x)
				&& (scenario.out_sec_start.y == cur_out.y)
				&& (scenario.out_start.x == cen_x + q - 4)
				&& (scenario.out_start.y == cen_y + r - 4)) {
				from_rect = start_button_from;
				to_rect = tiny_to;
				to_rect.left -= 14;
				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;
			tiny_from = base_small_button_from;
			OffsetRect(&tiny_from,7 * (small_i % 10),7 * (small_i / 10));
			if (small_i > 0) {
				rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
				OffsetRect(&tiny_to,0,-7);
				}

				if (is_special(cen_x + q - 4,cen_y + r - 4) == TRUE) {
					tiny_from = base_small_button_from;
					OffsetRect(&tiny_from,7 * (7),7 * (0));
					rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
					OffsetRect(&tiny_to,0,-7);
					}
				if ((t_to_draw == 7) || (t_to_draw == 10) || (t_to_draw == 13) || (t_to_draw == 16)) {
					tiny_from = base_small_button_from;
					OffsetRect(&tiny_from,7 * (3),7 * (2));
					rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
					OffsetRect(&tiny_to,0,-7);
					}
				if (editing_town == FALSE) {
					for (i = 0; i < 4; i++)
						if ((cen_x + q - 4 == current_terrain.wandering_locs[i].x) &&
							(cen_y + r - 4 == current_terrain.wandering_locs[i].y)) {
							tiny_from = base_small_button_from;
							OffsetRect(&tiny_from,7 * (2),7 * (1));
							rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
							OffsetRect(&tiny_to,0,-7);
							i = 4;
							}

					}

				if (editing_town == TRUE) {
					for (i = 0; i < 4; i++)
						if ((cen_x + q - 4 == town.start_locs[i].x) &&
							(cen_y + r - 4 == town.start_locs[i].y)) {
							tiny_from = base_small_button_from;
							OffsetRect(&tiny_from,7 * (6 + i),7 * (1));
							rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
							OffsetRect(&tiny_to,0,-7);
							}
					for (i = 0; i < 4; i++)
						if ((cen_x + q - 4 == town.wandering_locs[i].x) &&
							(cen_y + r - 4 == town.wandering_locs[i].y)) {
							tiny_from = base_small_button_from;
							OffsetRect(&tiny_from,7 * (2),7 * (1));
							rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
							OffsetRect(&tiny_to,0,-7);
							i = 4;
							}
					if (is_web(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(5,0);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_crate(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(6,0);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_barrel(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(7,0);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_fire_barrier(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(0,2);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_quickfire(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(7,1);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_force_barrier(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(2,2);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					for (i = 0; i < 8; i++)
						if (is_sfx(cen_x + q - 4,cen_y + r - 4,i)) {
							from_rect = calc_rect(i,3);
							Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
							}
					for (x = 0; x < 64; x++)
						if ((cen_x + q - 4 == town.preset_items[x].item_loc.x) &&
						 (cen_y + r - 4 == town.preset_items[x].item_loc.y) && (town.preset_items[x].item_code >= 0)) {
						 }
					for (x = 0; x < 60; x++)
						if ((cen_x + q - 4 == t_d.creatures[x].start_loc.x) &&
						 (cen_y + r - 4 == t_d.creatures[x].start_loc.y) && (t_d.creatures[x].number != 0)) {
						 }

					 }
				}
	if (editing_town == TRUE) {
		draw_monsts(hdc);
		draw_items(hdc);
		}

	store_bmp = (HBITMAP)SelectObject(hdc,ter_draw_gworld);
	ClipRect(hdc,&clipping_rect);

	if (editing_town == TRUE) {
		// draw info rects
		for (i = 0; i < 16; i++)
			if (t_d.room_rect[i].left > -1) {
				draw_rect.left = 22 + 28 * (t_d.room_rect[i].left - cen_x + 4);
				draw_rect.right = 22 + 28 * (t_d.room_rect[i].right - cen_x + 4);
				draw_rect.top = 24 + 36 * (t_d.room_rect[i].top - cen_y + 4);
				draw_rect.bottom = 24 + 36 * (t_d.room_rect[i].bottom - cen_y + 4);

				//c = GetNearestPaletteIndex(hpal,red);
				new_brush = CreateSolidBrush(red);
				FrameRect(hdc,&draw_rect,new_brush);
				DeleteObject(new_brush);
				}
		// draw border rect
			draw_rect.left = 21 + 28 * (town.in_town_rect.left - cen_x + 4);
			draw_rect.right = 21 + 28 * (town.in_town_rect.right - cen_x + 4);
			draw_rect.top = 25 + 36 * (town.in_town_rect.top - cen_y + 4);
			draw_rect.bottom = 25 + 36 * (town.in_town_rect.bottom - cen_y + 4);

//			c = GetNearestPaletteIndex(hpal,white);
			new_brush = CreateSolidBrush(white);
			FrameRect(hdc,&draw_rect,new_brush);
			DeleteObject(new_brush);
		}
	if (editing_town == FALSE) {
		// draw info rects
		for (i = 0; i < 8; i++)
			if (current_terrain.info_rect[i].left > -1) {
				draw_rect.left = 22 + 28 * (current_terrain.info_rect[i].left - cen_x + 4);
				draw_rect.right = 22 + 28 * (current_terrain.info_rect[i].right - cen_x + 4);
				draw_rect.top = 24 + 36 * (current_terrain.info_rect[i].top - cen_y + 4);
				draw_rect.bottom = 24 + 36 * (current_terrain.info_rect[i].bottom - cen_y + 4);
				//c = GetNearestPaletteIndex(hpal,red);
				new_brush = CreateSolidBrush(red);

				FrameRect(hdc,&draw_rect,new_brush);
				DeleteObject(new_brush);
				}
		}
	undo_clip(hdc);
	SelectObject(hdc,store_bmp);

	small_any_drawn = FALSE;
	}

	if (cur_viewing_mode == 1) {
		if (small_any_drawn == FALSE) {
			InsetRect(&terrain_rect,1,1);
			paint_pattern(ter_draw_gworld,0,terrain_rect,1);
			InsetRect(&terrain_rect,-1,-1);
			//FrameRect(&terrain_rect);
			}
		for (q = 0; q < ((editing_town == TRUE) ? max_dim[town_type] : 48); q++)
			for (r = 0; r < ((editing_town == TRUE) ? max_dim[town_type] : 48); r++) {
				t_to_draw = (editing_town == TRUE) ? t_d.terrain[q][r] :
					current_terrain.terrain[q][r];
				if ((small_what_drawn[q][r] != t_to_draw) || (small_any_drawn == FALSE)) {
					draw_one_tiny_terrain_spot(q,r,t_to_draw,hdc);
					small_what_drawn[q][r] = t_to_draw;
					}
			}
		small_any_drawn = TRUE;
		}

	SelectObject(hdc,old_pen);
	DeleteObject(hdc);
	//draw_cur_string();
	place_location();

	rect_draw_some_item(ter_draw_gworld,terrain_rect,ter_draw_gworld,world_screen,0,1);
}