示例#1
0
void SoldierInSectorIncompaciated( SOLDIERTYPE *pSoldier, INT16 sGridNo )
{
	INT16 sWorldX, sWorldY;
	UINT8	ubNewDirection;
	INT16 sGoodGridNo;

	if ( !pSoldier->bInSector )
	{
		return;
	}

	// OK, look for sutable placement....
	sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, STAND_FALLFORWARD_STOP, sGridNo, 5, &ubNewDirection, FALSE );

	sWorldX = CenterX( sGoodGridNo );
	sWorldY = CenterY( sGoodGridNo );

	EVENT_SetSoldierPosition( pSoldier, sWorldX, sWorldY );

	EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
	EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );

	//pSoldier->bDesiredDirection = pSoldier->bDirection;

	EVENT_InitNewSoldierAnim( pSoldier, STAND_FALLFORWARD_STOP, 1, TRUE );
}
示例#2
0
void SoldierInSectorRepair( SOLDIERTYPE *pSoldier, INT16 sGridNo )
{
	INT16 sWorldX, sWorldY;
	UINT8	ubNewDirection;
	INT16 sGoodGridNo;

	if ( !pSoldier->bInSector )
	{
		return;
	}

	// OK, look for sutable placement....
	sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, BEING_REPAIRMAN, sGridNo, 5, &ubNewDirection, FALSE );

	sWorldX = CenterX( sGoodGridNo );
	sWorldY = CenterY( sGoodGridNo );

	EVENT_SetSoldierPosition( pSoldier, sWorldX, sWorldY );

	EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
	EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );

	//pSoldier->bDesiredDirection = pSoldier->bDirection;

	if ( !IS_MERC_BODY_TYPE( pSoldier ) )
	{
		EVENT_InitNewSoldierAnim( pSoldier, STANDING, 1, TRUE );
	}
	else
	{
		EVENT_InitNewSoldierAnim( pSoldier, BEING_REPAIRMAN, 1, TRUE );
	}
}
示例#3
0
/**
 * This fills in the fields of the New proto based on the
 * fields of the Old proto.
 *
 * @param New new proto to be filled in
 * @param Old old proto to be converted
 * 
 *  Globals: none
 * 
 * Exceptions: none
 * History: Mon Nov 26 09:45:39 1990, DSJ, Created.
 */
void MakeNewFromOld(PROTO New, PROTOTYPE *Old) {
  New->X = CenterX(Old->Mean);
  New->Y = CenterY(Old->Mean);
  New->Length = LengthOf(Old->Mean);
  New->Angle = OrientationOf(Old->Mean);
  FillABC(New);
} /* MakeNewFromOld */
/*----------------------------------------------------------------------------
						Public Code
-----------------------------------------------------------------------------*/
void DisplayProtoList(const char* ch, LIST protolist) {
  void* window = c_create_window("Char samples", 50, 200,
                                 520, 520, -130.0, 130.0, -130.0, 130.0);
  LIST proto = protolist;
  iterate(proto) {
    PROTOTYPE* prototype = reinterpret_cast<PROTOTYPE *>(first_node(proto));
    if (prototype->Significant)
      c_line_color_index(window, Green);
    else if (prototype->NumSamples == 0)
      c_line_color_index(window, Blue);
    else if (prototype->Merged)
      c_line_color_index(window, Magenta);
    else
      c_line_color_index(window, Red);
    float x = CenterX(prototype->Mean);
    float y = CenterY(prototype->Mean);
    double angle = OrientationOf(prototype->Mean) * 2 * M_PI;
    float dx = static_cast<float>(LengthOf(prototype->Mean) * cos(angle) / 2);
    float dy = static_cast<float>(LengthOf(prototype->Mean) * sin(angle) / 2);
    c_move(window, (x - dx) * 256, (y - dy) * 256);
    c_draw(window, (x + dx) * 256, (y + dy) * 256);
    if (prototype->Significant)
      tprintf("Green proto at (%g,%g)+(%g,%g) %d samples\n",
              x, y, dx, dy, prototype->NumSamples);
    else if (prototype->NumSamples > 0 && !prototype->Merged)
      tprintf("Red proto at (%g,%g)+(%g,%g) %d samples\n",
              x, y, dx, dy, prototype->NumSamples);
  }
  c_make_current(window);
}
示例#5
0
static int MainMenu(int x, int index, int cmd)
{
	int i;
	int y;
	static int selection[2] = { MODE_DONE, MODE_DONE };

	if (cmd & (CMD_BUTTON1 | CMD_BUTTON2)) {
		PlaySound(SND_BANG, 0, 255);
		return selection[index];
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (selection[index] > MODE_SELECTNAME) {
			selection[index]--;
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == MODE_SELECTNAME) {
			selection[index] = MODE_DONE;
			PlaySound(SND_SWITCH, 0, 255);
		}
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (selection[index] < MODE_DONE) {
			selection[index]++;
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == MODE_DONE) {
			selection[index] = MODE_SELECTNAME;
			PlaySound(SND_SWITCH, 0, 255);				
		}
	}

	y = CenterY((TextHeight() * MENU_COUNT));

	for (i = 1; i < MENU_COUNT; i++)
		DisplayMenuItem(x, y + i * TextHeight(), mainMenu[i],
				selection[index] == i);

	return MODE_MAIN;
}
示例#6
0
static int TemplateSelection(int loadFlag, int x, int index,
			     struct PlayerData *data, int cmd)
{
	int i;
	int y;
	static int selection[2] = { 0, 0 };

	if (cmd & CMD_BUTTON1)
	{
		if (loadFlag)
		{
			UseTemplate(index, data, &templates[selection[index]]);
		}
		else
		{
			SaveTemplate(data, &templates[selection[index]]);
		}
		SoundPlay(&gSoundDevice, rand() % SND_COUNT);
		return 0;
	}
	else if (cmd & CMD_BUTTON2)
	{
		SoundPlay(&gSoundDevice, rand() % SND_COUNT);
		return 0;
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (selection[index] > 0) {
			selection[index]--;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (selection[index] == 0)
		{
			selection[index] = MAX_TEMPLATE - 1;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (selection[index] < MAX_TEMPLATE - 1) {
			selection[index]++;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (selection[index] == MAX_TEMPLATE - 1)
		{
			selection[index] = 0;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
	}

	y = CenterY((CDogsTextHeight() * MAX_TEMPLATE));

	if (!loadFlag) {
		CDogsTextStringAt(x, y - 4 - CDogsTextHeight(), "Save ");
		CDogsTextString(data->name);
		CDogsTextString("...");
	}

	for (i = 0; i < MAX_TEMPLATE; i++)
		DisplayMenuItem(x, y + i * CDogsTextHeight(),
				templates[i].name, i == selection[index]);

	return 1;
}
示例#7
0
文件: Player.cpp 项目: Beulard/beul
void Player::DropWeapon(World& w){
    if(weapon != NULL){
        w.map->AddItem(weapon->GetID(), CenterX(), CenterY());
        delete weapon;

        weapon = NULL;
    }
}
示例#8
0
static int AppearanceSelection(const char **menu, int menuCount,
			       int x, int index,
			       struct PlayerData *data, int *property,
			       int cmd, int *selection)
{
	int y;
	int i;

	debug(D_NORMAL, "\n");

	if (cmd & (CMD_BUTTON1 | CMD_BUTTON2))
	{
		SoundPlay(&gSoundDevice, SND_MACHINEGUN);
		return 0;
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (selection[index] > 0) {
			selection[index]--;
			*property = selection[index];
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (selection[index] == 0)
		{
			selection[index] = menuCount - 1;
			*property = selection[index];
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (selection[index] < menuCount - 1) {
			selection[index]++;
			*property = selection[index];
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (selection[index] == menuCount - 1)
		{
			selection[index] = 0;
			*property = selection[index];
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
	}

	SetPlayer(index, data);

	y = CenterY((menuCount * CDogsTextHeight()));

	for (i = 0; i < menuCount; i++)
		DisplayMenuItem(x, y + i * CDogsTextHeight(), menu[i],
				i == selection[index]);

	return 1;
}
示例#9
0
void InternalSoldierInSectorSleep( SOLDIERTYPE *pSoldier, INT16 sGridNo, BOOLEAN fDoTransition )
{
	INT16 sWorldX, sWorldY;
	UINT8	ubNewDirection;
	INT16 sGoodGridNo;
	UINT16	usAnim = SLEEPING;

	if ( !pSoldier->bInSector )
	{
		return;
	}

	if ( AM_AN_EPC( pSoldier ) )
	{
	   usAnim = STANDING;
	}

	// OK, look for sutable placement....
	sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, usAnim, sGridNo, 5, &ubNewDirection, FALSE );

	sWorldX = CenterX( sGoodGridNo );
	sWorldY = CenterY( sGoodGridNo );

	EVENT_SetSoldierPosition( pSoldier, sWorldX, sWorldY );

	EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
	EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );

	//pSoldier->bDesiredDirection = pSoldier->bDirection;

	if ( AM_AN_EPC( pSoldier ) )
	{
		EVENT_InitNewSoldierAnim( pSoldier, STANDING, 1, TRUE );
	}
	else
	{
		if ( fDoTransition )
		{
			EVENT_InitNewSoldierAnim( pSoldier, GOTO_SLEEP, 1, TRUE );
		}
		else
		{
			EVENT_InitNewSoldierAnim( pSoldier, SLEEPING, 1, TRUE );
		}
	}
}
示例#10
0
static int BodyPartSelection(int x, int index, struct PlayerData *data,
			     int cmd, int *property, int *selection)
{
	int i;
	int y;

	if (cmd & (CMD_BUTTON1 | CMD_BUTTON2))
	{
		SoundPlay(&gSoundDevice, SND_POWERGUN);
		return 0;
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (*selection > 0) {
			(*selection)--;
			*property = IndexToShade(*selection);
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (*selection == 0)
		{
			(*selection) = PLAYER_BODY_COUNT - 1;
			*property = IndexToShade(*selection);
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (*selection < PLAYER_BODY_COUNT - 1) {
			(*selection)++;
			*property = IndexToShade(*selection);
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (*selection == PLAYER_BODY_COUNT - 1)
		{
			(*selection) = 0;
			*property = IndexToShade(*selection);
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
	}

	y = CenterY((PLAYER_BODY_COUNT * CDogsTextHeight()));

	SetPlayer(index, data);
	for (i = 0; i < PLAYER_BODY_COUNT; i++)
		DisplayMenuItem(x, y + i * CDogsTextHeight(), shadeNames[i],
				i == *selection);

	return 1;
}
示例#11
0
/*---------------------------------------------------------------------------*/
void MakeNewFromOld(PROTO New, PROTOTYPE *Old) {
/*
**  Parameters:
**    New new proto to be filled in
**    Old old proto to be converted
**  Globals: none
**  Operation: This fills in the fields of the New proto based on the
**    fields of the Old proto.
**  Return: none
**  Exceptions: none
**  History: Mon Nov 26 09:45:39 1990, DSJ, Created.
*/
  New->X = CenterX(Old->Mean);
  New->Y = CenterY(Old->Mean);
  New->Length = LengthOf(Old->Mean);
  New->Angle = OrientationOf(Old->Mean);
  FillABC(New);
} /* MakeNewFromOld */
示例#12
0
BOOLEAN TeleportSoldier( SOLDIERTYPE *pSoldier, INT16 sGridNo, BOOLEAN fForce )
{
	INT16 sX, sY;

	// Check dest...
	if ( NewOKDestination( pSoldier, sGridNo, TRUE, 0 ) || fForce )
	{
		// TELEPORT TO THIS LOCATION!
		sX = CenterX( sGridNo );
		sY = CenterY( sGridNo );
		EVENT_SetSoldierPosition( pSoldier, (FLOAT) sX, (FLOAT) sY );	

		pSoldier->sFinalDestination = sGridNo;

		// Make call to FOV to update items...
		RevealRoofsAndItems(pSoldier, TRUE, TRUE, pSoldier->bLevel, TRUE );
	
		// Handle sight!
		HandleSight(pSoldier,SIGHT_LOOK | SIGHT_RADIO);

		// Cancel services...
		GivingSoldierCancelServices( pSoldier );

		// Change light....
		if ( pSoldier->bLevel == 0 )
		{
			if(pSoldier->iLight!=(-1))
				LightSpriteRoofStatus(pSoldier->iLight, FALSE );
		}
		else
		{
			if(pSoldier->iLight!=(-1))
				LightSpriteRoofStatus(pSoldier->iLight, TRUE );
		}
		return( TRUE );
	}

	return( FALSE );
}
示例#13
0
// Add smoke to gridno
// ( Replacement algorithm uses distance away )
void AddSmokeEffectToTile( INT32 iSmokeEffectID, INT8 bType, INT16 sGridNo, INT8 bLevel )
{
    ANITILE_PARAMS	AniParams;
    ANITILE					*pAniTile;
    SMOKEEFFECT     *pSmoke;
    BOOLEAN         fDissipating = FALSE;

    pSmoke = &gSmokeEffectData[ iSmokeEffectID ];

    if ( ( pSmoke->ubDuration - pSmoke->bAge ) < 2 )
    {
        fDissipating = TRUE;
        // Remove old one...
        RemoveSmokeEffectFromTile( sGridNo, bLevel );
    }


    // If smoke effect exists already.... stop
    if ( gpWorldLevelData[ sGridNo ].ubExtFlags[ bLevel ] & ANY_SMOKE_EFFECT )
    {
        return;
    }

    // OK,  Create anitile....
    memset( &AniParams, 0, sizeof( ANITILE_PARAMS ) );
    AniParams.sGridNo							= sGridNo;

    if ( bLevel == 0 )
    {
        AniParams.ubLevelID						= ANI_STRUCT_LEVEL;
    }
    else
    {
        AniParams.ubLevelID						= ANI_ONROOF_LEVEL;
    }


    AniParams.sDelay							= (INT16)( 300 + Random( 300 ) );

    if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
    {
        AniParams.sStartFrame					= (INT16)0;
    }
    else
    {
        AniParams.sStartFrame					= (INT16)Random( 5 );
    }


    // Bare bones flags are...
//	AniParams.uiFlags							= ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_OPTIMIZEFORSMOKEEFFECT | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING;
    //AniParams.uiFlags							= ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING;


    if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
    {
        AniParams.uiFlags	= ANITILE_PAUSED | ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING;
    }
    else
    {
        AniParams.uiFlags	= ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING | ANITILE_ALWAYS_TRANSLUCENT;
    }

    AniParams.sX									= CenterX( sGridNo );
    AniParams.sY									= CenterY( sGridNo );
    AniParams.sZ									= (INT16)0;

    // Use the right graphic based on type..
    switch( bType )
    {
    case NORMAL_SMOKE_EFFECT:

        if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
        {
            strcpy( AniParams.zCachedFile, "TILECACHE\\smkechze.STI" );
        }
        else
        {
            if ( fDissipating )
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\smalsmke.STI" );
            }
            else
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\SMOKE.STI" );
            }
        }
        break;

    case TEARGAS_SMOKE_EFFECT:

        if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
        {
            strcpy( AniParams.zCachedFile, "TILECACHE\\tearchze.STI" );
        }
        else
        {
            if ( fDissipating )
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\smaltear.STI" );
            }
            else
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\TEARGAS.STI" );
            }
        }
        break;

    case MUSTARDGAS_SMOKE_EFFECT:

        if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
        {
            strcpy( AniParams.zCachedFile, "TILECACHE\\mustchze.STI" );
        }
        else
        {
            if ( fDissipating )
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\smalmust.STI" );
            }
            else
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\MUSTARD2.STI" );
            }
        }
        break;

    case CREATURE_SMOKE_EFFECT:

        if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
        {
            strcpy( AniParams.zCachedFile, "TILECACHE\\spit_gas.STI" );
        }
        else
        {
            if ( fDissipating )
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\spit_gas.STI" );
            }
            else
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\spit_gas.STI" );
            }
        }
        break;

    }

    // Create tile...
    pAniTile = CreateAnimationTile( &AniParams );

    // Set world flags
    gpWorldLevelData[ sGridNo ].ubExtFlags[ bLevel ] |= FromSmokeTypeToWorldFlags( bType );

    // All done...

    // Re-draw..... :(
    SetRenderFlags(RENDER_FLAG_FULL);
}
示例#14
0
static int WeaponSelection(int x, int index, struct PlayerData *data,
			   int cmd, int done)
{
	int i;
	int y;
	static int selection[2] = { 0, 0 };

	debug(D_VERBOSE, "\n");

	if (selection[index] > gMission.weaponCount)
		selection[index] = gMission.weaponCount;

	if (cmd & CMD_BUTTON1)
	{
		if (selection[index] == gMission.weaponCount)
		{
			SoundPlay(&gSoundDevice, SND_KILL2);
			return data->weaponCount > 0 ? 0 : 1;
		}

		if (data->weaponCount < MAX_WEAPONS) {
			for (i = 0; i < data->weaponCount; i++)
				if (data->weapons[i] == gMission.availableWeapons[selection[index]])
					return 1;

			data->weapons[data->weaponCount] = gMission.availableWeapons[selection[index]];
			data->weaponCount++;

			SoundPlay(&gSoundDevice, SND_SHOTGUN);
		}
		else
		{
			SoundPlay(&gSoundDevice, SND_KILL);
		}
	} else if (cmd & CMD_BUTTON2) {
		if (data->weaponCount) {
			data->weaponCount--;
			SoundPlay(&gSoundDevice, SND_PICKUP);
			done = 0;
		}
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (selection[index] > 0) {
			selection[index]--;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (selection[index] == 0)
		{
			selection[index] = gMission.weaponCount;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		done = 0;
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (selection[index] < gMission.weaponCount) {
			selection[index]++;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (selection[index] == gMission.weaponCount)
		{
			selection[index] = 0;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		done = 0;
	}

	if (!done) {
		y = CenterY((CDogsTextHeight() * gMission.weaponCount));

		for (i = 0; i < gMission.weaponCount; i++)
		{
			DisplayMenuItem(
				x,
				y + i * CDogsTextHeight(),
				gGunDescriptions[gMission.availableWeapons[i]].gunName,
				i == selection[index]);
		}

		DisplayMenuItem(x, y + i * CDogsTextHeight(), endChoice, i == selection[index]);
	}

	return !done;
}
示例#15
0
int SelectOptions(int cmd)
{
	static int index = 0;
	char s[10];
	int x, y;

	if (cmd == CMD_ESC)
		return MODE_MAIN;
	if (AnyButton(cmd) || Left(cmd) || Right(cmd)) {
		switch (index) {
		case 0:
			gOptions.playersHurt = !gOptions.playersHurt;
			PlaySound(SND_KILL, 0, 255);
			break;
		case 1:
			gOptions.displayFPS = !gOptions.displayFPS;
			PlaySound(SND_FLAMER, 0, 255);
			break;
		case 2:
			gOptions.displayTime = !gOptions.displayTime;
			PlaySound(SND_LAUNCH, 0, 255);
			break;
		case 3:
			if (gOptions.copyMode == COPY_REPMOVSD)
				gOptions.copyMode = COPY_DEC_JNZ;
			else
				gOptions.copyMode = COPY_REPMOVSD;
			PlaySound(SND_EXPLOSION, 0, 255);
			break;
		case 4:
			if (Left(cmd) && gOptions.brightness > -10)
				gOptions.brightness--;
			else if (Right(cmd) && gOptions.brightness < 10)
				gOptions.brightness++;
			else
				break;

			PlaySound(SND_POWERGUN, 0, 255);
			PaletteAdjust();
			break;
		case 5:
			if (gOptions.xSplit == 0) {
				gOptions.xSplit = SPLIT_X;
				gOptions.ySplit = SPLIT_Y;
			} else {
				gOptions.xSplit = gOptions.ySplit = 0;
			}

			PlaySound(SND_KILL3, 0, 255);

			break;
		case 6:
			if (Left(cmd)) {
				if (Button1(cmd) && Button2(cmd))
					gCampaign.seed -= 1000;
				else if (Button1(cmd))
					gCampaign.seed -= 10;
				else if (Button2(cmd))
					gCampaign.seed -= 100;
				else
					gCampaign.seed--;
			} else if (Right(cmd)) {
				if (Button1(cmd) && Button2(cmd))
					gCampaign.seed += 1000;
				else if (Button1(cmd))
					gCampaign.seed += 10;
				else if (Button2(cmd))
					gCampaign.seed += 100;
				else
					gCampaign.seed++;
			}

			break;
		case 7:
			if (Left(cmd)) {
				if (gOptions.difficulty > DIFFICULTY_VERYEASY)
						gOptions.difficulty--;
			} else if (Right(cmd)) {
				if (gOptions.difficulty < DIFFICULTY_VERYHARD)
						gOptions.difficulty++;
			}

			if (gOptions.difficulty > DIFFICULTY_VERYHARD) gOptions.difficulty = DIFFICULTY_VERYHARD;
			if (gOptions.difficulty < DIFFICULTY_VERYEASY) gOptions.difficulty = DIFFICULTY_VERYEASY;

			break;
		case 8:
			gOptions.slowmotion = !gOptions.slowmotion;

			break;
		case 9:
			if (Left(cmd)) {
				if (gOptions.density > 25)
					gOptions.density -= 25;
			} else if (Right(cmd)) {
				if (gOptions.density < 200)
					gOptions.density += 25;
			}

			break;
		case 10:
			if (Left(cmd)) {
				if (gOptions.npcHp > 25)
					gOptions.npcHp -= 25;
			} else if (Right(cmd)) {
				if (gOptions.npcHp < 200)
					gOptions.npcHp += 25;
			}

			break;
		case 11:
			if (Left(cmd)) {
				if (gOptions.playerHp > 25)
					gOptions.playerHp -= 25;
			} else if (Right(cmd)) {
				if (gOptions.playerHp < 200)
					gOptions.playerHp += 25;
			}

			break;
		case 12:
			Gfx_HintToggle(HINT_FULLSCREEN);
			InitVideo();

			break;

		case 13:
			{
				GFX_Mode *m = NULL;

				if (Left(cmd)) {
					m = Gfx_ModePrev();
				} else if (Right(cmd)) {
					m = Gfx_ModeNext();
				}

				if (m) {
					debug(D_NORMAL, "new mode? %d x %d\n", m->w, m->h);
					Gfx_SetHint(HINT_WIDTH, m->w);
					Gfx_SetHint(HINT_HEIGHT, m->h);
				}
			}

			break;

		case 14:
			{
				int fac = Gfx_GetHint(HINT_SCALEFACTOR);

				if (Left(cmd)) {
					fac--;
				} else if (Right(cmd)) {
					fac++;
				}

				if (fac >= 1 && fac <= 4) {
					Gfx_SetHint(HINT_SCALEFACTOR, (const int)fac);
					InitVideo();
				}
			}

			break;

		default:
			PlaySound(SND_BANG, 0, 255);

			return MODE_MAIN;
		}
	}

	if (Up(cmd)) {
		index--;
		if (index < 0)
			index = OPTIONS_COUNT - 1;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (Down(cmd)) {
		index++;
		if (index >= OPTIONS_COUNT)
			index = 0;
		PlaySound(SND_SWITCH, 0, 255);
	}

	TextStringSpecial("Game Options:", TEXT_XCENTER | TEXT_TOP, 0, (SCREEN_WIDTH / 12));
	
	x = CenterX(MenuWidth(optionsMenu, OPTIONS_COUNT));
	y = CenterY(MenuHeight(optionsMenu, OPTIONS_COUNT));
	
	DisplayMenuAt(x - 20, y, optionsMenu, OPTIONS_COUNT, index);

	x += MenuWidth(optionsMenu, OPTIONS_COUNT);
	x += 10;
	
	TextStringAt(x, y, gOptions.playersHurt ? "Yes" : "No");
	TextStringAt(x, y + TextHeight(),
		     gOptions.displayFPS ? "On" : "Off");
	TextStringAt(x, y + 2 * TextHeight(),
		     gOptions.displayTime ? "On" : "Off");
	TextStringAt(x, y + 3 * TextHeight(),
		     gOptions.copyMode ==
		     COPY_REPMOVSD ? "rep movsd" : "dec/jnz");
	sprintf(s, "%d", gOptions.brightness);
	TextStringAt(x, y + 4 * TextHeight(), s);
	TextStringAt(x, y + 5 * TextHeight(),
		     gOptions.xSplit ? "No" : "Yes");
	sprintf(s, "%u", gCampaign.seed);
	TextStringAt(x, y + 6 * TextHeight(), s);

	switch (gOptions.difficulty) {
		case DIFFICULTY_VERYEASY:
			strcpy(s, "Easiest");
			break;
		case DIFFICULTY_EASY:
			strcpy(s, "Easy");
			break;
		case DIFFICULTY_HARD:
			strcpy(s, "Hard");
			break;
		case DIFFICULTY_VERYHARD:
			strcpy(s, "Very hard");
			break;
		default:
			strcpy(s, "Normal");
			break;
	}

	TextStringAt(x, y + 7 * TextHeight(), s);
	TextStringAt(x, y + 8 * TextHeight(),
		     gOptions.slowmotion ? "Yes" : "No");
	sprintf(s, "%u%%", gOptions.density);
	TextStringAt(x, y + 9 * TextHeight(), s);
	sprintf(s, "%u%%", gOptions.npcHp);
	TextStringAt(x, y + 10 * TextHeight(), s);
	sprintf(s, "%u%%", gOptions.playerHp);
	TextStringAt(x, y + 11 * TextHeight(), s);
	sprintf(s, "%s", Gfx_GetHint(HINT_FULLSCREEN) ? "Yes" : "No");
	TextStringAt(x, y + 12 * TextHeight(), s);
	sprintf(s, "%dx%d", Gfx_GetHint(HINT_WIDTH), Gfx_GetHint(HINT_HEIGHT));
	TextStringAt(x, y + 13 * TextHeight(), s);
	sprintf(s, "%dx", Gfx_GetHint(HINT_SCALEFACTOR));
	TextStringAt(x, y + 14 * TextHeight(), s);


	return MODE_OPTIONS;
}
示例#16
0
static int NameSelection(int x, int index, struct PlayerData *data,
			 int cmd)
{
	int i;
	int y;

	//char s[2];
	static char letters[] =
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ !#?:.-0123456789";
	static char smallLetters[] =
		"abcdefghijklmnopqrstuvwxyz !#?:.-0123456789";
	static int selection[2] = { -1, -1 };

	// Kludge since Watcom won't let me initialize selection with a strlen()
	if (selection[0] < 0)
		selection[0] = selection[1] = strlen(letters);

	if (cmd & CMD_BUTTON1)
	{
		if (selection[index] == (int)strlen(letters))
		{
			SoundPlay(&gSoundDevice, SND_LAUNCH);
			return 0;
		}

		if (strlen(data->name) < sizeof(data->name) - 1) {
			int l = strlen(data->name);
			data->name[l + 1] = 0;
			if (l > 0 && data->name[l - 1] != ' ')
				data->name[l] =
				    smallLetters[selection[index]];
			else
				data->name[l] = letters[selection[index]];
			SoundPlay(&gSoundDevice, SND_MACHINEGUN);
		}
		else
		{
			SoundPlay(&gSoundDevice, SND_KILL);
		}
	}
	else if (cmd & CMD_BUTTON2)
	{
		if (data->name[0]) {
			data->name[strlen(data->name) - 1] = 0;
			SoundPlay(&gSoundDevice, SND_BANG);
		}
		else
		{
			SoundPlay(&gSoundDevice, SND_KILL);
		}
	}
	else if (cmd & CMD_LEFT)
	{
		if (selection[index] > 0)
		{
			selection[index]--;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	}
	else if (cmd & CMD_RIGHT)
	{
		if (selection[index] < (int)strlen(letters))
		{
			selection[index]++;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	} else if (cmd & CMD_UP) {
		if (selection[index] > 9) {
			selection[index] -= 10;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	}
	else if (cmd & CMD_DOWN)
	{
		if (selection[index] < (int)strlen(letters) - 9)
		{
			selection[index] += 10;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
		else if (selection[index] < (int)strlen(letters))
		{
			selection[index] = strlen(letters);
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	}

	#define ENTRY_COLS	10
	#define	ENTRY_SPACING	12

	y = CenterY(((CDogsTextHeight() * ((strlen(letters) - 1) / ENTRY_COLS) )));

	if (gOptions.twoPlayers && index == CHARACTER_PLAYER1)
	{
		x = CenterOf(
			0,
			gGraphicsDevice.cachedConfig.ResolutionWidth / 2
			,
			(ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a'));
	}
	else if (gOptions.twoPlayers && index == CHARACTER_PLAYER2)
	{
		x = CenterOf(
			gGraphicsDevice.cachedConfig.ResolutionWidth / 2,
			gGraphicsDevice.cachedConfig.ResolutionWidth,
			(ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a'));
	}
	else
	{
		x = CenterX((ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a'));
	}

	// Draw selection

	//s[1] = 0;
	for (i = 0; i < (int)strlen(letters); i++)
	{
		//s[0] = letters[i];

		CDogsTextGoto(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			 y + (i / ENTRY_COLS) * CDogsTextHeight());

		if (i == selection[index])
			CDogsTextCharWithTable(letters[i], &tableFlamed);
		else
			CDogsTextChar(letters[i]);
/*
		DisplayMenuItem(x + (i % 10) * 12,
				80 + (i / 10) * CDogsTextHeight(), s,
				i == selection[index]);
*/
	}

	DisplayMenuItem(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			y + (i / ENTRY_COLS) * CDogsTextHeight(),
			endChoice, i == selection[index]);

	return 1;
}
示例#17
0
int SelectControls(int cmd)
{
	static int index = 0;
	int x, y;

	if (cmd == CMD_ESC)
		return MODE_MAIN;
	if (AnyButton(cmd) || Left(cmd) || Right(cmd)) {
		PlaySound(rand() % SND_COUNT, 0, 255);
		switch (index) {
		case 0:
			ChangeControl(&gPlayer1Data, &gPlayer2Data);
			break;

		case 1:
			ChangeControl(&gPlayer2Data, &gPlayer1Data);
			break;

		case 2:
			gOptions.swapButtonsJoy1 = !gOptions.swapButtonsJoy1;
			break;

		case 3:
			gOptions.swapButtonsJoy2 = !gOptions.swapButtonsJoy2;
			break;

		case 4:
			return MODE_KEYS;

		case 5:
			InitSticks();
			AutoCalibrate();
			break;

		default:
			return MODE_MAIN;
		}
	}
	if (Up(cmd)) {
		index--;
		if (index < 0)
			index = CONTROLS_COUNT - 1;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (Down(cmd)) {
		index++;
		if (index >= CONTROLS_COUNT)
			index = 0;
		PlaySound(SND_SWITCH, 0, 255);
	}

	TextStringSpecial("Configure Controls:", TEXT_XCENTER | TEXT_TOP, 0, (SCREEN_WIDTH / 12));	
	
	x = CenterX(MenuWidth(controlsMenu, CONTROLS_COUNT));
	y = CenterY(MenuHeight(controlsMenu, CONTROLS_COUNT));
	
	DisplayMenuAt(x - 20, y, controlsMenu, CONTROLS_COUNT, index);
	
	x += MenuWidth(controlsMenu, CONTROLS_COUNT);
	x += 10;

	DisplayControl(x, y, gPlayer1Data.controls);
	DisplayControl(x, y + TextHeight(), gPlayer2Data.controls);
	TextStringAt(x, y + 2 * TextHeight(), gOptions.swapButtonsJoy1 ? "Yes" : "No");
	TextStringAt(x, y + 3 * TextHeight(), gOptions.swapButtonsJoy2 ? "Yes" : "No");
	return MODE_CONTROLS;
}
示例#18
0
 const Point2 Center() const 
 { 
   return Point2(CenterX(), CenterY()); 
 }
示例#19
0
void MenuDisplaySubmenus(menu_t *menu)
{
	int i;
	int x = 0, yStart = 0;
	int maxWidth = 0;

	switch (menu->type)
	{
	// TODO: refactor the three menu types (normal, options, campaign) into one
	case MENU_TYPE_NORMAL:
	case MENU_TYPE_OPTIONS:
		{
			int isCentered = menu->type == MENU_TYPE_NORMAL;
			int xOptions;
			for (i = 0; i < menu->u.normal.numSubMenus; i++)
			{
				int width = CDogsTextWidth(menu->u.normal.subMenus[i].name);
				if (width > maxWidth)
				{
					maxWidth = width;
				}
			}
			x = CenterX(maxWidth);
			if (!isCentered)
			{
				x -= 20;
			}
			yStart = CenterY(menu->u.normal.numSubMenus * CDogsTextHeight());
			xOptions = x + maxWidth + 10;

			// Display normal menu items
			for (i = 0; i < menu->u.normal.numSubMenus; i++)
			{
				int y = yStart + i * CDogsTextHeight();
				menu_t *subMenu = &menu->u.normal.subMenus[i];

				// Display menu item
				const char *name = subMenu->name;
				if (i == menu->u.normal.index)
				{
					CDogsTextStringWithTableAt(x, y, name, &tableFlamed);
				}
				else
				{
					CDogsTextStringAt(x, y, name);
				}

				// display option value
				if (subMenu->type == MENU_TYPE_SET_OPTION_TOGGLE ||
					subMenu->type == MENU_TYPE_SET_OPTION_RANGE ||
					subMenu->type == MENU_TYPE_SET_OPTION_SEED ||
					subMenu->type == MENU_TYPE_SET_OPTION_UP_DOWN_VOID_FUNC_VOID ||
					subMenu->type == MENU_TYPE_SET_OPTION_RANGE_GET_SET ||
					subMenu->type == MENU_TYPE_SET_OPTION_CHANGE_CONTROL ||
					subMenu->type == MENU_TYPE_VOID_FUNC_VOID)
				{
					int optionInt = MenuOptionGetIntValue(subMenu);
					switch (subMenu->u.option.displayStyle)
					{
					case MENU_OPTION_DISPLAY_STYLE_INT:
						CDogsTextIntAt(xOptions, y, optionInt);
						break;
					case MENU_OPTION_DISPLAY_STYLE_YES_NO:
						CDogsTextStringAt(xOptions, y, optionInt ? "Yes" : "No");
						break;
					case MENU_OPTION_DISPLAY_STYLE_ON_OFF:
						CDogsTextStringAt(xOptions, y, optionInt ? "On" : "Off");
						break;
					case MENU_OPTION_DISPLAY_STYLE_STR_FUNC:
						CDogsTextStringAt(xOptions, y, subMenu->u.option.uFunc.str());
						break;
					case MENU_OPTION_DISPLAY_STYLE_INT_TO_STR_FUNC:
						CDogsTextStringAt(xOptions, y, subMenu->u.option.uFunc.intToStr(optionInt));
						break;
					default:
						break;
					}
				}
			}
		}
		break;
	case MENU_TYPE_CAMPAIGNS:
		{
			int y = CenterY(12 * CDogsTextHeight());

		#define ARROW_UP	"\036"
		#define ARROW_DOWN	"\037"

			if (menu->u.normal.scroll != 0)
			{
				DisplayMenuItem(
					CenterX(CDogsTextWidth(ARROW_UP)),
					y - 2 - CDogsTextHeight(),
					ARROW_UP,
					0);
			}

			for (i = menu->u.normal.scroll;
				i < MIN(menu->u.normal.scroll + 12, menu->u.normal.numSubMenus);
				i++)
			{
				int isSelected = i == menu->u.normal.index;
				menu_t *subMenu = &menu->u.normal.subMenus[i];
				const char *name = subMenu->name;
				// TODO: display subfolders
				DisplayMenuItem(
					CenterX(CDogsTextWidth(name)), y, name, isSelected);

				if (isSelected)
				{
					char s[255];
					const char *filename = subMenu->u.campaign.filename;
					int isBuiltin = subMenu->u.campaign.isBuiltin;
					sprintf(s, "( %s )", isBuiltin ? "Internal" : filename);
					CDogsTextStringSpecial(
						s,
						TEXT_XCENTER | TEXT_BOTTOM,
						0,
						gGraphicsDevice.cachedConfig.ResolutionWidth / 12);
				}

				y += CDogsTextHeight();
			}

			if (i < menu->u.normal.numSubMenus - 1)
			{
				DisplayMenuItem(
					CenterX(CDogsTextWidth(ARROW_DOWN)),
					y + 2,
					ARROW_DOWN,
					0);
			}
		}
		break;
	case MENU_TYPE_KEYS:
		{
			int xKeys;
			x = CenterX((CDogsTextCharWidth('a') * 10)) / 2;
			xKeys = x * 3;
			yStart = (gGraphicsDevice.cachedConfig.ResolutionHeight / 2) - (CDogsTextHeight() * 10);

			for (i = 0; i < menu->u.normal.numSubMenus; i++)
			{
				int y = yStart + i * CDogsTextHeight();
				int isSelected = i == menu->u.normal.index;
				menu_t *subMenu = &menu->u.normal.subMenus[i];

				const char *name = subMenu->name;
				if (isSelected &&
					subMenu->type != MENU_TYPE_SET_OPTION_CHANGE_KEY)
				{
					CDogsTextStringWithTableAt(x, y, name, &tableFlamed);
				}
				else
				{
					CDogsTextStringAt(x, y, name);
				}

				if (subMenu->type == MENU_TYPE_SET_OPTION_CHANGE_KEY)
				{
					const char *keyName;
					if (menu->u.normal.changeKeyMenu == subMenu)
					{
						keyName = "Press a key";
					}
					else if (subMenu->u.changeKey.code == KEY_CODE_MAP)
					{
						keyName = SDL_GetKeyName(gConfig.Input.PlayerKeys[0].Keys.map);
					}
					else
					{
						keyName = SDL_GetKeyName(InputGetKey(
							subMenu->u.changeKey.keys,
							subMenu->u.changeKey.code));
					}
					DisplayMenuItem(xKeys, y, keyName, isSelected);
				}
			}
		}
		break;
	default:
		assert(0);
		break;
	}
}
示例#20
0
void AddSoldierToSectorGridNo( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubDirection, BOOLEAN fUseAnimation, UINT16 usAnimState, UINT16 usAnimCode )
{
	INT16 sWorldX, sWorldY;
	INT16 sNewGridNo;
	UINT8	ubNewDirection;
	UINT8	ubInsertionCode;
	BOOLEAN fUpdateFinalPosition = TRUE;


	// Add merc to gridno
	sWorldX = CenterX( sGridNo );
	sWorldY = CenterY( sGridNo );

	// Set reserved location!
	pSoldier->sReservedMovementGridNo = NOWHERE;

	// Save OLD insertion code.. as this can change...
	ubInsertionCode = pSoldier->ubStrategicInsertionCode;

	// Remove any pending animations
	pSoldier->usPendingAnimation = NO_PENDING_ANIMATION;
	pSoldier->usPendingAnimation2 = NO_PENDING_ANIMATION;
	pSoldier->ubPendingDirection = NO_PENDING_DIRECTION;
	pSoldier->ubPendingAction		 = NO_PENDING_ACTION;

	//If we are not loading a saved game
	if( (gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
	{
		// Set final dest to be the same...
		fUpdateFinalPosition = FALSE;
	}


	// If this is a special insertion location, get path!
	if ( ubInsertionCode == INSERTION_CODE_ARRIVING_GAME )
	{
		EVENT_SetSoldierPositionAndMaybeFinalDestAndMaybeNotDestination( pSoldier, sWorldX, sWorldY, fUpdateFinalPosition, fUpdateFinalPosition );
		EVENT_SetSoldierDirection( pSoldier, ubDirection );
		EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection );
	}
	else if ( ubInsertionCode == INSERTION_CODE_CHOPPER )
	{

	}
	else
	{
		EVENT_SetSoldierPositionAndMaybeFinalDestAndMaybeNotDestination( pSoldier, sWorldX, sWorldY, fUpdateFinalPosition, fUpdateFinalPosition );

		//if we are loading, dont set the direction ( they are already set )
		if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
		{
			EVENT_SetSoldierDirection( pSoldier, ubDirection );

			EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection );
		}
	}

	if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
	{
		if ( !( pSoldier->uiStatusFlags & SOLDIER_DEAD ) )
		{
			if ( pSoldier->bTeam == gbPlayerNum )
			{
				RevealRoofsAndItems( pSoldier, TRUE, FALSE, pSoldier->bLevel, TRUE );

        // ATE: Patch fix: If we are in an non-interruptable animation, stop!
        if ( pSoldier->usAnimState == HOPFENCE )
        {
          pSoldier->fInNonintAnim = FALSE;
          SoldierGotoStationaryStance( pSoldier );
        }

				EVENT_StopMerc( pSoldier, sGridNo, ubDirection );
			}
		}

		// If just arriving, set a destination to walk into from!
		if ( ubInsertionCode == INSERTION_CODE_ARRIVING_GAME )
		{
			// Find a sweetspot near...
			sNewGridNo = FindGridNoFromSweetSpot( pSoldier, gMapInformation.sNorthGridNo, 4, &ubNewDirection );
			EVENT_GetNewSoldierPath( pSoldier, sNewGridNo, WALKING );		
		}

		// If he's an enemy... set presence
		if ( !pSoldier->bNeutral && (pSoldier->bSide != gbPlayerNum ) )
		{
      // ATE: Added if not bloodcats
      // only do this once they are seen.....
      if ( pSoldier->ubBodyType != BLOODCAT )
      {
			  SetEnemyPresence( );
      }
		}
	}

	if ( !( pSoldier->uiStatusFlags & SOLDIER_DEAD ) )
	{
		//if we are loading a 'pristine' map ( ie, not loading a saved game )
		if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
		{
			// ATE: Double check if we are on the roof that there is a roof there!
			if ( pSoldier->bLevel == 1 )
			{
				if ( !FindStructure( pSoldier->sGridNo, STRUCTURE_ROOF ) )
				{
					SetSoldierHeight( pSoldier, (FLOAT)( 0 )  );
				}
			}

			if ( ubInsertionCode != INSERTION_CODE_ARRIVING_GAME )
			{
				// default to standing on arrival
				if ( pSoldier->usAnimState != HELIDROP )
				{
					if ( fUseAnimation )
					{
						EVENT_InitNewSoldierAnim( pSoldier, usAnimState, usAnimCode, TRUE );
					}
					else if ( pSoldier->ubBodyType != CROW )
					{
						EVENT_InitNewSoldierAnim( pSoldier, STANDING, 1, TRUE );
					}
				}

				// ATE: if we are below OK life, make them lie down!
				if ( pSoldier->bLife < OKLIFE )
				{
					SoldierInSectorIncompaciated( pSoldier, pSoldier->sInsertionGridNo );
				}
				else if ( pSoldier->fMercAsleep == TRUE )
				{
					InternalSoldierInSectorSleep( pSoldier, pSoldier->sInsertionGridNo, FALSE );
				}
				else if ( pSoldier->bAssignment == PATIENT )
				{
					SoldierInSectorPatient( pSoldier, pSoldier->sInsertionGridNo );
				}
				else if ( pSoldier->bAssignment == DOCTOR )
				{
					SoldierInSectorDoctor( pSoldier, pSoldier->sInsertionGridNo );
				}
				else if ( pSoldier->bAssignment == REPAIR )
				{
					SoldierInSectorRepair( pSoldier, pSoldier->sInsertionGridNo );
				}

        // ATE: Make sure movement mode is up to date!
  			pSoldier->usUIMovementMode =  GetMoveStateBasedOnStance( pSoldier, gAnimControl[ pSoldier->usAnimState ].ubEndHeight );	

			}
		}
		else
		{
			// THIS ALL SHOULD HAVE BEEN HANDLED BY THE FACT THAT A GAME WAS LOADED

			//EVENT_InitNewSoldierAnim( pSoldier, pSoldier->usAnimState, pSoldier->usAniCode, TRUE );

			// if the merc had a final destination, get the merc walking there
			//if( pSoldier->sFinalDestination != pSoldier->sGridNo )
			//{
			//	EVENT_GetNewSoldierPath( pSoldier, pSoldier->sFinalDestination, pSoldier->usUIMovementMode );
			//}
		}
	}
}
示例#21
0
int SelectVolume(int cmd)
{
	static int index = 0;
	char s[10];
	int x, y;

	if (cmd == CMD_ESC)
		return MODE_MAIN;

	if (AnyButton(cmd) && index == VOLUME_COUNT - 1)
		return MODE_MAIN;

	if (Left(cmd)) {
		switch (index) {
			case 0:
				if (FXVolume() > 8)
					SetFXVolume(FXVolume() - 8);
				break;
			case 1:
				if (MusicVolume() > 8)
					SetMusicVolume(MusicVolume() - 8);
				break;
			case 2:
				if (FXChannels() > 2)
					SetFXChannels(FXChannels() - 2);
				break;
			case 3:
				break;
		}

		PlaySound(SND_SWITCH, 0, 255);
	} else if (Right(cmd)) {
		switch (index) {
			case 0:
				if (FXVolume() < 64)
					SetFXVolume(FXVolume() + 8);
				break;
			case 1:
				if (MusicVolume() < 64)
					SetMusicVolume(MusicVolume() + 8);
				break;
			case 2:
				if (FXChannels() < 8)
					SetFXChannels(FXChannels() + 2);
				break;
			case 3:
				break;
		}

		PlaySound(SND_SWITCH, 0, 255);
	} else if (Up(cmd)) {
		index--;

		if (index < 0)
			index = VOLUME_COUNT - 1;

		PlaySound(SND_SWITCH, 0, 255);
	} else if (Down(cmd)) {
		index++;

		if (index >= VOLUME_COUNT)
			index = 0;

		PlaySound(SND_SWITCH, 0, 255);
	}

	TextStringSpecial("Configure Sound:", TEXT_XCENTER | TEXT_TOP, 0, (SCREEN_WIDTH / 12));
	
	x = CenterX(MenuWidth(volumeMenu, VOLUME_COUNT));
	y = CenterY(MenuHeight(volumeMenu, VOLUME_COUNT));
	
	DisplayMenuAt(x - 20, y, volumeMenu, VOLUME_COUNT, index);
	
	x += MenuWidth(volumeMenu, VOLUME_COUNT);
	x += 10;	

	sprintf(s, "%d", FXVolume() / 8);
	TextStringAt(x, y, s);
	sprintf(s, "%d", MusicVolume() / 8);
	TextStringAt(x, y + TextHeight(), s);
	sprintf(s, "%d", FXChannels());
	TextStringAt(x, y + 2 * TextHeight(), s);
	TextStringAt(x, y + 3 * TextHeight(), "No");

	return MODE_VOLUME;
}
示例#22
0
int SelectCampaign(int dogFight, int cmd)
{
	static int campaignIndex = 0;
	static int dogfightIndex = 0;
	int count, x, y, i, j;
	struct FileEntry *list = dogFight ? dogfightList : campaignList;
	char *prefix = dogFight ? "dogfights/" : "missions/";
	int *index = dogFight ? &dogfightIndex : &campaignIndex;
	struct FileEntry *f;

	for (count = 0, f = list; f != NULL; f = f->next, count++);

	if (cmd == CMD_ESC)
		return MODE_MAIN;

	if (AnyButton(cmd)) {
		for (i = 0, f = list; f != NULL && i < *index;
		     f = f->next, i++);

		if (f && f->name[0]) {
			if (customSetting.missions)
				free(customSetting.missions);
			if (customSetting.characters)
				free(customSetting.characters);
			memset(&customSetting, 0, sizeof(customSetting));

			if (LoadCampaign(GetDataFilePath(join(prefix,f->name)), &customSetting, 0, 0) ==
			    CAMPAIGN_OK)
				gCampaign.setting = &customSetting;
			else
				SetupBuiltin(dogFight, 0);
		} else if (f)
			SetupBuiltin(dogFight, f->data);
		else {
			SetupBuiltin(dogFight, 0);
		}

//  gCampaign.seed = 0;
		PlaySound(SND_HAHAHA, 0, 255);
		printf(">> Entering MODE_PLAY\n");
		return MODE_PLAY;
	}
	
	if (Left(cmd) || Up(cmd)) {
		(*index)--;
		if (*index < 0)
			*index = count - 1;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (Right(cmd) || Down(cmd)) {
		(*index)++;
		if (*index >= count)
			*index = 0;
		PlaySound(SND_SWITCH, 0, 255);
	}	
	
	if (dogFight)
		TextStringSpecial("Select a dogfight scenario:", TEXT_TOP | TEXT_XCENTER, 0, (SCREEN_WIDTH / 12));
	else
		TextStringSpecial("Select a campaign:", TEXT_TOP | TEXT_XCENTER, 0, (SCREEN_WIDTH / 12));

	x = CenterX(240);
	y = CenterY(12 * TextHeight());
	
#define ARROW_UP	"\036"
#define ARROW_DOWN	"\037"
	
	for (i = 0, f = list; f != NULL && i <= *index - 12; f = f->next, i++);

	if (i)
		DisplayMenuItem(CenterX(TextWidth(ARROW_UP)), y - 2 - TextHeight(), ARROW_UP, 0);

	for (j = 0; f != NULL && j < 12; f = f->next, i++, j++) {
		DisplayMenuItem(CenterX(TextWidth(f->info)), y, f->info, i == *index);
		
		if (i == *index) {
			char s[255];

			if (strlen(f->name) == 0)
				sprintf(s, "( Internal )");
			else
				sprintf(s, "( %s )", f->name);

			TextStringSpecial(s, TEXT_XCENTER | TEXT_BOTTOM, 0, (SCREEN_WIDTH / 12));
		}
			
		y += TextHeight();
	}

	if (f)
		DisplayMenuItem(CenterX(TextWidth(ARROW_DOWN)), y + 2, ARROW_DOWN, 0);
		
	return dogFight ? MODE_DOGFIGHT : MODE_CAMPAIGN;
}
示例#23
0
void KariudoKen::_Move()
{
	SetAnim( mStatus );

	// 自機の位置を取得
	int jx = GAMECONTROL->GetJiki()->GetAtHtPointX();
	int jy = GAMECONTROL->GetJiki()->GetAtHtPointY();

	// ----当たりの処理
	MapAtHt();

	if( mStatus != SHINDA )
		Ataridp();


	switch( mStatus ){
		case ARUKI: {
			// ----自機の位置を確認
			float sax = jx - CenterX();
			float say = jy - CenterY();
			float sa = sqrt(sax*sax + say*say);

			if( sa < KARIKENKGHANI ){
				mStatus = WAIT1;
			}

			break;
		}
		
		case WAIT1:
			mSpX = 0;
			WAIT_TIMER(mKgTimer, KARIKENWTM1);
			mStatus = KOGEKI;
			WAIT_END
			break;

		case KOGEKI:
			if( mAniNoX == 2 &&  !mSeFl ){//SE
				//SE
				if( !IsGamenGai() )
					GAMECONTROL->GetSoundController()->PlaySE("audio\\se\\se_ken_atack.wav");
				mSeFl = true;
			}
			mSpX = 0;
			mMuki = CenterX() < jx;
			if( mDousaEnd ){
				mStatus = WAIT2;
				mSeFl = false;
			}
			break;
	
		case WAIT2:
			mSpX = 0;
			WAIT_TIMER(mKgTimer, KARIKENWTM2);
			mStatus = ARUKI;
			WAIT_END
			break;
	}
	
	Draw();

	mSpX += mAccX;
	mSpY += mAccY;
	mX	 += mSpX + mAshibaSpX;
	mY	 += mSpY;

	// 当たり判定のフレーム
	if( mStatus != SHINDA )
		HtFrame();
}
示例#24
0
static int NameSelection(int x, int index, struct PlayerData *data,
			 int cmd)
{
	int i;
	int y;

	char s[2];
	static char letters[] =
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ !#?:.-0123456789";
	static char smallLetters[] =
		"abcdefghijklmnopqrstuvwxyz !#?:.-0123456789";
	static int selection[2] = { -1, -1 };

	// Kludge since Watcom won't let me initialize selection with a strlen()
	if (selection[0] < 0)
		selection[0] = selection[1] = strlen(letters);

	if (cmd & CMD_BUTTON1) {
		if (selection[index] == strlen(letters)) {
			PlaySound(SND_LAUNCH, 0, 255);
			return 0;
		}

		if (strlen(data->name) < sizeof(data->name) - 1) {
			int l = strlen(data->name);
			data->name[l + 1] = 0;
			if (l > 0 && data->name[l - 1] != ' ')
				data->name[l] =
				    smallLetters[selection[index]];
			else
				data->name[l] = letters[selection[index]];
			PlaySound(SND_MACHINEGUN, 0, 255);
		} else
			PlaySound(SND_KILL, 0, 255);
	} else if (cmd & CMD_BUTTON2) {
		if (data->name[0]) {
			data->name[strlen(data->name) - 1] = 0;
			PlaySound(SND_BANG, 0, 255);
		} else
			PlaySound(SND_KILL, 0, 255);
	} else if (cmd & CMD_LEFT) {
		if (selection[index] > 0) {
			selection[index]--;
			PlaySound(SND_DOOR, 0, 255);
		}
	} else if (cmd & CMD_RIGHT) {
		if (selection[index] < strlen(letters)) {
			selection[index]++;
			PlaySound(SND_DOOR, 0, 255);
		}
	} else if (cmd & CMD_UP) {
		if (selection[index] > 9) {
			selection[index] -= 10;
			PlaySound(SND_DOOR, 0, 255);
		}
	} else if (cmd & CMD_DOWN) {
		if (selection[index] < strlen(letters) - 9) {
			selection[index] += 10;
			PlaySound(SND_DOOR, 0, 255);
		} else if (selection[index] < strlen(letters)) {
			selection[index] = strlen(letters);
			PlaySound(SND_DOOR, 0, 255);
		}
	}

	#define ENTRY_COLS	10
	#define	ENTRY_SPACING	12
	
	y = CenterY(((TextHeight() * ((strlen(letters) - 1) / ENTRY_COLS) )));

	if (gOptions.twoPlayers && index == CHARACTER_PLAYER1)
		x = CenterOf(0, (SCREEN_WIDTH / 2), ((ENTRY_SPACING * (ENTRY_COLS - 1)) + TextCharWidth('a')));
	else if (gOptions.twoPlayers && index == CHARACTER_PLAYER2)
		x = CenterOf((SCREEN_WIDTH / 2), (SCREEN_WIDTH), ((ENTRY_SPACING * (ENTRY_COLS - 1)) + TextCharWidth('a')));
	else
		x = CenterX(((ENTRY_SPACING * (ENTRY_COLS - 1)) + TextCharWidth('a')));

	// Draw selection

	s[1] = 0;
	for (i = 0; i < strlen(letters); i++) {
		s[0] = letters[i];

		TextGoto(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			 y + (i / ENTRY_COLS) * TextHeight());

		if (i == selection[index])
			TextCharWithTable(letters[i], &tableFlamed);
		else
			TextChar(letters[i]);
/*
		DisplayMenuItem(x + (i % 10) * 12,
				80 + (i / 10) * TextHeight(), s,
				i == selection[index]);
*/
	}

	DisplayMenuItem(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			y + (i / ENTRY_COLS) * TextHeight(),
			endChoice, i == selection[index]);

	return 1;
}
示例#25
0
static int WeaponSelection(int x, int index, struct PlayerData *data,
			   int cmd, int done)
{
	int i;
	int y;
	static int selection[2] = { 0, 0 };

	debug(D_NORMAL, "\n");

	if (selection[index] > gMission.weaponCount)
		selection[index] = gMission.weaponCount;

	if (cmd & CMD_BUTTON1) {
		if (selection[index] == gMission.weaponCount) {
			PlaySound(SND_KILL2, 0, 255);
			return data->weaponCount > 0 ? 0 : 1;
		}

		if (data->weaponCount < MAX_WEAPONS) {
			for (i = 0; i < data->weaponCount; i++)
				if (data->weapons[i] == gMission.availableWeapons[selection[index]])
					return 1;

			data->weapons[data->weaponCount] = gMission.availableWeapons[selection[index]];
			data->weaponCount++;

			PlaySound(SND_SHOTGUN, 0, 255);
		} else {
			PlaySound(SND_KILL, 0, 255);
		}
	} else if (cmd & CMD_BUTTON2) {
		if (data->weaponCount) {
			data->weaponCount--;
			PlaySound(SND_PICKUP, 0, 255);
			done = 0;
		}
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (selection[index] > 0) {
			selection[index]--;
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == 0) {
			selection[index] = gMission.weaponCount;
			PlaySound(SND_SWITCH, 0, 255);
		}
		done = 0;
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (selection[index] < gMission.weaponCount) {
			selection[index]++;
			PlaySound(SND_SWITCH, 0, 255);
		} else if (selection[index] == gMission.weaponCount) {
			selection[index] = 0;
			PlaySound(SND_SWITCH, 0, 255);
		}
		done = 0;
	}

	if (!done) {
		y = CenterY((TextHeight() * gMission.weaponCount));

		for (i = 0; i < gMission.weaponCount; i++)
			DisplayMenuItem(x, y + i * TextHeight(),
					gunDesc[gMission.availableWeapons[i]].
					gunName, i == selection[index]);

		DisplayMenuItem(x, y + i * TextHeight(), endChoice, i == selection[index]);
	}

	return !done;
}