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

feat(Core) Dynamic Creature/GameObject #14893

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5d6b19a
temp
Feb 6, 2023
70c5e8b
new fixes
Feb 6, 2023
57dfd72
new fixes
Feb 7, 2023
3c48e97
final core fixes
Feb 7, 2023
185c05a
other fixes
Feb 7, 2023
c260041
New builds fixes & Remove SAVE_RESPAWN_TIME_IMMEDIATELY
Feb 7, 2023
0460efc
fix builds compile with Create()
Feb 8, 2023
2810a38
fix build compile with GuidWarning() and GuidAlert()
Feb 8, 2023
86d8df0
new fixes
Feb 8, 2023
b2f0dad
final build fixes and codestyle
Feb 8, 2023
4d944b4
fix gcc/clang and cli build
Feb 8, 2023
7559239
try new fix
Feb 8, 2023
ddff700
fix build, important new modifications for cs_npc, and strings for dy…
Feb 8, 2023
b42411a
remove unused variable and _DespawnAtEvade()
Feb 8, 2023
5adeaeb
.
Feb 8, 2023
82a7e9e
simplify the method for now
Feb 8, 2023
1d52016
.
Feb 8, 2023
33526b5
.
Feb 8, 2023
44a5b30
missing WorldMock
Feb 9, 2023
38a3156
remove unused variable, and some other improvements
Feb 10, 2023
07634fd
fix id naming, and allow to keep 3 ids for creautres
Feb 10, 2023
917ba95
remove some sql lines waiting to implement new commands
Feb 10, 2023
07655af
import last change in commands and restore sql strings
Feb 10, 2023
a1834f6
.
Feb 10, 2023
adb7818
Revert "."
Feb 11, 2023
49611d3
try a new fix
Feb 11, 2023
717f606
Merge branch 'master' into dynamic-crea-go
Feb 11, 2023
69a3e5a
remove list respawn and fix codestyle
Feb 11, 2023
fa5cd8f
fix last commit
Feb 11, 2023
36d6e22
build fix
Feb 11, 2023
17f1a26
Merge branch 'dynamic-crea-go' of https://github.com/Maelthyrr/Person…
Feb 11, 2023
206bc29
codestyle
Feb 12, 2023
a57c42d
update from master branch
Feb 12, 2023
90cfc34
Merge branch 'azerothcore:master' into dynamic-crea-go
Feb 15, 2023
6d408cc
remove unused method
Feb 15, 2023
e6f1752
Merge branch 'dynamic-crea-go' of https://github.com/Maelthyrr/Person…
Feb 15, 2023
9aa8fe6
fix few LOG_ERROR in Creatures.cpp
Feb 15, 2023
87a5e16
Merge branch 'azerothcore:master' into dynamic-crea-go
Feb 21, 2023
ec5cbdd
Merge branch 'azerothcore:master' into dynamic-crea-go
Feb 26, 2023
97a46bb
already present in AC
Feb 26, 2023
4a2184e
use GetGameTime in CheckRespawn()
Feb 26, 2023
1bf4497
update from master
Mar 11, 2023
dfb9151
use ftm in some log
Mar 11, 2023
71cbc47
fix with last commit
Mar 11, 2023
ac5cb76
new fixes
Mar 11, 2023
e8e16e4
few restore changes and fix some other things
Mar 11, 2023
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
Prev Previous commit
Next Next commit
final build fixes and codestyle
  • Loading branch information
Maelthyrr committed Feb 8, 2023
commit b2f0dadb66c0b7a5b5f8ff253bb8e70305c03a82
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,12 @@ INSERT INTO `spawn_group` (`groupId`, `spawnType`, `spawnId`) VALUES
(3, 0, 202337),
(3, 0, 2017),
(3, 0, 132683);

-- remove potential duplicates
DELETE FROM `spawn_group` WHERE `groupId` != 3 AND `spawnType`=0 AND `spawnId` IN (SELECT `spawnId` FROM (SELECT `spawnId` FROM `spawn_group` WHERE `groupId`=3 AND `spawnType`=0) as `temp`);
DELETE FROM `spawn_group` WHERE `groupId` != 4 AND `spawnType`=1 AND `spawnId` IN (SELECT `spawnId` FROM (SELECT `spawnId` FROM `spawn_group` WHERE `groupId`=4 AND `spawnType`=1) as `temp`);

-- Update trinity strings for various cs_list strings, to support showing spawn ID and guid.
-- Update Acore strings for various cs_list strings, to support showing spawn ID and guid.
UPDATE `acore_string`
SET `content_default` = '%d (Entry: %d) - |cffffffff|Hgameobject:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r %s %s'
WHERE `entry` = 517;
Expand Down
5 changes: 5 additions & 0 deletions data/sql/updates/pending_db_world/rev_1675863321192995800.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Cherry-pick: https://github.com/TrinityCore/TrinityCore/commit/3d4bebd8d9210fbb84f8fc75742e248071192b09
-- (Co-authored-by: Treeston <treeston@users.noreply.github.com>)
DELETE FROM `spawn_group` WHERE `spawnType`=0 AND `spawnId` IN (22831,36626,23708,39059);
INSERT INTO `spawn_group` (`groupId`,`spawnType`,`spawnId`) VALUES
(3,0,22831), (3,0,36626), (3,0,23708), (3,0,39059);
2 changes: 2 additions & 0 deletions src/server/game/AI/CreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class CreatureAI : public UnitAI

// Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
virtual void AttackedBy(Unit* /*attacker*/) {}

// Should return true if the NPC is currently being escorted
virtual bool IsEscorted() { return false; }

// Called when creature is spawned or respawned (for reseting variables)
Expand Down
8 changes: 8 additions & 0 deletions src/server/game/Entities/Creature/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3755,6 +3755,14 @@ uint32 Creature::GetPlayerDamageReq() const
return _playerDamageReq;
}

bool Creature::IsEscorted() const
{
if (!IsAIEnabled)
return false;

return AI()->IsEscorted();
}

std::string Creature::GetDebugInfo() const
{
std::stringstream sstr;
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 @@ -391,7 +391,7 @@ class Creature : public Unit, public GridObject<Creature>, public MovableMapObje

void ModifyThreatPercentTemp(Unit* victim, int32 percent, Milliseconds duration);

bool IsEscorted(bool onlyIfActive = true) const;
bool IsEscorted() const;

std::string GetDebugInfo() const override;

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/GameObject/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask, bool
if (!data.spawnId)
data.spawnId = m_spawnId;
ASSERT(data.spawnId == m_spawnId);

data.id = GetEntry();
data.spawnPoint.WorldRelocate(this);
data.phaseMask = phaseMask;
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Entities/Object/ObjectGuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ void ObjectGuidGeneratorBase::HandleCounterOverflow(HighGuid high)

void ObjectGuidGeneratorBase::CheckGuidTrigger(ObjectGuid::LowType guidlow)
{
if (!World::IsGuidAlert() && guidlow > sWorld->getIntConfig(CONFIG_RESPAWN_GUIDALERTLEVEL))
if (!sWorld->IsGuidAlert() && guidlow > sWorld->getIntConfig(CONFIG_RESPAWN_GUIDALERTLEVEL))
sWorld->TriggerGuidAlert();
else if (!World::IsGuidWarning() && guidlow > sWorld->getIntConfig(CONFIG_RESPAWN_GUIDWARNLEVEL))
else if (!sWorld->IsGuidWarning() && guidlow > sWorld->getIntConfig(CONFIG_RESPAWN_GUIDWARNLEVEL))
sWorld->TriggerGuidWarning();
}

Expand Down
3 changes: 1 addition & 2 deletions src/server/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8167,7 +8167,7 @@ void ObjectMgr::DeleteCreatureData(ObjectGuid::LowType guid)
{
RemoveCreatureFromGrid(guid, data);
OnDeleteSpawnData(data);
}
}

_creatureDataStore.erase(guid);
}
Expand All @@ -8181,7 +8181,6 @@ void ObjectMgr::DeleteGameObjectData(ObjectGuid::LowType guid)
RemoveGameobjectFromGrid(guid, data);
OnDeleteSpawnData(data);
}


_gameObjectDataStore.erase(guid);
}
Expand Down
2 changes: 0 additions & 2 deletions src/server/game/Maps/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3754,8 +3754,6 @@ void Map::SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uin

void Map::SaveRespawnTimeDB(SpawnObjectType type, ObjectGuid::LowType spawnId, time_t respawnTime, CharacterDatabaseTransaction dbTrans)
{
// CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); -> is it neeeded ?

// Just here for support of compatibility mode
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement((type == SPAWN_TYPE_GAMEOBJECT) ? CHAR_REP_GO_RESPAWN : CHAR_REP_CREATURE_RESPAWN);
stmt->SetData(0, spawnId);
Expand Down
2 changes: 2 additions & 0 deletions src/server/game/World/IWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ class IWorld
virtual void RemoveOldCorpses() = 0;
virtual void TriggerGuidWarning() = 0;
virtual void TriggerGuidAlert() = 0;
virtual bool IsGuidWarning() const = 0;
virtual bool IsGuidAlert() const = 0;
};

#endif //AZEROTHCORE_IWORLD_H
8 changes: 4 additions & 4 deletions src/server/game/World/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ class World: public IWorld
void RemoveOldCorpses() override;
void TriggerGuidWarning() override;
void TriggerGuidAlert() override;
static bool IsGuidWarning() { return _guidWarn; }
static bool IsGuidAlert() { return _guidAlert; }
bool IsGuidWarning() const override { return _guidWarn; }
bool IsGuidAlert() const override { return _guidAlert; }

protected:
void _UpdateGameTime();
Expand Down Expand Up @@ -460,8 +460,8 @@ class World: public IWorld

std::mutex _guidAlertLock;

static bool _guidWarn;
static bool _guidAlert;
bool _guidWarn;
bool _guidAlert;
uint32 _warnDiff;
time_t _warnShutdownTime;

Expand Down
1 change: 0 additions & 1 deletion src/server/scripts/Commands/cs_npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ class npc_commandscript : public CommandScript
CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
data.id1 = id;
data.phaseMask = chr->GetPhaseMaskForSpawn();


Creature* creature = trans->CreateNPCPassenger(guid, &data);

Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Commands/cs_wp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ class wp_commandscript : public CommandScript
wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
//TODO: Should we first use "Create" then use "LoadFromDB"?
if (!wpCreature2->LoadFromDB(wpCreature2->GetSpawnId(), map, true, false))
if (!wpCreature2->LoadFromDB(wpCreature2->GetSpawnId(), map, true, false))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
Expand Down