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

ChangeModesOperation needs to send a notification that updates player fight/chase modes. #2

Open
sean-owen opened this issue Sep 21, 2020 · 1 comment

Comments

@sean-owen
Copy link

Copied over from jlnunez89/fibula-mmo#75 (comment)

Problem:

Currently, when a ChangeModesOperation is executed, the player who's fight and chase modes changed is not made aware of the changes, essentially desynchronizing the modes seen in the client.

Solution:

  1. Create a new outgoing packet for OutgoingGamePacketType.PlayerModes under the namespace/folder Fibula.Communications.Packets.Outgoing:

    /// <summary>
    /// Updates a player's modes.
    /// </summary>
    PlayerModes = 0xA7,
    
  2. Create a new packet writer under the namespace/folder Fibula.Protocol.V772.PacketWriters for that new packet.

  3. Hook up the new packet writer in Fibula.Protocol.V772.CompositionRootExtensions class.

  4. Finally, in ChangeModesOperation.Execute, add a new notification that sends the new packet to the player, to update their modes.

@sean-owen
Copy link
Author

https://github.com/Fibula-MMO/fibula-server/blob/master/src/Fibula.Mechanics/Operations/ChangeModesOperation.cs

@jlnunez89 I decided to try and have a crack at this issue. Initially familiarizing myself with the solution & projects and I do have a question - info below.

Looking at the Execute method of the ChangeModesOperation.cs, snippet below, and I am trying to understand:

  1. Why is assignment of combatantCreature.SafeMode commented out?
protected override void Execute(IOperationContext context)
       {
           var onCreature = this.GetRequestor(context.CreatureFinder);

           if (onCreature == null || !(onCreature is ICombatant combatantCreature))
           {
               return;
           }

           context.Logger.Debug($"{onCreature.Name} changed modes to {this.FightMode} and {this.ChaseMode}, safety: {this.IsSafeModeOn}.");

           combatantCreature.FightMode = this.FightMode;
           combatantCreature.ChaseMode = this.ChaseMode;

           if (this.ChaseMode == ChaseMode.Chase && combatantCreature.AutoAttackTarget != null)
           {
               combatantCreature.SetFollowTarget(combatantCreature.AutoAttackTarget);
           }
           else if (this.ChaseMode == ChaseMode.Stand)
           {
               combatantCreature.SetFollowTarget(null);
           }

           /* combatantCreature.SafeMode = this.IsSafeModeOn; */
       }

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

No branches or pull requests

1 participant