Tangible Object Use - State Checking

From SWGANH Wiki
Jump to: navigation, search

Background

There are times when using objects in game (such a banking terminal) is inappropriate like when the player is in combat or dead.

Currently when a player uses an object, the callback handler has to check against every possible state where we want to cancel the command such as:

if(playerObject == NULL || !playerObject->isConnected() || playerObject->getSamplingState() || playerObject->isIncapacitated() || playerObject->isDead()|| playerObject->checkState(CreatureState_Combat)) { return; }

In contrast, the combat system handles this in a different manner. The DB contains a list of combat skills such as UnarmedHit1 along with what states they may be used (eg. not whilst prone). These are loaded into the zone on startup.

When a player uses a combat skill the combat handler/queue checks the player against these states and decides whether to call the skill handler or not.

Proposed Changes

Whilst the current method works, moving to a similar system to the combat system has advantages:

  • We would no longer need to check for every individual use separately (which creates a lot of copy and paste code as well as quirky bugs where some objects aren't correctly checked but others are).
  • Allows changes to be made in the DB without code alterations/knowledge.