37#define HAPPINESS_UFO_SALE_GAIN 0.02
38#define HAPPINESS_UFO_SALE_LOSS 0.005
49 const capacities_t* capacity = &installation->ufoCapacity;
50 if (capacity->
max > 0 && capacity->
max > capacity->
cur) {
51 cgi->UI_ExecuteConfunc(
"ui_uforecovery_ufoyards %d \"%s\" %d %d",
54 std::max(capacity->
max - capacity->
cur, 0),
68 if (
cgi->Cmd_Argc() < 4) {
69 cgi->Com_Printf(
"Usage: %s <ufoType> <damage> <installationIDX>\n",
cgi->Cmd_Argv(0));
75 cgi->Com_Printf(
"%s Invalid UFO type\n",
cgi->Cmd_Argv(0));
79 float condition = atof(
cgi->Cmd_Argv(2));
80 if (condition < 0.0f || condition > 100.0f) {
81 cgi->Com_Printf(
"%s Invalid UFO damage value\n",
cgi->Cmd_Argv(0));
86 if (installation ==
nullptr || installation->
ufoCapacity.
max <= 0) {
87 cgi->Com_Printf(
"%s Invalid Installation IDX\n",
cgi->Cmd_Argv(0));
92 cgi->Com_Printf(
"%s The selected installation has no spare capacity\n",
cgi->Cmd_Argv(0));
110 if (
cgi->Cmd_Argc() < 2) {
111 cgi->Com_Printf(
"Usage: %s <ufoType>\n",
cgi->Cmd_Argv(0));
116 if (ufo ==
nullptr) {
117 cgi->Com_Printf(
"%s Invalid ufo Type\n",
cgi->Cmd_Argv(0));
129 cgi->UI_ExecuteConfunc(
"ui_uforecovery_nations %s \"%s\" %d %s %.2f",
145 if (
cgi->Cmd_Argc() < 4) {
146 cgi->Com_Printf(
"Usage: %s <ufoID> <nationId> <price>\n",
cgi->Cmd_Argv(0));
151 if (nation ==
nullptr) {
152 cgi->Com_Printf(
"%s: Nation not found\n",
cgi->Cmd_Argv(0));
156 int price = atoi(
cgi->Cmd_Argv(3));
158 cgi->Com_Printf(
"%s: Invalid price\n",
cgi->Cmd_Argv(0));
163 cgi->Cmd_Argv(1),
_(nation->
name), price);
179 NAT_SetHappiness(
ccs.curCampaign->minhappiness, nat, nat->stats[0].happiness + ufoHappiness);
196 return "disassembling";
203 return "transferring";
218 cgi->UI_ExecuteConfunc(
"show_storedufo -");
226 if (
Q_streq(status,
"transferring")) {
242 if (
cgi->Cmd_Argc() < 2) {
243 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Usage: %s <idx> [0|1]\nWhere the second, optional parameter is the confirmation.\n",
cgi->Cmd_Argv(0));
248 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Stored UFO with idx: %i does not exist\n", atoi(
cgi->Cmd_Argv(1)));
253 if (
cgi->Cmd_Argc() < 3 || !atoi(
cgi->Cmd_Argv(2))) {
257 cgi->UI_PopupButton(
_(
"Destroy stored UFO"),
_(
"Do you really want to destroy this stored UFO?"),
258 command,
_(
"Destroy"),
_(
"Destroy stored UFO"),
259 "ui_pop;",
_(
"Cancel"),
_(
"Forget it"),
260 nullptr,
nullptr,
nullptr);
272 if (
cgi->Cmd_Argc() < 2) {
279 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Stored UFO with idx: %i does not exist\n", atoi(
cgi->Cmd_Argv(1)));
283 cgi->UI_ExecuteConfunc(
"ufotransferlist_clear");
288 const char* nationName = nat ?
_(nat->
name) :
"";
289 const int freeSpace = std::max(0, ins->ufoCapacity.max - ins->ufoCapacity.cur);
290 cgi->UI_ExecuteConfunc(
"ufotransferlist_addyard %d \"%s\" \"%s\" %d %d", ins->idx, ins->name, nationName, freeSpace, ins->ufoCapacity.max);
299 if (
cgi->Cmd_Argc() < 2) {
306 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Installation with idx: %i does not exist\n", atoi(
cgi->Cmd_Argv(1)));
310 cgi->UI_ExecuteConfunc(
"ufotransferlist_clearufos %d", ins->
idx);
312 if (ufo->installation != ins)
314 cgi->UI_ExecuteConfunc(
"ufotransferlist_addufos %d %d \"%s\"", ins->
idx, ufo->idx, ufo->ufoTemplate->model);
326 if (
cgi->Cmd_Argc() < 3) {
327 cgi->Com_Printf(
"Usage: %s <stored-ufo-idx> <ufoyard-idx>\n",
cgi->Cmd_Argv(0));
331 if (ufo ==
nullptr) {
332 cgi->Com_Printf(
"Stored ufo with idx %i not found.\n", atoi(
cgi->Cmd_Argv(1)));
337 cgi->Com_Printf(
"Installation with idx: %i does not exist\n", atoi(
cgi->Cmd_Argv(2)));
344 {
"cp_uforecovery_sell_init",
UR_DialogInitSell_f,
"Function to initialize sell recovered UFO to desired nation."},
345 {
"cp_uforecovery_store_init",
UR_DialogInitStore_f,
"Function to initialize store recovered UFO in desired base."},
347 {
"cp_uforecovery_sell_start",
UR_DialogStartSell_f,
"Function to start UFO selling processing."},
352 {
"ui_transferufo",
US_TransferUFO_f,
"Transfer stored UFO to another UFO Yard"},
353 {
nullptr,
nullptr,
nullptr}
DateTime class definition.
Share stuff between the different cgame implementations.
Class describing a point of time.
const aircraft_t * AIR_GetAircraft(const char *name)
Searches the global array of aircraft types for a given aircraft.
const aircraft_t * AIR_GetAircraftSilent(const char *name)
Searches the global array of aircraft types for a given aircraft.
#define AIR_IsUFO(aircraft)
void CP_UpdateCredits(int credits)
Sets credits and update mn_credits cvar.
Header file for single player campaign control.
const cgame_import_t * cgi
nation_t * GEO_GetNation(const vec2_t pos)
Translate nation map color to nation.
Header for Geoscape management.
installation_t * INS_GetByIDX(int idx)
Get installation by it's index.
#define INS_ForeachOfType(var, installationType)
uiMessageListNodeMessage_t * MS_AddNewMessage(const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup, bool playSound)
Adds a new message to message stack.
char cp_messageBuffer[MAX_MESSAGE_TEXT]
void NAT_SetHappiness(const float minhappiness, nation_t *nation, const float happiness)
Updates the nation happiness.
nation_t * NAT_GetNationByID(const char *nationID)
Return a nation-pointer by the nations id.
const nationInfo_t * NAT_GetCurrentMonthInfo(const nation_t *const nation)
Get the current month nation stats.
const char * NAT_GetHappinessString(const float happiness)
Translates the nation happiness float value to a string.
#define NAT_Foreach(var)
iterates trough nations
const char * CP_SecondConvert(int second)
Converts a number of second into a char to display.
int Date_DateToSeconds(const DateTime &date)
Convert a date to seconds.
Campaign geoscape time header.
const char * UFO_GetName(const aircraft_t *ufocraft)
Returns name of the UFO if UFO has been researched.
storedUFO_t * US_GetStoredUFOByIDX(const int idx)
Returns a stored ufo.
void US_RemoveStoredUFO(storedUFO_t *ufo)
Removes an UFO from the storage.
storedUFO_t * US_StoreUFO(const aircraft_t *ufoTemplate, installation_t *installation, DateTime &date, float condition)
Adds an UFO to the storage.
bool US_TransferUFO(storedUFO_t *ufo, installation_t *ufoyard)
Start transferring of a stored UFO.
UFO recovery and storing.
void UR_InitCallbacks(void)
static void US_SelectStoredUfo_f(void)
Send Stored UFO data to the UI.
static void US_TransferUFO_f(void)
Callback to start the transfer of a stored UFO.
static void UR_DialogInitStore_f(void)
Function to initialize list of storage locations for recovered UFO.
#define HAPPINESS_UFO_SALE_LOSS
static void US_FillUFOTransfer_f(void)
Fills UFO Yard UI with transfer destinations.
const char * US_StoredUFOStatus(const storedUFO_t *ufo)
Returns string representation of the stored UFO's status.
static void UR_DialogStartStore_f(void)
Function to start UFO recovery process.
static const cmdList_t ufoRecoveryCallbacks[]
static void US_DestroyStoredUFO_f(void)
Destroys a stored UFO.
static void UR_DialogInitSell_f(void)
Function to initialize list to sell recovered UFO to desired nation.
static void UR_DialogStartSell_f(void)
Function to start UFO selling process.
#define HAPPINESS_UFO_SALE_GAIN
void UR_ShutdownCallbacks(void)
static void US_FillUFOTransferUFOs_f(void)
Send Stored UFOs of the destination UFO Yard.
UFO recovery and storing callback header file.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
float frand(void)
Return random values between 0 and 1.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
An aircraft with all it's data.
Store capacities in base.
A installation with all it's data.
Detailed information about the nation relationship (currently per month, but could be used elsewhere)...
Structure for stored UFOs.
production_t * disassembly
const aircraft_t * ufoTemplate
installation_t * installation