Core/Movement: Allow using run when moving randomly
This commit is contained in:
1 parent
4534308280
commit
1793f39fcc
5 files changed
+63
-21
No files matched your search
@@ -0,0 +1,3 @@
|
||||
--
|
||||
ALTER TABLE `creature_template_movement` ADD `Random` tinyint(3) UNSIGNED NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `creature_movement_override` ADD `Random` tinyint(3) UNSIGNED NOT NULL DEFAULT '0';
|
||||
@@ -61,12 +61,14 @@ std::string CreatureMovementData::ToString() const
|
||||
{
|
||||
char const* const GroundStates[] = { "None", "Run", "Hover" };
|
||||
char const* const FlightStates[] = { "None", "DisableGravity", "CanFly" };
|
||||
char const* const RandomStates[] = { "Walk", "CanRun", "AlwaysRun" };
|
||||
|
||||
std::ostringstream str;
|
||||
str << std::boolalpha
|
||||
<< "Ground: " << GroundStates[AsUnderlyingType(Ground)]
|
||||
<< ", Swim: " << Swim
|
||||
<< ", Flight: " << FlightStates[AsUnderlyingType(Flight)];
|
||||
<< ", Flight: " << FlightStates[AsUnderlyingType(Flight)]
|
||||
<< ", Random: " << RandomStates[AsUnderlyingType(Random)];
|
||||
if (Rooted)
|
||||
str << ", Rooted";
|
||||
|
||||
|
||||
@@ -92,20 +92,33 @@ enum class CreatureFlightMovementType : uint8
|
||||
Max
|
||||
};
|
||||
|
||||
enum class CreatureRandomMovementType : uint8
|
||||
{
|
||||
Walk,
|
||||
CanRun,
|
||||
AlwaysRun,
|
||||
|
||||
Max
|
||||
};
|
||||
|
||||
struct TC_GAME_API CreatureMovementData
|
||||
{
|
||||
CreatureMovementData() : Ground(CreatureGroundMovementType::Run), Flight(CreatureFlightMovementType::None), Swim(true), Rooted(false) { }
|
||||
CreatureMovementData() : Ground(CreatureGroundMovementType::Run), Flight(CreatureFlightMovementType::None),
|
||||
Swim(true), Rooted(false), Random(CreatureRandomMovementType::Walk) { }
|
||||
|
||||
CreatureGroundMovementType Ground;
|
||||
CreatureFlightMovementType Flight;
|
||||
bool Swim;
|
||||
bool Rooted;
|
||||
CreatureRandomMovementType Random;
|
||||
|
||||
bool IsGroundAllowed() const { return Ground != CreatureGroundMovementType::None; }
|
||||
bool IsSwimAllowed() const { return Swim; }
|
||||
bool IsFlightAllowed() const { return Flight != CreatureFlightMovementType::None; }
|
||||
bool IsRooted() const { return Rooted; }
|
||||
|
||||
CreatureRandomMovementType GetRandom() const { return Random; }
|
||||
|
||||
std::string ToString() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -437,8 +437,8 @@ void ObjectMgr::LoadCreatureTemplates()
|
||||
"dynamicflags, family, trainer_class, type, type_flags, type_flags2, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, "
|
||||
// 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
||||
"spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, "
|
||||
// 62 63 64 65 66 67 68 69 70
|
||||
"ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, "
|
||||
// 62 63 64 65 66 67 68 69 70 71
|
||||
"ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Random, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, "
|
||||
// 71 72 73 74 75 76 77 78
|
||||
"ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, movementId, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, "
|
||||
// 79 80
|
||||
@@ -540,22 +540,25 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
|
||||
if (!fields[68].IsNull())
|
||||
creatureTemplate.Movement.Rooted = fields[65].GetBool();
|
||||
|
||||
creatureTemplate.HoverHeight = fields[66].GetFloat();
|
||||
creatureTemplate.ModHealth = fields[67].GetFloat();
|
||||
creatureTemplate.ModHealthExtra = fields[68].GetFloat();
|
||||
creatureTemplate.ModMana = fields[69].GetFloat();
|
||||
creatureTemplate.ModManaExtra = fields[70].GetFloat();
|
||||
creatureTemplate.ModArmor = fields[71].GetFloat();
|
||||
creatureTemplate.ModDamage = fields[72].GetFloat();
|
||||
creatureTemplate.ModExperience = fields[73].GetFloat();
|
||||
if (!fields[66].IsNull())
|
||||
creatureTemplate.Movement.Random = static_cast<CreatureRandomMovementType>(fields[66].GetUInt8());
|
||||
|
||||
creatureTemplate.RacialLeader = fields[74].GetBool();
|
||||
creatureTemplate.movementId = fields[75].GetUInt32();
|
||||
creatureTemplate.RegenHealth = fields[76].GetBool();
|
||||
creatureTemplate.MechanicImmuneMask = fields[77].GetUInt32();
|
||||
creatureTemplate.SpellSchoolImmuneMask = fields[78].GetUInt32();
|
||||
creatureTemplate.flags_extra = fields[79].GetUInt32();
|
||||
creatureTemplate.ScriptID = GetScriptId(fields[80].GetCString());
|
||||
creatureTemplate.HoverHeight = fields[67].GetFloat();
|
||||
creatureTemplate.ModHealth = fields[68].GetFloat();
|
||||
creatureTemplate.ModHealthExtra = fields[69].GetFloat();
|
||||
creatureTemplate.ModMana = fields[70].GetFloat();
|
||||
creatureTemplate.ModManaExtra = fields[71].GetFloat();
|
||||
creatureTemplate.ModArmor = fields[72].GetFloat();
|
||||
creatureTemplate.ModDamage = fields[73].GetFloat();
|
||||
creatureTemplate.ModExperience = fields[74].GetFloat();
|
||||
|
||||
creatureTemplate.RacialLeader = fields[75].GetBool();
|
||||
creatureTemplate.movementId = fields[76].GetUInt32();
|
||||
creatureTemplate.RegenHealth = fields[77].GetBool();
|
||||
creatureTemplate.MechanicImmuneMask = fields[78].GetUInt32();
|
||||
creatureTemplate.SpellSchoolImmuneMask = fields[79].GetUInt32();
|
||||
creatureTemplate.flags_extra = fields[80].GetUInt32();
|
||||
creatureTemplate.ScriptID = GetScriptId(fields[81].GetCString());
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadCreatureTemplateAddons()
|
||||
@@ -1132,6 +1135,13 @@ void ObjectMgr::CheckCreatureMovement(char const* table, uint64 id, CreatureMove
|
||||
table, uint32(creatureMovement.Flight), id);
|
||||
creatureMovement.Flight = CreatureFlightMovementType::None;
|
||||
}
|
||||
|
||||
if (creatureMovement.Random >= CreatureRandomMovementType::Max)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "`%s`.`Random` wrong value (%u) for Id " UI64FMTD ", setting to Walk.",
|
||||
table, uint32(creatureMovement.Random), id);
|
||||
creatureMovement.Random = CreatureRandomMovementType::Walk;
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadCreatureAddons()
|
||||
@@ -1448,7 +1458,7 @@ void ObjectMgr::LoadCreatureMovementOverrides()
|
||||
|
||||
_creatureMovementOverrides.clear();
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT SpawnId, Ground, Swim, Flight, Rooted from creature_movement_override");
|
||||
QueryResult result = WorldDatabase.Query("SELECT SpawnId, Ground, Swim, Flight, Rooted, Random from creature_movement_override");
|
||||
if (!result)
|
||||
{
|
||||
TC_LOG_INFO("server.loading", ">> Loaded 0 creature movement overrides. DB table `creature_movement_override` is empty!");
|
||||
@@ -1470,6 +1480,7 @@ void ObjectMgr::LoadCreatureMovementOverrides()
|
||||
movement.Swim = fields[2].GetBool();
|
||||
movement.Flight = static_cast<CreatureFlightMovementType>(fields[3].GetUInt8());
|
||||
movement.Rooted = fields[4].GetBool();
|
||||
movement.Random = static_cast<CreatureRandomMovementType>(fields[6].GetUInt8());
|
||||
|
||||
CheckCreatureMovement("creature_movement_override", spawnId, movement);
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -129,9 +129,22 @@ void RandomMovementGenerator<Creature>::SetRandomLocation(Creature* owner)
|
||||
return;
|
||||
}
|
||||
|
||||
bool walk = true;
|
||||
switch (owner->GetMovementTemplate().GetRandom())
|
||||
{
|
||||
case CreatureRandomMovementType::CanRun:
|
||||
walk = owner->IsWalking();
|
||||
break;
|
||||
case CreatureRandomMovementType::AlwaysRun:
|
||||
walk = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Movement::MoveSplineInit init(owner);
|
||||
init.MovebyPath(_path->GetPath());
|
||||
init.SetWalk(true);
|
||||
init.SetWalk(walk);
|
||||
int32 splineDuration = init.Launch();
|
||||
|
||||
_wanderSteps--;
|
||||
|
||||
Reference in new issue
Block a user