Example #1
0
void Block::Drawcreaturetext(){
	t_SpriteWithOffset sprite;
	/*if(config.hide_outer_blocks){
	if(x == ownerSegment->x || x == ownerSegment->x + ownerSegment->sizex - 1) return;
	if(y == ownerSegment->y || y == ownerSegment->y + ownerSegment->sizey - 1) return;
	}*/

	int32_t drawx = x;
	int32_t drawy = y;
	int32_t drawz = z; //- ownerSegment->sizez + 1;

	correctBlockForSegmetOffset( drawx, drawy, drawz);
	correctBlockForRotation( drawx, drawy, drawz, ownerSegment->rotation);
	pointToScreen((int*)&drawx, (int*)&drawy, drawz);
	drawx -= TILEWIDTH>>1;

	// creature
	// ensure there is *some* creature according to the map data
	// (no guarantee it is the right one)
	if(creaturePresent && (config.show_hidden_blocks || !designation.bits.hidden))
	{
		DrawCreatureText(drawx, drawy, creature);
	}

}
Example #2
0
void WorldSegment::addBlock(Block* b){
	this->blocks.push_back(b);
	//b = &(this->blocks[ blocks.size() - 1]);

	uint32_t x = b->x;
	uint32_t y = b->y;
	uint32_t z = b->z;
	//make local
	x -= this->x;
	y -= this->y;
	z -= this->z;

	//rotate
	correctBlockForRotation( (int32_t&)x, (int32_t&)y, (int32_t&)z, rotation);
	uint32_t index = x + (y * this->sizex) + ((z) * this->sizex * this->sizey);
	blocksAsPointerVolume[index] = b;
}
Example #3
0
Block* WorldSegment::getBlockRelativeTo(uint32_t x, uint32_t y, uint32_t z,  dirRelative direction, int distance)
{
	int32_t lx = x;
	int32_t ly = y;
	int32_t lz = z;
	//make local
	lx -= this->x;
	ly -= this->y;
	lz -= this->z;

	correctBlockForRotation( (int32_t&)lx,(int32_t&)ly,(int32_t&)lz, rotation);
	switch (direction){
	case eUp:
		ly-= distance; break;
	case eDown:
		ly+= distance; break;
	case eLeft:
		lx-= distance; break;
	case eRight:
		lx+= distance; break;
	case eAbove:
		lz+= distance; break;
	case eBelow:
		lz-= distance; break;
	case eUpLeft:
		ly-= distance; lx-= distance; break;
	case eUpRight:
		ly-= distance; lx+= distance; break;
	case eDownLeft:
		ly+= distance; lx-= distance; break;
	case eDownRight:
		ly+= distance; lx+= distance; break;
	}

	if((int)lx < 0 || lx >= this->sizex) return 0;
	if((int)ly < 0 || ly >= this->sizey) return 0;
	if((int)lz < 0 || lz >= this->sizez) return 0;

	uint32_t index = lx + (ly * this->sizex) + ((lz) * this->sizex * this->sizey);
	return blocksAsPointerVolume[index];
}
Example #4
0
Block* WorldSegment::getBlock(int32_t x, int32_t y, int32_t z){
	if(x < this->x || x >= this->x + this->sizex) return 0;
	if(y < this->y || y >= this->y + this->sizey) return 0;
	if(z < this->z || z >= this->z + this->sizez) return 0;
	/*for(uint32_t i=0; i<this->blocks.size(); i++){
	Block* b = this->blocks[i];
	if(x == b->x && y == b->y && z == b->z)
	return b;
	}
	return 0;*/

	uint32_t lx = x;
	uint32_t ly = y;
	uint32_t lz = z;
	//make local
	lx -= this->x;
	ly -= this->y;
	lz -= this->z;

	correctBlockForRotation( (int32_t&)lx,(int32_t&)ly,(int32_t&)lz , rotation);

	uint32_t index = lx + (ly * this->sizex) + ((lz) * this->sizex * this->sizey);
	return blocksAsPointerVolume[index];
}
void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, bool chop)
{
	if(defaultsheet == 0) defaultsheet = IMGObjectSheet;
	//sprites can be offset by a random amount, both animationwise, and just variationwise.
	//the base offset is set here.
	int rando = randomCube[(b->x)%RANDOM_CUBE][(b->y)%RANDOM_CUBE][(b->z)%RANDOM_CUBE];
	//and the random offset of the animation frame is set here, provided the sprite iis set to use random animation frames. 
	int offsetAnimFrame = ((randomanimation?rando:0) + currentAnimationFrame) % MAX_ANIMFRAME;
	//the following stuff is only bothered with if the animation frames say it should be drawn. this can be over-ridden
	// by setting animate to 0

	if(sheetindex == 48)
	{
		int spam = 0;
		spam++;
	}

	if ((animframes & (1 << offsetAnimFrame)) || !animate)
	{
		//if set by the xml file, a random offset between 0 and 'variations' is added to the sprite.
		int randoffset = 0;
		if(variations)
			randoffset = rando%variations;

		if(!b)
			return;
		//if the xml says that this is a blood sprite, and offset is set here for proper pooling. this over-rides the random offset.
		if(bloodsprite)
			randoffset = getBloodOffset(b);
		if((water_direction < 0) || (water_direction == get_relative_water_direction(b)))
		{
			if(( //these are all border conditions. this first section is a list of positive conditions. if at least one of the border conditions is met, the tile can be shown.
				(openborders & b->openborders) ||
				(upstairborders & b->upstairborders) ||
				(downstairborders & b->downstairborders) ||
				(rampborders & b->rampborders) ||
				(wallborders & b->wallborders) ||
				(floorborders & b->floorborders) ||
				(lightborders & b->lightborders)
				) && !( //This second block consists of negative conditions. if /any/ of these border conditions are met, the tile will not be drawn
				(notopenborders & b->openborders) ||
				(notupstairborders & b->upstairborders) ||
				(notdownstairborders & b->downstairborders) ||
				(notrampborders & b->rampborders) ||
				(notwallborders & b->wallborders) ||
				(notfloorborders & b->floorborders) ||
				(darkborders & b->lightborders)
				))
			{
				int foo = 0;
				if(
					(
						snowmin <= b->snowlevel &&
						(snowmax == -1 || snowmax >= b->snowlevel)
					) &&
					(
						bloodmin <= b->bloodlevel &&
						(bloodmax == -1 || bloodmax >= b->bloodlevel)
					) &&
					(
						mudmin <= b->mudlevel &&
						(mudmax == -1 || mudmax >= b->mudlevel)
					) &&
					(
						grassmin <= b->grasslevel &&
						(grassmax == -1 || grassmax >= b->grasslevel)
					) &&
					//only bother with this tile if it's in the light, or not.
					(
						(light==LIGHTANY) ||
						(
							(light==LIGHTYES) && b->designation.bits.outside
						)
						||
						(
                            (light==LIGHTNO) && !(b->designation.bits.outside)
						)
					) &&
					(
						(grasstype == -1) || (grasstype == b->grassmat)
					) &&
					(
						(grass_growth == GRASS_GROWTH_ANY) || 
						(
							(grass_growth == GRASS_GROWTH_NORMAL) && 
							(
							(b->tileMaterial == tiletype_material::GRASS_DARK) ||
								(b->tileMaterial == tiletype_material::GRASS_LIGHT)
							)
						) ||
						(
							(grass_growth == GRASS_GROWTH_DRY) &&
							(b->tileMaterial == tiletype_material::GRASS_DRY)
						) ||
						(
							(grass_growth == GRASS_GROWTH_DEAD) &&
							(b->tileMaterial == tiletype_material::GRASS_DEAD)
							)
							)
							)
				{
					int32_t drawx = x;
					int32_t drawy = y;
					int32_t drawz = z; //- ownerSegment->sizez + 1;

					correctBlockForSegmetOffset( drawx, drawy, drawz);
					correctBlockForRotation( drawx, drawy, drawz, b->ownerSegment->rotation);
					int32_t viewx = drawx;
					int32_t viewy = drawy;
					int32_t viewz = drawz;
					pointToScreen((int*)&drawx, (int*)&drawy, drawz);
					drawx -= (TILEWIDTH>>1)*config.scale;

					if(((drawx + spritewidth*config.scale) < 0) || (drawx > al_get_bitmap_width(al_get_target_bitmap())) || ((drawy + spriteheight*config.scale) < 0) || (drawy > al_get_bitmap_height(al_get_target_bitmap())))
						return;

					int sheetx, sheety;
					if(tilelayout == BLOCKTILE)
					{
						sheetx = ((sheetindex+tileoffset+randoffset) % SHEET_OBJECTSWIDE) * spritewidth;
						sheety = ((sheetindex+tileoffset+randoffset) / SHEET_OBJECTSWIDE) * spriteheight;
					}
					else if(tilelayout == RAMPBOTTOMTILE)
					{
						sheetx = SPRITEWIDTH * b->ramp.index;
						sheety = ((TILEHEIGHT + FLOORHEIGHT + SPRITEHEIGHT) * (sheetindex+tileoffset+randoffset))+(TILEHEIGHT + FLOORHEIGHT);
					}
					else if(tilelayout == RAMPTOPTILE)
					{
						sheetx = SPRITEWIDTH * b->ramp.index;
						sheety = (TILEHEIGHT + FLOORHEIGHT + SPRITEHEIGHT) * (sheetindex+tileoffset+randoffset);
					}
					else
					{
						sheetx = ((sheetindex+tileoffset+randoffset) % SHEET_OBJECTSWIDE) * spritewidth;
						sheety = ((sheetindex+tileoffset+randoffset) / SHEET_OBJECTSWIDE) * spriteheight;
					}
					ALLEGRO_COLOR shade_color = get_color(b);
					if(!b->designation.bits.pile && config.fog_of_war && (contentLoader->gameMode.g_mode == GAMEMODE_ADVENTURE))
					{
						shade_color.r *= 0.25f;
						shade_color.g *= 0.25f;
						shade_color.b *= 0.25f;
					}
					if(chop && ( halftile == HALFTILECHOP))
					{
						if(fileindex < 0)
						{
							if(config.block_count)
								config.drawcount ++;
							if(shade_color.a > 0.001f)
								al_draw_tinted_scaled_bitmap(
								defaultsheet, premultiply(shade_color),
								sheetx * spritescale,
								(sheety+WALL_CUTOFF_HEIGHT) * spritescale,
								spritewidth * spritescale,
								(spriteheight-WALL_CUTOFF_HEIGHT) * spritescale,
								drawx + (offset_x + offset_user_x)*config.scale,
								drawy + (offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT)*config.scale,
								spritewidth*config.scale,
								(spriteheight-WALL_CUTOFF_HEIGHT)*config.scale,
								0);
						}
						else 
						{
							if(config.block_count)
								config.drawcount ++;

							if(shade_color.a > 0.001f)
								al_draw_tinted_scaled_bitmap(
								getImgFile(fileindex),
								premultiply(shade_color),
								sheetx * spritescale,
								(sheety+WALL_CUTOFF_HEIGHT) * spritescale,
								spritewidth * spritescale,
								(spriteheight-WALL_CUTOFF_HEIGHT) * spritescale,
								drawx + (offset_x + offset_user_x)*config.scale,
								drawy + (offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT)*config.scale,
								spritewidth*config.scale,
								(spriteheight-WALL_CUTOFF_HEIGHT)*config.scale,
								0);
						}
						//draw cut-off floor thing
						if(config.block_count)
							config.drawcount ++;

						if(shade_color.a > 0.001f)
							al_draw_scaled_bitmap(IMGObjectSheet, 
							TILEWIDTH * SPRITEFLOOR_CUTOFF, 0,
							SPRITEWIDTH, SPRITEWIDTH, 
							drawx+offset_x, drawy+offset_y-((SPRITEHEIGHT-WALL_CUTOFF_HEIGHT)/2),
							SPRITEWIDTH*config.scale, SPRITEWIDTH*config.scale, 0);
					}
					else if ((chop && (halftile == HALFTILEYES)) || (!chop && (halftile == HALFTILENO)) || (!chop && (halftile == HALFTILECHOP)) || (halftile == HALFTILEBOTH))
					{
						if((isoutline == OUTLINENONE) || ((isoutline == OUTLINERIGHT) && (b->depthBorderNorth)) || ((isoutline == OUTLINELEFT) && (b->depthBorderWest)) || ((isoutline == OUTLINEBOTTOM) && (b->depthBorderDown)))
						{
							if(fileindex < 0)
							{
								if(config.block_count)
									config.drawcount ++;

								if(shade_color.a > 0.001f)
									al_draw_tinted_scaled_bitmap(
									defaultsheet, premultiply(shade_color),
									sheetx * spritescale,
									sheety * spritescale,
									spritewidth * spritescale,
									spriteheight * spritescale,
									drawx + (offset_x + offset_user_x)*config.scale,
									drawy + (offset_user_y + (offset_y - WALLHEIGHT))*config.scale,
									spritewidth*config.scale,
									spriteheight*config.scale,
									0);
							}
							else 
							{
								if(config.block_count)
									config.drawcount ++;

								if(shade_color.a > 0.001f)
									al_draw_tinted_scaled_bitmap(
									getImgFile(fileindex),
									premultiply(shade_color),
									sheetx * spritescale,
									sheety * spritescale,
									spritewidth * spritescale,
									spriteheight * spritescale,
									drawx + (offset_x + offset_user_x)*config.scale,
									drawy + (offset_user_y + (offset_y - WALLHEIGHT))*config.scale,
									spritewidth*config.scale,
									spriteheight*config.scale,
									0);
							}
						}
						if(needoutline)
						{
							//drawy -= (WALLHEIGHT);
							//Northern border
							if(b->depthBorderNorth)
								DrawSpriteFromSheet(281, IMGObjectSheet, al_map_rgb(255,255,255), drawx + (offset_x)*config.scale, drawy + (offset_y)*config.scale, b );

							//Western border
							if(b->depthBorderWest)
								DrawSpriteFromSheet(280, IMGObjectSheet, al_map_rgb(255,255,255), drawx + (offset_x)*config.scale, drawy + (offset_y)*config.scale, b );

							//drawy += (WALLHEIGHT);
						}
					}
					//draw_textf_border(font, al_map_rgb(255,255,255), drawx, drawy, 0, "%d,%d", fileindex, sheetindex);
				}
			}
Example #6
0
void Block::Draw()
{
	if(!visible)
		return;
	if((material.type == INORGANIC) && (material.index == -1))
	{
		material.index = 0;
	}

	
	if((!(this->designation.bits.hidden) || config.show_hidden_blocks) && config.block_count)
	{
		config.tilecount ++;
	}

	bool defaultSnow = 1;
	t_SpriteWithOffset sprite;
	c_sprite* spriteobject;
	/*if(config.hide_outer_blocks){
	if(x == ownerSegment->x || x == ownerSegment->x + ownerSegment->sizex - 1) return;
	if(y == ownerSegment->y || y == ownerSegment->y + ownerSegment->sizey - 1) return;
	}*/

	drawx = x;
	drawy = y;
	drawz = z; //- ownerSegment->sizez + 1;


	correctBlockForSegmetOffset( drawx, drawy, drawz);
	correctBlockForRotation( drawx, drawy, drawz, ownerSegment->rotation);
	pointToScreen((int*)&drawx, (int*)&drawy, drawz);
	drawx -= (TILEWIDTH>>1)*config.scale;

	if(((drawx + TILEWIDTH*config.scale) < 0) || (drawx > al_get_bitmap_width(al_get_target_bitmap())) || ((drawy + (TILEHEIGHT + FLOORHEIGHT)*config.scale) < 0) || (drawy - WALLHEIGHT*config.scale > al_get_bitmap_height(al_get_target_bitmap())))
		return;

	bool chopThisBlock = 0;

	if(config.truncate_walls == 1) chopThisBlock = 1;
	else if(config.truncate_walls == 2 && obscuringCreature == 1) chopThisBlock = 1;
	else if(config.truncate_walls == 3 && (obscuringCreature == 1 || obscuringBuilding == 1)) chopThisBlock = 1;
	else if(config.truncate_walls == 4 && obscuringBuilding == 1) chopThisBlock = 1;

	if(building.info.type == BUILDINGTYPE_BLACKBOX)
	{
		DrawSpriteFromSheet( SPRITEOBJECT_BLACK, IMGObjectSheet, al_map_rgb(255,255,255), drawx, drawy+FLOORHEIGHT*config.scale, this);
		DrawSpriteFromSheet( SPRITEOBJECT_BLACK, IMGObjectSheet, al_map_rgb(255,255,255), drawx, drawy, this);
		return;
	}


	ALLEGRO_COLOR tileBorderColor = al_map_rgb(85,85,85);
	int rando = randomCube[x%RANDOM_CUBE][y%RANDOM_CUBE][z%RANDOM_CUBE];
	//Draw Floor
	if(
		tileShapeBasic==tiletype_shape_basic::Floor || 
		tileShapeBasic==tiletype_shape_basic::Wall ||
		tileShapeBasic==tiletype_shape_basic::Ramp || 
		tileShapeBasic==tiletype_shape_basic::Stair
		)
	{

		//If tile has no floor, look for a Filler Floor from it's wall
		if (tileShapeBasic==tiletype_shape_basic::Floor)
		{
			spriteobject = GetFloorSpriteMap(tileType, this->material, consForm);
		}
		else if (tileShapeBasic==tiletype_shape_basic::Wall)
		{
			spriteobject = GetFloorSpriteMap(tileType, this->material, consForm);
		}
		else if (tileShapeBasic==tiletype_shape_basic::Ramp)
		{
			spriteobject = GetFloorSpriteMap(tileType, this->material, consForm);
		}
		else if (tileShapeBasic==tiletype_shape_basic::Stair)
		{
			spriteobject = GetFloorSpriteMap(tileType, this->material, consForm);
		} 
		if(spriteobject->get_sheetindex() != INVALID_INDEX)
		{
			////if floor is muddy, override regular floor
			//if( mudlevel && water.index == 0)
			//{
			//	sprite.sheetIndex = SPRITEFLOOR_WATERFLOOR;
			//	sprite.fileIndex = INVALID_INDEX;
			//}
			////if floor is snowed down, override  regular floor
			//if( snowlevel )
			//{
			//	sprite.sheetIndex = SPRITEFLOOR_SNOW;
			//	sprite.fileIndex = INVALID_INDEX;
			//	spriteOffset = 0;
			//	al_set_separate_blender(op, src, dst, alpha_op, alpha_src, alpha_dst, color);
			//}

			if (spriteobject->get_sheetindex() == UNCONFIGURED_INDEX)
			{
				spriteobject->set_sheetindex(SPRITEOBJECT_FLOOR_NA);
				spriteobject->set_fileindex(INVALID_INDEX);
				spriteobject->set_offset(0, WALLHEIGHT);
				spriteobject->draw_world(x, y, z, this);
			}
			else
				spriteobject->draw_world(x, y, z, this);
		}
	}

	//Floor Engravings
		if((tileShapeBasic==tiletype_shape_basic::Floor) && engraving_character && engraving_flags.bits.floor)
	{
		DrawSpriteFromSheet( engraving_character, IMGEngFloorSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
	}


	//draw surf
		//fixme: needs to be scaled
	if(Eff_SeaFoam.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_SeaFoam.matt.type, Eff_SeaFoam.matt.index);
		tint.a*=Eff_SeaFoam.density/100.0f;
		al_draw_tinted_bitmap(sprite_oceanwave,tint, drawx, drawy - (WALLHEIGHT), 0);
	}

	//Draw Ramp
	if(tileShapeBasic==tiletype_shape_basic::Ramp){
		spriteobject = GetBlockSpriteMap(tileType, material, consForm);
		if (spriteobject->get_sheetindex() == UNCONFIGURED_INDEX)
		{
			spriteobject->set_sheetindex(0);
			spriteobject->set_fileindex(INVALID_INDEX);
			spriteobject->set_defaultsheet(IMGRampSheet);
		}
		if (spriteobject->get_sheetindex() != INVALID_INDEX)
		{
			spriteobject->set_size(SPRITEWIDTH, SPRITEHEIGHT);
			spriteobject->set_tile_layout(RAMPBOTTOMTILE);
			spriteobject->draw_world(x, y, z, this, (chopThisBlock && this->z == ownerSegment->z + ownerSegment->sizez -2));
		}
		spriteobject->set_tile_layout(BLOCKTILE);
	}


	drawFloorBlood ( this, drawx, drawy );


	//first part of snow
	if(tileShapeBasic!=tiletype_shape_basic::Ramp && tileShapeBasic!=tiletype_shape_basic::Wall && tileShapeBasic!=tiletype_shape_basic::Stair && defaultSnow)
	{
		if(snowlevel > 75)
		{
			DrawSpriteFromSheet( 20, IMGObjectSheet, al_map_rgb(255,255,255), drawx, drawy, this);
		}
		else if(snowlevel > 50)
		{
			DrawSpriteFromSheet( 21, IMGObjectSheet, al_map_rgb(255,255,255), drawx, drawy, this );
		}
		else if(snowlevel > 25)
		{
			DrawSpriteFromSheet( 22, IMGObjectSheet, al_map_rgb(255,255,255), drawx, drawy, this );
		}
		else if(snowlevel > 0)
		{
			DrawSpriteFromSheet( 23, IMGObjectSheet, al_map_rgb(255,255,255), drawx, drawy, this );
		}
	}


	////vegetation
	//if(tree.index > 0 || tree.type > 0){
	//	c_sprite * vegetationsprite = 0;
	//	vegetationsprite = GetSpriteVegetation( (TileClass) getVegetationType( this->floorType ), tree.index );
	//	if(vegetationsprite)
	//		vegetationsprite->draw_world(x, y, z);
	//}

	//items
	if(Item.item.type >= 0)
	{
		if(
			contentLoader->itemConfigs[Item.item.type] && 
			(Item.item.type < contentLoader->itemConfigs[Item.item.type]->subItems.size()) && 
			contentLoader->itemConfigs[Item.item.type]->subItems[Item.item.type])
		{
			contentLoader->itemConfigs[Item.item.type]->subItems[Item.item.type]->sprite.draw_world(x, y, z, this);
		}
		else if (
			contentLoader->itemConfigs[Item.item.type] &&
			contentLoader->itemConfigs[Item.item.type]->configured)
		{
			contentLoader->itemConfigs[Item.item.type]->default_sprite.draw_world(x, y, z, this);
		}
		else
			DrawSpriteFromSheet( 350, IMGObjectSheet, lookupMaterialColor(Item.matt.type, Item.matt.index, Item.dyed), drawx, (tileShapeBasic==tiletype_shape_basic::Ramp)?(drawy - ((WALLHEIGHT/2)*config.scale)):drawy , this);
	}


	//shadow
	if (shadow > 0)
	{
		DrawSpriteFromSheet( BASE_SHADOW_TILE + shadow - 1, IMGObjectSheet, al_map_rgb(255,255,255), drawx, (tileShapeBasic==tiletype_shape_basic::Ramp)?(drawy - ((WALLHEIGHT/2)*config.scale)):drawy , this);
	}

	//Building
	bool skipBuilding =
        (building.info.type == building_type::Civzone && !config.show_stockpiles) ||
        (building.info.type == building_type::Stockpile && !config.show_zones);

	if(building.info.type != BUILDINGTYPE_NA && !skipBuilding)
	{
		for(uint32_t i=0; i < building.sprites.size(); i++)
		{
			spriteobject = &building.sprites[i];
			if(building.parent)
				spriteobject->draw_world(x, y, z, building.parent);
			else
				spriteobject->draw_world(x, y, z, this);
		}
	}

	//Draw Stairs
	if(tileShapeBasic==tiletype_shape_basic::Stair)
	{
		bool mirrored = false;
		if(findWallCloseTo(ownerSegment, this) == eSimpleW)
			mirrored = true;

		//down part
		spriteobject = GetFloorSpriteMap(tileType, material, consForm);
		if(spriteobject->get_sheetindex() != INVALID_INDEX && spriteobject->get_sheetindex() != UNCONFIGURED_INDEX)
		{
			if (mirrored)
				spriteobject->draw_world_offset(x, y, z, this, 1);
			else
				spriteobject->draw_world(x, y, z, this);
		}

		//up part
		spriteobject = GetBlockSpriteMap(tileType, material, consForm);
		if(spriteobject->get_sheetindex() != INVALID_INDEX && spriteobject->get_sheetindex() != UNCONFIGURED_INDEX)
		{
			if (mirrored)
				spriteobject->draw_world_offset(x, y, z, this, 1);
			else
				spriteobject->draw_world(x, y, z, this);
		}
	}

	if(tileShapeBasic==tiletype_shape_basic::Wall)
	{
		//draw wall
		spriteobject =  GetBlockSpriteMap(tileType, material, consForm);
		int spriteOffset = 0;
		if (spriteobject->get_sheetindex() == UNCONFIGURED_INDEX)
		{
			spriteobject->set_sheetindex(SPRITEOBJECT_WALL_NA);
			spriteobject->set_fileindex(INVALID_INDEX);
				spriteobject->set_tile_layout(BLOCKTILE);
				spriteobject->set_defaultsheet(IMGObjectSheet);
		}
		if (spriteobject->get_sheetindex() == INVALID_INDEX)
		{
			//skip   
		}    
		else 
		{
			spriteobject->draw_world(x, y, z, this, (chopThisBlock && this->z == ownerSegment->z + ownerSegment->sizez -2));
		}
	}

	//Wall Engravings
	if((tileShapeBasic==tiletype_shape_basic::Wall) && engraving_character)
	{
		if(ownerSegment->rotation == 0)
		{
            if(engraving_flags.bits.east)
				DrawSpriteFromSheet( engraving_character, IMGEngRightSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
            if(engraving_flags.bits.south)
				DrawSpriteFromSheet( engraving_character, IMGEngLeftSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
		}
		if(ownerSegment->rotation == 1)
		{
            if(engraving_flags.bits.north)
				DrawSpriteFromSheet( engraving_character, IMGEngRightSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
            if(engraving_flags.bits.east)
				DrawSpriteFromSheet( engraving_character, IMGEngLeftSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
		}
		if(ownerSegment->rotation == 2)
		{
            if(engraving_flags.bits.west)
				DrawSpriteFromSheet( engraving_character, IMGEngRightSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
            if(engraving_flags.bits.north)
				DrawSpriteFromSheet( engraving_character, IMGEngLeftSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
		}
		if(ownerSegment->rotation == 3)
		{
            if(engraving_flags.bits.south)
				DrawSpriteFromSheet( engraving_character, IMGEngRightSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
            if(engraving_flags.bits.west)
				DrawSpriteFromSheet( engraving_character, IMGEngLeftSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
		}
	}


	if(water.index > 0)
	{
		//if(waterlevel == 7) waterlevel--;
		if(water.type == 0)
		{
			contentLoader->water[water.index-1].sprite.draw_world(x, y, z, this, (chopThisBlock && this->z == ownerSegment->z + ownerSegment->sizez -2));
		}
		else
		{
			contentLoader->lava[water.index-1].sprite.draw_world(x, y, z, this, (chopThisBlock && this->z == ownerSegment->z + ownerSegment->sizez -2));
		}
	}

	// creature
	// ensure there is *some* creature according to the map data
	// (no guarantee it is the right one)
	if(creaturePresent && (config.show_hidden_blocks || !designation.bits.hidden))
	{
		DrawCreature(drawx, drawy, creature, this);
	}

	//second part of snow
	if(tileShapeBasic!=tiletype_shape_basic::Wall && tileShapeBasic!=tiletype_shape_basic::Stair && defaultSnow)
	{
		if(snowlevel > 75)
		{
			DrawSpriteFromSheet( 24, IMGObjectSheet, al_map_rgb(255,255,255), drawx, drawy, this );
		}
		else if(snowlevel > 50)
		{
			DrawSpriteFromSheet( 25, IMGObjectSheet, al_map_rgb(255,255,255), drawx, drawy, this );
		}
		else if(snowlevel > 25)
		{
			DrawSpriteFromSheet( 26, IMGObjectSheet, al_map_rgb(255,255,255), drawx, drawy, this );
		}
	}

	if(Eff_Web.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_Web.matt.type, Eff_Web.matt.index);
		tint.a*=Eff_Web.density/100.0f;
		DrawSpriteFromSheet(rando%5, sprite_webing, tint, drawx, drawy, this, 4.0f);
		//al_draw_tinted_bitmap(sprite_webing,tint, drawx, drawy - (WALLHEIGHT), 0);
	}
	if(Eff_Miasma.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_Miasma.matt.type, Eff_Miasma.matt.index);
		draw_particle_cloud(Eff_Miasma.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_miasma, tint);
	}
	if(Eff_Steam.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_Steam.matt.type, Eff_Steam.matt.index);
		draw_particle_cloud(Eff_Steam.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_water, tint);
	}
	if(Eff_Mist.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_Mist.matt.type, Eff_Mist.matt.index);
		draw_particle_cloud(Eff_Mist.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_water2, tint);
	}
	if(Eff_MaterialDust.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_MaterialDust.matt.type, Eff_MaterialDust.matt.index);
		draw_particle_cloud(Eff_MaterialDust.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_dust, tint);
	}
	if(Eff_MagmaMist.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_MagmaMist.matt.type, Eff_MagmaMist.matt.index);
		draw_particle_cloud(Eff_MagmaMist.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_magma, tint);
	}
	if(Eff_Smoke.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_Smoke.matt.type, Eff_Smoke.matt.index);
		draw_particle_cloud(Eff_Smoke.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_smoke, tint);
	}
	if(Eff_Dragonfire.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_Dragonfire.matt.type, Eff_Dragonfire.matt.index);
		tint.a*=Eff_Dragonfire.density/100.0f;
		tint.g*=Eff_Dragonfire.density/100.0f;
		tint.b*=Eff_Dragonfire.density/100.0f;
		int size = 3 - ((Eff_Dragonfire.density-1)/25);
		DrawSpriteFromSheet((((currentFrameLong+rando)%8)*20+size), sprite_dragonfire, tint, drawx, drawy, this, 2.0f);
		//ALLEGRO_COLOR tint = lookupMaterialColor(Eff_Dragonfire.matt.type, Eff_Dragonfire.matt.index);
		//draw_particle_cloud(Eff_Dragonfire.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_dragonfire, tint);
	}
	if(Eff_Fire.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_Fire.matt.type, Eff_Fire.matt.index);
		tint.a*=Eff_Fire.density/100.0f;
		tint.g*=Eff_Fire.density/100.0f;
		tint.b*=Eff_Fire.density/100.0f;
		int size = 3 - ((Eff_Fire.density-1)/25);
		DrawSpriteFromSheet((((currentFrameLong+rando)%8)*20+size), sprite_dragonfire, tint, drawx, drawy, this, 2.0f);
		//ALLEGRO_COLOR tint = lookupMaterialColor(Eff_Fire.matt.type, Eff_Fire.matt.index);
		//draw_particle_cloud(Eff_Fire.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_fire, tint);
	}
	if(Eff_MaterialGas.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_MaterialGas.matt.type, Eff_MaterialGas.matt.index);
		draw_particle_cloud(Eff_MaterialGas.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_boiling, tint);
	}
	if(Eff_MaterialVapor.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_MaterialVapor.matt.type, Eff_MaterialVapor.matt.index);
		draw_particle_cloud(Eff_MaterialVapor.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_boiling, tint);
	}
	if(Eff_OceanWave.density > 0)
	{
		ALLEGRO_COLOR tint = lookupMaterialColor(Eff_OceanWave.matt.type, Eff_OceanWave.matt.index);
		draw_particle_cloud(Eff_OceanWave.density, drawx, drawy - (SPRITEHEIGHT/2), SPRITEWIDTH, SPRITEHEIGHT, sprite_water, tint);
	}
}
Example #7
0
void Block::Draw(BITMAP* target){
	int sheetOffsetX, sheetOffsetY;
	t_SpriteWithOffset sprite;
  /*if(config.hide_outer_blocks){
    if(x == ownerSegment->x || x == ownerSegment->x + ownerSegment->sizex - 1) return;
    if(y == ownerSegment->y || y == ownerSegment->y + ownerSegment->sizey - 1) return;
  }*/

	int32_t drawx = x;
	int32_t drawy = y;
  int32_t drawz = z; //- ownerSegment->sizez + 1;

	correctBlockForSegmetOffset( drawx, drawy, drawz);
  correctBlockForRotation( drawx, drawy, drawz);
	pointToScreen((int*)&drawx, (int*)&drawy, drawz);
	drawx -= TILEWIDTH>>1;

  int tileBorderColor = makecol(85,85,85);

	//Draw Floor
  if(floorType > 0 || wallType > 0 || ramp.type > 0 || stairType > 0){
	  
    //If tile has no floor, look for a Filler Floor from it's wall
    if (floorType > 0)
    {
	    sprite = GetFloorSpriteMap(floorType, this->material);
    }
	else if (wallType > 0)
	{
    	sprite = GetFloorSpriteMap(wallType, this->material);
	}
	else if (ramp.type > 0)
	{
    	sprite = GetFloorSpriteMap(ramp.type, this->material);
	}
	else if (stairType > 0)
	{
    	sprite = GetFloorSpriteMap(stairType, this->material);
	}
	
    if(sprite.sheetIndex != INVALID_INDEX)
    {
	    
	    //if floor is muddy, override regular floor
	    if( occ.bits.mud && water.index == 0)
			{
	      sprite.sheetIndex = SPRITEFLOOR_WATERFLOOR;
	      sprite.fileIndex = INVALID_INDEX;
			}
			//if floor is snowed down, override  regular floor
			if( occ.bits.snow )
			{
				sprite.sheetIndex = SPRITEFLOOR_SNOW;
	      sprite.fileIndex = INVALID_INDEX;
			}
		
			if (sprite.sheetIndex == UNCONFIGURED_INDEX)
			{
					sprite.sheetIndex = SPRITEOBJECT_FLOOR_NA;
					sprite.fileIndex = INVALID_INDEX;
			}
	
   		sheetOffsetX = TILEWIDTH * (sprite.sheetIndex % SHEET_OBJECTSWIDE);
   		sheetOffsetY = (TILEHEIGHT + FLOORHEIGHT) * (sprite.sheetIndex / SHEET_OBJECTSWIDE);
			masked_blit(imageSheet(sprite,IMGObjectSheet), target, sheetOffsetX,sheetOffsetY, drawx,drawy, TILEWIDTH,TILEHEIGHT + FLOORHEIGHT);
	}

    //Northern frame
    if(this->depthBorderNorth)
      line(target, drawx + (TILEWIDTH>>1), drawy, drawx+TILEWIDTH-1, drawy+(TILEHEIGHT>>1)-1, tileBorderColor);

    //Western frame
    if(this->depthBorderWest)
      line(target, drawx, drawy+(TILEHEIGHT>>1)-1, drawx+(TILEWIDTH>>1)-1, drawy, tileBorderColor);
	}

	//Draw Ramp
  if(ramp.type > 0){
	  sprite = GetBlockSpriteMap(ramp.type, material);
	  if (sprite.sheetIndex == UNCONFIGURED_INDEX)
	  {
		sprite.sheetIndex = 0;
		sprite.fileIndex = INVALID_INDEX;
	  }
	  if (sprite.sheetIndex != INVALID_INDEX)
	  {
    sheetOffsetX = SPRITEWIDTH * ramp.index;
    sheetOffsetY = ((TILEHEIGHT + FLOORHEIGHT + SPRITEHEIGHT) * sprite.sheetIndex)+(TILEHEIGHT + FLOORHEIGHT);
	
		masked_blit(imageSheet(sprite,IMGRampSheet), target, sheetOffsetX,sheetOffsetY, drawx,drawy - (WALLHEIGHT), SPRITEWIDTH, SPRITEHEIGHT);
	}}


	//vegetation
	if(tree.index > 0 || tree.type > 0){
     sprite =  GetSpriteVegetation( (TileClass) getVegetationType( this->floorType ), tree.index );
        DrawSpriteFromSheet( sprite.sheetIndex, target, imageSheet(sprite,IMGObjectSheet), drawx, drawy );
	}

	//shadow
	if (shadow > 0)
	{
		DrawSpriteFromSheet( BASE_SHADOW_TILE + shadow - 1, target, IMGObjectSheet, drawx, (ramp.type > 0)?(drawy - (WALLHEIGHT/2)):drawy );
	}

	//Building
  bool skipBuilding =
    (building.info.type == BUILDINGTYPE_STOCKPILE && !config.show_stockpiles) ||
    (building.info.type == BUILDINGTYPE_ZONE && !config.show_zones);

  if(building.info.type != BUILDINGTYPE_NA && !skipBuilding){

    int spriteNum =  SPRITEOBJECT_NA; //getBuildingSprite(this->building, mirroredBuilding);

   for(uint32_t i=0; i < building.sprites.size(); i++){
	   sprite = building.sprites[i];
	   if (!(sprite.animFrames & (1 << currentAnimationFrame)))
	   		continue;
      DrawSpriteFromSheet(sprite.sheetIndex , target, imageSheet(sprite,IMGObjectSheet), 

        drawx + building.sprites[i].x,
        drawy + building.sprites[i].y);
    }
	}




	//Draw Stairs
	if(stairType > 0){
		//down part
		//skipping at the moment?
		//int spriteNum = GetFloorSpriteMap(stairType,material);
    //DrawSpriteFromSheet( spriteNum, target, IMGObjectSheet, drawx, drawy );

		//up part
    bool mirrored = false;
    if(findWallCloseTo(ownerSegment, this) == eSimpleW)
      mirrored = true;
    sprite = GetBlockSpriteMap(stairType, material);
    if(sprite.sheetIndex != INVALID_INDEX && sprite.sheetIndex != UNCONFIGURED_INDEX)
    {
       if (mirrored)
      		sprite.sheetIndex += 1;
      DrawSpriteFromSheet( sprite.sheetIndex, target, imageSheet(sprite,IMGObjectSheet), drawx, drawy );
  }
	}

  //Draw Walls
	if(wallType > 0){
    //draw wall
    sprite =  GetBlockSpriteMap(wallType, material);

    if (sprite.sheetIndex == UNCONFIGURED_INDEX)
    {
	 	sprite.sheetIndex = SPRITEOBJECT_WALL_NA;
		sprite.fileIndex = INVALID_INDEX;  
    }
    if (sprite.sheetIndex == INVALID_INDEX)
    {
	 	//skip   
    }    
    else if( config.truncate_walls && this->z == ownerSegment->z + ownerSegment->sizez -2){
      int sheetx = sprite.sheetIndex % SHEET_OBJECTSWIDE;
      int sheety = sprite.sheetIndex / SHEET_OBJECTSWIDE;
      //draw a tiny bit of wall
      masked_blit(imageSheet(sprite,IMGObjectSheet), target,
        sheetx * SPRITEWIDTH, sheety * SPRITEHEIGHT+WALL_CUTOFF_HEIGHT,
        drawx, drawy - (WALLHEIGHT)+WALL_CUTOFF_HEIGHT, SPRITEWIDTH, SPRITEHEIGHT-WALL_CUTOFF_HEIGHT);
      //draw cut-off floor thing
      masked_blit(IMGObjectSheet, target,
        TILEWIDTH * SPRITEFLOOR_CUTOFF, 0,
        drawx, drawy-(SPRITEHEIGHT-WALL_CUTOFF_HEIGHT)/2, SPRITEWIDTH, SPRITEWIDTH);
    }
    else {
      DrawSpriteFromSheet(sprite.sheetIndex, target, imageSheet(sprite,IMGObjectSheet), drawx, drawy );

      drawy -= (WALLHEIGHT);
      //Northern border
      if(this->depthBorderNorth)
        line(target, drawx + (TILEWIDTH>>1), drawy, drawx+TILEWIDTH-1, drawy+(TILEHEIGHT>>1)-1, tileBorderColor);

      //Western border
      if(this->depthBorderWest)
        line(target, drawx, drawy+(TILEHEIGHT>>1)-1, drawx+(TILEWIDTH>>1)-1, drawy, tileBorderColor);

      drawy += (WALLHEIGHT);
    }
	}