Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core/Text] Replace old Object::MonsterSay with Unit:: Say #330

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/game/AI/CreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class TC_GAME_API CreatureAI : public UnitAI
virtual bool IsEscorted() { return false; }

// Called when creature is spawned or respawned (for reseting variables)
virtual void JustRespawned() { Reset(); }
virtual void JustAppeared() { Reset(); }

// Called at waypoint reached or point movement finished
virtual void MovementInform(uint32 /*type*/, uint32 /*id*/) { }
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void npc_escortAI::JustDied(Unit* /*killer*/)
}
}

void npc_escortAI::JustRespawned()
void npc_escortAI::JustAppeared()
{
m_uiEscortState = STATE_ESCORT_NONE;

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/ScriptedAI/ScriptedEscortAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct npc_escortAI : public ScriptedAI
void AttackStart(Unit* who) override;
void MoveInLineOfSight(Unit* who) override;
void JustDied(Unit*) override;
void JustRespawned() override;
void JustAppeared() override;
void ReturnToLastPoint();
void EnterEvadeMode() override;
void UpdateAI(uint32 diff) override; //the "internal" update, calls UpdateEscortAI()
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void FollowerAI::JustDied(Unit* /*killer*/)
}
}

void FollowerAI::JustRespawned()
void FollowerAI::JustAppeared()
{
m_uiFollowState = STATE_FOLLOW_NONE;

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FollowerAI : public ScriptedAI

void JustDied(Unit*);

void JustRespawned();
void JustAppeared();

void UpdateAI(uint32); //the "internal" update, calls UpdateFollowerAI()
virtual void UpdateFollowerAI(uint32); //used when it's needed to add code in update (abilities, scripted events, etc)
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/SmartScripts/SmartAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ bool SmartAI::AssistPlayerInCombat(Unit* who)
return false;
}

void SmartAI::JustRespawned()
void SmartAI::JustAppeared()
{
mDespawnTime = 0;
mDespawnState = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/SmartScripts/SmartAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TC_GAME_API SmartAI : public CreatureAI
bool IsEscortInvokerInRange();

// Called when creature is spawned or respawned
void JustRespawned() override;
void JustAppeared() override;

// Called after InitializeAI(), EnterEvadeMode() for resetting variables
void Reset() override;
Expand Down
20 changes: 12 additions & 8 deletions src/server/game/Entities/Creature/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ m_PlayerDamageReq(0), m_lootRecipient(), m_lootRecipientGroup(0), m_corpseRemove
m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f), m_WalkMode(0.0f), m_reactState(REACT_AGGRESSIVE),
m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
m_creatureInfo(nullptr), m_creatureData(nullptr), m_path_id(0), m_formation(NULL), m_respawnDelayMax(0), dynamicHealthPlayersCount(0)
m_creatureInfo(nullptr), m_creatureData(nullptr), m_path_id(0), m_formation(nullptr), m_triggerJustAppeared(true), m_respawnDelayMax(0), dynamicHealthPlayersCount(0)
{
m_regenTimer = 0;
m_valuesCount = UNIT_END;
Expand All @@ -231,7 +231,7 @@ m_creatureInfo(nullptr), m_creatureData(nullptr), m_path_id(0), m_formation(NULL
m_ReactDistance = 0;

ResetLootMode(); // restore default loot mode
TriggerJustRespawned = false;

m_isTempWorldObject = false;
_focusSpell = NULL;
}
Expand Down Expand Up @@ -558,10 +558,10 @@ void Creature::SetPhaseMask(uint32 newPhaseMask, bool update)

void Creature::Update(uint32 diff)
{
if (IsAIEnabled && TriggerJustRespawned)
if (IsAIEnabled && m_triggerJustAppeared)
{
TriggerJustRespawned = false;
AI()->JustRespawned();
m_triggerJustAppeared = false;
AI()->JustAppeared();
if (m_vehicleKit)
m_vehicleKit->Reset();
if (GetMap()->IsRaid() && ((InstanceMap*)GetMap())->GetInstanceScript())
Expand Down Expand Up @@ -1770,9 +1770,13 @@ void Creature::Respawn(bool force)

GetMotionMaster()->InitDefault();

//Call AI respawn virtual function
if (IsAIEnabled)
TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing
// Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState();

if (UnitAI* ai = AI()) // reset the AI to be sure no dirty or uninitialized values will be used till next tick
ai->Reset();

m_triggerJustAppeared = true;//delay event to next tick so all creatures are created on the map before processing

uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
if (poolid)
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Creature/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma

//Formation var
CreatureGroup* m_formation;
bool TriggerJustRespawned;
bool m_triggerJustAppeared;

Spell const* _focusSpell; ///> Locks the target during spell cast for proper facing
CreatureTextRepeatGroup m_textRepeat;
Expand Down
28 changes: 0 additions & 28 deletions src/server/game/Entities/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2549,34 +2549,6 @@ namespace Trinity
};
} // namespace Trinity

void WorldObject::MonsterSay(const char* text, uint32 language, WorldObject const* target)
{
CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());

Cell cell(p);
cell.SetNoCreate();

Trinity::MonsterCustomChatBuilder say_build(this, CHAT_MSG_MONSTER_SAY, text, language, target);
Trinity::LocalizedPacketDo<Trinity::MonsterCustomChatBuilder> say_do(say_build);
Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::MonsterCustomChatBuilder> > say_worker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), say_do);
TypeContainerVisitor<Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::MonsterCustomChatBuilder> >, WorldTypeMapContainer > message(say_worker);
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY));
}

