Skip to content

Commit

Permalink
Remove unused HandleCommands and HandleSpecificCommands methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohicatv committed Jan 26, 2025
1 parent 1a8a968 commit 6bc3e94
Showing 1 changed file with 0 additions and 74 deletions.
74 changes: 0 additions & 74 deletions Projects/UOContent/Mobiles/AI/BaseAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,80 +547,6 @@ private void HandleTraining(Mobile from)
// 501505: Alas, I cannot teach thee anything.
}
}

// I broke this during refactoring or it never worked right.
// player mobile speech comamnds are not registered by control pet.
// probably missing something in the OnSpeech events or methods.
private void HandleCommands(SpeechEventArgs e)
{
if (m_Mobile.Debug)
{
m_Mobile.DebugSay("Listening...");
}

var isOwner = e.Mobile == m_Mobile.ControlMaster;
var isFriend = !isOwner && m_Mobile.IsPetFriend(e.Mobile);

if (e.Mobile.Alive && (isOwner || isFriend))
{
if (m_Mobile.Debug)
{
m_Mobile.DebugSay("It is from my Master.");
}

var commands = new Dictionary<int, Action>
{
{ 0x164, () => HandleComeCommand(e.Mobile, isOwner) }, // all come
{ 0x165, () => BeginPickTarget(e.Mobile, OrderType.Follow) }, // all follow
{ 0x166, () => HandleGuardCommand(e.Mobile, isOwner) }, // all guard
{ 0x16B, () => HandleGuardCommand(e.Mobile, isOwner) }, // all guard me
{ 0x167, () => HandleSimpleCommand(e.Mobile, OrderType.Stop) }, // all stop
{ 0x168, () => HandleAttackCommand(e.Mobile, isOwner) }, // all kill
{ 0x169, () => HandleAttackCommand(e.Mobile, isOwner) }, // all attack
{ 0x16C, () => HandleSimpleCommand(e.Mobile, OrderType.Follow, e.Mobile) }, // all follow me
{ 0x170, () => HandleSimpleCommand(e.Mobile, OrderType.Stay) } // all stay
};

foreach (var keyword in e.Keywords)
{
if (commands.TryGetValue(keyword, out var action))
{
action.Invoke();
return;
}
}

HandleSpecificCommands(e, isOwner, e.Speech);
}
}

private void HandleSpecificCommands(SpeechEventArgs e, bool isOwner, string speech)
{
var specificCommands = new Dictionary<int, Action>
{
{ 0x155, () => HandleComeCommand(e.Mobile, isOwner) }, // *come
{ 0x156, () => HandleDropCommand(e.Mobile, isOwner, speech) }, // *drop
{ 0x15A, () => BeginPickTarget(e.Mobile, OrderType.Follow) }, // *follow
{ 0x15B, () => HandleFriendCommand(e.Mobile, isOwner, speech) }, // *friend
{ 0x15C, () => HandleGuardCommand(e.Mobile, isOwner) }, // *guard
{ 0x15D, () => HandleAttackCommand(e.Mobile, isOwner) }, // *kill
{ 0x15E, () => HandleAttackCommand(e.Mobile, isOwner) }, // *attack
{ 0x161, () => HandleSimpleCommand(e.Mobile, OrderType.Stop) }, // *stop
{ 0x163, () => HandleSimpleCommand(e.Mobile, OrderType.Follow, e.Mobile) }, // *follow me
{ 0x16D, () => HandleReleaseCommand(e.Mobile, isOwner, speech) }, // *release
{ 0x16E, () => HandleTransferCommand(e.Mobile, isOwner, speech) }, // *transfer
{ 0x16F, () => HandleSimpleCommand(e.Mobile, OrderType.Stay) } // *stay
};

foreach (var keyword in e.Keywords)
{
if (specificCommands.TryGetValue(keyword, out var action))
{
action.Invoke();
return;
}
}
}

private void HandleComeCommand(Mobile from, bool isOwner)
{
Expand Down

0 comments on commit 6bc3e94

Please sign in to comment.