Пример #1
0
  void Board::notify(const Piece::Position& position)
  {
    auto& b = *this;
    auto& notifier = b[position];

    for (const auto& d : {Piece::Alignment::horizontal, Piece::Alignment::vertical, Piece::Alignment::counter_diagonal, Piece::Alignment::leading_diagonal})
      notifier.notify(b, d, 0, notifier);
    for (int it(1); it <= 4; ++it) {
      auto r = Piece::Alignment::horizontal * it + position;
      if (!is_out(r) && b[r].notify(b, Piece::Alignment::horizontal, it, notifier)) notify(r);
      r = Piece::Alignment::horizontal * -it + position;
      if (!is_out(r) && b[r].notify(b, Piece::Alignment::horizontal, -it, notifier)) notify(r);
      r = Piece::Alignment::vertical * it + position;
      if (!is_out(r) && b[r].notify(b, Piece::Alignment::vertical, it, notifier)) notify(r);
      r = Piece::Alignment::vertical * -it + position;
      if (!is_out(r) && b[r].notify(b, Piece::Alignment::vertical, -it, notifier)) notify(r);
      r = Piece::Alignment::leading_diagonal * it + position;
      if (!is_out(r) && b[r].notify(b, Piece::Alignment::leading_diagonal, it, notifier)) notify(r);
      r = Piece::Alignment::leading_diagonal * -it + position;
      if (!is_out(r) && b[r].notify(b, Piece::Alignment::leading_diagonal, -it, notifier)) notify(r);
      r = Piece::Alignment::counter_diagonal * it + position;
      if (!is_out(r) && b[r].notify(b, Piece::Alignment::counter_diagonal, it, notifier)) notify(r);
      r = Piece::Alignment::counter_diagonal * -it + position;
      if (!is_out(r) && b[r].notify(b, Piece::Alignment::counter_diagonal, -it, notifier)) notify(r);
    }
  }
