MCPcopy Create free account
hub / github.com/EasyRPG/Player / CommandShowInn

Method CommandShowInn

src/game_interpreter_map.cpp:449–535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447}
448
449bool Game_Interpreter_Map::CommandShowInn(lcf::rpg::EventCommand const& com) { // code 10730
450 int inn_type = com.parameters[0];
451 int inn_price = com.parameters[1];
452 // Not used, but left here for documentation purposes
453 // bool has_inn_handlers = com.parameters[2] != 0;
454
455 if (inn_price == 0) {
456 if (Game_Message::IsMessageActive()) {
457 return false;
458 }
459
460 // Skip prompt.
461 _async_op = ContinuationShowInnStart(com.indent, 0, inn_price);
462 return true;
463 }
464
465 // Emulates RPG_RT behavior (Bug?) Inn's called by parallel events
466 // overwrite the current message.
467 if (main_flag && !Game_Message::CanShowMessage(main_flag)) {
468 return false;
469 }
470
471 PendingMessage pm(Game_Message::CommandCodeInserter);
472 pm.SetFromForegroundInterpreter(main_flag);
473
474 std::string_view greeting_1, greeting_2, greeting_3, accept, cancel;
475
476 switch (inn_type) {
477 case 0:
478 greeting_1 = lcf::Data::terms.inn_a_greeting_1;
479 greeting_2 = lcf::Data::terms.inn_a_greeting_2;
480 greeting_3 = lcf::Data::terms.inn_a_greeting_3;
481 accept = lcf::Data::terms.inn_a_accept;
482 cancel = lcf::Data::terms.inn_a_cancel;
483 break;
484 case 1:
485 greeting_1 = lcf::Data::terms.inn_b_greeting_1;
486 greeting_2 = lcf::Data::terms.inn_b_greeting_2;
487 greeting_3 = lcf::Data::terms.inn_b_greeting_3;
488 accept = lcf::Data::terms.inn_b_accept;
489 cancel = lcf::Data::terms.inn_b_cancel;
490 break;
491 }
492
493 if (Player::IsRPG2kE()) {
494 auto price_s = std::to_string(inn_price);
495 pm.PushLine(
496 Utils::ReplacePlaceholders(
497 greeting_1,
498 Utils::MakeArray('V', 'U'),
499 Utils::MakeSvArray(price_s, lcf::Data::terms.gold)
500 )
501 );
502 pm.PushLine(
503 Utils::ReplacePlaceholders(
504 greeting_3,
505 Utils::MakeArray('V', 'U'),
506 Utils::MakeSvArray(price_s, lcf::Data::terms.gold)

Callers

nothing calls this directly

Calls 9

MakeArrayFunction · 0.85
MakeSvArrayFunction · 0.85
GetGoldMethod · 0.80
SetChoiceResetColorsMethod · 0.80
PushChoiceMethod · 0.80
SetShowGoldWindowMethod · 0.80
SetChoiceContinuationMethod · 0.80
PushLineMethod · 0.45

Tested by

no test coverage detected