Beispiel #1
0
static void DrawObjectiveHighlight(
	TTileItem *ti, Tile *tile, DrawBuffer *b, Vec2i offset)
{
	color_t color;
	if (ti->flags & TILEITEM_OBJECTIVE)
	{
		// Objective
		const int objective = ObjectiveFromTileItem(ti->flags);
		const Objective *o =
			CArrayGet(&gMission.missionData->Objectives, objective);
		if (o->Flags & OBJECTIVE_HIDDEN)
		{
			return;
		}
		if (!(o->Flags & OBJECTIVE_POSKNOWN) &&
			(tile->flags & MAPTILE_OUT_OF_SIGHT))
		{
			return;
		}
		color = o->color;
	}
	else if (ti->kind == KIND_PICKUP)
	{
		// Gun pickup
		const Pickup *p = CArrayGet(&gPickups, ti->id);
		if (!PickupIsManual(p))
		{
			return;
		}
		color = colorDarker;
	}
	else
	{
		return;
	}
	
	const Vec2i pos = Vec2iNew(
		ti->x - b->xTop + offset.x, ti->y - b->yTop + offset.y);
	const int pulsePeriod = ConfigGetInt(&gConfig, "Game.FPS");
	int alphaUnscaled =
		(gMission.time % pulsePeriod) * 255 / (pulsePeriod / 2);
	if (alphaUnscaled > 255)
	{
		alphaUnscaled = 255 * 2 - alphaUnscaled;
	}
	color.a = (Uint8)alphaUnscaled;
	if (ti->getPicFunc != NULL)
	{
		Vec2i picOffset;
		const Pic *pic = ti->getPicFunc(ti->id, &picOffset);
		BlitPicHighlight(
			&gGraphicsDevice, pic, Vec2iAdd(pos, picOffset), color);
	}
	else if (ti->kind == KIND_CHARACTER)
	{
		TActor *a = CArrayGet(&gActors, ti->id);
		ActorPics pics = GetCharacterPicsFromActor(a);
		DrawActorHighlight(&pics, pos, color);
	}
}
Beispiel #2
0
static void DrawObjectiveHighlight(
	TTileItem *ti, Tile *tile, DrawBuffer *b, Vec2i offset)
{
	if (!(ti->flags & TILEITEM_OBJECTIVE))
	{
		return;
	}
	int objective = ObjectiveFromTileItem(ti->flags);
	MissionObjective *mo =
		CArrayGet(&gMission.missionData->Objectives, objective);
	if (mo->Flags & OBJECTIVE_HIDDEN)
	{
		return;
	}
	if (!(mo->Flags & OBJECTIVE_POSKNOWN) &&
		(tile->flags & MAPTILE_OUT_OF_SIGHT))
	{
		return;
	}
	Vec2i pos = Vec2iNew(
		ti->x - b->xTop + offset.x, ti->y - b->yTop + offset.y);
	struct Objective *o =
		CArrayGet(&gMission.Objectives, objective);
	color_t color = o->color;
	int pulsePeriod = FPS_FRAMELIMIT;
	int alphaUnscaled =
		(gMission.time % pulsePeriod) * 255 / (pulsePeriod / 2);
	if (alphaUnscaled > 255)
	{
		alphaUnscaled = 255 * 2 - alphaUnscaled;
	}
	color.a = (Uint8)alphaUnscaled;
	if (ti->getPicFunc != NULL)
	{
		Vec2i picOffset;
		const Pic *pic = ti->getPicFunc(ti->id, &picOffset);
		BlitPicHighlight(
			&gGraphicsDevice, pic, Vec2iAdd(pos, picOffset), color);
	}
	else if (ti->getActorPicsFunc != NULL)
	{
		ActorPics pics = ti->getActorPicsFunc(ti->id);
		// Do not highlight dead, dying or transparent characters
		if (!pics.IsDead && !pics.IsTransparent)
		{
			for (int i = 0; i < 3; i++)
			{
				if (PicIsNotNone(&pics.Pics[i]))
				{
					BlitPicHighlight(
						&gGraphicsDevice,
						&pics.Pics[i], pos, color);
				}
			}
		}
	}
}
Beispiel #3
0
int CheckMissionObjective(int flags)
{
	int index;

	if (TileItemIsObjective(flags)) {
		index = ObjectiveFromTileItem(flags);
		gMission.objectives[index].done++;
		return 1;
	}
	return 0;
}
Beispiel #4
0
static void DrawObjectiveName(
	const TTileItem *ti, DrawBuffer *b, const Vec2i offset)
{
	const int objective = ObjectiveFromTileItem(ti->flags);
	const Objective *o =
		CArrayGet(&gMission.missionData->Objectives, objective);
	const char *typeName = ObjectiveTypeStr(o->Type);
	const Vec2i textPos = Vec2iNew(
		ti->x - b->xTop + offset.x - FontStrW(typeName) / 2,
		ti->y - b->yTop + offset.y);
	FontStr(typeName, textPos);
}
Beispiel #5
0
static void DrawObjectiveCompass(
	GraphicsDevice *g, Vec2i playerPos, Rect2i r, bool showExit)
{
	// Draw exit position
	if (showExit)
	{
		DrawCompassArrow(
			g, r, MapGetExitPos(&gMap), playerPos, colorGreen, "Exit");
	}

	// Draw objectives
	Map *map = &gMap;
	Vec2i tilePos;
	for (tilePos.y = 0; tilePos.y < map->Size.y; tilePos.y++)
	{
		for (tilePos.x = 0; tilePos.x < map->Size.x; tilePos.x++)
		{
			Tile *tile = MapGetTile(map, tilePos);
			for (int i = 0; i < (int)tile->things.size; i++)
			{
				TTileItem *ti =
					ThingIdGetTileItem(CArrayGet(&tile->things, i));
				if (!(ti->flags & TILEITEM_OBJECTIVE))
				{
					continue;
				}
				int objective = ObjectiveFromTileItem(ti->flags);
				MissionObjective *mo =
					CArrayGet(&gMission.missionData->Objectives, objective);
				if (mo->Flags & OBJECTIVE_HIDDEN)
				{
					continue;
				}
				if (!(mo->Flags & OBJECTIVE_POSKNOWN) &&
					!tile->isVisited)
				{
					continue;
				}
				const ObjectiveDef *o =
					CArrayGet(&gMission.Objectives, objective);
				color_t color = o->color;
				DrawCompassArrow(
					g, r, Vec2iNew(ti->x, ti->y), playerPos, color, NULL);
			}
		}
	}
}
Beispiel #6
0
void UpdateMissionObjective(
	struct MissionOptions *options, int flags, ObjectiveType type,
	int player, Vec2i pos)
{
	if (!(flags & TILEITEM_OBJECTIVE))
	{
		return;
	}
	int idx = ObjectiveFromTileItem(flags);
	MissionObjective *mobj = CArrayGet(&options->missionData->Objectives, idx);
	if (mobj->Type != type)
	{
		return;
	}
	GameEvent e;
	e.Type = GAME_EVENT_UPDATE_OBJECTIVE;
	e.u.UpdateObjective.ObjectiveIndex = idx;
	e.u.UpdateObjective.Update = 1;
	e.u.UpdateObjective.PlayerIndex = player;
	e.u.UpdateObjective.Pos = pos;
	GameEventsEnqueue(&gGameEvents, e);
}
Beispiel #7
0
void DisplayAutoMap(int showAll)
{
	int x, y, i, j;
	TTile *tile;
	unsigned char *p;
	unsigned char *screen;
	TTileItem *t;
	int cmd1, cmd2;
	int obj;

	screen = p = GetDstScreen();
	for (x = 0; x < SCREEN_MEMSIZE; x++)
		p[x] = tableGreen[p[x] & 0xFF];

	screen += MAP_YOFFS * SCREEN_WIDTH + MAP_XOFFS;
	for (y = 0; y < YMAX; y++)
		for (i = 0; i < MAP_FACTOR; i++) {
			for (x = 0; x < XMAX; x++)
				if (AutoMap(x, y) || showAll) {
					tile = &Map(x, y);
					for (j = 0; j < MAP_FACTOR; j++)
						if ((tile->flags & IS_WALL) != 0)
							*screen++ = WALL_COLOR;
						else if ((tile->flags & NO_WALK)
							 != 0)
							*screen++ = DoorColor(x, y);
						else
							*screen++ = FLOOR_COLOR;
				} else
					screen += MAP_FACTOR;
			screen += SCREEN_WIDTH - XMAX * MAP_FACTOR;
		}

	for (y = 0; y < YMAX; y++)
		for (x = 0; x < XMAX; x++) {
			t = Map(x, y).things;
			while (t) {
				if ((t->flags & TILEITEM_OBJECTIVE) != 0) {
					obj =
					    ObjectiveFromTileItem(t->
								  flags);
					if ((gMission.missionData->
					     objectives[obj].
					     flags & OBJECTIVE_HIDDEN) == 0
					    || showAll) {
						if ((gMission.missionData->
						     objectives[obj].
						     flags &
						     OBJECTIVE_POSKNOWN) !=
						    0 || AutoMap(x, y)
						    || showAll)
							DisplayObjective(t,
									 obj);
					}
				} else if (t->kind == KIND_OBJECT && t->data && AutoMap(x, y)) {
					TObject *o = t->data;

					if (o->objectIndex == OBJ_KEYCARD_RED)
						DrawDot(t, RED_DOOR_COLOR);
					else if (o->objectIndex == OBJ_KEYCARD_BLUE)
						DrawDot(t, BLUE_DOOR_COLOR);
					else if (o->objectIndex == OBJ_KEYCARD_GREEN)
						DrawDot(t, GREEN_DOOR_COLOR);
					else if (o->objectIndex ==  OBJ_KEYCARD_YELLOW)
						DrawDot(t, YELLOW_DOOR_COLOR);
				}

				t = t->next;
			}
		}


	DisplayPlayer(gPlayer1);
	DisplayPlayer(gPlayer2);

	DisplayExit();
	DisplaySummary();

	CopyToScreen();

	if (!showAll) {
		do {
			cmd1 = cmd2 = 0;
			GetPlayerCmd(gPlayer1 ? &cmd1 : NULL,
				     gPlayer2 ? &cmd2 : NULL);
		}
		while (((cmd1 | cmd2) & CMD_BUTTON3) != 0 || KeyDown(gOptions.mapKey));
		memset(GetDstScreen(), 0, SCREEN_MEMSIZE);
	}
}