summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actions/commands.cpp42
-rw-r--r--src/actions/commands.h1
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h9
-rw-r--r--src/input/pages/basic.cpp6
5 files changed, 55 insertions, 4 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index cd35ba9aa..eafd0b82b 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -713,19 +713,34 @@ impHandler0(fireHomunculus)
return true;
}
-impHandler(buy)
+static Being *findBeing(const std::string &name)
{
- const std::string args = event.args;
Being *being = nullptr;
- if (args.empty())
+ if (name.empty())
{
being = localPlayer->getTarget();
}
else
{
being = actorManager->findBeingByName(
- args, ActorType::Unknown);
+ name, ActorType::Unknown);
+ }
+ if (!being)
+ {
+ being = actorManager->findNearestLivingBeing(
+ localPlayer, 1, ActorType::Npc, true);
+ }
+ if (!being)
+ {
+ being = actorManager->findNearestLivingBeing(
+ localPlayer, 1, ActorType::Player, true);
}
+ return being;
+}
+
+impHandler(buy)
+{
+ Being *being = findBeing(event.args);
if (!being)
return false;
@@ -742,4 +757,23 @@ impHandler(buy)
return false;
}
+impHandler(sell)
+{
+ Being *being = findBeing(event.args);
+ if (!being)
+ return false;
+
+ if (being->getType() == ActorType::Npc)
+ {
+ npcHandler->sell(being->getId());
+ return true;
+ }
+ else if (being->getType() == ActorType::Player)
+ {
+ buySellHandler->requestBuyList(being->getName());
+ return true;
+ }
+ return false;
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index 29fa6ef27..8f55b023e 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -77,6 +77,7 @@ namespace Actions
decHandler(setHomunculusName);
decHandler(fireHomunculus);
decHandler(buy);
+ decHandler(sell);
} // namespace Actions
#undef decHandler
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index 7187e2914..7e8a15ab1 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -491,6 +491,7 @@ namespace InputAction
NEXT_INV_TAB,
CONTEXT_MENU,
BUY,
+ SELL,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 2a8904503..f4579881c 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -4162,6 +4162,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
InputCondition::GAME,
"buy",
false},
+ {"keySell",
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ Input::GRP_DEFAULT,
+ &Actions::sell,
+ InputAction::NO_VALUE, 50,
+ InputCondition::GAME,
+ "sell",
+ false},
};
#endif // INPUT_INPUTACTIONMAP_H
diff --git a/src/input/pages/basic.cpp b/src/input/pages/basic.cpp
index f514d388b..5840e92c3 100644
--- a/src/input/pages/basic.cpp
+++ b/src/input/pages/basic.cpp
@@ -243,6 +243,12 @@ SetupActionData setupActionDataBasic[] =
},
{
// TRANSLATORS: input action name
+ N_("Sell"),
+ InputAction::SELL,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
N_("Open context menu"),
InputAction::CONTEXT_MENU,
"",