MM: MM1: Added Tavern view

This commit is contained in:
Paul Gilbert
2023-03-01 23:27:48 -08:00
parent 1f69adcd18
commit 950ca3745d
7 changed files with 242 additions and 6 deletions
@@ -516,6 +516,12 @@ enhdialogs:
select: "Select"
exit: "Exit"
non_caster: "Not a spell caster..."
tavern:
title: "Tavern"
drink: "\x01""37Drink"
gather: "\x01""37Gather"
tip: "\x01""37Tip"
rumor: "\x01""37Rumors"
temple:
title: "Temple"
heal: "\x01""37Heal"
+2
View File
@@ -36,6 +36,7 @@
#include "mm/mm1/views_enh/quick_ref.h"
#include "mm/mm1/views_enh/interactions/statue.h"
#include "mm/mm1/views_enh/locations/market.h"
#include "mm/mm1/views_enh/locations/tavern.h"
#include "mm/mm1/views_enh/locations/temple.h"
#include "mm/mm1/views_enh/locations/training.h"
#include "mm/mm1/views_enh/spells/cast_spell.h"
@@ -54,6 +55,7 @@ private:
Views::Title _title;
ViewsEnh::Interactions::Statue _statue;
ViewsEnh::Locations::Market _market;
ViewsEnh::Locations::Tavern _tavern;
ViewsEnh::Locations::Temple _temple;
ViewsEnh::Locations::Training _training;
ViewsEnh::Spells::CastSpell _castSpell;
@@ -0,0 +1,168 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "mm/mm1/views_enh/locations/tavern.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/mm1.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Locations {
Tavern::Tavern() : Location("Tavern", LOC_TAVERN) {
addButton(&_escSprite, Common::Point(24, 100), 0, KEYBIND_ESCAPE);
}
void Tavern::draw() {
Location::draw();
const Character &c = *g_globals->_currCharacter;
setReduced(false);
writeLine(0, STRING["enhdialogs.tavern.title"], ALIGN_MIDDLE);
writeLine(1, STRING["enhdialogs.location.options_for"], ALIGN_MIDDLE);
writeLine(3, c._name, ALIGN_MIDDLE);
writeLine(5, STRING["enhdialogs.tavern.drink"], ALIGN_LEFT, 10);
writeLine(6, STRING["enhdialogs.tavern.gather"], ALIGN_LEFT, 10);
writeLine(7, STRING["enhdialogs.tavern.tip"], ALIGN_LEFT, 10);
writeLine(8, STRING["enhdialogs.tavern.rumor"], ALIGN_LEFT, 10);
writeLine(10, STRING["enhdialogs.location.gold"]);
writeLine(10, Common::String::format("%d",
g_globals->_currCharacter->_gold), ALIGN_RIGHT);
setReduced(true);
writeString(27, 122, STRING["enhdialogs.location.esc"]);
}
bool Tavern::msgGame(const GameMessage &msg) {
Location::msgGame(msg);
/*
if (msg._name == "UPDATE")
checkCharacter();
*/
return true;
}
bool Tavern::msgKeypress(const KeypressMessage &msg) {
// If a delay is active, end it
if (endDelay())
return true;
switch (msg.keycode) {
case Common::KEYCODE_d:
haveADrink();
break;
case Common::KEYCODE_g:
g_globals->_currCharacter->gatherGold();
redraw();
break;
case Common::KEYCODE_t:
tipBartender();
break;
case Common::KEYCODE_r:
listenForRumors();
break;
default:
return Location::msgKeypress(msg);
break;
}
return true;
}
bool Tavern::msgAction(const ActionMessage &msg) {
if (endDelay())
return true;
if (msg._action == KEYBIND_ESCAPE) {
leave();
return true;
}
return Location::msgAction(msg);
}
void Tavern::messageShown() {
redraw();
}
void Tavern::haveADrink() {
if (g_globals->_currCharacter->_condition) {
Sound::sound(SOUND_2);
displayMessage(STRING["dialogs.tavern.terrible"]);
} else if (subtractGold(1)) {
if (++g_globals->_currCharacter->_numDrinks < 3 ||
g_engine->getRandomNumber(10) <
g_globals->_currCharacter->_endurance) {
displayMessage(STRING["dialogs.tavern.great_stuff"]);
} else {
if (!(g_globals->_currCharacter->_condition & BAD_CONDITION))
g_globals->_currCharacter->_condition |= POISONED;
Sound::sound(SOUND_2);
displayMessage(STRING["dialogs.tavern.you_feel_sick"]);
}
}
}
void Tavern::tipBartender() {
if (g_globals->_currCharacter->_condition) {
displayMessage(STRING["dialogs.tavern.go_see_clerics"]);
} else if (subtractGold(1)) {
if (g_globals->_currCharacter->_numDrinks == 0) {
displayMessage(STRING["dialogs.tavern.have_a_drink"]);
} else if (g_engine->getRandomNumber(3) != 3) {
displayMessage(STRING["dialogs.tavern.have_another_round"]);
} else {
int townNum = g_maps->_currentMap->dataByte(Maps::MAP_ID);
displayMessage(STRING[Common::String::format(
"dialogs.tavern.tips.%d_%d",
townNum, g_globals->_currCharacter->_numDrinks
)]);
}
}
}
void Tavern::listenForRumors() {
Common::String msg = STRING["dialogs.tavern.rumors.none"];
if (!g_globals->_heardRumor) {
g_globals->_heardRumor = true;
msg = STRING[Common::String::format(
"dialogs.tavern.rumors.%d",
g_engine->getRandomNumber(16))];
}
displayMessage(msg);
}
} // namespace Location
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
@@ -0,0 +1,65 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_ENH_LOCATIONS_TAVERN_H
#define MM1_VIEWS_ENH_LOCATIONS_TAVERN_H
#include "mm/mm1/views_enh/locations/location.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Locations {
class Tavern : public Location {
private:
/**
* Have a drink
*/
void haveADrink();
/**
* Tip the bartender
*/
void tipBartender();
/**
* Listen for rumors
*/
void listenForRumors();
public:
Tavern();
void draw() override;
bool msgGame(const GameMessage &msg);
bool msgKeypress(const KeypressMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
void messageShown() override;
};
} // namespace Locations
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif
@@ -197,11 +197,6 @@ void Training::train() {
}
}
void Training::timeout() {
checkCharacter();
Location::timeout();
}
void Training::messageShown() {
checkCharacter();
redraw();
@@ -61,7 +61,6 @@ public:
bool msgGame(const GameMessage &msg);
bool msgKeypress(const KeypressMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
void timeout() override;
void messageShown() override;
};
+1
View File
@@ -146,6 +146,7 @@ MODULE_OBJS += \
mm1/views_enh/interactions/statue.o \
mm1/views_enh/locations/location.o \
mm1/views_enh/locations/market.o \
mm1/views_enh/locations/tavern.o \
mm1/views_enh/locations/temple.o \
mm1/views_enh/locations/training.o \
mm1/maps/maps.o \