Pet Battles: Dynamically mark critters as wild battle pets
This commit is contained in:
@@ -55,6 +55,9 @@
|
||||
#include "ZoneScript.h"
|
||||
#include <G3D/g3dmath.h>
|
||||
#include <sstream>
|
||||
//WowCommunity
|
||||
#include "BattlePetMgr.h"
|
||||
//WowCommunity
|
||||
|
||||
CreatureMovementData::CreatureMovementData() : HoverInitiallyEnabled(false), Chase(CreatureChaseMovementType::Run),
|
||||
Random(CreatureRandomMovementType::Walk), InteractionPauseTimer(sWorld->getIntConfig(CONFIG_CREATURE_STOP_FOR_PLAYER)) { }
|
||||
@@ -1685,6 +1688,43 @@ void Creature::SelectWildBattlePetLevel()
|
||||
}
|
||||
}
|
||||
|
||||
//WowCommunity
|
||||
|
||||
void Creature::TryMarkAsWildBattlePet()
|
||||
{
|
||||
// If creature already has the wild battle pet flag from its template, just assign level
|
||||
if (IsWildBattlePet())
|
||||
{
|
||||
SelectWildBattlePetLevel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this creature's entry has a matching BattlePetSpecies (DB2 link)
|
||||
BattlePetSpeciesEntry const* species = BattlePets::BattlePetMgr::GetBattlePetSpeciesByCreature(GetEntry());
|
||||
if (!species)
|
||||
return;
|
||||
|
||||
// Only mark capturable species as wild battle pets (excludes companions, boss pets, etc.)
|
||||
if (!species->GetFlags().HasFlag(BattlePetSpeciesFlags::Capturable))
|
||||
return;
|
||||
|
||||
// Species that can't battle should never be wild battle pets
|
||||
if (species->GetFlags().HasFlag(BattlePetSpeciesFlags::CantBattle))
|
||||
return;
|
||||
|
||||
// Roll chance ? ~40% of eligible critters become wild battle pets, 60% stay regular
|
||||
if (urand(1, 100) > WILD_BATTLE_PET_MARK_CHANCE)
|
||||
return;
|
||||
|
||||
// Mark this creature as a wild battle pet
|
||||
SetNpcFlag(UNIT_NPC_FLAG_WILD_BATTLE_PET);
|
||||
SelectWildBattlePetLevel();
|
||||
|
||||
TC_LOG_DEBUG("entities.unit", "Creature {} (Entry: {}, SpawnID: {}) dynamically marked as wild battle pet (Species: {})",
|
||||
GetName(), GetEntry(), GetSpawnId(), species->ID);
|
||||
}
|
||||
|
||||
//WowCommunity
|
||||
float Creature::GetHealthMod(CreatureClassifications classification)
|
||||
{
|
||||
switch (classification)
|
||||
@@ -1956,7 +1996,7 @@ bool Creature::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap,
|
||||
|
||||
SetSpawnHealth();
|
||||
|
||||
SelectWildBattlePetLevel();
|
||||
TryMarkAsWildBattlePet();
|
||||
|
||||
// checked at creature_template loading
|
||||
m_defaultMovementType = MovementGeneratorType(data->movementType);
|
||||
@@ -2344,6 +2384,7 @@ void Creature::Respawn(bool force)
|
||||
UpdateEntry(m_originalEntry);
|
||||
|
||||
SelectLevel();
|
||||
TryMarkAsWildBattlePet();
|
||||
|
||||
setDeathState(JUST_RESPAWNED);
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ enum class VendorDataTypeFlags : int32
|
||||
DEFINE_ENUM_FLAG(VendorDataTypeFlags);
|
||||
|
||||
static constexpr uint8 WILD_BATTLE_PET_DEFAULT_LEVEL = 1;
|
||||
static constexpr uint32 WILD_BATTLE_PET_MARK_CHANCE = 40; // % of eligible critters that become wild battle pets
|
||||
static constexpr size_t CREATURE_TAPPERS_SOFT_CAP = 5;
|
||||
|
||||
//used for handling non-repeatable random texts
|
||||
@@ -104,6 +105,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
void SelectLevel();
|
||||
void UpdateLevelDependantStats();
|
||||
void SelectWildBattlePetLevel();
|
||||
void TryMarkAsWildBattlePet();
|
||||
void LoadEquipment(int8 id = 1, bool force = false);
|
||||
void SetSpawnHealth();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user