diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/CombatHandler.cpp | 8 | ||||
-rw-r--r-- | src/game/Creature.cpp | 2 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 6 | ||||
-rw-r--r-- | src/game/CreatureEventAI.h | 6 | ||||
-rw-r--r-- | src/game/CreatureEventAIMgr.cpp | 7 | ||||
-rw-r--r-- | src/game/Pet.cpp | 6 | ||||
-rw-r--r-- | src/game/Pet.h | 2 | ||||
-rw-r--r-- | src/game/Player.cpp | 4 | ||||
-rw-r--r-- | src/game/Player.h | 2 | ||||
-rw-r--r-- | src/game/Unit.h | 5 |
10 files changed, 39 insertions, 9 deletions
diff --git a/src/game/CombatHandler.cpp b/src/game/CombatHandler.cpp index f732f128fd0..b49f573a5e4 100644 --- a/src/game/CombatHandler.cpp +++ b/src/game/CombatHandler.cpp @@ -75,7 +75,13 @@ void WorldSession::HandleSetSheathedOpcode( WorldPacket & recv_data ) //sLog.outDebug( "WORLD: Recvd CMSG_SETSHEATHED Message guidlow:%u value1:%u", GetPlayer()->GetGUIDLow(), sheathed ); - GetPlayer()->SetSheath(sheathed); + if(sheathed >= MAX_SHEATH_STATE) + { + sLog.outError("Unknown sheath state %u ??",sheathed); + return; + } + + GetPlayer()->SetSheath(SheathState(sheathed)); } void WorldSession::SendAttackStop(Unit const* enemy) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index aba48f985b7..6eecc3213fa 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -340,7 +340,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data ) m_regenHealth = GetCreatureInfo()->RegenHealth; // creatures always have melee weapon ready if any - SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE ); + SetSheath(SHEATH_STATE_MELEE); SelectLevel(GetCreatureInfo()); if (team == HORDE) diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index c2ae915c9a4..267ceb5f7de 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -795,6 +795,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } break; } + + case ACTION_T_SET_SHEATH: + { + m_creature->SetSheath(SheathState(action.set_sheath.sheath)); + break; + } } } diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 7b9fe84453e..eb9a2a2dff5 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -102,6 +102,7 @@ enum EventAI_ActionType ACTION_T_DIE = 37, // No Params ACTION_T_ZONE_COMBAT_PULSE = 38, // No Params ACTION_T_CALL_FOR_HELP = 39, // Radius + ACTION_T_SET_SHEATH = 40, // Sheath (0-passive,1-melee,2-ranged) ACTION_T_SET_ACTIVE = 101, //Apply ACTION_T_SET_AGGRESSIVE = 102, //Apply @@ -369,6 +370,11 @@ struct CreatureEventAI_Action { uint32 radius; } call_for_help; + // ACTION_T_SET_SHEATH = 40 + struct + { + uint32 sheath; + } set_sheath; // RAW struct { diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index 1905fa72d41..af79ae5189c 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -641,6 +641,13 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.update_template.creatureId)) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.update_template.creatureId); break; + case ACTION_T_SET_SHEATH: + if (action.set_sheath.sheath >= MAX_SHEATH_STATE) + { + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses wrong sheath state %u.", i, j+1, action.set_sheath.sheath); + action.set_sheath.sheath = SHEATH_STATE_UNARMED; + } + break; case ACTION_T_EVADE: //No Params case ACTION_T_FLEE_FOR_ASSIST: //No Params case ACTION_T_DIE: //No Params diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 4d7c851b2df..cd920852952 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -197,7 +197,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool break; case HUNTER_PET: SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100); - SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE); + SetSheath(SHEATH_STATE_MELEE); SetByteValue(UNIT_FIELD_BYTES_2, 2, fields[9].GetBool() ? UNIT_RENAME_NOT_ALLOWED : UNIT_RENAME_ALLOWED); SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); @@ -747,7 +747,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) if(cinfo->type == CREATURE_TYPE_BEAST) { SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100); - SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE ); + SetSheath(SHEATH_STATE_MELEE); SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_ALLOWED); SetUInt32Value(UNIT_MOD_CAST_SPEED, creature->GetUInt32Value(UNIT_MOD_CAST_SPEED)); } @@ -1676,7 +1676,7 @@ bool Pet::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint3 if(!InitEntry(Entry)) return false; - SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE); + SetSheath(SHEATH_STATE_MELEE); return true; } diff --git a/src/game/Pet.h b/src/game/Pet.h index b4d5b928e97..28798080623 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -251,4 +251,4 @@ class Pet : public Guardian assert(false); } }; -#endif
\ No newline at end of file +#endif diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 111b4e1bd48..46975d18fa9 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -8188,7 +8188,7 @@ void Player::SetVirtualItemSlot( uint8 i, Item* item) } } -void Player::SetSheath( uint32 sheathed ) +void Player::SetSheath( SheathState sheathed ) { switch (sheathed) { @@ -8214,7 +8214,7 @@ void Player::SetSheath( uint32 sheathed ) SetVirtualItemSlot(2,NULL); break; } - SetByteValue(UNIT_FIELD_BYTES_2, 0, sheathed); // this must visualize Sheath changing for other players... + Unit::SetSheath(sheathed); // this must visualize Sheath changing for other players... } uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const diff --git a/src/game/Player.h b/src/game/Player.h index 26892cde3f3..0d7d3068d92 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -938,7 +938,7 @@ class TRINITY_DLL_SPEC Player : public Unit /*********************************************************/ void SetVirtualItemSlot( uint8 i, Item* item); - void SetSheath( uint32 sheathed ); + void SetSheath( SheathState sheathed ); // overwrite Unit version uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const; uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const; Item* GetItemByGuid( uint64 guid ) const; diff --git a/src/game/Unit.h b/src/game/Unit.h index 75bc9d927f1..399d0667e3e 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -219,6 +219,8 @@ enum SheathState SHEATH_STATE_RANGED = 2 // prepared ranged weapon }; +#define MAX_SHEATH_STATE 3 + // byte (1 from 0..3) of UNIT_FIELD_BYTES_2 enum UnitBytes2_Flags { @@ -1036,6 +1038,9 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void ApplyAttackTimePercentMod(WeaponAttackType att,float val, bool apply); void ApplyCastTimePercentMod(float val, bool apply); + SheathState GetSheath() const { return SheathState(GetByteValue(UNIT_FIELD_BYTES_2, 0)); } + virtual void SetSheath( SheathState sheathed ) { SetByteValue(UNIT_FIELD_BYTES_2, 0, sheathed); } + // faction template id uint32 getFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); } void setFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction ); } |