void WorldObject::MonsterSay(int32 textId, uint32 language, WorldObject const* target)
{
CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());

Cell cell(p);
cell.SetNoCreate();

Trinity::MonsterChatBuilder say_build(this, CHAT_MSG_MONSTER_SAY, textId, language, target);
Trinity::LocalizedPacketDo<Trinity::MonsterChatBuilder> say_do(say_build);
Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::MonsterChatBuilder> > say_worker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), say_do);
TypeContainerVisitor<Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker);
cell.Visit(p, message, *GetMap(), *this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY));
}

void WorldObject::MonsterYell(const char* text, uint32 language, WorldObject const* target)
{
CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
Expand Down
2 changes: 0 additions & 2 deletions src/server/game/Entities/Object/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation

virtual uint8 GetLevelForTarget(WorldObject const* /*target*/) const { return 1; }

void MonsterSay(const char* text, uint32 language, WorldObject const* target);
void MonsterYell(const char* text, uint32 language, WorldObject const* target);
void MonsterSay(int32 textId, uint32 language, WorldObject const* target);
void MonsterYell(int32 textId, uint32 language, WorldObject const* target);

void PlayDistanceSound(uint32 sound_id, Player* target = NULL);
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/LuaEngine/HookMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1539,9 +1539,9 @@ struct HookMgr::ElunaCreatureAI : ScriptedAI
}

// Called when creature is spawned or respawned (for reseting variables)
void JustRespawned() override
void JustAppeared() override
{
ScriptedAI::JustRespawned();
ScriptedAI::JustAppeared();
int bind = sEluna->CreatureEventBindings->GetBind(me->GetEntry(), CREATURE_EVENT_ON_SPAWN);
if (!bind)
return;
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Battlegrounds/alterac_valley.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class npc_av_marshal_or_warmaster : public CreatureScript
_hasAura = false;
}

void JustRespawned() override
void JustAppeared() override
{
Reset();
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Battlegrounds/boss_balinda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct boss_balinda : public ScriptedAI
_events.ScheduleEvent(EVENT_BALINDA_RESET, 5s);
}

void JustRespawned() override
void JustAppeared() override
{
Reset();
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Battlegrounds/boss_drekthar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct boss_drekthar : public ScriptedAI
_events.ScheduleEvent(EVENT_DREKTHAR_RESET, 5s);
}

