aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/EventAI.txt20
-rw-r--r--src/game/CombatHandler.cpp8
-rw-r--r--src/game/Creature.cpp2
-rw-r--r--src/game/CreatureEventAI.cpp6
-rw-r--r--src/game/CreatureEventAI.h6
-rw-r--r--src/game/CreatureEventAIMgr.cpp7
-rw-r--r--src/game/Pet.cpp6
-rw-r--r--src/game/Pet.h2
-rw-r--r--src/game/Player.cpp4
-rw-r--r--src/game/Player.h2
-rw-r--r--src/game/Unit.h5
11 files changed, 59 insertions, 9 deletions
diff --git a/doc/EventAI.txt b/doc/EventAI.txt
index 2390bb02c5f..5137c26dd18 100644
--- a/doc/EventAI.txt
+++ b/doc/EventAI.txt
@@ -129,6 +129,7 @@ Params are always read from Param1, then Param2, then Param3.
37 ACTION_T_DIE No Params Kills the creature
38 ACTION_T_ZONE_COMBAT_PULSE No Params Places all players within the instance into combat with the creature. Only works in combat and only works inside of instances.
39 ACTION_T_CALL_FOR_HELP Radius Call any friendly creatures (if its not in combat/etc) in radius attack creature target.
+40 ACTION_T_SET_SHEATH Sheath Let set sheath state for creature (0-no weapon show (not used mostly by creatures), 1-melee weapon show, 2-ranged weapon show)
* = Use -1 to specify that if this param is picked to do nothing. Random is constant between actions within an event. So if you have a random Yell and a random Sound they will match up (ex: param2 with param2)
@@ -684,6 +685,25 @@ This is commonly used if you need to Instakill the creature for one reason or an
--------------------------------
Places all players within the instance into combat with the creature. Only works in combat and only works inside of instances.
+----------------------------
+39 = ACTION_T_CALL_FOR_HELP:
+----------------------------
+Parameter 1: Radius - All friendly (not only same faction) creatures will go to help
+
+Call any friendly creatures (if its not in combat/etc) in radius attack creature target.
+Mostly used when call to help more wide that normal aggro radius or auto-used call for assistance, and need apply at some event.
+
+-------------------------
+40 ACTION_T_SET_SHEATH:
+-------------------------
+Parameter 1: Sheath state
+0 SHEATH_STATE_UNARMED not prepared weapon show (not used mostly by creatures)
+1 SHEATH_STATE_MELEE melee weapon prepared show
+2 SHEATH_STATE_RANGED ranged weapon prepared show
+
+Let set sheath state for creature.
+Note: SHEATH_STATE_RANGED case work in combat state only if combat not start as melee commands.
+This possible setup by set ar event AI start (single used EVENT_T_TIMER_OOC set ACTION_T_COMBAT_MOVEMENT 0 for creature that prefered ranged attack)
=========================================
Target Types
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 ); }