コード例 #1
0
static void
DoBuy (RESPONSE_REF R)
{
	COUNT credit;
	SIZE needed_credit;
	BYTE slot;
	DWORD capacity;

	credit = MAKE_WORD (
			GET_GAME_STATE (MELNORME_CREDIT0),
			GET_GAME_STATE (MELNORME_CREDIT1)
			);

	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--);

	if (credit == 0)
	{
		AskedToBuy = TRUE;
		NPCPhrase (NEED_CREDIT);

		NatureOfConversation (R);
	}
	else if (PLAYER_SAID (R, buy_fuel)
			|| PLAYER_SAID (R, buy_1_fuel)
			|| PLAYER_SAID (R, buy_5_fuel)
			|| PLAYER_SAID (R, buy_10_fuel)
			|| PLAYER_SAID (R, buy_25_fuel)
			|| PLAYER_SAID (R, fill_me_up))
	{
		needed_credit = 0;
		if (PLAYER_SAID (R, buy_1_fuel))
			needed_credit = 1;
		else if (PLAYER_SAID (R, buy_5_fuel))
			needed_credit = 5;
		else if (PLAYER_SAID (R, buy_10_fuel))
			needed_credit = 10;
		else if (PLAYER_SAID (R, buy_25_fuel))
			needed_credit = 25;
		else if (PLAYER_SAID (R, fill_me_up))
			needed_credit = (capacity - GLOBAL_SIS (FuelOnBoard)
					+ FUEL_TANK_SCALE - 1)
				/ FUEL_TANK_SCALE;

		if (needed_credit == 0)
		{
			if (!GET_GAME_STATE (MELNORME_FUEL_PROCEDURE))
			{
				NPCPhrase (BUY_FUEL_INTRO);
				SET_GAME_STATE (MELNORME_FUEL_PROCEDURE, 1);
			}
		}
		else
		{
			if (GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE
					+ needed_credit > capacity / FUEL_TANK_SCALE)
			{
				NPCPhrase (NO_ROOM_FOR_FUEL);
				goto TryFuelAgain;
			}

			if ((int)(needed_credit * (BIO_CREDIT_VALUE / 2)) <= (int)credit)
			{
				DWORD f;

				NPCPhrase (GOT_FUEL);

				f = (DWORD)needed_credit * FUEL_TANK_SCALE;
				LockMutex (GraphicsLock);
				while (f > 0x3FFFL)
				{
					DeltaSISGauges (0, 0x3FFF, 0);
					f -= 0x3FFF;
				}
				DeltaSISGauges (0, (SIZE)f, 0);
				UnlockMutex (GraphicsLock);
			}
			needed_credit *= (BIO_CREDIT_VALUE / 2);
		}
		if (needed_credit)
		{
			DeltaCredit (-needed_credit);
			if (GLOBAL_SIS (FuelOnBoard) >= capacity)
				goto BuyBuyBuy;
		}
TryFuelAgain:
		NPCPhrase (HOW_MUCH_FUEL);

		Response (buy_1_fuel, DoBuy);
		Response (buy_5_fuel, DoBuy);
		Response (buy_10_fuel, DoBuy);
		Response (buy_25_fuel, DoBuy);
		Response (fill_me_up, DoBuy);
		Response (done_buying_fuel, DoBuy);
	}
	else if (PLAYER_SAID (R, buy_technology)
			|| PLAYER_SAID (R, buy_new_tech))
	{
		BYTE stack;

		needed_credit = 0;
		if (PLAYER_SAID (R, buy_technology))
		{
			if (!GET_GAME_STATE (MELNORME_TECH_PROCEDURE))
			{
				NPCPhrase (BUY_NEW_TECH_INTRO);
				SET_GAME_STATE (MELNORME_TECH_PROCEDURE, 1);
			}
			stack = 0;
		}
		else
		{
			RESPONSE_REF pStr;

			stack = GET_GAME_STATE (MELNORME_TECH_STACK);
			switch (stack)
			{
				case 0:
					pStr = OK_BUY_NEW_TECH_1;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 1:
					pStr = OK_BUY_NEW_TECH_2;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 2:
					pStr = OK_BUY_NEW_TECH_3;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 3:
					pStr = OK_BUY_NEW_TECH_4;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 4:
					pStr = OK_BUY_NEW_TECH_5;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 5:
					pStr = OK_BUY_NEW_TECH_6;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 6:
					pStr = OK_BUY_NEW_TECH_7;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 7:
					pStr = OK_BUY_NEW_TECH_8;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 8:
					pStr = OK_BUY_NEW_TECH_9;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 9:
					pStr = OK_BUY_NEW_TECH_10;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 10:
					pStr = OK_BUY_NEW_TECH_11;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 11:
					pStr = OK_BUY_NEW_TECH_12;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
				case 12:
					pStr = OK_BUY_NEW_TECH_13;
					needed_credit = 75 * BIO_CREDIT_VALUE;
					break;
			}
			if ((int)needed_credit > (int)credit)
			{
				DeltaCredit (-needed_credit);
				goto BuyBuyBuy;
			}
			else
			{
				++stack;
				NPCPhrase (pStr);
				DeltaCredit (-needed_credit);
			}
		}

		switch (stack)
		{
			case 0:
				if (GLOBAL (ModuleCost[BLASTER_WEAPON]) == 0)
				{
					NPCPhrase (NEW_TECH_1);
					break;
				}
				++stack;
			case 1:
				GLOBAL (ModuleCost[BLASTER_WEAPON]) =
						4000 / MODULE_COST_SCALE;
				if (!GET_GAME_STATE (IMPROVED_LANDER_SPEED))
				{
					NPCPhrase (NEW_TECH_2);
					break;
				}
				++stack;
			case 2:
				SET_GAME_STATE (IMPROVED_LANDER_SPEED, 1);
				if (GLOBAL (ModuleCost[ANTIMISSILE_DEFENSE]) == 0)
				{
					NPCPhrase (NEW_TECH_3);
					break;
				}
				++stack;
			case 3:
				GLOBAL (ModuleCost[ANTIMISSILE_DEFENSE]) =
						4000 / MODULE_COST_SCALE;
				if (!(GET_GAME_STATE (LANDER_SHIELDS)
						& (1 << BIOLOGICAL_DISASTER)))
				{
					NPCPhrase (NEW_TECH_4);
					break;
				}
				++stack;
			case 4:
				credit = GET_GAME_STATE (LANDER_SHIELDS)
						| (1 << BIOLOGICAL_DISASTER);
				SET_GAME_STATE (LANDER_SHIELDS, credit);
				if (!GET_GAME_STATE (IMPROVED_LANDER_CARGO))
				{
					NPCPhrase (NEW_TECH_5);
					break;
				}
				++stack;
			case 5:
				SET_GAME_STATE (IMPROVED_LANDER_CARGO, 1);
				if (GLOBAL (ModuleCost[HIGHEFF_FUELSYS]) == 0)
				{
					NPCPhrase (NEW_TECH_6);
					break;
				}
				++stack;
			case 6:
				GLOBAL (ModuleCost[HIGHEFF_FUELSYS]) =
						1000 / MODULE_COST_SCALE;
				if (!GET_GAME_STATE (IMPROVED_LANDER_SHOT))
				{
					NPCPhrase (NEW_TECH_7);
					break;
				}
				++stack;
			case 7:
				SET_GAME_STATE (IMPROVED_LANDER_SHOT, 1);
				if (!(GET_GAME_STATE (LANDER_SHIELDS)
						& (1 << EARTHQUAKE_DISASTER)))
				{
					NPCPhrase (NEW_TECH_8);
					break;
				}
				++stack;
			case 8:
				credit = GET_GAME_STATE (LANDER_SHIELDS)
						| (1 << EARTHQUAKE_DISASTER);
				SET_GAME_STATE (LANDER_SHIELDS, credit);
				if (GLOBAL (ModuleCost[TRACKING_SYSTEM]) == 0)
				{
					NPCPhrase (NEW_TECH_9);
					break;
				}
				++stack;
			case 9:
				GLOBAL (ModuleCost[TRACKING_SYSTEM]) =
						5000 / MODULE_COST_SCALE;
				if (!(GET_GAME_STATE (LANDER_SHIELDS)
						& (1 << LIGHTNING_DISASTER)))
				{
					NPCPhrase (NEW_TECH_10);
					break;
				}
				++stack;
			case 10:
				credit = GET_GAME_STATE (LANDER_SHIELDS)
						| (1 << LIGHTNING_DISASTER);
				SET_GAME_STATE (LANDER_SHIELDS, credit);
				if (!(GET_GAME_STATE (LANDER_SHIELDS)
						& (1 << LAVASPOT_DISASTER)))
				{
					NPCPhrase (NEW_TECH_11);
					break;
				}
				++stack;
			case 11:
				credit = GET_GAME_STATE (LANDER_SHIELDS)
						| (1 << LAVASPOT_DISASTER);
				SET_GAME_STATE (LANDER_SHIELDS, credit);
				if (GLOBAL (ModuleCost[CANNON_WEAPON]) == 0)
				{
					NPCPhrase (NEW_TECH_12);
					break;
				}
				++stack;
			case 12:
				GLOBAL (ModuleCost[CANNON_WEAPON]) =
						6000 / MODULE_COST_SCALE;
				if (GLOBAL (ModuleCost[SHIVA_FURNACE]) == 0)
				{
					NPCPhrase (NEW_TECH_13);
					break;
				}
				++stack;
			case 13:
				GLOBAL (ModuleCost[SHIVA_FURNACE]) =
						4000 / MODULE_COST_SCALE;
				NPCPhrase (NEW_TECH_ALL_GONE);
				SET_GAME_STATE (MELNORME_TECH_STACK, stack);
				goto BuyBuyBuy;
		}
		SET_GAME_STATE (MELNORME_TECH_STACK, stack);

		Response (buy_new_tech, DoBuy);
		Response (no_buy_new_tech, DoBuy);
	}
	else if (PLAYER_SAID (R, buy_info)
			|| PLAYER_SAID (R, buy_current_events)
			|| PLAYER_SAID (R, buy_alien_races)
			|| PLAYER_SAID (R, buy_history))
	{
		needed_credit = 0;
		if (PLAYER_SAID (R, buy_info))
		{
			if (GET_GAME_STATE (MELNORME_INFO_PROCEDURE))
				NPCPhrase (OK_BUY_INFO);
			else
			{
				NPCPhrase (BUY_INFO_INTRO);
				SET_GAME_STATE (MELNORME_INFO_PROCEDURE, 1);
			}
		}
		else
		{
#define INFO_COST 75
			needed_credit = INFO_COST;
			if ((int)credit >= (int)needed_credit)
			{
				if (PLAYER_SAID (R, buy_current_events))
					CurrentEvents ();
				else if (PLAYER_SAID (R, buy_alien_races))
					AlienRaces ();
				else /* if (R == buy_history) */
					History ();
			}

			DeltaCredit (-needed_credit);
			if (GET_GAME_STATE (MELNORME_EVENTS_INFO_STACK) < NUM_EVENT_ITEMS
					 || GET_GAME_STATE (MELNORME_ALIEN_INFO_STACK) < NUM_ALIEN_RACE_ITEMS
					 || GET_GAME_STATE (MELNORME_HISTORY_INFO_STACK) < NUM_HISTORY_ITEMS)
			{
			}
			else
			{
				NPCPhrase (INFO_ALL_GONE);
				goto BuyBuyBuy;
			}
		}

		if (GET_GAME_STATE (MELNORME_EVENTS_INFO_STACK) < NUM_EVENT_ITEMS)
			Response (buy_current_events, DoBuy);
		if (GET_GAME_STATE (MELNORME_ALIEN_INFO_STACK) < NUM_ALIEN_RACE_ITEMS)
			Response (buy_alien_races, DoBuy);
		if (GET_GAME_STATE (MELNORME_HISTORY_INFO_STACK) < NUM_HISTORY_ITEMS)
			Response (buy_history, DoBuy);
		Response (done_buying_info, DoBuy);
	}
	else
	{
		if (PLAYER_SAID (R, done_buying_fuel))
			NPCPhrase (OK_DONE_BUYING_FUEL);
		else if (PLAYER_SAID (R, no_buy_new_tech))
			NPCPhrase (OK_NO_BUY_NEW_TECH);
		else if (PLAYER_SAID (R, done_buying_info))
			NPCPhrase (OK_DONE_BUYING_INFO);
		else
			NPCPhrase (WHAT_TO_BUY);

BuyBuyBuy:
		if (GLOBAL_SIS (FuelOnBoard) < capacity)
			Response (buy_fuel, DoBuy);
		if (GET_GAME_STATE (MELNORME_TECH_STACK) < NUM_TECH_ITEMS)
			Response (buy_technology, DoBuy);
		if (GET_GAME_STATE (MELNORME_ALIEN_INFO_STACK) < NUM_ALIEN_RACE_ITEMS
				|| GET_GAME_STATE (MELNORME_HISTORY_INFO_STACK) < NUM_HISTORY_ITEMS
				|| GET_GAME_STATE (MELNORME_EVENTS_INFO_STACK) < NUM_EVENT_ITEMS)
			Response (buy_info, DoBuy);
		Response (done_buying, NatureOfConversation);
		Response (be_leaving_now, ExitConversation);
	}
}
コード例 #2
0
static void
NatureOfConversation (RESPONSE_REF R)
{
	BYTE num_new_rainbows;
	UWORD rainbow_mask;
	COUNT Credit;

	if (PLAYER_SAID (R, get_on_with_business))
	{
		SET_GAME_STATE (MELNORME_YACK_STACK2, 5);
		R = 0;
	}

	Credit = DeltaCredit (0);
	if (R == 0)
	{
		BYTE stack;

		stack = (BYTE)(GET_GAME_STATE (MELNORME_YACK_STACK2) - 5);
		switch (stack++)
		{
			case 0:
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_1);
				break;
			case 1:
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_2);
				break;
			case 2:
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_3);
				break;
			case 3:
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_4);
				break;
			case 4:
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_5);
				break;
			case 5:
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_6);
				break;
			case 6:
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_7);
				break;
			case 7:
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_8);
				break;
			case 8:
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_9);
				break;
			default:
				--stack;
				NPCPhrase (HELLO_AND_DOWN_TO_BUSINESS_10);
				break;
		}
		SET_GAME_STATE (MELNORME_YACK_STACK2, stack + 5);
	}

	rainbow_mask = MAKE_WORD (
			GET_GAME_STATE (RAINBOW_WORLD0),
			GET_GAME_STATE (RAINBOW_WORLD1)
			);
	num_new_rainbows = (BYTE)(-GET_GAME_STATE (MELNORME_RAINBOW_COUNT));
	while (rainbow_mask)
	{
		if (rainbow_mask & 1)
			++num_new_rainbows;

		rainbow_mask >>= 1;
	}

	if (GLOBAL_SIS (FuelOnBoard) > 0
			|| GLOBAL_SIS (TotalBioMass)
			|| Credit
			|| num_new_rainbows)
	{
		if (!GET_GAME_STATE (TRADED_WITH_MELNORME))
		{
			SET_GAME_STATE (TRADED_WITH_MELNORME, 1);

			NPCPhrase (TRADING_INFO);
		}

		if (R == 0)
		{
				/* Melnorme reports any news and turns purple */
			NPCPhrase (BUY_OR_SELL);
			AlienTalkSegue(1);
			XFormColorMap (GetColorMapAddress (
					SetAbsColorMapIndex (CommData.AlienColorMap, 1)
					), ONE_SECOND / 2);
			AlienTalkSegue((COUNT)~0);
		}
		else if (PLAYER_SAID (R, why_turned_purple))
		{
			SET_GAME_STATE (WHY_MELNORME_PURPLE, 1);

			NPCPhrase (TURNED_PURPLE_BECAUSE);
		}
		else if (PLAYER_SAID (R, done_selling))
		{
			NPCPhrase (OK_DONE_SELLING);
		}
		else if (PLAYER_SAID (R, done_buying))
		{
			NPCPhrase (OK_DONE_BUYING);
		}

		if (!GET_GAME_STATE (WHY_MELNORME_PURPLE))
		{
			Response (why_turned_purple, NatureOfConversation);
		}
		if (!AskedToBuy)
			Response (buy, DoBuy);
		if (PHRASE_ENABLED (sell))
			Response (sell, DoSell);
		Response (goodbye, ExitConversation);
	}
	else /* needs to be rescued */
	{
		if (GET_GAME_STATE (MELNORME_RESCUE_REFUSED))
		{
			NPCPhrase (CHANGED_MIND);

			Response (yes_changed_mind, DoRescue);
			Response (no_changed_mind, ExitConversation);
		}
		else
		{
			BYTE num_rescues;

			num_rescues = GET_GAME_STATE (MELNORME_RESCUE_COUNT);
			switch (num_rescues)
			{
				case 0:
					NPCPhrase (RESCUE_EXPLANATION);
					break;
				case 1:
					NPCPhrase (RESCUE_AGAIN_1);
					break;
				case 2:
					NPCPhrase (RESCUE_AGAIN_2);
					break;
				case 3:
					NPCPhrase (RESCUE_AGAIN_3);
					break;
				case 4:
					NPCPhrase (RESCUE_AGAIN_4);
					break;
				case 5:
					NPCPhrase (RESCUE_AGAIN_5);
					break;
			 }

			if (num_rescues < 5)
			{
				++num_rescues;
				SET_GAME_STATE (MELNORME_RESCUE_COUNT, num_rescues);
			}

			NPCPhrase (SHOULD_WE_HELP_YOU);

			Response (yes_help, DoRescue);
			Response (no_help, ExitConversation);
		}
	}
}
コード例 #3
0
ファイル: melnorm.c プロジェクト: intgr/sc2-uqm
static void
DoBuy (RESPONSE_REF R)
{
	COUNT credit;
	SIZE needed_credit;
	BYTE slot;
	DWORD capacity;

	credit = GetAvailableCredits ();

	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--);

	// If they're out of credits, educate them on how commerce works.
	if (credit == 0)
	{
		AskedToBuy = TRUE;
		NPCPhrase (NEED_CREDIT);

		NatureOfConversation (R);
	}
	else if (PLAYER_SAID (R, buy_fuel)
			|| PLAYER_SAID (R, buy_1_fuel)
			|| PLAYER_SAID (R, buy_5_fuel)
			|| PLAYER_SAID (R, buy_10_fuel)
			|| PLAYER_SAID (R, buy_25_fuel)
			|| PLAYER_SAID (R, fill_me_up))
	{
		needed_credit = 0;
		if (PLAYER_SAID (R, buy_1_fuel))
			needed_credit = 1;
		else if (PLAYER_SAID (R, buy_5_fuel))
			needed_credit = 5;
		else if (PLAYER_SAID (R, buy_10_fuel))
			needed_credit = 10;
		else if (PLAYER_SAID (R, buy_25_fuel))
			needed_credit = 25;
		else if (PLAYER_SAID (R, fill_me_up))
			needed_credit = (capacity - GLOBAL_SIS (FuelOnBoard)
					+ FUEL_TANK_SCALE - 1)
				/ FUEL_TANK_SCALE;

		if (needed_credit == 0)
		{
			if (!GET_GAME_STATE (MELNORME_FUEL_PROCEDURE))
			{
				NPCPhrase (BUY_FUEL_INTRO);
				SET_GAME_STATE (MELNORME_FUEL_PROCEDURE, 1);
			}
		}
		else
		{
			if (GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE
					+ needed_credit > capacity / FUEL_TANK_SCALE)
			{
				NPCPhrase (NO_ROOM_FOR_FUEL);
				goto TryFuelAgain;
			}

			if ((int)(needed_credit * (BIO_CREDIT_VALUE / 2)) <= (int)credit)
			{
				DWORD f;

				NPCPhrase (GOT_FUEL);

				f = (DWORD)needed_credit * FUEL_TANK_SCALE;
				while (f > 0x3FFFL)
				{
					DeltaSISGauges (0, 0x3FFF, 0);
					f -= 0x3FFF;
				}
				DeltaSISGauges (0, (SIZE)f, 0);
			}
			needed_credit *= (BIO_CREDIT_VALUE / 2);
		}
		if (needed_credit)
		{
			DeltaCredit (-needed_credit);
			if (GLOBAL_SIS (FuelOnBoard) >= capacity)
				goto BuyBuyBuy;
		}
TryFuelAgain:
		NPCPhrase (HOW_MUCH_FUEL);

		Response (buy_1_fuel, DoBuy);
		Response (buy_5_fuel, DoBuy);
		Response (buy_10_fuel, DoBuy);
		Response (buy_25_fuel, DoBuy);
		Response (fill_me_up, DoBuy);
		Response (done_buying_fuel, DoBuy);
	}
	else if (PLAYER_SAID (R, buy_technology)
			|| PLAYER_SAID (R, buy_new_tech))
	{
		// Note that this code no longer uses the MELNORME_TECH_STACK state
		// buts, as they're not needed; we can tell what technologies the
		// player has by using the technology API above.  This opens the
		// possibility of the player acquiring tech from someplace other than
		// the Melnorme.
		const TechSaleData* nextTech;

		// If it's our first time, give an introduction.
		if (!GET_GAME_STATE (MELNORME_TECH_PROCEDURE))
		{
			NPCPhrase (BUY_NEW_TECH_INTRO);
			SET_GAME_STATE (MELNORME_TECH_PROCEDURE, 1);
		}

		// Did the player just attempt to buy a tech?
		if (PLAYER_SAID (R, buy_new_tech))
		{
			nextTech = GetNextTechForSale ();
			if (!nextTech)
				goto BuyBuyBuy; // No tech left to buy

			if (!DeltaCredit (-nextTech->price))
				goto BuyBuyBuy;  // Can't afford it

			// Make the sale
			GrantTech (nextTech->techId);
			NPCPhrase (nextTech->sold_line);
		}

		nextTech = GetNextTechForSale ();
		if (!nextTech)
		{
			NPCPhrase (NEW_TECH_ALL_GONE);
			goto BuyBuyBuy; // No tech left to buy
		}

		NPCPhrase (nextTech->sale_line);

		Response (buy_new_tech, DoBuy);
		Response (no_buy_new_tech, DoBuy);
	}
	else if (PLAYER_SAID (R, buy_info)
			|| PLAYER_SAID (R, buy_current_events)
			|| PLAYER_SAID (R, buy_alien_races)
			|| PLAYER_SAID (R, buy_history))
	{
		if (!GET_GAME_STATE (MELNORME_INFO_PROCEDURE))
		{
			NPCPhrase (BUY_INFO_INTRO);
			SET_GAME_STATE (MELNORME_INFO_PROCEDURE, 1);
		}
		else if (PLAYER_SAID (R, buy_info))
		{
			NPCPhrase (OK_BUY_INFO);
		}
		else
		{
#define INFO_COST 75
			if (!DeltaCredit (-INFO_COST))
				goto BuyBuyBuy;

			if (PLAYER_SAID (R, buy_current_events))
				CurrentEvents ();
			else if (PLAYER_SAID (R, buy_alien_races))
				AlienRaces ();
			else if (PLAYER_SAID (R, buy_history))
				History ();
		}

		if (!AnyInfoLeftToSell ())
		{
			NPCPhrase (INFO_ALL_GONE);
			goto BuyBuyBuy;
		}

		if (GET_GAME_STATE (MELNORME_EVENTS_INFO_STACK) < NUM_EVENT_ITEMS)
			Response (buy_current_events, DoBuy);
		if (GET_GAME_STATE (MELNORME_ALIEN_INFO_STACK) < NUM_ALIEN_RACE_ITEMS)
			Response (buy_alien_races, DoBuy);
		if (GET_GAME_STATE (MELNORME_HISTORY_INFO_STACK) < NUM_HISTORY_ITEMS)
			Response (buy_history, DoBuy);
		Response (done_buying_info, DoBuy);
	}
	else
	{
		if (PLAYER_SAID (R, done_buying_fuel))
			NPCPhrase (OK_DONE_BUYING_FUEL);
		else if (PLAYER_SAID (R, no_buy_new_tech))
			NPCPhrase (OK_NO_BUY_NEW_TECH);
		else if (PLAYER_SAID (R, done_buying_info))
			NPCPhrase (OK_DONE_BUYING_INFO);
		else
			NPCPhrase (WHAT_TO_BUY);

BuyBuyBuy:
		if (GLOBAL_SIS (FuelOnBoard) < capacity)
			Response (buy_fuel, DoBuy);
		if (GetNextTechForSale ())
			Response (buy_technology, DoBuy);
		if (AnyInfoLeftToSell ())
			Response (buy_info, DoBuy);

		Response (done_buying, NatureOfConversation);
		Response (be_leaving_now, ExitConversation);
	}
}
コード例 #4
0
static void
DoSell (RESPONSE_REF R)
{
	BYTE num_new_rainbows;
	UWORD rainbow_mask;
	SIZE added_credit;
	int what_to_sell_queued = 0;

	rainbow_mask = MAKE_WORD (
			GET_GAME_STATE (RAINBOW_WORLD0),
			GET_GAME_STATE (RAINBOW_WORLD1)
			);
	num_new_rainbows = (BYTE)(-GET_GAME_STATE (MELNORME_RAINBOW_COUNT));
	while (rainbow_mask)
	{
		if (rainbow_mask & 1)
			++num_new_rainbows;

		rainbow_mask >>= 1;
	}

	if (!PLAYER_SAID (R, sell))
	{
		if (PLAYER_SAID (R, sell_life_data))
		{
			DWORD TimeIn;

			added_credit = GLOBAL_SIS (TotalBioMass) * BIO_CREDIT_VALUE;

			NPCPhrase (SOLD_LIFE_DATA1);
			NPCPhrase (-(int)GLOBAL_SIS (TotalBioMass));
			NPCPhrase (SOLD_LIFE_DATA2);
			NPCPhrase (-(int)added_credit);
			NPCPhrase (SOLD_LIFE_DATA3);
			// queue WHAT_TO_SELL before talk-segue
			if (num_new_rainbows)
			{
				NPCPhrase (WHAT_TO_SELL);
				what_to_sell_queued = 1;
			}
			AlienTalkSegue (1);

			DrawCargoStrings ((BYTE)~0, (BYTE)~0);
			SleepThread (ONE_SECOND / 2);
			TimeIn = GetTimeCounter ();
			DrawCargoStrings (
					(BYTE)NUM_ELEMENT_CATEGORIES,
					(BYTE)NUM_ELEMENT_CATEGORIES
					);
			do
			{
				TimeIn = GetTimeCounter ();
				if (AnyButtonPress (TRUE))
				{
					DeltaCredit (GLOBAL_SIS (TotalBioMass) * BIO_CREDIT_VALUE);
					GLOBAL_SIS (TotalBioMass) = 0;
				}
				else
				{
					--GLOBAL_SIS (TotalBioMass);
					DeltaCredit (BIO_CREDIT_VALUE);
				}
				DrawCargoStrings (
						(BYTE)NUM_ELEMENT_CATEGORIES,
						(BYTE)NUM_ELEMENT_CATEGORIES
						);
			} while (GLOBAL_SIS (TotalBioMass));
			SleepThread (ONE_SECOND / 2);

			LockMutex (GraphicsLock);
			ClearSISRect (DRAW_SIS_DISPLAY);
			UnlockMutex (GraphicsLock);
		}
		else /* if (R == sell_rainbow_locations) */
		{
			added_credit = num_new_rainbows * (250 * BIO_CREDIT_VALUE);

			NPCPhrase (SOLD_RAINBOW_LOCATIONS1);
			NPCPhrase (-(int)num_new_rainbows);
			NPCPhrase (SOLD_RAINBOW_LOCATIONS2);
			NPCPhrase (-(int)added_credit);
			NPCPhrase (SOLD_RAINBOW_LOCATIONS3);

			num_new_rainbows += GET_GAME_STATE (MELNORME_RAINBOW_COUNT);
			SET_GAME_STATE (MELNORME_RAINBOW_COUNT, num_new_rainbows);
			num_new_rainbows = 0;

			DeltaCredit (added_credit);
		}
		
		AskedToBuy = FALSE;
	}

	if (GLOBAL_SIS (TotalBioMass) || num_new_rainbows)
	{
		if (!what_to_sell_queued)
			NPCPhrase (WHAT_TO_SELL);

		if (GLOBAL_SIS (TotalBioMass))
			Response (sell_life_data, DoSell);
		if (num_new_rainbows)
			Response (sell_rainbow_locations, DoSell);
		Response (done_selling, NatureOfConversation);
	}
	else
	{
		if (PLAYER_SAID (R, sell))
			NPCPhrase (NOTHING_TO_SELL);
		DISABLE_PHRASE (sell);

		NatureOfConversation (R);
	}
}
コード例 #5
0
ファイル: melnorm.c プロジェクト: intgr/sc2-uqm
static void
NatureOfConversation (RESPONSE_REF R)
{
	BYTE num_new_rainbows;
	UWORD rainbow_mask;
	COUNT Credit;

	if (PLAYER_SAID (R, get_on_with_business))
	{
		SET_GAME_STATE (MELNORME_YACK_STACK2, 5);
		R = 0;
	}

	// Draw credits display
	DeltaCredit (0);
	Credit = GetAvailableCredits ();
	if (R == 0)
	{
		BYTE stack = GET_GAME_STATE (MELNORME_YACK_STACK2) - 5;
		NPCPhrase (GetLineSafe (hello_and_down_to_business_lines, stack));
		if (stack < (NUM_HELLO_LINES - 1))
			++stack;
		SET_GAME_STATE (MELNORME_YACK_STACK2, stack + 5);
	}

	rainbow_mask = MAKE_WORD (
			GET_GAME_STATE (RAINBOW_WORLD0),
			GET_GAME_STATE (RAINBOW_WORLD1)
			);
	num_new_rainbows = (BYTE)(-GET_GAME_STATE (MELNORME_RAINBOW_COUNT));
	while (rainbow_mask)
	{
		if (rainbow_mask & 1)
			++num_new_rainbows;

		rainbow_mask >>= 1;
	}

	if (GLOBAL_SIS (FuelOnBoard) > 0
			|| GLOBAL_SIS (TotalBioMass)
			|| Credit
			|| num_new_rainbows)
	{
		if (!GET_GAME_STATE (TRADED_WITH_MELNORME))
		{
			SET_GAME_STATE (TRADED_WITH_MELNORME, 1);

			NPCPhrase (TRADING_INFO);
		}

		if (R == 0)
		{
				/* Melnorme reports any news and turns purple */
			NPCPhrase (BUY_OR_SELL);
			AlienTalkSegue (1);
			XFormColorMap (GetColorMapAddress (
					SetAbsColorMapIndex (CommData.AlienColorMap, 1)
					), ONE_SECOND / 2);
			AlienTalkSegue ((COUNT)~0);
		}
		else if (PLAYER_SAID (R, why_turned_purple))
		{
			SET_GAME_STATE (WHY_MELNORME_PURPLE, 1);

			NPCPhrase (TURNED_PURPLE_BECAUSE);
		}
		else if (PLAYER_SAID (R, done_selling))
		{
			NPCPhrase (OK_DONE_SELLING);
		}
		else if (PLAYER_SAID (R, done_buying))
		{
			NPCPhrase (OK_DONE_BUYING);
		}

		if (!GET_GAME_STATE (WHY_MELNORME_PURPLE))
		{
			Response (why_turned_purple, NatureOfConversation);
		}
		if (!AskedToBuy)
			Response (buy, DoBuy);
		if (PHRASE_ENABLED (sell))
			Response (sell, DoSell);
		Response (goodbye, ExitConversation);
	}
	else /* needs to be rescued */
	{
		if (GET_GAME_STATE (MELNORME_RESCUE_REFUSED))
		{
			NPCPhrase (CHANGED_MIND);

			Response (yes_changed_mind, DoRescue);
			Response (no_changed_mind, ExitConversation);
		}
		else
		{
			BYTE num_rescues = GET_GAME_STATE (MELNORME_RESCUE_COUNT);
			NPCPhrase (GetLineSafe (rescue_lines, num_rescues));

			if (num_rescues < NUM_RESCUE_LINES - 1)
			{
				++num_rescues;
				SET_GAME_STATE (MELNORME_RESCUE_COUNT, num_rescues);
			}

			NPCPhrase (SHOULD_WE_HELP_YOU);

			Response (yes_help, DoRescue);
			Response (no_help, ExitConversation);
		}
	}
}