Skip to content

Instantly share code, notes, and snippets.

@daftmugi
Last active September 19, 2023 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daftmugi/f5f83c7668b95ba4e93a065f7572d3fc to your computer and use it in GitHub Desktop.
Save daftmugi/f5f83c7668b95ba4e93a065f7572d3fc to your computer and use it in GitHub Desktop.
diff --git game/Player.cpp game/Player.cpp
index 2973772..69e4494 100644
--- game/Player.cpp
+++ game/Player.cpp
@@ -11465,10 +11465,20 @@ void idPlayer::PerformFrob(EImpulseState impulseState, idEntity* target, bool al
// Retrieve the entity before trying to add it to the inventory, the pointer
// might be cleared after calling AddToInventory().
idEntity* highlightedEntity = m_FrobEntity.GetEntity();
-
- if (impulseState == EPressed)
+
+ const bool repeatMultiloot =
+ impulseState == ERepeat &&
+ multiloot &&
+ // Obsttorte: don't do anything if we are multilooting and this is no inventory item
+ target->spawnArgs.GetString("inv_name", nullptr) != nullptr &&
+ // Daft Mugi: Do not multiloot immobile readables (indirectly identified by snd_acquire null)
+ target->spawnArgs.GetString("snd_acquire", nullptr) != nullptr;
+
+ if (impulseState == EPressed || repeatMultiloot)
{
// Fire the STIM_FROB response on key down (if defined) on this entity
+ // Daft Mugi #6270: STIM_FROB response needs to be triggered when
+ // multiloot is likely to succeed on ERepeat.
target->TriggerResponse(this, ST_FROB);
}
@@ -11503,29 +11513,13 @@ void idPlayer::PerformFrob(EImpulseState impulseState, idEntity* target, bool al
// Inventory item could not be used with the highlighted entity, proceed with ordinary frob action
- // These actions are only applicable for EPressed buttonstate
- if (impulseState == EPressed || ((impulseState == ERepeat) && multiloot))
+ // Try to add world item to inventory
+ if (impulseState == EPressed || repeatMultiloot)
{
-
// First we have to check whether that entity is an inventory
// item. In that case, we have to add it to the inventory and
// hide the entity.
- if (multiloot &&
- // Obsttorte: don't do anything if we are multilooting and this is no inventory item
- (target->spawnArgs.GetString("inv_name", nullptr) == nullptr ||
- // Daft Mugi: Do not multiloot immobile readables (indirectly identified by snd_acquire null)
- target->spawnArgs.GetString("snd_acquire", nullptr) == nullptr))
- {
- return;
- }
-
- // Daft Mugi #6270: STIM_FROB response has not yet been fired when ERepeat,
- // so do it now before trying to add item to inventory when multilooting.
- if ((impulseState == ERepeat) && multiloot) {
- target->TriggerResponse(this, ST_FROB);
- }
-
// Trigger the frob action script on key down
target->FrobAction(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment