DB/Lock: Difference between revisions

From wowdev
Jump to navigation Jump to search
mNo edit summary
 
(2 intermediate revisions by one other user not shown)
Line 5: Line 5:
   uint32_t m_Index[4];
   uint32_t m_Index[4];
   uint32_t m_Skill[4];
   uint32_t m_Skill[4];
   uint32_t m_Action[4];
   uint32_t m_Action[4]; // OpenAction
  };
  };
==Structure==
==Structure==
Line 13: Line 13:
  10 Lock_Properties[8] Integer If the corresponding Type field is 2 then this is an iRefID_[[LockType.dbc]].  
  10 Lock_Properties[8] Integer If the corresponding Type field is 2 then this is an iRefID_[[LockType.dbc]].  
  If the corresponding Type field value is 1 then this is the itemID of the key or item that 'unlocks' this item.  
  If the corresponding Type field value is 1 then this is the itemID of the key or item that 'unlocks' this item.  
{{Template:Sandbox/VersionRange|min_expansionlevel=6}} If the corresponding Type field is 3 then this is a [[DB/Spell|Spell ID]]
  18 Required_Skill[8] Integer Required skill needed for Lock_Properties
  18 Required_Skill[8] Integer Required skill needed for Lock_Properties
  26 Action[8] Integer Something to do with direction / opening / closing. used in <code>CGGameObject_C::IsValidOpenAction</code>
  26 Action[8] Integer Something to do with direction / opening / closing. used in <code>CGGameObject_C::IsValidOpenAction</code>


==1.12.1.5875, 6.0.1.18179==
==1.12.1.5875 - 6.0.1.18179==
  struct LockRec {
  struct LockRec {
   uint32_t m_ID;
   uint32_t m_ID;
Line 24: Line 25:
   uint32_t m_Action[8];
   uint32_t m_Action[8];
  };
  };
==Action Validation==
<tt>m_Action</tt> is used to validate if the gameObject is eligible to be (re)used based on it's current state. This check is used in conjunction with the item/skill/spell requirements. This logic appears to be the same throughout {{Template:Sandbox/VersionRange|min_expansionlevel=0|max_expansionlevel=6}}.
<syntaxhighlight lang="cpp">
bool CGGameObject_C::IsValidOpenAction(OpenAction action)
{
  GOState state = this->m_gameObj->m_state; 
  bool locked = gameObject->m_flags & 0x2;
  if ( state == GO_STATE_ACTIVE_ALTERNATIVE ) // destroyed
    return action == OPENACTION_REBUILD;
  if ( action == OPENACTION_CLOSE )
    return state == GO_STATE_ACTIVE;
 
  if ( state != GO_STATE_READY )
    return false;
 
  if( action == OPENACTION_OPEN && locked )
    return false;
 
  if( action == OPENACTION_OPEN_UNLOCK && !locked )
    return false;
 
  return true;
}
enum OpenAction
{
  OPENACTION_OPEN        = 0x0,
  OPENACTION_OPEN_UNLOCK = 0x1, // mandatory unlock before open
  OPENACTION_CLOSE      = 0x2,
  OPENACTION_DESTROY    = 0x3, // mostly used by spells
  OPENACTION_REBUILD    = 0x4  // not seen in any DB
};
// taken from Trinity
enum GOState
{
  GO_STATE_ACTIVE            = 0,  // used and not reset (closed door is open)
  GO_STATE_READY              = 1,  // initial unused state (closed door is closed)
  GO_STATE_ACTIVE_ALTERNATIVE = 2,  // used and destroyed ([Blow Zul'Farrak Door]'s spell effect)
};
</syntaxhighlight>
[[Category:DBC]]
[[Category:DBC]]
[[Category:DBC_Alpha]]
[[Category:DBC_Alpha]]

Latest revision as of 08:08, 16 April 2018

0.5.3.3368

struct LockRec {
  uint32_t m_ID;
  uint32_t m_Type[4];
  uint32_t m_Index[4];
  uint32_t m_Skill[4];
  uint32_t m_Action[4]; // OpenAction
};

Structure

Column	Field 			Type 		Notes 
1 	ID 			Integer 	
2 	Type[8] 		Integer 	If this is 1, then the next lock_properties is an item ID, if it's 2, then it's an iRef to LockType.dbc 
10 	Lock_Properties[8] 	Integer 	If the corresponding Type field is 2 then this is an iRefID_LockType.dbc. 
						If the corresponding Type field value is 1 then this is the itemID of the key or item that 'unlocks' this item. 
						≥ WoD If the corresponding Type field is 3 then this is a Spell ID
18 	Required_Skill[8] 	Integer 	Required skill needed for Lock_Properties
26 	Action[8] 		Integer 	Something to do with direction / opening / closing. used in CGGameObject_C::IsValidOpenAction

1.12.1.5875 - 6.0.1.18179

struct LockRec {
  uint32_t m_ID;
  foreign_key<uint32_t, &LockTypeRec::m_ID> m_Type[8];
  uint32_t m_Index[8];
  uint32_t m_Skill[8];
  uint32_t m_Action[8];
};

Action Validation

m_Action is used to validate if the gameObject is eligible to be (re)used based on it's current state. This check is used in conjunction with the item/skill/spell requirements. This logic appears to be the same throughout PreVanilla … WoD.

bool CGGameObject_C::IsValidOpenAction(OpenAction action)
{
  GOState state = this->m_gameObj->m_state;  
  bool locked = gameObject->m_flags & 0x2;

  if ( state == GO_STATE_ACTIVE_ALTERNATIVE ) // destroyed
    return action == OPENACTION_REBUILD;

  if ( action == OPENACTION_CLOSE )
    return state == GO_STATE_ACTIVE; 
  
  if ( state != GO_STATE_READY )
    return false;
	  
  if( action == OPENACTION_OPEN && locked )
    return false;
	  
  if( action == OPENACTION_OPEN_UNLOCK && !locked )
    return false;
  
  return true;
}

enum OpenAction
{
  OPENACTION_OPEN        = 0x0,
  OPENACTION_OPEN_UNLOCK = 0x1, // mandatory unlock before open
  OPENACTION_CLOSE       = 0x2,
  OPENACTION_DESTROY     = 0x3, // mostly used by spells
  OPENACTION_REBUILD     = 0x4  // not seen in any DB
};

// taken from Trinity
enum GOState
{
  GO_STATE_ACTIVE             = 0,  // used and not reset (closed door is open)
  GO_STATE_READY              = 1,  // initial unused state (closed door is closed)
  GO_STATE_ACTIVE_ALTERNATIVE = 2,  // used and destroyed ([Blow Zul'Farrak Door]'s spell effect)
};