mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-07 10:21:31 +00:00
ULTIMA4: Ready weapon to keybinder
This commit is contained in:
parent
f2bd9f0f92
commit
22bc8e5438
@ -64,6 +64,7 @@ Debugger::Debugger() : Shared::Debugger() {
|
||||
registerCmd("pass", WRAP_METHOD(Debugger, cmdPass));
|
||||
registerCmd("peer", WRAP_METHOD(Debugger, cmdPeer));
|
||||
registerCmd("quitAndSave", WRAP_METHOD(Debugger, cmdQuitAndSave));
|
||||
registerCmd("ready", WRAP_METHOD(Debugger, cmdReadyWeapon));
|
||||
|
||||
registerCmd("3d", WRAP_METHOD(Debugger, cmd3d));
|
||||
registerCmd("collisions", WRAP_METHOD(Debugger, cmdCollisions));
|
||||
@ -154,7 +155,12 @@ void Debugger::castSpell(int player) {
|
||||
cmdCastSpell(2, argv);
|
||||
}
|
||||
|
||||
void Debugger::readyWeapon(int player) {
|
||||
Common::String param = Common::String::format("%d", player);
|
||||
const char *argv[2] = { "ready", param.c_str() };
|
||||
|
||||
cmdReadyWeapon(2, argv);
|
||||
}
|
||||
|
||||
|
||||
bool Debugger::cmdMove(int argc, const char **argv) {
|
||||
@ -728,6 +734,69 @@ bool Debugger::cmdQuitAndSave(int argc, const char **argv) {
|
||||
return isDebuggerActive();
|
||||
}
|
||||
|
||||
bool Debugger::cmdReadyWeapon(int argc, const char **argv) {
|
||||
int player = -1;
|
||||
if (argc == 2)
|
||||
player = strToInt(argv[1]);
|
||||
|
||||
// get the player if not provided
|
||||
if (player == -1) {
|
||||
printN("Ready a weapon for: ");
|
||||
player = gameGetPlayer(true, false);
|
||||
if (player == -1)
|
||||
return isDebuggerActive();
|
||||
}
|
||||
|
||||
// get the weapon to use
|
||||
g_context->_stats->setView(STATS_WEAPONS);
|
||||
printN("Weapon: ");
|
||||
WeaponType weapon = (WeaponType)AlphaActionController::get(WEAP_MAX + 'a' - 1, "Weapon: ");
|
||||
g_context->_stats->setView(STATS_PARTY_OVERVIEW);
|
||||
if (weapon == -1)
|
||||
return isDebuggerActive();
|
||||
|
||||
PartyMember *p = g_context->_party->member(player);
|
||||
const Weapon *w = Weapon::get(weapon);
|
||||
|
||||
|
||||
if (!w) {
|
||||
print("");
|
||||
return isDebuggerActive();
|
||||
}
|
||||
switch (p->setWeapon(w)) {
|
||||
case EQUIP_SUCCEEDED:
|
||||
print("%s", w->getName().c_str());
|
||||
break;
|
||||
case EQUIP_NONE_LEFT:
|
||||
print("%cNone left!%c", FG_GREY, FG_WHITE);
|
||||
break;
|
||||
case EQUIP_CLASS_RESTRICTED:
|
||||
{
|
||||
Common::String indef_article;
|
||||
|
||||
switch (tolower(w->getName()[0])) {
|
||||
case 'a':
|
||||
case 'e':
|
||||
case 'i':
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'y':
|
||||
indef_article = "an";
|
||||
break;
|
||||
default:
|
||||
indef_article = "a";
|
||||
break;
|
||||
}
|
||||
|
||||
print("\n%cA %s may NOT use %s %s%c", FG_GREY, getClassName(p->getClass()),
|
||||
indef_article.c_str(), w->getName().c_str(), FG_WHITE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isDebuggerActive();
|
||||
}
|
||||
|
||||
|
||||
bool Debugger::cmd3d(int argc, const char **argv) {
|
||||
if (g_context->_location->_context == CTX_DUNGEON) {
|
||||
|
@ -169,6 +169,12 @@ private:
|
||||
*/
|
||||
bool cmdQuitAndSave(int argc, const char **argv);
|
||||
|
||||
/**
|
||||
* Readies a weapon for a player. Prompts for the player and/or the
|
||||
* weapon if not provided.
|
||||
*/
|
||||
bool cmdReadyWeapon(int argc, const char **argv);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Collision detection on/off
|
||||
@ -312,6 +318,11 @@ public:
|
||||
* Cast a spell
|
||||
*/
|
||||
void castSpell(int player);
|
||||
|
||||
/**
|
||||
* Ready a weapon
|
||||
*/
|
||||
void readyWeapon(int player);
|
||||
};
|
||||
|
||||
extern Debugger *g_debugger;
|
||||
|
@ -690,10 +690,6 @@ bool GameController::keyPressed(int key) {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'r':
|
||||
readyWeapon();
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if (g_context->_location->_context == CTX_DUNGEON)
|
||||
dungeonSearch();
|
||||
@ -1342,66 +1338,6 @@ void GameController::avatarMovedInDungeon(MoveEvent &event) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Readies a weapon for a player. Prompts for the player and/or the
|
||||
* weapon if not provided.
|
||||
*/
|
||||
void readyWeapon(int player) {
|
||||
|
||||
// get the player if not provided
|
||||
if (player == -1) {
|
||||
screenMessage("Ready a weapon for: ");
|
||||
player = gameGetPlayer(true, false);
|
||||
if (player == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
// get the weapon to use
|
||||
g_context->_stats->setView(STATS_WEAPONS);
|
||||
screenMessage("Weapon: ");
|
||||
WeaponType weapon = (WeaponType) AlphaActionController::get(WEAP_MAX + 'a' - 1, "Weapon: ");
|
||||
g_context->_stats->setView(STATS_PARTY_OVERVIEW);
|
||||
if (weapon == -1)
|
||||
return;
|
||||
|
||||
PartyMember *p = g_context->_party->member(player);
|
||||
const Weapon *w = Weapon::get(weapon);
|
||||
|
||||
|
||||
if (!w) {
|
||||
screenMessage("\n");
|
||||
return;
|
||||
}
|
||||
switch (p->setWeapon(w)) {
|
||||
case EQUIP_SUCCEEDED:
|
||||
screenMessage("%s\n", w->getName().c_str());
|
||||
break;
|
||||
case EQUIP_NONE_LEFT:
|
||||
screenMessage("%cNone left!%c\n", FG_GREY, FG_WHITE);
|
||||
break;
|
||||
case EQUIP_CLASS_RESTRICTED: {
|
||||
Common::String indef_article;
|
||||
|
||||
switch (tolower(w->getName()[0])) {
|
||||
case 'a':
|
||||
case 'e':
|
||||
case 'i':
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'y':
|
||||
indef_article = "an";
|
||||
break;
|
||||
default:
|
||||
indef_article = "a";
|
||||
break;
|
||||
}
|
||||
|
||||
screenMessage("\n%cA %s may NOT use %s %s%c\n", FG_GREY, getClassName(p->getClass()),
|
||||
indef_article.c_str(), w->getName().c_str(), FG_WHITE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void talk() {
|
||||
screenMessage("Talk: ");
|
||||
|
@ -238,13 +238,11 @@ void gameUpdateScreen(void);
|
||||
void gameSpellEffect(int spell, int player, Sound sound);
|
||||
|
||||
/* action functions */
|
||||
void opendoor();
|
||||
bool gamePeerCity(int city, void *data);
|
||||
void peer(bool useGem = true);
|
||||
void talk();
|
||||
bool fireAt(const Coords &coords, bool originAvatar);
|
||||
Direction gameGetDirection();
|
||||
void readyWeapon(int player = -1);
|
||||
|
||||
/* checking functions */
|
||||
void gameCheckHullIntegrity(void);
|
||||
|
@ -939,7 +939,7 @@ bool CombatController::keyPressed(int key) {
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
readyWeapon(getFocus());
|
||||
g_debugger->readyWeapon(getFocus());
|
||||
break;
|
||||
|
||||
case 't':
|
||||
|
@ -60,8 +60,9 @@ static const KeybindingRecord KEYS[] = {
|
||||
{ KEYBIND_PASS, "PASS", "Pass", "pass", "SPACE", nullptr },
|
||||
{ KEYBIND_PEER, "PEER", "Peer", "peer", "p", nullptr },
|
||||
{ KEYBIND_QUIT_SAVE, "QUIT-SAVE", "Quit and Save", "quitAndSave", "q", nullptr },
|
||||
{ KEYBIND_READY_WEAPON, "READY-WEAPON", "Ready Weapon", "ready", nullptr },
|
||||
|
||||
{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr, nullptr }
|
||||
{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr, nullptr }
|
||||
};
|
||||
|
||||
static const KeybindingRecord CHEAT_KEYS[] = {
|
||||
|
@ -34,7 +34,7 @@ enum KeybindingAction {
|
||||
KEYBIND_ENTER, KEYBIND_FIRE, KEYBIND_GET, KEYBIND_HOLE_UP,
|
||||
KEYBIND_IGNITE, KEYBIND_JIMMY, KEYBIND_LOCATE, KEYBIND_MIX,
|
||||
KEYBIND_NEW_ORDER, KEYBIND_OPEN_DOOR, KEYBIND_PASS,
|
||||
KEYBIND_PEER, KEYBIND_QUIT_SAVE,
|
||||
KEYBIND_PEER, KEYBIND_QUIT_SAVE, KEYBIND_READY_WEAPON,
|
||||
|
||||
KEYBIND_NONE
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user