Пример #2
0
bool is_out() {
	if((overall_mode == MODE_OUTDOORS) || (overall_mode == MODE_LOOK_OUTDOORS))
		return true;
	else if(overall_mode == MODE_SHOPPING) {
		std::swap(overall_mode, store_pre_shop_mode);
		bool ret = is_out();
		std::swap(overall_mode, store_pre_shop_mode);
		return ret;
	} else if(overall_mode == MODE_TALKING) {
		std::swap(overall_mode, store_pre_talk_mode);
		bool ret = is_out();
		std::swap(overall_mode, store_pre_talk_mode);
		return ret;
	} else return false;
}
Пример #3
0
// Returns 6 if can't see, O.W. returns the # of a PC that can see
short party_can_see(location where) {
	short i;
	
	if(is_out()) {
		if((point_onscreen(univ.party.p_loc,where)) && (can_see_light(univ.party.p_loc,where,sight_obscurity) < 5))
			return 1;
		else return 6;
	}
	if(fog_lifted)
		return point_onscreen(univ.town.p_loc,where) ? 1 : 6;
	if(is_town()) {
		if( ((point_onscreen(univ.town.p_loc,where)) || (overall_mode == MODE_LOOK_TOWN)) && (pt_in_light(univ.town.p_loc,where) )
			&& (can_see_light(univ.town.p_loc,where,sight_obscurity) < 5))
			return 1;
		else return 6;
	}
	
	// Now for combat checks. Doing separately for efficiency. Check first for light. If
	//   dark, give up.
	if((which_combat_type != 0) && !combat_pt_in_light(where))
		return 6;
	
	for(i = 0; i < 6; i++)
		if(univ.party[i].main_status == eMainStatus::ALIVE) {
			if(can_see_light(univ.party[i].combat_pos,where,sight_obscurity) < 5)
				return i;
		}
	
	return 6;
}
Пример #4
0
void do_sign(short town_num, short which_sign, short sign_type)
//town_num; // Will be 0 - 200 for town, 200 - 290 for outdoors
//short sign_type; // terrain type
{
	char sign_text[256];
	location view_loc;

	view_loc = (is_out()) ? party.p_loc : c_town.p_loc;
	SetCursor(sword_curs);

	cd_create_dialog(1014,mainPtr);

	store_sign_mode = sign_type;
	if (terrain_pic[sign_type] < 1000)
		csp(1014,3,terrain_pic[sign_type]);
		else csp(1014,3,94);

	if (town_num >= 200) {
		town_num -= 200;
		load_outdoors(town_num % scenario.out_width, town_num / scenario.out_width,party.i_w_c.x,party.i_w_c.y,
			1,which_sign + 100,(char *) sign_text);
		}
		else {
			sprintf((char *) sign_text,"%s",data_store->town_strs[120 + which_sign]);
			}
	csit(1014,2,(char *) sign_text);

	while (dialog_not_toast)
		ModalDialog();
	cd_kill_dialog(1014,0);
}
Пример #5
0
void draw_fields(location where){
	if(!point_onscreen(center,where)) return;
	if(party_can_see(where) >= 6) return;
	location where_draw(4 + where.x - center.x, 4 + where.y - center.y);
	sf::Texture& fields_gworld = *ResMgr::get<ImageRsrc>("fields");
	if(is_out()){
		if(univ.out.is_spot(where.x,where.y))
			Draw_Some_Item(fields_gworld,calc_rect(4,0),terrain_screen_gworld,where_draw,1,0);
		return;
	}
	if(univ.town.is_force_wall(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(0,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_fire_wall(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(1,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_antimagic(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(2,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_scloud(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(3,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_ice_wall(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(4,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_blade_wall(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(5,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_sleep_cloud(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(6,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_block(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(3,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_spot(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(4,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_web(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(5,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_crate(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(6,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_barrel(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(7,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_fire_barr(where.x,where.y) || univ.town.is_force_barr(where.x,where.y))
		Draw_Some_Item(*ResMgr::get<ImageRsrc>("teranim"),calc_rect(8+(anim_ticks%4),4),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_quickfire(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(7,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_sm_blood(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(0,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_med_blood(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(1,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_lg_blood(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(2,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_sm_slime(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(3,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_lg_slime(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(4,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_ash(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(5,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_bones(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(6,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_rubble(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(7,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_force_cage(where.x,where.y)) {
		Draw_Some_Item(fields_gworld,calc_rect(1,0),terrain_screen_gworld,where_draw,1,0);
		forcecage_locs.push_back(where_draw);
	}
}
Пример #6
0
  Piece& Board::operator[](const Piece::Position& pair)
  {
    static Piece tampon(Piece::identity::out);

    if (is_out(pair))
      return tampon;
    return m_board.at(static_cast< unsigned >(pair.y)).at(static_cast< unsigned >(pair.x));
  }
Пример #7
0
// All purpose function to check is spot is free for travel into.
bool is_blocked(location to_check) {
	short i,gr;
	ter_num_t ter;
	
	if(is_out()) {
		if(impassable(univ.out[to_check.x][to_check.y])) {
			return true;
		}
		if(to_check == univ.party.p_loc)
			return true;
		for(i = 0; i < univ.party.out_c.size(); i++)
			if((univ.party.out_c[i].exists))
				if(univ.party.out_c[i].m_loc == to_check)
					return true;
		return false;
	}
	
	if((is_town()) || (is_combat())) {
		ter = univ.town->terrain(to_check.x,to_check.y);
		gr = univ.scenario.ter_types[ter].picture;
		
		// Terrain blocking?
		if(impassable(ter)) {
			return true;
		}
		
		// Keep away from marked specials during combat
		if((is_combat()) && univ.town.is_spot(to_check.x, to_check.y))
			return true;
		if((is_combat()) && (univ.scenario.ter_types[coord_to_ter(to_check.x,to_check.y)].trim_type == eTrimType::CITY))
			return true; // TODO: Maybe replace eTrimType::CITY with a blockage == clear/special && is_special() check
		// Note: The purpose of the above check is to avoid portals.
		
		// Party there?
		if(is_town())
			if(to_check == univ.town.p_loc)
				return true;
		if(is_combat())
			for(i = 0; i < 6; i++)
				if(univ.party[i].main_status == eMainStatus::ALIVE && to_check == univ.party[i].combat_pos)
					return true;
		
		// Monster there?
		if(univ.target_there(to_check, TARG_MONST))
			return true;
		
		// Magic barrier?
		if(univ.town.is_force_barr(to_check.x,to_check.y))
			return true;
		
		if(univ.town.is_force_cage(to_check.x,to_check.y))
			return true;
		
		return false;
	}
	return true;
}
Пример #8
0
//short dest; // 0 - terrain gworld   1 - screen
// if terrain_to_draw is -1, do black
// if terrain_to_draw >= 10000, force to draw graphic which is terrain_to_draw - 10000
void draw_one_terrain_spot (short i,short j,short terrain_to_draw) {
	rectangle where_draw;
	rectangle source_rect;
	sf::Texture* source_gworld;
	short anim_type = 0;
	location l;
	
	l.x = i; l.y = j;
	if(supressing_some_spaces && (l != ok_space[0]) && (l != ok_space[1]) && (l != ok_space[2]) && (l != ok_space[3]))
		return;
	
	where_draw = calc_rect(i,j);
 	where_draw.offset(13,13);
 	if(terrain_to_draw == -1) {
		fill_rect(terrain_screen_gworld, where_draw, sf::Color::Black);
		return;
	}
 	
	if(terrain_to_draw >= 10000) { // force using a specific graphic
		terrain_to_draw -= 10000;
		int which_sheet = terrain_to_draw / 50;
		source_gworld = ResMgr::get<ImageRsrc>("ter" + std::to_string(1 + which_sheet)).get();
		terrain_to_draw %= 50;
		source_rect = calc_rect(terrain_to_draw % 10, terrain_to_draw / 10);
		anim_type = -1;
	}
	else if(univ.scenario.ter_types[terrain_to_draw].picture >= 2000) { // custom
		graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(univ.scenario.ter_types[terrain_to_draw].picture - 2000 + (anim_ticks % 4));
		anim_type = 0;
	}
	else if(univ.scenario.ter_types[terrain_to_draw].picture >= 1000) { // custom
		graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(univ.scenario.ter_types[terrain_to_draw].picture - 1000);
	}
	else if(univ.scenario.ter_types[terrain_to_draw].picture >= 960) { // animated
		source_gworld = ResMgr::get<ImageRsrc>("teranim").get();
		terrain_to_draw = univ.scenario.ter_types[terrain_to_draw].picture;
		source_rect = calc_rect(4 * ((terrain_to_draw - 960) / 5) + (anim_ticks % 4),(terrain_to_draw - 960) % 5);
		anim_type = 0;
	}
	else {
		terrain_to_draw = univ.scenario.ter_types[terrain_to_draw].picture;
		int which_sheet = terrain_to_draw / 50;
		source_gworld = ResMgr::get<ImageRsrc>("ter" + std::to_string(1 + which_sheet)).get();
		terrain_to_draw %= 50;
		source_rect = calc_rect(terrain_to_draw % 10, terrain_to_draw / 10);
		anim_type = -1;
	}
	
	if(anim_type >= 0) {
		if((is_town()) || (is_out()))
			anim_onscreen = true;
	}
	
	rect_draw_some_item(*source_gworld, source_rect, terrain_screen_gworld, where_draw);
}
Пример #9
0
void apply_unseen_mask()
{
	Rect base_rect = {9,9,53,45},to_rect,big_to = {13,13,337,265};
	GrafPtr old_port;
	short i,j,k,l;
	ConstPatternParam c;
	bool need_bother = false;
	
	if (PSD[SDF_NO_FRILLS] > 0)
		return;

	if ((is_combat()) && (which_combat_type == 0))
		return;
	if (!(is_out()) && (univ.town->lighting_type > 0))
		return;
		
	for (i = 0; i < 11; i++)
		for (j = 0; j < 11; j++) 
			if (unexplored_area[i + 1][j + 1] == 1)
				need_bother = true;
	if (need_bother == false)
		return;
				
	GetPort(&old_port);
	SetPort(terrain_screen_gworld);
	//p = *bw_pats[3];
	//c = p;
	c = *bw_pats[3];
	PenPat(c);
	PenMode(notPatOr);
	
	for (i = 0; i < 11; i++)
		for (j = 0; j < 11; j++) 
			if (unexplored_area[i + 1][j + 1] == 1) {

					to_rect = base_rect;
					OffsetRect(&to_rect,-28 + i * 28,-36 + 36 * j);
					SectRect(&to_rect,&big_to,&to_rect);
					PaintRect(&to_rect);
					//PaintRoundRect(&to_rect,4,4);
					for (k = i - 2; k < i + 1; k++)
						for (l = j - 2; l < j + 1; l++)
							if ((k >= 0) && (l >= 0) && (k < 9) && (l < 9) && ((k != i - 1) || (l != j - 1)))
								terrain_there[k][l] = -1;

				}
	
	//p = *bw_pats[6];
	//c = p;
	c = *bw_pats[6];
	PenPat(c);
	PenMode(patCopy);
	SetPort(old_port);
}
Пример #10
0
short light_radius() {
	short store = 1,i;
	short extra_levels[6] = {10,20,50,75,110,140};
	
	if(((which_combat_type == 0) && (is_combat()))
		|| (is_out()) || (univ.town->lighting_type == 0))
		return 200;
	for(i = 0; i < 6; i++)
		if(univ.party.light_level > extra_levels[i])
			store++;
	return store;
}
Пример #11
0
bool rand_move(char i)
{
	bool acted_yet = false;
	short j;
	location store_loc;
	
	// first, if outdoor, just roam. 
	if (is_out()) {
		store_loc = random_shift(univ.party.out_c[i].m_loc);
		return outdoor_move_monster(i,store_loc);
		}
		
	if (univ.town.monst[i].targ_loc == univ.town.monst[i].cur_loc)
		univ.town.monst[i].targ_loc.x = 0;
			
	// FIrst, try to move to monst_targs. If it don't work, then we'll shift.
	if (univ.town.monst[i].targ_loc.x > 0)
		acted_yet = seek_party(i,univ.town.monst[i].cur_loc,univ.town.monst[i].targ_loc);

	if (acted_yet == false) {
		univ.town.monst[i].targ_loc.x = 0;
		for (j = 0; j < 3; j++) {
			store_loc = univ.town.monst[i].cur_loc;
			store_loc.x += get_ran(1,0,24) - 12;
			store_loc.y += get_ran(1,0,24) - 12;
			if ((loc_off_act_area(store_loc) == false) && (can_see(univ.town.monst[i].cur_loc,store_loc,0) < 5)) {
				univ.town.monst[i].targ_loc = store_loc; j = 3;
				}
			}

		if (univ.town.monst[i].targ_loc.x == 0) {
			// maybe pick a wand loc, else juist pick a loc
			j = get_ran(1,0,3);
			store_loc = univ.town->wandering_locs[j];
			
			if ((loc_off_act_area(store_loc) == false) && (get_ran(1,0,1) == 1))
				univ.town.monst[i].targ_loc = store_loc;
				else {
				store_loc = univ.town.monst[i].cur_loc;
				store_loc.x += get_ran(1,0,20) - 10;
				store_loc.y += get_ran(1,0,20) - 10;
				if (loc_off_act_area(store_loc) == false)
					univ.town.monst[i].targ_loc = store_loc;
				}
			}
		if (univ.town.monst[i].targ_loc.x > 0)
			acted_yet = seek_party(i,univ.town.monst[i].cur_loc,univ.town.monst[i].targ_loc);
		}

	return acted_yet;
}
Пример #12
0
void alter_space(short i,short j,ter_num_t ter) {
	if(is_out()) {
		location l(i,j);
		l = local_to_global(l);
		univ.out[l.x][l.y] = ter;
		univ.out->terrain[i][j] = ter;
	} else {
		ter_num_t former = univ.town->terrain(i,j);
		univ.town->terrain(i,j) = ter;
		if(univ.scenario.ter_types[ter].special == eTerSpec::CONVEYOR)
			univ.town.belt_present = true;
		if(univ.scenario.ter_types[former].light_radius != univ.scenario.ter_types[ter].light_radius)
			univ.town->set_up_lights();
	}
}
Пример #13
0
void CartesianProductDb::write_map_to_freq_file(const std::vector<int>& cv, const char *f_name) const
{
  std::vector<std::pair<int,int> > vp_map(cv.size());
  for (std::vector<int>::size_type i=0; i<cv.size(); ++i)
  {
    vp_map[i] = std::make_pair(cv[i], i);
  }
  std::sort(vp_map.begin(), vp_map.end());

  std::fstream is_out(f_name, std::ios::out | std::ios::binary);
  
  for (std::vector<std::pair<int,int> >::reverse_iterator vpIt=vp_map.rbegin(); vpIt!=vp_map.rend(); ++vpIt)
  {
    is_out << vpIt->second << "\t" << vpIt->first << "\n";
  }

  is_out.close();
}
Пример #14
0
int main(){
    if (init("MUAMUAMUAMAMAMA")){
        printf("Error al Iniciar");
        return 1;
    }
    
    
    int x = 100, y = 100;

    if(load_files())
        return 1;
    
    
    while(quit){
        
        Uint8 *keystates = SDL_GetKeyState( NULL );
        if( keystates[ SDLK_ESCAPE ] )
            break;
            
        /*while( SDL_PollEvent( &event ) ){
           printf("lol"); 
            if( event.type == SDL_QUIT ){
                
                quit = false;
            }
        }*/
        
        move(&x, &y);
        
        is_out(&x, &y);
        apply_surface( 0, 0, background, screen );
        apply_surface( x, y, actor, screen );
        SDL_Flip( screen );
    }
    clean_up();   
    return 0;
}
Пример #15
0
void apply_light_mask() 
{
	GrafPtr old_port;
	Rect temp = {0,0,108,84},paint_rect,base_rect = {0,0,36,28};
	Rect big_to = {13,13,337,265};
	short i,j;
	bool is_dark = false,same_mask = true;
	if (PSD[SDF_NO_FRILLS] > 0)
		return;
	if (is_out())
		return;
	if (univ.town->lighting_type == 0)
		return;
	
	if (oval_region == NULL) {
		temp_rect_rgn = NewRgn();
		dark_mask_region = NewRgn();
		oval_region = NewRgn();
		OpenRgn();
		FrameOval(&temp);
		CloseRgn(oval_region);
		}
	
	// Process the light array
	for (i = 2; i < 11; i++)
		for (j = 2; j < 11; j++) 
			if (light_area[i][j] == 0) is_dark = true;
	if (is_dark == false) { 
		for (i = 2; i < 11; i++)
			for (j = 2; j < 11; j++) 
				last_light_mask[i][j] = 0;
		return;
		}
	for (i = 1; i < 12; i++)
		for (j = 1; j < 12; j++)
			if ((light_area[i - 1][j - 1] >= 1) && (light_area[i + 1][j - 1] >= 1) && 
				(light_area[i - 1][j] >= 1) && (light_area[i + 1][j] >= 1) && 
				(light_area[i - 1][j + 1] >= 1) && (light_area[i + 1][j + 1] >= 1) && 
				(light_area[i][j - 1] >= 1) && (light_area[i][j + 1] >= 1)) {
					light_area[i][j] = 2;
					}
	for (i = 1; i < 12; i++)
		for (j = 1; j < 12; j++)
			if ((light_area[i - 1][j - 1] >= 2) && (light_area[i + 1][j - 1] >= 2) && 
				(light_area[i - 1][j] >= 2) && (light_area[i + 1][j] >= 2) && 
				(light_area[i - 1][j + 1] >= 2) && (light_area[i + 1][j + 1] >= 2) && 
				(light_area[i][j - 1] >= 2) && (light_area[i][j + 1] >= 2)) {
					light_area[i][j] = 3;
					}
		
	GetPort(&old_port);
	SetPort(terrain_screen_gworld);

	for (i = 2; i < 11; i++)
		for (j = 2; j < 11; j++) {
			if (light_area[i][j] == 1)
				terrain_there[i - 2][j - 2] = -1;
			}
	for (i = 0; i < 13; i++)
		for (j = 0; j < 13; j++) 
			if (last_light_mask[i][j] != light_area[i][j])
				same_mask = false;
	
	if (same_mask == true) {
		PaintRgn(dark_mask_region);
		SetPort(old_port);
		return;
		}
	SetRectRgn(dark_mask_region,big_to.left,big_to.top,big_to.right,big_to.bottom);
	for (i = 0; i < 13; i++)
		for (j = 0; j < 13; j++) 
			last_light_mask[i][j] = light_area[i][j];
	for (i = 1; i < 12; i++)
		for (j = 1; j < 12; j++) {
			if (light_area[i][j] == 2) {
				
				OffsetRgn(oval_region,13 + 28 * (i - 3), 13 + 36 * (j - 3));
				
				DiffRgn(dark_mask_region,oval_region,dark_mask_region);
				
				OffsetRgn(oval_region,-13 + -1 * (28 * (i - 3)),-13 + -1 * (36 * (j - 3)));
				//PaintRect(&paint_rect);
				}
			if (light_area[i][j] == 3) {
				paint_rect = base_rect;
				OffsetRect(&paint_rect,13 + 28 * (i - 2),13 + 36 * (j - 2));
				SetRectRgn(temp_rect_rgn,paint_rect.left,paint_rect.top,
					paint_rect.right + 28,paint_rect.bottom + 36);
				DiffRgn(dark_mask_region,temp_rect_rgn,dark_mask_region);
				if (light_area[i + 1][j] == 3) light_area[i + 1][j] = 0;
				if (light_area[i + 1][j + 1] == 3) light_area[i + 1][j + 1] = 0;
				if (light_area[i][j + 1] == 3) light_area[i][j + 1] = 0;
				}
			}

	//rect_draw_some_item(light_mask_gworld,big_from,terrain_screen_gworld,big_to,0,0);
	PaintRgn(dark_mask_region);
	SetPort(old_port);

}
Пример #16
0
void make_explored(short i,short j) {
	if(is_out())
		univ.out.out_e[i][j] = 1;
	else univ.town.set_explored(i,j,true);
}
Пример #17
0
void take_explored(short i,short j) {
	if(is_out())
		univ.out.out_e[i][j] = 0;
	else univ.town.set_explored(i,j,false);
}
Пример #18
0
 Register after_save() const {
   assert(is_out() || is_global(), "register not visible after save");
   return is_out() ? as_Register(encoding() + (ibase - obase)) : (const Register)this;
 }
Пример #19
0
bool is_explored(short i,short j) {
	if(is_out())
		return (univ.out.out_e[i][j] != 0) ? true : false;
	else return univ.town.is_explored(i,j);
}
Пример #20
0
void draw_monsters() {
	short i,j = 0,k;
	short width,height;
	rectangle source_rect,to_rect;
	location where_draw,store_loc;
	ter_num_t ter;
	rectangle monst_rects[4][4] = {
		{{0,0,36,28}},
		{{0,7,18,21},{18,7,36,21}},
		{{9,0,27,14},{9,14,27,28}},
		{{0,0,18,14},{0,14,18,28},{18,0,36,14},{18,14,36,28}}
	};
	
	if(is_out())
		for(i = 0; i < 10; i++)
			if(univ.party.out_c[i].exists) {
				if((point_onscreen(univ.party.p_loc, univ.party.out_c[i].m_loc)) &&
					(can_see_light(univ.party.p_loc, univ.party.out_c[i].m_loc,sight_obscurity) < 5)) {
					where_draw.x = univ.party.out_c[i].m_loc.x - univ.party.p_loc.x + 4;
					where_draw.y = univ.party.out_c[i].m_loc.y - univ.party.p_loc.y + 4;
					
					for(j = 0; univ.party.out_c[i].what_monst.monst[j] == 0 && j < 7; j++);
					
					short picture_wanted;
					if(j == 7) univ.party.out_c[i].exists = false; // begin watch out
					else {
						picture_wanted = get_monst_picnum(univ.party.out_c[i].what_monst.monst[j]);
					} // end watch out
					
					if(univ.party.out_c[i].exists) {
						get_monst_dims(univ.party.out_c[i].what_monst.monst[j],&width,&height);
						if(picture_wanted >= 1000) {
							for(k = 0; k < width * height; k++) {
								sf::Texture* src_gw;
								graf_pos_ref(src_gw, source_rect) = spec_scen_g.find_graphic(picture_wanted % 1000 +
																							 ((univ.party.out_c[i].direction < 4) ? 0 : (width * height)) + k);
								to_rect = monst_rects[(width - 1) * 2 + height - 1][k];
								to_rect.offset(13 + 28 * where_draw.x,13 + 36 * where_draw.y);
								rect_draw_some_item(*src_gw, source_rect, terrain_screen_gworld,to_rect, sf::BlendAlpha);
							}
						}
						if(picture_wanted < 1000) {
							for(k = 0; k < width * height; k++) {
								source_rect = get_monster_template_rect(picture_wanted,(univ.party.out_c[i].direction < 4) ? 0 : 1,k);
								to_rect = monst_rects[(width - 1) * 2 + height - 1][k];
								to_rect.offset(13 + 28 * where_draw.x,13 + 36 * where_draw.y);
								int which_sheet = m_pic_index[picture_wanted].i / 20;
								sf::Texture& monst_gworld = *ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet));
								rect_draw_some_item(monst_gworld, source_rect, terrain_screen_gworld,to_rect, sf::BlendAlpha);
							}
						}
					}
				}
			}
	if(is_town() || is_combat()) {
		for(i = 0; i < univ.town.monst.size(); i++)
			if(univ.town.monst[i].active != 0 && !univ.town.monst[i].invisible && univ.town.monst[i].status[eStatus::INVISIBLE] <= 0)
				if(point_onscreen(center,univ.town.monst[i].cur_loc) && party_can_see_monst(i)) {
					where_draw.x = univ.town.monst[i].cur_loc.x - center.x + 4;
					where_draw.y = univ.town.monst[i].cur_loc.y - center.y + 4;
					get_monst_dims(univ.town.monst[i].number,&width,&height);
					
					for(k = 0; k < width * height; k++) {
						store_loc = where_draw;
						store_loc.x += k % width;
						store_loc.y += k / width;
						ter = univ.town->terrain(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y);
						// in bed?
						if(store_loc.x >= 0 && store_loc.x < 9 && store_loc.y >= 0 && store_loc.y < 9 &&
						   (univ.scenario.ter_types[ter].special == eTerSpec::BED) && isHumanoid(univ.town.monst[i].m_type)
						   && (univ.town.monst[i].active == 1 || univ.town.monst[i].target == 6) &&
						   width == 1 && height == 1)
							draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + univ.scenario.ter_types[ter].flag1);
						else if(univ.town.monst[i].picture_num >= 1000) {
							bool isParty = univ.town.monst[i].picture_num >= 10000;
							sf::Texture* src_gw;
							pic_num_t need_pic = (univ.town.monst[i].picture_num % 1000) + k;
							if(univ.town.monst[i].direction >= 4) need_pic += width * height;
							if(combat_posing_monster == i + 100) need_pic += (2 * width * height);
							graf_pos_ref(src_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty);
							Draw_Some_Item(*src_gw, source_rect, terrain_screen_gworld, store_loc, 1, 0);
						} else {
							pic_num_t this_monst = univ.town.monst[i].picture_num;
							int pic_mode = (univ.town.monst[i].direction) < 4 ? 0 : 1;
							pic_mode += (combat_posing_monster == i + 100) ? 10 : 0;
							source_rect = get_monster_template_rect(this_monst, pic_mode, k);
							int which_sheet = m_pic_index[this_monst].i / 20;
							sf::Texture& monst_gworld = *ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet));
							Draw_Some_Item(monst_gworld, source_rect, terrain_screen_gworld, store_loc, 1, 0);
						}
					}
				}
	}
}
Пример #21
0
void draw_party_symbol(location center) {
	rectangle source_rect;
	location target(4,4);
	short i = 0;
	
	if(!can_draw_pcs)
		return;
	if(!univ.party.is_alive())
		return;
	if((is_town()) && (univ.town.p_loc.x > 70))
		return;
	if(overall_mode == MODE_LOOK_TOWN || cartoon_happening) {
		target.x += univ.town.p_loc.x - center.x;
		target.y += univ.town.p_loc.y - center.y;
	}
	
	if((univ.party.in_boat < 0) && (univ.party.in_horse < 0)) {
		i = first_active_pc();
		sf::Texture* from_gw;
		pic_num_t pic = univ.party[i].which_graphic;
		if(pic >= 1000) {
			bool isParty = pic >= 10000;
			pic_num_t need_pic = pic % 1000;
			if(univ.party.direction >= 4)
				need_pic++;
			graf_pos_ref(from_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty);
		} else if(pic >= 100) {
			// Note that we assume it's a 1x1 graphic.
			// PCs can't be larger than that, but we leave it to the scenario designer to avoid assigning larger graphics.
			pic_num_t need_pic = pic - 100;
			int mode = 0;
			if(univ.party.direction >= 4)
				mode++;
			source_rect = get_monster_template_rect(need_pic, mode, 0);
			int which_sheet = m_pic_index[need_pic].i / 20;
			from_gw = ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)).get();
		} else {
			source_rect = calc_rect(2 * (pic / 8), pic % 8);
			if(univ.party.direction >= 4)
				source_rect.offset(28,0);
			from_gw = ResMgr::get<ImageRsrc>("pcs").get();
		}
		ter_num_t ter = 0;
		if(is_out())
			ter = univ.out[univ.party.p_loc.x][univ.party.p_loc.y];
		else if(is_town() || is_combat())
			ter = univ.town->terrain(univ.town.p_loc.x,univ.town.p_loc.y);
		// now wedge in bed graphic
		if(is_town() && univ.scenario.ter_types[ter].special == eTerSpec::BED)
			draw_one_terrain_spot((short) target.x,(short) target.y,10000 + univ.scenario.ter_types[ter].flag1);
		else Draw_Some_Item(*from_gw, source_rect, terrain_screen_gworld, target, 1, 0);
	}
	else if(univ.party.in_boat >= 0) {
		if(univ.party.direction == DIR_N) i = 2;
		else if(univ.party.direction == DIR_S) i = 3;
		else i = univ.party.direction > DIR_S;
		Draw_Some_Item(*ResMgr::get<ImageRsrc>("vehicle"), calc_rect(i,0), terrain_screen_gworld, target, 1, 0);
	}else {
		i = univ.party.direction > 3;
		Draw_Some_Item(*ResMgr::get<ImageRsrc>("vehicle"), calc_rect(i + 2, 1), terrain_screen_gworld, target, 1, 0);
	}
}