void JustRespawned() override
void JustAppeared() override
{
Reset();
Talk(YELL_RESPAWN);
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Battlegrounds/boss_galvangar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct boss_galvangar : public ScriptedAI
_events.ScheduleEvent(EVENT_GALVANGAR_RESET, 5s);
}

void JustRespawned() override
void JustAppeared() override
{
Reset();
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Battlegrounds/boss_vanndar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct boss_vanndar : public ScriptedAI
_events.ScheduleEvent(EVENT_VANNDAR_RESET, 5s);
}

void JustRespawned() override
void JustAppeared() override
{
Reset();
Talk(YELL_RESPAWN);
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Battlegrounds/isle_of_conquest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct boss_isle_of_conquest : public ScriptedAI
//Talk(YELL_AGGRO);
}

void JustRespawned() override
void JustAppeared() override
{
Reset();
}
Expand Down
6 changes: 3 additions & 3 deletions src/server/scripts/Commands/cs_wp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class wp_commandscript : public CommandScript
path_number = strtok((char*)args, " ");

uint32 pathid = 0;
uint32 guidLow = 0;
ObjectGuid::LowType guidLow = 0;
Creature* target = handler->getSelectedCreature();

// Did player provide a path_id?
Expand Down Expand Up @@ -212,7 +212,7 @@ class wp_commandscript : public CommandScript
target->LoadPath(pathid);
target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
target->GetMotionMaster()->Initialize();
target->MonsterSay("Path loaded.", LANG_UNIVERSAL, NULL);
target->Say("Path loaded.", LANG_UNIVERSAL);

return true;
}
Expand Down Expand Up @@ -276,7 +276,7 @@ class wp_commandscript : public CommandScript
target->SetDefaultMovementType(IDLE_MOTION_TYPE);
target->GetMotionMaster()->MoveTargetedHome();
target->GetMotionMaster()->Initialize();
target->MonsterSay("Path unloaded.", 0, 0);
target->Say("Path unloaded.", LANG_UNIVERSAL);
return true;
}

Expand Down
19 changes: 15 additions & 4 deletions src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,11 +884,14 @@ class npc_ros_dark_rider : public CreatureScript
};

// correct way: 52312 52314 52555 ...
enum Creatures_SG
enum TheGiftThatKeepsOnGiving
{
NPC_GHOULS = 28845,
NPC_GHOSTS = 28846,
SAY_LINE_0 = 0,

NPC_GHOULS = 28845,
NPC_GHOSTS = 28846,
};

class npc_dkc1_gothik : public CreatureScript
{
public:
Expand Down Expand Up @@ -993,10 +996,18 @@ class npc_scarlet_ghoul : public CreatureScript
// Ghouls should display their Birth Animation
// Crawling out of the ground
//DoCast(me, 35177, true);
//me->MonsterSay("Mommy?", LANG_UNIVERSAL, 0);
me->SetReactState(REACT_DEFENSIVE);
}

void JustAppeared() override
{
CreatureAI::JustAppeared();

if (urand(0, 1))
if (Unit* owner = me->GetOwner())
Talk(SAY_LINE_0, owner);
}

void FindMinions(Unit* owner)
{
std::list<Creature*> MinionList;
Expand Down
4 changes: 2 additions & 2 deletions src/server/scripts/EasternKingdoms/zone_vashjir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ struct npc_drowning_soldier_and_warrior : public ScriptedAI
{
npc_drowning_soldier_and_warrior(Creature* creature) : ScriptedAI(creature)
{
JustRespawned();
JustAppeared();
}

void JustRespawned() override
void JustAppeared() override
{
me->setRegeneratingHealth(false);
me->SetHealth(6190);
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Kalimdor/zone_durotar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ struct npc_captive_pitescale_scout : public ScriptedAI
{
npc_captive_pitescale_scout(Creature* creature) : ScriptedAI(creature) { }

void JustRespawned() override
void JustAppeared() override
{
if (GameObject* caje = me->FindNearestGameObject(201968, 30.0f))
caje->ResetDoorOrButton();
Expand Down
Loading
Loading