[7905] Implement ACTION_T_SET_SHEATH for creature event ai make possibility set ranged fire state. Author: VladimirMangos

Also related cleanup code in field cases and player Player::SetSheath.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-28 18:43:57 -05:00
parent 451471d438
commit 1288761fb7
11 changed files with 59 additions and 9 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;
}
}
}

View File

@@ -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
{

View File

@@ -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

View File

@@ -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;
}

View File

@@ -251,4 +251,4 @@ class Pet : public Guardian
assert(false);
}
};
#endif
#endif

View File

@@ -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

View File

@@ -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;

View File

@@ -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 ); }