forked from cmangos/mangos-tbc
-
Notifications
You must be signed in to change notification settings - Fork 0
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
cyberium
wants to merge
23
commits into
master
Choose a base branch
from
formation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Formation #1
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
49dc096
Formation code for spawngroup
cyberium 1d2e4b6
Improve waypoint movegen
cyberium 916a121
Some improvement to formation
cyberium 50d04ab
Enforce movement_template table for spawngroupÃ
cyberium 53e9a80
Change script command to group target instead of formation
cyberium 2dc7e33
Add possibility to assign dynamically a formation to a creature group
cyberium 93ee4ad
Fix a little mistake npc formation switch command error message
cyberium 0914fb7
Improve a bit the npc formation info command
cyberium b3a9b86
Removing some unneeded ingame command
cyberium 5ccfc7a
Some more cleaning to formation code
cyberium 1858c31
Set keep compact option from formation entry
cyberium b95981b
Temp hack to fix movetype for static group formation
cyberium 89a2ed5
Merge FormationData constructors
cyberium 4adab4d
remove duplicate code in FormationMovementGenerator::Update
cyberium 2f1930e
Add change spread and change option script command
cyberium 8c8bb06
some code style
cyberium 10d2067
Use better method to get best position for followers
cyberium ebc7e0d
Implement followers check to master distance
cyberium 3148be1
Fix movement type for formation in db
cyberium c489723
Prepare for release
cyberium 5c5126b
Prepare SCRIPT_COMMAND_SPAWN_GROUP(51) for release
cyberium 803a198
[s2439] Add Formation sql
cyberium 3db02e9
Last fixes for release
cyberium File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
ALTER TABLE db_version CHANGE COLUMN required_s2438_01_mangos_spawn_groups required_s2439_01_mangos_groups_formation bit; | ||
|
||
ALTER TABLE `spawn_group_spawn` ADD COLUMN `SlotId` tinyint(4) NOT NULL DEFAULT -1 COMMENT '0 is the leader, -1 not part of the formation' AFTER `Guid`; | ||
|
||
DROP TABLE IF EXISTS `spawn_group_formation`; | ||
CREATE TABLE `spawn_group_formation` ( | ||
`SpawnGroupID` int(11) NOT NULL COMMENT 'Spawn group id', | ||
`FormationType` tinyint(11) NOT NULL DEFAULT 0 COMMENT 'Formation shape 0..6', | ||
`FormationSpread` float(11, 0) NOT NULL DEFAULT 0 COMMENT 'Distance between formation members', | ||
`FormationOptions` int(11) NOT NULL DEFAULT 0 COMMENT 'Keep formation compact (bit 1)', | ||
`MovementID` int(11) NOT NULL DEFAULT 0 COMMENT 'Id from waypoint_path path', | ||
`MovementType` tinyint(11) NOT NULL COMMENT 'Same as creature table', | ||
`Comment` varchar(255) NULL DEFAULT NULL, | ||
PRIMARY KEY (`SpawnGroupID`) | ||
); | ||
|
||
DROP TABLE IF EXISTS `waypoint_path`; | ||
CREATE TABLE `waypoint_path` ( | ||
`entry` mediumint(8) UNSIGNED NOT NULL COMMENT 'Creature entry', | ||
`pathId` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Path ID for entry', | ||
`point` mediumint(8) UNSIGNED NOT NULL DEFAULT 0, | ||
`position_x` float NOT NULL DEFAULT 0, | ||
`position_y` float NOT NULL DEFAULT 0, | ||
`position_z` float NOT NULL DEFAULT 0, | ||
`orientation` float NOT NULL DEFAULT 0, | ||
`waittime` int(10) UNSIGNED NOT NULL DEFAULT 0, | ||
`script_id` mediumint(8) UNSIGNED NOT NULL DEFAULT 0, | ||
`comment` text NULL DEFAULT NULL, | ||
PRIMARY KEY (`entry`, `pathId`, `point`) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2317,6 +2317,165 @@ bool ChatHandler::HandleNpcShowLootCommand(char* /*args*/) | |
return true; | ||
} | ||
|
||
// show detailed information of creature formation if exist | ||
bool ChatHandler::HandleNpcGroupInfoCommand(char* /*args*/) | ||
{ | ||
Creature* creature = getSelectedCreature(); | ||
|
||
if (!creature) | ||
{ | ||
SendSysMessage(LANG_SELECT_CREATURE); | ||
SetSentErrorMessage(true); | ||
return false; | ||
} | ||
|
||
auto gData = creature->GetCreatureGroup(); | ||
if (!gData) | ||
{ | ||
SendSysMessage("Creature is not in group"); | ||
return true; | ||
} | ||
|
||
PSendSysMessage("Group id[%u]", gData->GetGroupId()); | ||
PSendSysMessage("Group name: %s", gData->GetGroupEntry().Name.c_str()); | ||
|
||
Unit* master = nullptr; | ||
if (gData->GetFormationData()) | ||
master = gData->GetFormationData()->GetMaster(); | ||
|
||
if (master) | ||
{ | ||
if (master == creature) | ||
SendSysMessage("Creature is formation leader"); | ||
else if (creature->GetFormationSlot()) | ||
SendSysMessage("Creature is in formation slot"); | ||
else | ||
SendSysMessage("Error: unable to retrieve the slot of the creature."); | ||
} | ||
|
||
PSendSysMessage("%s", gData->to_string().c_str()); | ||
return true; | ||
} | ||
|
||
// show detailed information of group behavior | ||
// bool ChatHandler::HandleNpcGroupBehaviorShowCommand(char* /*args*/) | ||
// { | ||
// Creature* creature = getSelectedCreature(); | ||
// | ||
// if (!creature) | ||
// { | ||
// SendSysMessage(LANG_SELECT_CREATURE); | ||
// SetSentErrorMessage(true); | ||
// return false; | ||
// } | ||
// | ||
// | ||
// return true; | ||
// } | ||
|
||
// set behavior of targeted group | ||
// bool ChatHandler::HandleNpcGroupBehaviorSetCommand(char* args) | ||
// { | ||
// Creature* creature = getSelectedCreature(); | ||
// | ||
// if (!creature) | ||
// { | ||
// SendSysMessage(LANG_SELECT_CREATURE); | ||
// SetSentErrorMessage(true); | ||
// return false; | ||
// } | ||
// | ||
// return true; | ||
// } | ||
|
||
// reset creature formation template | ||
bool ChatHandler::HandleNpcFormationInfoCommand(char* /*args*/) | ||
{ | ||
Creature* creature = getSelectedCreature(); | ||
|
||
if (!creature) | ||
{ | ||
SendSysMessage(LANG_SELECT_CREATURE); | ||
SetSentErrorMessage(true); | ||
return false; | ||
} | ||
|
||
auto currSlot = creature->GetFormationSlot(); | ||
if (!currSlot) | ||
{ | ||
SendSysMessage("Creature is not in formation"); | ||
return true; | ||
} | ||
|
||
PSendSysMessage("%s", currSlot->GetFormationData()->to_string().c_str()); | ||
return true; | ||
} | ||
|
||
// reset creature formation template | ||
bool ChatHandler::HandleNpcFormationResetCommand(char* /*args*/) | ||
{ | ||
Creature* creature = getSelectedCreature(); | ||
|
||
if (!creature) | ||
{ | ||
SendSysMessage(LANG_SELECT_CREATURE); | ||
SetSentErrorMessage(true); | ||
return false; | ||
} | ||
|
||
auto currSlot = creature->GetFormationSlot(); | ||
if (!currSlot) | ||
{ | ||
SendSysMessage("Creature is not in formation"); | ||
return true; | ||
} | ||
|
||
currSlot->GetFormationData()->Reset(); | ||
|
||
// need implementation | ||
SendSysMessage("Formation is reset to default!"); | ||
return true; | ||
} | ||
|
||
// change creature formation template | ||
bool ChatHandler::HandleNpcFormationSwitchCommand(char* args) | ||
{ | ||
Creature* creature = getSelectedCreature(); | ||
|
||
if (!creature) | ||
{ | ||
SendSysMessage(LANG_SELECT_CREATURE); | ||
SetSentErrorMessage(true); | ||
return false; | ||
} | ||
|
||
auto currSlot = creature->GetFormationSlot(); | ||
if (!currSlot) | ||
{ | ||
SendSysMessage("Creature is not in formation"); | ||
return true; | ||
} | ||
|
||
uint32 formationId; | ||
if (!ExtractUInt32(&args, formationId)) | ||
{ | ||
PSendSysMessage("Please provide a valid formation id!\n.npc formation switch #formationId"); | ||
return false; | ||
} | ||
|
||
if (formationId >= static_cast<uint32>(SpawnGroupFormationType::SPAWN_GROUP_FORMATION_TYPE_COUNT)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{ | ||
PSendSysMessage("Formation shape id should be in 0..%u range!", static_cast<uint32>(SpawnGroupFormationType::SPAWN_GROUP_FORMATION_TYPE_COUNT) - 1); | ||
return true; | ||
} | ||
|
||
if (!currSlot->GetFormationData()->SwitchFormation(static_cast<SpawnGroupFormationType>(formationId))) | ||
PSendSysMessage("Failed to switch formation template!"); | ||
else | ||
SendSysMessage("Formation shape changed."); | ||
return true; | ||
} | ||
|
||
// TODO: NpcCommands that need to be fixed : | ||
|
||
bool ChatHandler::HandleNpcNameCommand(char* /*args*/) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.