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

Formation #1

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Formation #1

wants to merge 23 commits into from

Conversation

cyberium
Copy link
Owner

🍰 Pullrequest

Proof

  • None

Issues

  • None

How2Test

  • None

Todo / Checklist

  • None

charmer->GetFormationSlot()->GetFormationData()->Add(m_player);
}
else
m_player->GetMotionMaster()->MoveFollow(charmer, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE, true);
Copy link

@killerwife killerwife Dec 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is multiple of these, maybe handle it in MoveFollow? Player based quasi formation also needs the same logic, when you lets say have army of the dead in wotlk or multiple guardians and hunter pet, they should all dynamically calculate angle.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well first at this stage formation is a sub option for creaturegroup meaning that formation need a creature group absolutly and its designed only for creature as leader.
Thus some big change have to be done to be able to make a player as a master and more to have some other kind of group that will be attached to player.

Secondly you are asking for more than just adding it as exception of the movefollow we had a discussion about it with tobi and it seem that movefollow should even been replaced by some 'move in formation' with position computed depending of the player's followers.

SendSysMessage("Error: unable to retrieve the slot of the creature.");
}

SendSysMessage(gData->to_string().c_str());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non standard way of things. Compiler will scream. Do PSendSys and format specifier %s and pass it as arg 1.

return false;
}

if (formationId >= static_cast<uint32>(SpawnGroupFormationType::SPAWN_GROUP_FORMATION_TYPE_COUNT))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

primitives are best typecasted as c-style cast, since they arent really heresy. Curious choice of enum class, shauren loves them, buuuut historically in cmangos they seem out of place. Not really opposed to it tho.

case 2: // SetFormation
{

break;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brackets unnecessary with only break

{
if (m_script->textId[0] == 1)
{
auto respPos = creature->GetRespawnPosition();
Copy link

@killerwife killerwife Dec 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shauren kindly explained to me not to use auto like this. I know what the type is, but anyone else reviewing wont. So in these cases dont use auto and put Position there. Its bad when doing it in github interface, i.e. bad for OS. I use it mainly for pairs, tuples, iterators and other templated nonsense.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lazyness spotted you are correct


Creature* leader = static_cast<Creature*>(pTarget);

auto groupData = leader->GetCreatureGroup();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same point here, I have no fkin clue what it should be :D

if (LogIfNotCreature(pSource))
return false;

CreatureGroup* grpData = nullptr;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grpData and later groupData, quite confusing variable choice


switch (m_script->formationData.command)
{
case 2: // set formation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing indent

break;
}

FormationEntrySPtr fEntry = std::make_shared<FormationEntry>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be shared ptr at entry level and not at global level. Not inherently wrong just curious.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum yes maybe not needed too here

break;
}

if (m_script->x <= 15)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a super odd way of using X. Use a different parameter. Do you really need a float?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i can make it x10 maybe in some data if need but will be even less intuitive

@@ -445,6 +447,13 @@ struct ScriptInfo
uint32 empty2; // datalong2
} logKill;

struct // SCRIPT_COMMAND_MOVE_DYNAMIC (37)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong comment im pretty sure

fEntry->Options = fields[4].GetUInt32();
fEntry->Comment = fields[5].GetCppString();

auto gItr = newContainer->spawnGroupMap.find(fEntry->GroupId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just name it itr, its not like you have several iterators there.

@@ -1126,6 +1179,7 @@ void ObjectMgr::LoadSpawnGroups()
SpawnGroupDbGuids guid;
guid.Id = fields[0].GetUInt32();
guid.DbGuid = fields[1].GetUInt32();
guid.SlotId = fields[2].GetInt32();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 default?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we will have to talk about that

SPAWN_GROUP_FORMATION_TYPE_FANNED_OUT_IN_FRONT = 5,
SPAWN_GROUP_FORMATION_TYPE_CIRCLE_THE_LEADER = 6,

SPAWN_GROUP_FORMATION_TYPE_COUNT = 7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 8th type missing here maybe? Even adding a placeholder would be cool even if its not implemented.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is it?

@@ -74,8 +75,39 @@ enum MovementGeneratorType
EXTERNAL_WAYPOINT_MOVE = 17, // Only used in UnitAI::MovementInform when a waypoint is reached. The pathId >= 0 is added as additonal value
EXTERNAL_WAYPOINT_MOVE_START = 18, // Only used in UnitAI::MovementInform when a waypoint is started. The pathId >= 0 is added as additional value
EXTERNAL_WAYPOINT_FINISHED_LAST = 19, // Only used in UnitAI::MovementInform when the waittime of the last wp is finished The pathId >= 0 is added as additional value

FORMATION_MOTION_TYPE = 20, // TargetedMovementGenerator.h

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will it work in creature table, in DB it will be still 2?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That have nothing to do with defaut movement type in db.
Its only for movement generator internally and used for follower i should rename it.

Fiw last reached point to previous point after calling
WaypointMovementGenerator<Creature>::SetNextWaypoint(uint32 pointId)
Add script command add creature, remove creature, switch formation type
Handle adding and removing player from/to formation (in case of possessning)
Fix a couple of issues
Add a db script command to make it possible
```
datalong = command(2 for formation create)
datalong2 = group id to send this command (0 mean remove the formation of current group)
int[0] = type
int[1] = options
int[2] = MovementType
int[3] = MovementID
spread = x
```
Better to avoid problems with forgetted variables initialization and duplicate code
a bit more cleaning and soma error text fixes
Remove some of the  custom code not needed anymore
So if master respawn very far from its followers they will get teleported or run to it.

also fix formation shape reset after master respawn
We should take care of how we handle movement in core and generalize the fact that movement id should not be tied to an entry or a guid. So everything in creature_movement or creature_movement_template should be moved to new movement_template table.
Specify the change for command MOVE_TO that will now support move to respawn pos for the creature itself or its entire group.
Only formation code in it for now
Ability to set formation shape, spread and options via script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants