-
Notifications
You must be signed in to change notification settings - Fork 62
Fix NPC skill hitbox detection and add debug tooling #646
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3c7d21a
Fix SAT intersection bug for Circle vs Polygon
AngeloTadeucci 5f5b49b
Fix NPC skill hitbox direction and target resolution
AngeloTadeucci 726f47b
Add --no-ai flag to npc spawn command
AngeloTadeucci 9c62bf5
Add mob-attack command for testing NPC skill hitboxes
AngeloTadeucci 55cbb4e
Add skill hitbox visualization to DebugGame
AngeloTadeucci 4be8a0c
Fix safe revive blocked when RevivalReturnId is 0
AngeloTadeucci f83399b
Fix SkillMapper reading height instead of width for range Width
AngeloTadeucci 86862c4
Fix circle projection; add collision tests
AngeloTadeucci 03b25b1
format
AngeloTadeucci b6b9c33
Adjust debug renderer and fix target acquisition
AngeloTadeucci 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,72 @@ | ||
| using System.CommandLine; | ||
| using System.CommandLine.Invocation; | ||
| using System.CommandLine.IO; | ||
| using Maple2.Model.Enum; | ||
| using Maple2.Model.Metadata; | ||
| using Maple2.Server.Game.Model; | ||
| using Maple2.Server.Game.Session; | ||
|
|
||
| namespace Maple2.Server.Game.Commands; | ||
|
|
||
| public class MobAttackCommand : GameCommand { | ||
| private readonly GameSession session; | ||
|
|
||
| public MobAttackCommand(GameSession session) : base(AdminPermissions.Debug, "mob-attack", "Make first mob on map use a skill.") { | ||
| this.session = session; | ||
|
|
||
| var skillId = new Argument<int?>("skillId", () => null, "Skill id for the mob to use."); | ||
| var skillLevel = new Option<short>(["--level", "-l"], () => 1, "Skill level."); | ||
|
|
||
| AddArgument(skillId); | ||
| AddOption(skillLevel); | ||
| this.SetHandler<InvocationContext, int?, short>(Handle, skillId, skillLevel); | ||
| } | ||
|
|
||
| private void Handle(InvocationContext ctx, int? skillId, short skillLevel) { | ||
| if (session.Field is null) { | ||
| ctx.Console.Error.WriteLine("No field loaded."); | ||
| return; | ||
| } | ||
|
|
||
| // Find first mob on the map | ||
| FieldNpc? mob = session.Field.Mobs.Values.FirstOrDefault(); | ||
| if (mob is null) { | ||
| ctx.Console.Error.WriteLine("No mobs found on the current map."); | ||
| return; | ||
| } | ||
|
|
||
| ctx.Console.Out.WriteLine($"Using mob: {mob.Value.Metadata.Name} (Id: {mob.Value.Metadata.Id}, ObjectId: {mob.ObjectId})"); | ||
|
|
||
| // Check if mob has skills | ||
| NpcMetadataSkill.Entry[] entries = mob.Value.Metadata.Skill.Entries; | ||
| if (entries.Length == 0) { | ||
| ctx.Console.Error.WriteLine("This mob has no skills."); | ||
| return; | ||
| } | ||
|
|
||
| // If no skill id passed, list available skills grouped by id | ||
| if (skillId is null) { | ||
| ctx.Console.Out.WriteLine("Available skills:"); | ||
| foreach (var group in entries.GroupBy(e => e.Id)) { | ||
| string levels = string.Join(", ", group.Select(e => e.Level)); | ||
| ctx.Console.Out.WriteLine($" SkillId: {group.Key} (Levels: {levels})"); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| // Validate skill exists in metadata | ||
| if (!session.Field.SkillMetadata.TryGet(skillId.Value, skillLevel, out SkillMetadata? _)) { | ||
| ctx.Console.Error.WriteLine($"Skill {skillId.Value} level {skillLevel} not found in metadata."); | ||
| return; | ||
| } | ||
|
|
||
| // Warn if the mob does not own the skill in its own skill list | ||
| if (!entries.Any(e => e.Id == skillId.Value && e.Level == skillLevel)) { | ||
| ctx.Console.Out.WriteLine($"Warning: {mob.Value.Metadata.Name} does not have skill {skillId.Value} (level {skillLevel}) in its skill list. Casting anyway..."); | ||
| } | ||
|
|
||
| // Cast the skill facing the player | ||
| mob.CastAiSkill(skillId.Value, skillLevel, faceTarget: 1, facePos: session.Player.Position); | ||
| ctx.Console.Out.WriteLine($"Mob {mob.Value.Metadata.Name} casting skill {skillId.Value} (level {skillLevel})."); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.