static bool GenerateSpathi_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet) { COUNT angle; GenerateDefault_generateMoons (solarSys, planet); if (matchWorld (solarSys, planet, 0, MATCH_PLANET)) { #ifdef NOTYET utf8StringCopy (GLOBAL_SIS (PlanetName), sizeof (GLOBAL_SIS (PlanetName)), "Spathiwa"); #endif /* NOTYET */ solarSys->MoonDesc[0].data_index = PELLUCID_WORLD; solarSys->MoonDesc[0].alternate_colormap = NULL; solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + MOON_DELTA; angle = NORMALIZE_ANGLE (LOWORD (RandomContext_Random (SysGenRNG))); solarSys->MoonDesc[0].location.x = COSINE (angle, solarSys->MoonDesc[0].radius); solarSys->MoonDesc[0].location.y = SINE (angle, solarSys->MoonDesc[0].radius); ComputeSpeed(&solarSys->MoonDesc[0], TRUE, 1); } return true; }
static void RealizeMistake (RESPONSE_REF R) { (void) R; // ignored NPCPhrase (DGRUNTI); SET_GAME_STATE (SHOFIXTI_STACK1, 0); SET_GAME_STATE (SHOFIXTI_STACK3, 0); SET_GAME_STATE (SHOFIXTI_STACK2, 3); { UNICODE buf[ALLIANCE_NAME_BUFSIZE]; GetAllianceName (buf, name_1); construct_response ( shared_phrase_buf, i_am_captain0, GLOBAL_SIS (CommanderName), i_am_captain1, buf, i_am_captain2, GLOBAL_SIS (ShipName), i_am_captain3, (UNICODE*)NULL); } DoResponsePhrase (i_am_captain0, ExplainDefeat, shared_phrase_buf); Response (i_am_nice, ExplainDefeat); Response (i_am_guy, ExplainDefeat); }
static void Intro (void) { SET_GAME_STATE (STARBASE_AVAILABLE, 1); NPCPhrase (STARBASE_WILL_BE_READY); return; if (GET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER)) { NPCPhrase (VERY_IMPRESSIVE); Response (cook_their_butts, ByeBye); Response (overthrow_evil_aliens, ByeBye); Response (annihilate_those_monsters, ByeBye); } else if (GET_GAME_STATE (STARBASE_VISITED)) { if (GET_GAME_STATE (RADIOACTIVES_PROVIDED)) { if (GET_GAME_STATE (MOONBASE_DESTROYED) == 0) { TellMoonBase (0); } else { BaseDestroyed (0); } } else { CommData.AlienColorMap = SetAbsColorMapIndex (CommData.AlienColorMap, 1); NPCPhrase (DO_YOU_HAVE_RADIO_THIS_TIME); if (GLOBAL_SIS (ElementAmounts[RADIOACTIVE])) GiveRadios (0); else AskAfterRadios (0); } } else /* first visit */ { CommData.AlienColorMap = SetAbsColorMapIndex (CommData.AlienColorMap, 1); SET_GAME_STATE (STARBASE_VISITED, 1); NPCPhrase (ARE_YOU_SUPPLY_SHIP); construct_response ( shared_phrase_buf, no_but_well_help0, GLOBAL_SIS (ShipName), no_but_well_help1, (UNICODE*)NULL); DoResponsePhrase (no_but_well_help0, NoRadioactives, shared_phrase_buf); Response (yes_this_is_supply_ship, NoRadioactives); Response (what_slave_planet, NoRadioactives); } }
static void SpathiPassword (RESPONSE_REF R) { if (R == 0) { BYTE NumVisits; NumVisits = GET_GAME_STATE (SPATHI_HOME_VISITS); switch (NumVisits++) { default: NPCPhrase (WHAT_IS_PASSWORD); NumVisits = 1; break; case 1: NPCPhrase (WHAT_IS_PASSWORD_AGAIN); --NumVisits; break; } SET_GAME_STATE (SPATHI_HOME_VISITS, NumVisits); } else if (PLAYER_SAID (R, what_do_i_get)) { NPCPhrase (YOU_GET_TO_LIVE); DISABLE_PHRASE (what_do_i_get); } if (GET_GAME_STATE (FOUND_PLUTO_SPATHI) || GET_GAME_STATE (KNOW_SPATHI_PASSWORD)) { Response (good_password, SpathiCouncil); if (PHRASE_ENABLED (what_do_i_get)) { Response (what_do_i_get, SpathiPassword); } } else { construct_response (shared_phrase_buf, we_are_vindicator0, GLOBAL_SIS (CommanderName), we_are_vindicator1, GLOBAL_SIS (ShipName), we_are_vindicator2, (UNICODE*)NULL); DoResponsePhrase (we_are_vindicator0, ExitConversation, shared_phrase_buf); Response (gort_merenga, ExitConversation); Response (guph_florp, ExitConversation); Response (wagngl_fthagn, ExitConversation); Response (pleeese, ExitConversation); Response (screw_password, ExitConversation); } }
static void DrawElementAmount (COUNT element, bool selected) { RECT r; TEXT t; UNICODE buf[40]; r.corner.x = ELEMENT_SEL_ORG_X; r.extent.width = ELEMENT_SEL_WIDTH; r.extent.height = ELEMENT_SPACING_Y - 2; if (element == NUM_ELEMENT_CATEGORIES) r.corner.y = BIO_ORG_Y; else r.corner.y = ELEMENT_ORG_Y + (element * ELEMENT_SPACING_Y); // draw line background SetContextForeGroundColor (selected ? CARGO_SELECTED_BACK_COLOR : CARGO_BACK_COLOR); DrawFilledRectangle (&r); t.align = ALIGN_RIGHT; t.pStr = buf; t.baseline.y = r.corner.y + TEXT_BASELINE; if (element == NUM_ELEMENT_CATEGORIES) { // Bio snprintf (buf, sizeof buf, "%u", GLOBAL_SIS (TotalBioMass)); } else { // Element // print element's worth SetContextForeGroundColor (selected ? CARGO_SELECTED_WORTH_COLOR : CARGO_WORTH_COLOR); t.baseline.x = ELEMENT_COL_1; snprintf (buf, sizeof buf, "%u", GLOBAL (ElementWorth[element])); t.CharCount = (COUNT)~0; font_DrawText (&t); snprintf (buf, sizeof buf, "%u", GLOBAL_SIS (ElementAmounts[element])); } // print the element/bio amount SetContextForeGroundColor (selected ? CARGO_SELECTED_AMOUNT_COLOR : CARGO_AMOUNT_COLOR); t.baseline.x = ELEMENT_COL_2; t.CharCount = (COUNT)~0; font_DrawText (&t); }
void dumpPlanet (FILE *out, const PLANET_DESC *planet) { (*pSolarSysState->genFuncs->generateName) (pSolarSysState, planet); fprintf (out, "- %-37s %s\n", GLOBAL_SIS (PlanetName), planetTypeString (planet->data_index & ~PLANET_SHIELDED)); dumpWorld (out, planet); }
static void DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode) { RECT r; SetContext (SpaceContext); GetContextClipRect (&r); BatchGraphics (); if (Mode != DRAW_ORBITAL_UPDATE) { SetTransitionSource (NULL); DrawSISFrame (); DrawSISMessage (NULL); DrawSISTitle (GLOBAL_SIS (PlanetName)); DrawStarBackGround (); DrawPlanetSurfaceBorder (); } if (Mode == DRAW_ORBITAL_WAIT) { STAMP s; SetContext (GetScanContext (NULL)); s.frame = CaptureDrawable (LoadGraphic (ORBENTER_PMAP_ANIM)); s.origin.x = -SAFE_X; s.origin.y = 0; DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); } else if (Mode == DRAW_ORBITAL_FULL) { DrawDefaultPlanetSphere (); } if (Mode != DRAW_ORBITAL_WAIT) { SetContext (GetScanContext (NULL)); DrawPlanet (0, BLACK_COLOR); } if (Mode != DRAW_ORBITAL_UPDATE) { ScreenTransition (3, &r); } UnbatchGraphics (); // for later RepairBackRect() // JMS_GFX if (RESOLUTION_FACTOR == 0) LoadIntoExtraScreen (&r); else LoadIntoExtraScreen_Fs (&r); }
static void AquaintZoqFot (RESPONSE_REF R) { if (PLAYER_SAID (R, which_fot)) { NPCPhrase_cb (HE_IS0, &SelectAlienZOQ); NPCPhrase_cb (HE_IS1, &SelectAlienPIK); NPCPhrase_cb (HE_IS2, &SelectAlienZOQ); NPCPhrase_cb (HE_IS3, &SelectAlienPIK); NPCPhrase_cb (HE_IS4, &SelectAlienZOQ); NPCPhrase_cb (HE_IS5, &SelectAlienPIK); NPCPhrase_cb (HE_IS6, &SelectAlienZOQ); NPCPhrase_cb (HE_IS7, &SelectAlienPIK); ZFPTalkSegue ((COUNT)~0); DISABLE_PHRASE (which_fot); } else if (PLAYER_SAID (R, quiet_toadies)) { NPCPhrase_cb (TOLD_YOU0, &SelectAlienZOQ); NPCPhrase_cb (TOLD_YOU1, &SelectAlienPIK); NPCPhrase_cb (TOLD_YOU2, &SelectAlienZOQ); NPCPhrase_cb (TOLD_YOU3, &SelectAlienPIK); NPCPhrase_cb (TOLD_YOU4, &SelectAlienZOQ); NPCPhrase_cb (TOLD_YOU5, &SelectAlienPIK); NPCPhrase_cb (TOLD_YOU6, &SelectAlienZOQ); NPCPhrase_cb (TOLD_YOU7, &SelectAlienPIK); ZFPTalkSegue ((COUNT)~0); DISABLE_PHRASE (quiet_toadies); } if (PHRASE_ENABLED (we_are_vindicator0)) { UNICODE buf[ALLIANCE_NAME_BUFSIZE]; GetAllianceName (buf, name_1); construct_response ( shared_phrase_buf, we_are_vindicator0, buf, we_are_vindicator1, GLOBAL_SIS (ShipName), we_are_vindicator2, (UNICODE*)NULL); } if (PHRASE_ENABLED (which_fot)) Response (which_fot, AquaintZoqFot); if (PHRASE_ENABLED (we_are_vindicator0)) DoResponsePhrase (we_are_vindicator0, ZoqFotIntro, shared_phrase_buf); if (PHRASE_ENABLED (quiet_toadies)) Response (quiet_toadies, AquaintZoqFot); Response (all_very_interesting, ExitConversation); Response (valuable_info, ExitConversation); }
// Move the Flagship to the destination of the autopilot. // Should only be called from HyperSpace/QuasiSpace. // It can be called from debugHook directly after entering HS/QS though. void doInstantMove (void) { // Move to the new location: if ((GLOBAL (autopilot)).x == ~0 || (GLOBAL (autopilot)).y == ~0) { // If no destination has been selected, use the current location // as the destination. (GLOBAL (autopilot)).x = LOGX_TO_UNIVERSE(GLOBAL_SIS (log_x)); (GLOBAL (autopilot)).y = LOGY_TO_UNIVERSE(GLOBAL_SIS (log_y)); } else { // A new destination has been selected. GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX((GLOBAL (autopilot)).x); GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY((GLOBAL (autopilot)).y); } // Check for a solar systems at the destination. if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) { // If there's a solar system at the destination, enter it. CurStarDescPtr = FindStar (0, &(GLOBAL (autopilot)), 0, 0); if (CurStarDescPtr) { // Leave HyperSpace/QuasiSpace if we're there: SET_GAME_STATE (USED_BROADCASTER, 0); GLOBAL (CurrentActivity) &= ~IN_BATTLE; // Enter IP: GLOBAL (ShipFacing) = 0; GLOBAL (ip_planet) = 0; GLOBAL (in_orbit) = 0; // This causes the ship position in IP to be reset. GLOBAL (CurrentActivity) |= START_INTERPLANETARY; } } // Turn off the autopilot: (GLOBAL (autopilot)).x = ~0; (GLOBAL (autopilot)).y = ~0; }
static void DoRescue (RESPONSE_REF R) { SIZE dx, dy; COUNT fuel_required; (void) R; // ignored dx = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)) - SOL_X; dy = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)) - SOL_Y; fuel_required = square_root ( (DWORD)((long)dx * dx + (long)dy * dy) ) + (2 * FUEL_TANK_SCALE); if (StripShip (fuel_required)) { Response (take_it, ExitConversation); Response (leave_it, ExitConversation); } }
BOOLEAN DevicesMenu (void) { MENU_STATE MenuState; DEVICES_STATE DevicesState; memset (&MenuState, 0, sizeof MenuState); MenuState.privData = &DevicesState; memset (&DevicesState, 0, sizeof DevicesState); DevicesState.count = InventoryDevices (DevicesState.list, NUM_DEVICES); if (!DevicesState.count) return FALSE; DrawDevices (&DevicesState, (COUNT)~0, MenuState.CurState); SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT); MenuState.InputFunc = DoManipulateDevices; DoInput (&MenuState, TRUE); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); if (GLOBAL_SIS (CrewEnlisted) != (COUNT)~0 && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { LockMutex (GraphicsLock); ClearSISRect (DRAW_SIS_DISPLAY); UnlockMutex (GraphicsLock); if (!GET_GAME_STATE (PORTAL_COUNTER) && !(GLOBAL (CurrentActivity) & START_ENCOUNTER) && GLOBAL_SIS (CrewEnlisted) != (COUNT)~0) return TRUE; } return FALSE; }
static COUNT ShipWorth (void) { BYTE i; SBYTE crew_pods; COUNT worth; worth = GLOBAL_SIS (NumLanders) * GLOBAL (ModuleCost[PLANET_LANDER]); for (i = 0; i < NUM_DRIVE_SLOTS; ++i) { if (GLOBAL_SIS (DriveSlots[i]) < EMPTY_SLOT) worth += GLOBAL (ModuleCost[FUSION_THRUSTER]); } for (i = 0; i < NUM_JET_SLOTS; ++i) { if (GLOBAL_SIS (JetSlots[i]) < EMPTY_SLOT) worth += GLOBAL (ModuleCost[TURNING_JETS]); } crew_pods = -(SBYTE)( (GLOBAL_SIS (CrewEnlisted) + CREW_POD_CAPACITY - 1) / CREW_POD_CAPACITY ); for (i = 0; i < NUM_MODULE_SLOTS; ++i) { BYTE which_module; which_module = GLOBAL_SIS (ModuleSlots[i]); if (which_module < BOMB_MODULE_0 && (which_module != CREW_POD || ++crew_pods > 0)) { worth += GLOBAL (ModuleCost[which_module]); } } return (worth); }
static void DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode) { RECT r = { { SIS_ORG_X, SIS_ORG_Y }, { SIS_SCREEN_WIDTH, SIS_SCREEN_HEIGHT } }; BatchGraphics (); if (Mode != DRAW_ORBITAL_UPDATE) { SetTransitionSource (NULL); DrawSISFrame (); DrawSISMessage (NULL_PTR); DrawSISTitle (GLOBAL_SIS (PlanetName)); DrawStarBackGround (TRUE); } SetContext (SpaceContext); if (Mode == DRAW_ORBITAL_WAIT) { STAMP s; s.frame = CaptureDrawable ( LoadGraphic (ORBENTER_PMAP_ANIM)); s.origin.x = -SAFE_X; s.origin.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT; DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); } else { DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0); } if (Mode != DRAW_ORBITAL_UPDATE) { ScreenTransition (3, &r); } UnbatchGraphics (); if (Mode != DRAW_ORBITAL_WAIT) { LoadIntoExtraScreen (&r); } }
void GetAllianceName (UNICODE *buf, RESPONSE_REF name_1) { COUNT i; STRING S; i = GET_GAME_STATE (NEW_ALLIANCE_NAME); S = SetAbsStringTableIndex (CommData.ConversationPhrases, (name_1 - 1) + i); // XXX: this should someday be changed so that the function takes // the buffer size as an argument strcpy (buf, (UNICODE *)GetStringAddress (S)); if (i == 3) { strcat (buf, GLOBAL_SIS (CommanderName)); strcat (buf, (UNICODE *)GetStringAddress (SetRelStringTableIndex (S, 1))); } }
static DWORD getStripRandomSeed (void) { DWORD x, y; // We truncate the location because encounters move the ship slightly in // HSpace, and throw some other relatively immutable values in the mix to // vary the deal when stuck at the same general location again. // It is still possible but unlikely for encounters to move the ship into // another truncation sector so the player could choose from 2 deals. x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)) / 100; y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)) / 100; // prime numbers help randomness return y * 1013 + x + GLOBAL_SIS (NumLanders) + GLOBAL_SIS (ModuleSlots[1]) + GLOBAL_SIS (ModuleSlots[4]) + GLOBAL_SIS (ModuleSlots[7]) + GLOBAL_SIS (ModuleSlots[10]); }
void ShowRemainingCapacity (void) { RECT r; TEXT t; CONTEXT OldContext; UNICODE buf[40]; OldContext = SetContext (StatusContext); SetContextFont (TinyFont); r.corner.x = 40; r.corner.y = FREE_ORG_Y; snprintf (buf, sizeof buf, "%u", GetStorageBayCapacity () - GLOBAL_SIS (TotalElementMass)); t.baseline.x = ELEMENT_COL_2 + 1; t.baseline.y = r.corner.y + TEXT_BASELINE; t.align = ALIGN_RIGHT; t.pStr = buf; t.CharCount = (COUNT)~0; r.extent.width = t.baseline.x - r.corner.x + 1; r.extent.height = ELEMENT_SPACING_Y - 2; BatchGraphics (); // erase previous free amount SetContextForeGroundColor (CARGO_BACK_COLOR); DrawFilledRectangle (&r); // print the new free amount SetContextForeGroundColor (CARGO_WORTH_COLOR); font_DrawText (&t); UnbatchGraphics (); SetContext (OldContext); }
void DrawCaptainsWindow (STARSHIP *StarShipPtr) { COORD y; COORD y_offs; RECT r; STAMP s; FRAME Frame; RACE_DESC *RDPtr; RDPtr = StarShipPtr->RaceDescPtr; Frame = RDPtr->ship_data.captain_control.background; if (Frame) { Frame = SetAbsFrameIndex (Frame, 0); RDPtr->ship_data.captain_control.background = Frame; Frame = SetRelFrameIndex (Frame, 1); RDPtr->ship_data.captain_control.turn = Frame; Frame = SetRelFrameIndex (Frame, 5); RDPtr->ship_data.captain_control.thrust = Frame; Frame = SetRelFrameIndex (Frame, 3); RDPtr->ship_data.captain_control.weapon = Frame; Frame = SetRelFrameIndex (Frame, 3); RDPtr->ship_data.captain_control.special = Frame; } BatchGraphics (); // Grey area under and around captain's window. assert (StarShipPtr->playerNr >= 0); y_offs = status_y_offsets[StarShipPtr->playerNr]; r.corner.x = CAPTAIN_XOFFS - RES_STAT_SCALE(4); // JMS_GFX r.corner.y = y_offs + SHIP_INFO_HEIGHT; r.extent.width = STATUS_WIDTH - 2; r.extent.height = SHIP_STATUS_HEIGHT - CAPTAIN_YOFFS + (4 << RESOLUTION_FACTOR); // JMS_GFX SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08)); DrawFilledRectangle (&r); // Left border of the status panel. SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F)); r.corner.x = 1; r.corner.y = y_offs + SHIP_INFO_HEIGHT; r.extent.width = 1; r.extent.height = (SHIP_STATUS_HEIGHT - SHIP_INFO_HEIGHT - 2); DrawFilledRectangle (&r); r.corner.x = 0; ++r.extent.height; DrawFilledRectangle (&r); // Lower and right border of the status panel. SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); r.corner.x = STATUS_WIDTH - 1; r.corner.y = y_offs + SHIP_INFO_HEIGHT; r.extent.width = 1; r.extent.height = SHIP_STATUS_HEIGHT - SHIP_INFO_HEIGHT; DrawFilledRectangle (&r); r.corner.x = STATUS_WIDTH - 2; DrawFilledRectangle (&r); r.corner.x = 1; r.extent.width = STATUS_WIDTH - 2; r.corner.y = y_offs + (SHIP_STATUS_HEIGHT - 2); r.extent.height = 1; DrawFilledRectangle (&r); r.corner.x = 0; ++r.extent.width; ++r.corner.y; DrawFilledRectangle (&r); y = y_offs + CAPTAIN_YOFFS; // Darker grey rectangle at bottom and right of captain's window SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F)); r.corner.x = CAPTAIN_WIDTH + CAPTAIN_XOFFS; r.corner.y = y; r.extent.width = 1; r.extent.height = CAPTAIN_HEIGHT; DrawFilledRectangle (&r); r.corner.x = CAPTAIN_XOFFS - 1; r.corner.y += CAPTAIN_HEIGHT; r.extent.width = CAPTAIN_WIDTH + 2; r.extent.height = 1; DrawFilledRectangle (&r); // Light grey rectangle at top and left of captains window SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); r.corner.x = CAPTAIN_XOFFS - 1; r.extent.width = CAPTAIN_WIDTH + 2; r.corner.y = y - 1; r.extent.height = 1; DrawFilledRectangle (&r); r.corner.x = CAPTAIN_XOFFS - 1; r.extent.width = 1; r.corner.y = y; r.extent.height = CAPTAIN_HEIGHT; DrawFilledRectangle (&r); s.frame = RDPtr->ship_data.captain_control.background; s.origin.x = CAPTAIN_XOFFS; s.origin.y = y; DrawStamp (&s); if (StarShipPtr->captains_name_index == 0 && StarShipPtr->playerNr == RPG_PLAYER_NUM) { // This is SIS TEXT t; t.baseline.x = STATUS_WIDTH >> 1; t.baseline.y = y + RES_CASE(6,-22,-44); // JMS_GFX t.align = ALIGN_CENTER; t.pStr = GLOBAL_SIS (CommanderName); t.CharCount = (COUNT)~0; SetContextForeGroundColor (RES_CASE(BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x00), 0x02), BLACK_COLOR, BLACK_COLOR)); SetContextFont (TinyFont); font_DrawText (&t); }
static void HomeWorld (RESPONSE_REF R) { BYTE i, LastStack; RESPONSE_REF pStr[3]; LastStack = 0; pStr[0] = pStr[1] = pStr[2] = 0; if (PLAYER_SAID (R, we_are_us0)) { NPCPhrase (TERRIBLY_EXCITING); SET_GAME_STATE (SLYLANDRO_STACK1, 1); DISABLE_PHRASE (we_are_us0); } else if (PLAYER_SAID (R, what_other_visitors)) { NPCPhrase (VISITORS); SET_GAME_STATE (PLAYER_KNOWS_PROBE, 1); SET_GAME_STATE (SLYLANDRO_STACK1, 2); } else if (PLAYER_SAID (R, any_other_visitors)) { NPCPhrase (LONG_AGO); SET_GAME_STATE (SLYLANDRO_STACK1, 3); } else if (PLAYER_SAID (R, what_about_sentient_milieu)) { NPCPhrase (MET_TAALO_THEY_ARE_FROM); SET_GAME_STATE (SLYLANDRO_STACK1, 4); } else if (PLAYER_SAID (R, who_else)) { NPCPhrase (PRECURSORS); SET_GAME_STATE (SLYLANDRO_STACK1, 5); } else if (PLAYER_SAID (R, precursors_yow)) { NPCPhrase (ABOUT_PRECURSORS); SET_GAME_STATE (SLYLANDRO_STACK1, 6); } else if (PLAYER_SAID (R, must_know_more)) { NPCPhrase (ALL_WE_KNOW); SET_GAME_STATE (SLYLANDRO_STACK1, 7); } else if (PLAYER_SAID (R, who_are_you)) { NPCPhrase (WE_ARE_SLY); LastStack = 1; SET_GAME_STATE (SLYLANDRO_STACK2, 1); } else if (PLAYER_SAID (R, where_are_you)) { NPCPhrase (DOWN_HERE); LastStack = 2; SET_GAME_STATE (SLYLANDRO_STACK3, 1); } else if (PLAYER_SAID (R, thats_impossible_1)) { NPCPhrase (NO_ITS_NOT_1); LastStack = 2; SET_GAME_STATE (SLYLANDRO_STACK3, 2); } else if (PLAYER_SAID (R, thats_impossible_2)) { NPCPhrase (NO_ITS_NOT_2); LastStack = 2; SET_GAME_STATE (SLYLANDRO_STACK3, 3); } else if (PLAYER_SAID (R, like_more_about_you)) { SlylandroInfo (R); return; } else if (PLAYER_SAID (R, enough_about_me)) NPCPhrase (OK_ENOUGH_YOU); else if (PLAYER_SAID (R, enough_info)) NPCPhrase (OK_ENOUGH_INFO); else if (PLAYER_SAID (R, enough_probe)) NPCPhrase (OK_ENOUGH_PROBE); else if (PLAYER_SAID (R, mega_self_destruct)) { NPCPhrase (WHY_YES_THERE_IS); SET_GAME_STATE (SLYLANDRO_KNOW_BROKEN, 1); SET_GAME_STATE (DESTRUCT_CODE_ON_SHIP, 1); i = GET_GAME_STATE (SLYLANDRO_MULTIPLIER) + 1; SET_GAME_STATE (SLYLANDRO_MULTIPLIER, i); AddEvent (RELATIVE_EVENT, 0, 0, 0, SLYLANDRO_RAMP_DOWN); } switch (GET_GAME_STATE (SLYLANDRO_STACK1)) { case 0: construct_response (shared_phrase_buf, we_are_us0, GLOBAL_SIS (CommanderName), we_are_us1, GLOBAL_SIS (ShipName), we_are_us2, (UNICODE*)NULL); pStr[0] = we_are_us0; break; case 1: pStr[0] = what_other_visitors; break; case 2: pStr[0] = any_other_visitors; break; case 3: pStr[0] = what_about_sentient_milieu; break; case 4: pStr[0] = who_else; break; case 5: pStr[0] = precursors_yow; break; case 6: pStr[0] = must_know_more; break; } switch (GET_GAME_STATE (SLYLANDRO_STACK2)) { case 0: pStr[1] = who_are_you; break; case 1: if (PHRASE_ENABLED (like_more_about_you)) pStr[1] = like_more_about_you; break; } switch (GET_GAME_STATE (SLYLANDRO_STACK3)) { case 0: pStr[2] = where_are_you; break; case 1: pStr[2] = thats_impossible_1; break; case 2: pStr[2] = thats_impossible_2; break; } if (pStr[LastStack]) { if (pStr[LastStack] != we_are_us0) Response (pStr[LastStack], HomeWorld); else DoResponsePhrase (pStr[LastStack], HomeWorld, shared_phrase_buf); } for (i = 0; i < 3; ++i) { if (i != LastStack && pStr[i]) { if (pStr[i] != we_are_us0) Response (pStr[i], HomeWorld); else DoResponsePhrase (pStr[i], HomeWorld, shared_phrase_buf); } } if (GET_GAME_STATE (SLYLANDRO_STACK1)) { switch (GET_GAME_STATE (SLYLANDRO_STACK4)) { case 0: Response (happy_to_tell_more, HumanInfo); break; case 1: Response (would_you_like_to_know_more, HumanInfo); break; } } if (GET_GAME_STATE (PLAYER_KNOWS_PROBE) && !GET_GAME_STATE (SLYLANDRO_KNOW_BROKEN)) { switch (GET_GAME_STATE (SLYLANDRO_STACK5)) { case 0: Response (what_are_probes, ProbeInfo); break; case 1: if (PHRASE_ENABLED (know_more_probe)) Response (know_more_probe, ProbeInfo); break; } } Response (bye, ExitConversation); }
static BOOLEAN RestartMenu (MENU_STATE *pMS) { TimeCount TimeOut; ReinitQueue (&race_q[0]); ReinitQueue (&race_q[1]); SetContext (ScreenContext); GLOBAL (CurrentActivity) |= CHECK_ABORT; if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0 && GET_GAME_STATE (UTWIG_BOMB_ON_SHIP) && !GET_GAME_STATE (UTWIG_BOMB)) { // player blew himself up with Utwig bomb SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0); SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND / 8) + ONE_SECOND / 60); SetContextBackGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); ClearDrawable (); FlushColorXForms (); TimeOut = ONE_SECOND / 8; } else { TimeOut = ONE_SECOND / 2; if (LOBYTE (LastActivity) == WON_LAST_BATTLE) { GLOBAL (CurrentActivity) = WON_LAST_BATTLE; Victory (); Credits (TRUE); FreeGameData (); GLOBAL (CurrentActivity) = CHECK_ABORT; } } LastActivity = 0; NextActivity = 0; // TODO: This fade is not always necessary, especially after a splash // screen. It only makes a user wait. SleepThreadUntil (FadeScreen (FadeAllToBlack, TimeOut)); if (TimeOut == ONE_SECOND / 8) SleepThread (ONE_SECOND * 3); pMS->CurFrame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM)); DrawRestartMenuGraphic (pMS); GLOBAL (CurrentActivity) &= ~CHECK_ABORT; SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetDefaultMenuRepeatDelay (); DoInput (pMS, TRUE); StopMusic (); if (pMS->hMusic) { DestroyMusic (pMS->hMusic); pMS->hMusic = 0; } Flash_terminate (pMS->flashContext); pMS->flashContext = 0; DestroyDrawable (ReleaseDrawable (pMS->CurFrame)); pMS->CurFrame = 0; if (GLOBAL (CurrentActivity) == (ACTIVITY)~0) return (FALSE); // timed out if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); // quit TimeOut = FadeScreen (FadeAllToBlack, ONE_SECOND / 2); SleepThreadUntil (TimeOut); FlushColorXForms (); SeedRandomNumbers (); return (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE); }
static void ByeBye (RESPONSE_REF R) { if (PLAYER_SAID (R, ok_i_will_get_radios)) NPCPhrase (THANKS_FOR_HELPING); else if (PLAYER_SAID (R, well_go_get_them_now)) NPCPhrase (GLAD_WHEN_YOU_COME_BACK); else if (PLAYER_SAID (R, we_will_take_care_of_base)) { NPCPhrase (GOOD_LUCK_WITH_BASE); SET_GAME_STATE (WILL_DESTROY_BASE, 1); } else if (PLAYER_SAID (R, take_care_of_base_again)) NPCPhrase (GOOD_LUCK_AGAIN); else if (PLAYER_SAID (R, base_was_abandoned) || PLAYER_SAID (R, i_lied_it_was_abandoned)) { NPCPhrase (IT_WAS_ABANDONED); NPCPhrase (HERE_COMES_ILWRATH); SET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER, 1); } else if (PLAYER_SAID (R, oh_yes_big_fight)) { NPCPhrase (IM_GLAD_YOU_WON); NPCPhrase (HERE_COMES_ILWRATH); SET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER, 1); } else if (PLAYER_SAID (R, i_cant_talk_about_it)) { NPCPhrase (IM_SURE_IT_WAS_DIFFICULT); NPCPhrase (HERE_COMES_ILWRATH); SET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER, 1); } else if (PLAYER_SAID (R, cook_their_butts) || PLAYER_SAID (R, overthrow_evil_aliens) || PLAYER_SAID (R, annihilate_those_monsters)) { SET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER, 0); if (PLAYER_SAID (R, cook_their_butts)) NPCPhrase (COOK_BUTTS); else if (PLAYER_SAID (R, overthrow_evil_aliens)) NPCPhrase (OVERTHROW_ALIENS); else /* if (R == annihilate_those_monsters) */ NPCPhrase (KILL_MONSTERS); construct_response (shared_phrase_buf, name_40, GLOBAL_SIS (CommanderName), name_41, (UNICODE*)NULL); NPCPhrase (THIS_MAY_SEEM_SILLY); Response (name_1, ByeBye); Response (name_2, ByeBye); Response (name_3, ByeBye); DoResponsePhrase (name_40, ByeBye, shared_phrase_buf); SET_GAME_STATE (STARBASE_AVAILABLE, 1); } else { if (PLAYER_SAID (R, name_1)) { NPCPhrase (OK_THE_NAFS); SET_GAME_STATE (NEW_ALLIANCE_NAME, 0); } else if (PLAYER_SAID (R, name_2)) { NPCPhrase (OK_THE_CAN); SET_GAME_STATE (NEW_ALLIANCE_NAME, 1); } else if (PLAYER_SAID (R, name_3)) { NPCPhrase (OK_THE_UFW); SET_GAME_STATE (NEW_ALLIANCE_NAME, 2); } else /* if (PLAYER_SAID (R, name_4)) */ { NPCPhrase (OK_THE_NAME_IS_EMPIRE0); NPCPhrase (GLOBAL_PLAYER_NAME); NPCPhrase (OK_THE_NAME_IS_EMPIRE1); SET_GAME_STATE (NEW_ALLIANCE_NAME, 3); } NPCPhrase (STARBASE_WILL_BE_READY); } }
static void RevealSelf (RESPONSE_REF R) { BYTE i, stack; stack = 0; if (PLAYER_SAID (R, we_are_vindicator0)) { NPCPhrase (THATS_IMPOSSIBLE); DISABLE_PHRASE (we_are_vindicator0); } else if (PLAYER_SAID (R, our_mission_was_secret)) { NPCPhrase (ACKNOWLEDGE_SECRET); DISABLE_PHRASE (our_mission_was_secret); } else if (PLAYER_SAID (R, first_give_info)) { NPCPhrase (ASK_AWAY); stack = 1; DISABLE_PHRASE (first_give_info); } else if (PLAYER_SAID (R, whats_this_starbase)) { NPCPhrase (STARBASE_IS); stack = 1; DISABLE_PHRASE (whats_this_starbase); } else if (PLAYER_SAID (R, what_about_earth)) { NPCPhrase (HAPPENED_TO_EARTH); stack = 1; DISABLE_PHRASE (what_about_earth); } else if (PLAYER_SAID (R, where_are_urquan)) { NPCPhrase (URQUAN_LEFT); stack = 1; DISABLE_PHRASE (where_are_urquan); } else if (PLAYER_SAID (R, it_went_away)) NPCPhrase (DEEP_TROUBLE); else if (PLAYER_SAID (R, we_destroyed_it)) NPCPhrase (GOOD_NEWS); else if (PLAYER_SAID (R, what_probe)) NPCPhrase (SURE_HOPE); for (i = 0; i < 2; ++i, stack ^= 1) { if (stack == 1) { if (PHRASE_ENABLED (first_give_info)) Response (first_give_info, RevealSelf); else if (PHRASE_ENABLED (whats_this_starbase)) Response (whats_this_starbase, RevealSelf); else if (PHRASE_ENABLED (what_about_earth)) Response (what_about_earth, RevealSelf); else if (PHRASE_ENABLED (where_are_urquan)) Response (where_are_urquan, RevealSelf); else if (PHRASE_ENABLED (what_was_red_thing)) { Response (what_was_red_thing, TellProbe); } } else { if (PHRASE_ENABLED (we_are_vindicator0)) { construct_response (shared_phrase_buf, we_are_vindicator0, GLOBAL_SIS (CommanderName), we_are_vindicator1, GLOBAL_SIS (ShipName), we_are_vindicator2, (UNICODE*)NULL); DoResponsePhrase (we_are_vindicator0, RevealSelf, shared_phrase_buf); } else if (PHRASE_ENABLED (our_mission_was_secret)) Response (our_mission_was_secret, RevealSelf); else { if (GET_GAME_STATE (MOONBASE_DESTROYED) == 0) Response (we_are_here_to_help, TellMoonBase); else Response (we_are_here_to_help, BaseDestroyed); } } } }
static void TellMoonBase (RESPONSE_REF R) { if (R == 0) { NPCPhrase (DEALT_WITH_BASE_YET); } else if (PLAYER_SAID (R, i_lost_my_lander)) { NPCPhrase (HERE_IS_A_NEW_LANDER); ++GLOBAL_SIS (NumLanders); LockMutex (GraphicsLock); DrawLanders (); DeltaSISGauges (4, 0, 0); UnlockMutex (GraphicsLock); SET_GAME_STATE (LANDERS_LOST, 1); } else if (PLAYER_SAID (R, i_lost_another_lander)) { NPCPhrase (HERE_IS_ANOTHER_LANDER); ++GLOBAL_SIS (NumLanders); LockMutex (GraphicsLock); DrawLanders (); DeltaSISGauges (4, 0, 0); UnlockMutex (GraphicsLock); } else if (PLAYER_SAID (R, need_fuel_mercury) || PLAYER_SAID (R, need_fuel_luna)) { NPCPhrase (GIVE_FUEL); LockMutex (GraphicsLock); DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0); UnlockMutex (GraphicsLock); SET_GAME_STATE (GIVEN_FUEL_BEFORE, 1); } else if (PLAYER_SAID (R, need_fuel_again)) { NPCPhrase (GIVE_FUEL_AGAIN); LockMutex (GraphicsLock); DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0); UnlockMutex (GraphicsLock); } else if (PLAYER_SAID (R, we_are_here_to_help)) { NPCPhrase (BASE_ON_MOON); } else if (GET_GAME_STATE (STARBASE_YACK_STACK1) == 0) { NPCPhrase (ABOUT_BASE); SET_GAME_STATE (STARBASE_YACK_STACK1, 1); } else { NPCPhrase (ABOUT_BASE_AGAIN); } if (GLOBAL_SIS (NumLanders) == 0 && GET_GAME_STATE (CHMMR_BOMB_STATE) < 2) { if (GET_GAME_STATE (LANDERS_LOST)) Response (i_lost_another_lander, TellMoonBase); else Response (i_lost_my_lander, TellMoonBase); } if (GLOBAL_SIS (FuelOnBoard) < 2 * FUEL_TANK_SCALE) { if (GET_GAME_STATE (GIVEN_FUEL_BEFORE)) Response (need_fuel_again, TellMoonBase); else Response (need_fuel_luna, TellMoonBase); } if (GET_GAME_STATE (WILL_DESTROY_BASE) == 0) Response (we_will_take_care_of_base, ByeBye); else Response (take_care_of_base_again, ByeBye); if (GET_GAME_STATE (STARBASE_YACK_STACK1) == 0) Response (tell_me_about_base, TellMoonBase); else Response (tell_me_again, TellMoonBase); }
static void AskAfterRadios (RESPONSE_REF R) { if (PLAYER_SAID (R, i_lost_my_lander)) { NPCPhrase (HERE_IS_A_NEW_LANDER); ++GLOBAL_SIS (NumLanders); LockMutex (GraphicsLock); DrawLanders (); DeltaSISGauges (4, 0, 0); UnlockMutex (GraphicsLock); SET_GAME_STATE (LANDERS_LOST, 1); } else if (PLAYER_SAID (R, i_lost_another_lander)) { NPCPhrase (HERE_IS_ANOTHER_LANDER); ++GLOBAL_SIS (NumLanders); LockMutex (GraphicsLock); DrawLanders (); DeltaSISGauges (4, 0, 0); UnlockMutex (GraphicsLock); } else if (PLAYER_SAID (R, need_fuel_mercury) || PLAYER_SAID (R, need_fuel_luna)) { NPCPhrase (GIVE_FUEL); LockMutex (GraphicsLock); DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0); UnlockMutex (GraphicsLock); SET_GAME_STATE (GIVEN_FUEL_BEFORE, 1); } else if (PLAYER_SAID (R, need_fuel_again)) { NPCPhrase (GIVE_FUEL_AGAIN); LockMutex (GraphicsLock); DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0); UnlockMutex (GraphicsLock); } else if (PLAYER_SAID (R, where_get_radios)) { NPCPhrase (RADIOS_ON_MERCURY); DISABLE_PHRASE (where_get_radios); } { if (GLOBAL_SIS (NumLanders) == 0 && GET_GAME_STATE (CHMMR_BOMB_STATE) < 2) { if (GET_GAME_STATE (LANDERS_LOST)) Response (i_lost_another_lander, AskAfterRadios); else Response (i_lost_my_lander, AskAfterRadios); } if (GLOBAL_SIS (FuelOnBoard) < 2 * FUEL_TANK_SCALE) { if (GET_GAME_STATE (GIVEN_FUEL_BEFORE)) Response (need_fuel_again, AskAfterRadios); else Response (need_fuel_mercury, AskAfterRadios); } Response (well_go_get_them_now, ByeBye); if (PHRASE_ENABLED (where_get_radios)) { Response (where_get_radios, AskAfterRadios); } } }
static void NoRadioactives (RESPONSE_REF R) { if (PLAYER_SAID (R, yes_this_is_supply_ship)) { NPCPhrase (ABOUT_TIME); if (GLOBAL_SIS (ElementAmounts[RADIOACTIVE])) GiveRadios (0); else { Response (i_lied, NoRadioactives); Response (plumb_out, NoRadioactives); } } else { if (PLAYER_SAID (R, where_can_i_get_radios)) { NPCPhrase (RADIOS_ON_MERCURY); DISABLE_PHRASE (where_can_i_get_radios); } else if (PLAYER_SAID (R, no_but_well_help0)) NPCPhrase (THE_WHAT_FROM_WHERE); else if (PLAYER_SAID (R, what_slave_planet) || PLAYER_SAID (R, i_lied)) NPCPhrase (DONT_KNOW_WHO_YOU_ARE); else if (PLAYER_SAID (R, plumb_out)) NPCPhrase (WHAT_KIND_OF_IDIOT); else if (PLAYER_SAID (R, i_lost_my_lander)) { NPCPhrase (HERE_IS_A_NEW_LANDER); ++GLOBAL_SIS (NumLanders); LockMutex (GraphicsLock); DrawLanders (); DeltaSISGauges (4, 0, 0); UnlockMutex (GraphicsLock); SET_GAME_STATE (LANDERS_LOST, 1); } else if (PLAYER_SAID (R, i_lost_another_lander)) { NPCPhrase (HERE_IS_ANOTHER_LANDER); ++GLOBAL_SIS (NumLanders); LockMutex (GraphicsLock); DrawLanders (); DeltaSISGauges (4, 0, 0); UnlockMutex (GraphicsLock); } else if (PLAYER_SAID (R, need_fuel_mercury) || PLAYER_SAID (R, need_fuel_luna)) { NPCPhrase (GIVE_FUEL); LockMutex (GraphicsLock); DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0); UnlockMutex (GraphicsLock); SET_GAME_STATE (GIVEN_FUEL_BEFORE, 1); } else if (PLAYER_SAID (R, need_fuel_again)) { NPCPhrase (GIVE_FUEL_AGAIN); LockMutex (GraphicsLock); DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0); UnlockMutex (GraphicsLock); } if (GLOBAL_SIS (ElementAmounts[RADIOACTIVE])) GiveRadios (0); else { if (GLOBAL_SIS (NumLanders) == 0 && GET_GAME_STATE (CHMMR_BOMB_STATE) < 2) { if (GET_GAME_STATE (LANDERS_LOST)) Response (i_lost_another_lander, NoRadioactives); else Response (i_lost_my_lander, NoRadioactives); } if (GLOBAL_SIS (FuelOnBoard) < 2 * FUEL_TANK_SCALE) { if (GET_GAME_STATE (GIVEN_FUEL_BEFORE)) Response (need_fuel_again, NoRadioactives); else Response (need_fuel_mercury, NoRadioactives); } Response (ok_i_will_get_radios, ByeBye); if (PHRASE_ENABLED (where_can_i_get_radios)) { Response (where_can_i_get_radios, NoRadioactives); } } } }
static BOOLEAN DoPlanetOrbit (MENU_STATE *pMS) { BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT]; BOOLEAN handled; if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0) return FALSE; // XXX: pMS actually refers to pSolarSysState->MenuState handled = DoMenuChooser (pMS, PM_SCAN); if (handled) return TRUE; if (!select) return TRUE; LockMutex (GraphicsLock); SetFlashRect (NULL); UnlockMutex (GraphicsLock); switch (pMS->CurState) { case SCAN: ScanSystem (); if (GLOBAL (CurrentActivity) & START_ENCOUNTER) { // Found Fwiffo on Pluto return FALSE; } break; case EQUIP_DEVICE: select = DevicesMenu (); if (GLOBAL (CurrentActivity) & START_ENCOUNTER) { // Invoked Talking Pet, a Caster or Sun Device over Chmmr, // or a Caster for Ilwrath // Going into conversation return FALSE; } break; case CARGO: CargoMenu (); break; case ROSTER: select = RosterMenu (); break; case GAME_MENU: if (!GameOptions ()) return FALSE; // abort or load break; case STARMAP: { BOOLEAN AutoPilotSet; InputFrameCallback *oldCallback; // Deactivate planet rotation oldCallback = SetInputCallback (NULL); LockMutex (GraphicsLock); RepairSISBorder (); UnlockMutex (GraphicsLock); AutoPilotSet = StarMap (); if (GLOBAL (CurrentActivity) & CHECK_ABORT) return FALSE; // Reactivate planet rotation SetInputCallback (oldCallback); if (!AutoPilotSet) { // Redraw the orbital display LockMutex (GraphicsLock); DrawOrbitalDisplay (DRAW_ORBITAL_FULL); UnlockMutex (GraphicsLock); break; } // Fall through !!! } case NAVIGATION: return FALSE; } if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) { if (select) { // 3DO menu jumps to NAVIGATE after a successful submenu run if (optWhichMenu != OPT_PC) pMS->CurState = NAVIGATION; DrawMenuStateStrings (PM_SCAN, pMS->CurState); } LockMutex (GraphicsLock); SetFlashRect (SFR_MENU_3DO); UnlockMutex (GraphicsLock); } return TRUE; }
static void Buy (RESPONSE_REF R) { if (PLAYER_SAID (R, want_to_buy) || PLAYER_SAID (R, im_ready_to_buy)) { NPCPhrase (READY_TO_SELL); if (!GET_GAME_STATE (ROSY_SPHERE)) NPCPhrase (HAVE_SPHERE); if (!GET_GAME_STATE (ARTIFACT_2_ON_SHIP)) NPCPhrase (HAVE_ART_1); if (!GET_GAME_STATE (ARTIFACT_3_ON_SHIP)) NPCPhrase (HAVE_ART_2); NPCPhrase (SHIPS_AND_FUEL); SET_GAME_STATE (KNOW_DRUUGE_SLAVERS, 3); } else if (PLAYER_SAID (R, buy_druuge_ship)) { #define SHIP_CREW_COST 100 if (GLOBAL_SIS (CrewEnlisted) < SHIP_CREW_COST) NPCPhrase (NOT_ENOUGH_CREW); else if (EscortFeasibilityStudy (DRUUGE_SHIP) == 0) NPCPhrase (NOT_ENOUGH_ROOM); else { DeltaSISGauges (-SHIP_CREW_COST, 0, 0); SlaveryCount += SHIP_CREW_COST; AddEscortShips (DRUUGE_SHIP, 1); NPCPhrase (BOUGHT_SHIP); } } #define ARTIFACT_CREW_COST 100 else if (PLAYER_SAID (R, buy_rosy_sphere)) { if (GLOBAL_SIS (CrewEnlisted) < ARTIFACT_CREW_COST) NPCPhrase (NOT_ENOUGH_CREW); else { DeltaSISGauges (-ARTIFACT_CREW_COST, 0, 0); SlaveryCount += ARTIFACT_CREW_COST; SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 1); SET_GAME_STATE (ROSY_SPHERE, 1); NPCPhrase (BOUGHT_SPHERE); } } else if (PLAYER_SAID (R, buy_art_1)) { if (GLOBAL_SIS (CrewEnlisted) < ARTIFACT_CREW_COST) NPCPhrase (NOT_ENOUGH_CREW); else { DeltaSISGauges (-ARTIFACT_CREW_COST, 0, 0); SlaveryCount += ARTIFACT_CREW_COST; SET_GAME_STATE (ARTIFACT_2_ON_SHIP, 1); NPCPhrase (BOUGHT_ART_1); } } else if (PLAYER_SAID (R, buy_art_2)) { if (GLOBAL_SIS (CrewEnlisted) < ARTIFACT_CREW_COST) NPCPhrase (NOT_ENOUGH_CREW); else { DeltaSISGauges (-ARTIFACT_CREW_COST, 0, 0); SlaveryCount += ARTIFACT_CREW_COST; SET_GAME_STATE (ARTIFACT_3_ON_SHIP, 1); NPCPhrase (BOUGHT_ART_2); } } else if (PLAYER_SAID (R, buy_fuel)) { #define FUEL_CREW_COST 10 if (GLOBAL_SIS (CrewEnlisted) < FUEL_CREW_COST) NPCPhrase (NOT_ENOUGH_CREW); else { DeltaSISGauges (-FUEL_CREW_COST, FUEL_CREW_COST * FUEL_TANK_SCALE, 0); SlaveryCount += FUEL_CREW_COST; NPCPhrase (BOUGHT_FUEL); } } Response (buy_druuge_ship, Buy); if (!GET_GAME_STATE (ROSY_SPHERE)) Response (buy_rosy_sphere, Buy); if (!GET_GAME_STATE (ARTIFACT_2_ON_SHIP)) Response (buy_art_1, Buy); if (!GET_GAME_STATE (ARTIFACT_3_ON_SHIP)) Response (buy_art_2, Buy); Response (buy_fuel, Buy); Response (done_buying, TradeWorld); }
static void DoTransaction (RESPONSE_REF R) { if (PLAYER_SAID (R, sell_maidens)) { SET_GAME_STATE (MAIDENS_ON_SHIP, 0); } else if (PLAYER_SAID (R, sell_fragments)) { BYTE num_frags; if (GET_GAME_STATE (EGG_CASE0_ON_SHIP)) { SET_GAME_STATE (EGG_CASE0_ON_SHIP, 0); } else if (GET_GAME_STATE (EGG_CASE1_ON_SHIP)) { SET_GAME_STATE (EGG_CASE1_ON_SHIP, 0); } else if (GET_GAME_STATE (EGG_CASE2_ON_SHIP)) { SET_GAME_STATE (EGG_CASE2_ON_SHIP, 0); } num_frags = GET_GAME_STATE (FRAGMENTS_BOUGHT) + 1; SET_GAME_STATE (FRAGMENTS_BOUGHT, num_frags); } else if (PLAYER_SAID (R, sell_caster)) { SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 0); } else if (PLAYER_SAID (R, sell_spawner)) { SET_GAME_STATE (PORTAL_SPAWNER_ON_SHIP, 0); } if (!GET_GAME_STATE (ROSY_SPHERE) && GET_GAME_STATE (ROSY_SPHERE_ON_SHIP)) { SET_GAME_STATE (ROSY_SPHERE, 1); } else { BYTE trade_gas; BYTE ship_slots, ships_to_trade; trade_gas = 0; ships_to_trade = 0; ship_slots = EscortFeasibilityStudy (DRUUGE_SHIP); if (PLAYER_SAID (R, sell_maidens)) { NPCPhrase (BOUGHT_MAIDENS); ships_to_trade = 6; } else if (PLAYER_SAID (R, sell_fragments)) { NPCPhrase (BOUGHT_FRAGMENTS); ships_to_trade = 1; } else if (PLAYER_SAID (R, sell_caster)) { NPCPhrase (BOUGHT_CASTER); ships_to_trade = 0; trade_gas = 1; } else if (PLAYER_SAID (R, sell_spawner)) { NPCPhrase (BOUGHT_SPAWNER); ships_to_trade = 3; trade_gas = 1; } NPCPhrase (YOU_GET); if (ships_to_trade) { AddEscortShips (DRUUGE_SHIP, ships_to_trade); if (ship_slots >= ships_to_trade) NPCPhrase (DEAL_FOR_STATED_SHIPS); else if (ship_slots == 0) NPCPhrase (DEAL_FOR_NO_SHIPS); else NPCPhrase (DEAL_FOR_LESS_SHIPS); if (trade_gas) NPCPhrase (YOU_ALSO_GET); } if (trade_gas) { BYTE slot; COUNT f; DWORD capacity; capacity = FUEL_RESERVE; slot = NUM_MODULE_SLOTS - 1; do { if (GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK || GLOBAL_SIS (ModuleSlots[slot]) == HIGHEFF_FUELSYS) { COUNT volume; volume = GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK ? FUEL_TANK_CAPACITY : HEFUEL_TANK_CAPACITY; capacity += volume; } } while (slot--); capacity -= GLOBAL_SIS (FuelOnBoard); f = (COUNT)((capacity + (FUEL_TANK_SCALE >> 1)) / FUEL_TANK_SCALE); while (capacity > 0x3FFFL) { DeltaSISGauges (0, 0x3FFF, 0); capacity -= 0x3FFF; } DeltaSISGauges (0, (SIZE)capacity, 0); NPCPhrase (FUEL0); NPCNumber (f, NULL); NPCPhrase (FUEL1); if (f >= 250) NPCPhrase (HIDEOUS_DEAL); else if (f >= 100) NPCPhrase (BAD_DEAL); else if (f >= 50) NPCPhrase (FAIR_DEAL); else if (f >= 10) NPCPhrase (GOOD_DEAL); else NPCPhrase (FINE_DEAL); } } }
static BOOLEAN DoModifyRoster (MENU_STATE *pMS) { BYTE NewState; SBYTE sx, sy; RECT r; STAMP s; SHIP_FRAGMENT *StarShipPtr; BOOLEAN select, cancel, up, down, pgup, pgdn, horiz; if (GLOBAL (CurrentActivity) & CHECK_ABORT) { LockMutex (GraphicsLock); RosterCleanup (pMS); UnlockMutex (GraphicsLock); pMS->CurFrame = 0; return FALSE; } select = PulsedInputState.menu[KEY_MENU_SELECT]; cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; up = PulsedInputState.menu[KEY_MENU_UP]; down = PulsedInputState.menu[KEY_MENU_DOWN]; horiz = PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_RIGHT]; pgup = PulsedInputState.menu[KEY_MENU_PAGE_UP]; pgdn = PulsedInputState.menu[KEY_MENU_PAGE_DOWN]; if (pMS->Initialized && (pMS->CurState & SHIP_TOGGLE)) { SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL); } else { SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT); } if (!pMS->Initialized) { pMS->InputFunc = DoModifyRoster; pMS->Initialized = TRUE; pMS->CurState = NewState = 0; LockMutex (GraphicsLock); SetContext (StatusContext); goto SelectSupport; } else if (cancel && !(pMS->CurState & SHIP_TOGGLE)) { LockMutex (GraphicsLock); SetFlashRect (NULL, (FRAME)0); RosterCleanup (pMS); pMS->CurFrame = 0; DrawStatusMessage (NULL); UnlockMutex (GraphicsLock); return FALSE; } else if (select || cancel) { LockMutex (GraphicsLock); pMS->CurState ^= SHIP_TOGGLE; if (!(pMS->CurState & SHIP_TOGGLE)) SetFlashRect (NULL, (FRAME)0); else { RosterCleanup (pMS); r.corner.x = 2; r.corner.y = 130; r.extent.width = STATUS_MESSAGE_WIDTH; r.extent.height = STATUS_MESSAGE_HEIGHT; SetContext (StatusContext); SetFlashRect (&r, (FRAME)0); } UnlockMutex (GraphicsLock); } else if (pMS->CurState & SHIP_TOGGLE) { SIZE delta = 0; BOOLEAN failed = FALSE; if (up || pgup) { if (GLOBAL_SIS (CrewEnlisted)) delta = pgup ? 10 : 1; else failed = TRUE; } else if (down || pgdn) { if (GLOBAL_SIS (CrewEnlisted) < GetCPodCapacity (NULL)) delta = pgdn ? -10 : -1; else failed = TRUE; } if (delta != 0) { LockMutex (GraphicsLock); failed = !DeltaSupportCrew (delta); UnlockMutex (GraphicsLock); } if (failed) { // not enough room or crew PlayMenuSound (MENU_SOUND_FAILURE); } } else { POINT *pship_pos; NewState = pMS->CurState; sx = (SBYTE)((pMS->delta_item + 1) >> 1); if (horiz) { pship_pos = (POINT*)pMS->flash_frame1; if (NewState == (BYTE)(sx - 1)) NewState = (BYTE)(pMS->delta_item - 1); else if (NewState >= (BYTE)sx) { NewState -= sx; if (pship_pos[NewState].y < pship_pos[pMS->CurState].y) ++NewState; } else { NewState += sx; if (NewState != (BYTE)sx && pship_pos[NewState].y > pship_pos[pMS->CurState].y) --NewState; } } else if (down) { sy = 1; if (++NewState == (BYTE)pMS->delta_item) NewState = (BYTE)(sx - 1); else if (NewState == (BYTE)sx) NewState = 0; } else if (up) { sy = -1; if (NewState == 0) NewState += sx - 1; else if (NewState == (BYTE)sx) NewState = (BYTE)(pMS->delta_item - 1); else --NewState; } if (NewState != pMS->CurState) { LockMutex (GraphicsLock); SetContext (StatusContext); s.origin = pMS->first_item; StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), (HSHIPFRAG)pMS->CurFrame); s.frame = StarShipPtr->icons; UnlockShipFrag (&GLOBAL (built_ship_q), (HSHIPFRAG)pMS->CurFrame); DrawStamp (&s); SelectSupport: pship_pos = (POINT*)pMS->flash_frame1; pMS->first_item = pship_pos[NewState]; pMS->CurFrame = (FRAME)MatchSupportShip (pMS); DeltaSupportCrew (0); UnlockMutex (GraphicsLock); pMS->CurState = NewState; } if (pMS->flash_task == 0) pMS->flash_task = AssignTask (flash_ship_task, 2048, "flash roster menu"); } return TRUE; }
static BOOLEAN DoModifyRoster (MENU_STATE *pMS) { ROSTER_STATE *rosterState = pMS->privData; BOOLEAN select, cancel, up, down, horiz; if (GLOBAL (CurrentActivity) & CHECK_ABORT) return FALSE; select = PulsedInputState.menu[KEY_MENU_SELECT]; cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; up = PulsedInputState.menu[KEY_MENU_UP]; down = PulsedInputState.menu[KEY_MENU_DOWN]; // Left or right produces the same effect because there are 2 columns horiz = PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_RIGHT]; if (cancel && !rosterState->modifyingCrew) { return FALSE; } else if (select || cancel) { rosterState->modifyingCrew ^= true; if (!rosterState->modifyingCrew) { SetFlashRect (NULL); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); } else { drawModifiedSupportShip (rosterState); flashSupportShipCrew (); SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL); } } else if (rosterState->modifyingCrew) { SIZE delta = 0; BOOLEAN failed = FALSE; if (up) { if (GLOBAL_SIS (CrewEnlisted)) delta = 1; else failed = TRUE; } else if (down) { if (GLOBAL_SIS (CrewEnlisted) < GetCrewPodCapacity ()) delta = -1; else failed = TRUE; } if (delta != 0) { failed = !DeltaSupportCrew (rosterState, delta); } if (failed) { // not enough room or crew PlayMenuSound (MENU_SOUND_FAILURE); } } else { COUNT NewState; POINT *pship_pos = rosterState->shipPos; COUNT top_right = (rosterState->count + 1) >> 1; NewState = pMS->CurState; if (rosterState->count < 2) { // no navigation allowed } else if (horiz) { if (NewState == top_right - 1) NewState = rosterState->count - 1; else if (NewState >= top_right) { NewState -= top_right; if (pship_pos[NewState].y < pship_pos[pMS->CurState].y) ++NewState; } else { NewState += top_right; if (NewState != top_right && pship_pos[NewState].y > pship_pos[pMS->CurState].y) --NewState; } } else if (down) { ++NewState; if (NewState == rosterState->count) NewState = top_right; else if (NewState == top_right) NewState = 0; } else if (up) { if (NewState == 0) NewState = top_right - 1; else if (NewState == top_right) NewState = rosterState->count - 1; else --NewState; } BatchGraphics (); SetContext (StatusContext); if (NewState != pMS->CurState) { // Draw the previous escort in unselected state drawSupportShip (rosterState, FALSE); // Select the new one selectSupportShip (rosterState, NewState); pMS->CurState = NewState; } flashSupportShip (rosterState); UnbatchGraphics (); } SleepThread (ONE_SECOND / 30); return TRUE; }
static void Intro (void) { BYTE NumVisits; if (LOBYTE (GLOBAL (CurrentActivity)) == WON_LAST_BATTLE) { NPCPhrase (OUT_TAKES); setSegue (Segue_peace); return; } if (GET_GAME_STATE (DRUUGE_MANNER)) { if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7)) { NumVisits = GET_GAME_STATE (DRUUGE_HOME_VISITS); switch (NumVisits++) { case 0: NPCPhrase (HSTL_TRADE_WORLD_HELLO_1); break; case 1: NPCPhrase (HSTL_TRADE_WORLD_HELLO_2); --NumVisits; break; } SET_GAME_STATE (DRUUGE_HOME_VISITS, NumVisits); } else { NumVisits = GET_GAME_STATE (DRUUGE_VISITS); switch (NumVisits++) { case 0: NPCPhrase (HOSTILE_SPACE_HELLO_1); break; case 1: NPCPhrase (HOSTILE_SPACE_HELLO_2); --NumVisits; break; } SET_GAME_STATE (DRUUGE_VISITS, NumVisits); } setSegue (Segue_hostile); } else if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7)) { { NumVisits = GET_GAME_STATE (DRUUGE_HOME_VISITS); switch (NumVisits++) { case 0: NPCPhrase (INITIAL_TRADE_WORLD_HELLO); break; case 1: NPCPhrase (SSQ_TRADE_WORLD_HELLO_1); break; case 2: NPCPhrase (SSQ_TRADE_WORLD_HELLO_2); break; case 3: NPCPhrase (SSQ_TRADE_WORLD_HELLO_3); break; case 4: NPCPhrase (SSQ_TRADE_WORLD_HELLO_4); --NumVisits; break; } SET_GAME_STATE (DRUUGE_HOME_VISITS, NumVisits); } if (GET_GAME_STATE (ATTACKED_DRUUGE) && !GET_GAME_STATE (DRUUGE_DISCLAIMER)) { // There is no HOSTILE_TRADE voice track that we know of // so this is currently disabled //NPCPhrase (HOSTILE_TRADE); SET_GAME_STATE (DRUUGE_DISCLAIMER, 1); } if (GET_GAME_STATE (MAIDENS_ON_SHIP) && !GET_GAME_STATE (SCANNED_MAIDENS)) { NPCPhrase (SCAN_MAIDENS); SET_GAME_STATE (SCANNED_MAIDENS, 1); } if ((GET_GAME_STATE (EGG_CASE0_ON_SHIP) || GET_GAME_STATE (EGG_CASE1_ON_SHIP) || GET_GAME_STATE (EGG_CASE2_ON_SHIP)) && !GET_GAME_STATE (SCANNED_FRAGMENTS)) { if (GET_GAME_STATE (FRAGMENTS_BOUGHT) < 2) NPCPhrase (SCAN_FRAGMENTS); else NPCPhrase (ENOUGH_FRAGMENTS); SET_GAME_STATE (SCANNED_FRAGMENTS, 1); } if (GET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP) && !GET_GAME_STATE (SCANNED_CASTER)) { NPCPhrase (SCAN_DRUUGE_CASTER); SET_GAME_STATE (SCANNED_CASTER, 1); } if (GET_GAME_STATE (PORTAL_SPAWNER_ON_SHIP) && !GET_GAME_STATE (SCANNED_SPAWNER)) { NPCPhrase (SCAN_ARILOU_SPAWNER); SET_GAME_STATE (SCANNED_SPAWNER, 1); } TradeWorld ((RESPONSE_REF)0); } else if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 6)) { if (GET_GAME_STATE (BOMB_VISITS)) NPCPhrase (SUBSEQ_BOMB_WORLD_HELLO); else { NPCPhrase (INIT_BOMB_WORLD_HELLO); SET_GAME_STATE (BOMB_VISITS, 1); } BombAmbush ((RESPONSE_REF)0); } else if (GET_GAME_STATE (ATTACKED_DRUUGE)) { NumVisits = GET_GAME_STATE (DRUUGE_VISITS); switch (NumVisits++) { case 0: NPCPhrase (HOSTILE_SPACE_HELLO_1); break; case 1: NPCPhrase (HOSTILE_SPACE_HELLO_2); --NumVisits; break; } SET_GAME_STATE (DRUUGE_VISITS, NumVisits); setSegue (Segue_hostile); } else { NumVisits = 0; if (GetHeadLink (&GLOBAL (built_ship_q)) == 0) { for (NumVisits = 0; NumVisits < NUM_MODULE_SLOTS; ++NumVisits) { BYTE which_module; which_module = GLOBAL_SIS (ModuleSlots[NumVisits]); if (which_module >= GUN_WEAPON && which_module <= CANNON_WEAPON) { NumVisits = 0; break; } } } if (NumVisits) { NumVisits = GET_GAME_STATE (DRUUGE_SALVAGE); switch (NumVisits++) { case 0: NPCPhrase (SALVAGE_YOUR_SHIP_1); break; case 1: NPCPhrase (SALVAGE_YOUR_SHIP_2); --NumVisits; break; } SET_GAME_STATE (DRUUGE_SALVAGE, NumVisits); setSegue (Segue_hostile); AttemptedSalvage = TRUE; } else { NumVisits = GET_GAME_STATE (DRUUGE_VISITS); switch (NumVisits++) { case 0: NPCPhrase (INIT_SPACE_HELLO); break; case 1: NPCPhrase (SUBSEQUENT_SPACE_HELLO); --NumVisits; break; } SET_GAME_STATE (DRUUGE_VISITS, NumVisits); Space ((RESPONSE_REF)0); } } }