Exemple #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Success != false)
            {
                hash ^= Success.GetHashCode();
            }
            if (ItemCaptureMult != 0D)
            {
                hash ^= ItemCaptureMult.GetHashCode();
            }
            if (ItemFleeMult != 0D)
            {
                hash ^= ItemFleeMult.GetHashCode();
            }
            if (StopMovement != false)
            {
                hash ^= StopMovement.GetHashCode();
            }
            if (StopAttack != false)
            {
                hash ^= StopAttack.GetHashCode();
            }
            if (TargetMax != false)
            {
                hash ^= TargetMax.GetHashCode();
            }
            if (TargetSlow != false)
            {
                hash ^= TargetSlow.GetHashCode();
            }
            return(hash);
        }
Exemple #2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Success != false)
            {
                hash ^= Success.GetHashCode();
            }
            if (ItemCaptureMult != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(ItemCaptureMult);
            }
            if (ItemFleeMult != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(ItemFleeMult);
            }
            if (StopMovement != false)
            {
                hash ^= StopMovement.GetHashCode();
            }
            if (StopAttack != false)
            {
                hash ^= StopAttack.GetHashCode();
            }
            if (TargetMax != false)
            {
                hash ^= TargetMax.GetHashCode();
            }
            if (TargetSlow != false)
            {
                hash ^= TargetSlow.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public void Initialise(DataConfig dataConfig, AddonReader addonReader, RequirementFactory requirementFactory, ILogger logger, string?overridePathProfileFile)
        {
            SpiritPathFilename = string.Empty;

            Interact.Key            = InteractKey;
            Interact.Name           = "Interact";
            Interact.WaitForGCD     = false;
            Interact.DelayAfterCast = 0;
            Interact.PressDuration  = 30;
            Interact.Initialise(addonReader, requirementFactory, logger);

            Approach.Key            = InteractKey;
            Approach.Name           = "Approach";
            Approach.WaitForGCD     = false;
            Approach.DelayAfterCast = 0;
            Approach.PressDuration  = 10;
            Approach.Cooldown       = 150;
            Approach.Initialise(addonReader, requirementFactory, logger);

            AutoAttack.Key            = InteractKey;
            AutoAttack.Name           = "AutoAttack";
            AutoAttack.WaitForGCD     = false;
            AutoAttack.DelayAfterCast = 0;
            AutoAttack.Initialise(addonReader, requirementFactory, logger);

            StopAttack.PressDuration = 10;

            InitializeKeyActions(Pull, Interact, Approach, AutoAttack);
            InitializeKeyActions(Combat, Interact, Approach, AutoAttack);

            logger.LogInformation("[Form] Initialise KeyActions.");
            Form.ForEach(i => i.InitialiseForm(addonReader, requirementFactory, logger));

            Pull.Initialise("Pull", addonReader, requirementFactory, logger);
            Combat.Initialise("Combat", addonReader, requirementFactory, logger);
            Adhoc.Initialise("Adhoc", addonReader, requirementFactory, logger);
            NPC.Initialise("AdhocNpc", addonReader, requirementFactory, logger);
            Parallel.Initialise("Parallel", addonReader, requirementFactory, logger);

            Jump.Key = JumpKey;
            Jump.Initialise(addonReader, requirementFactory, logger);

            TargetLastTarget.Key = TargetLastTargetKey;
            TargetLastTarget.Initialise(addonReader, requirementFactory, logger);

            StandUp.Key = StandUpKey;
            StandUp.Initialise(addonReader, requirementFactory, logger);

            ClearTarget.Key = ClearTargetKey;
            ClearTarget.Initialise(addonReader, requirementFactory, logger);

            StopAttack.Key = StopAttackKey;
            StopAttack.Initialise(addonReader, requirementFactory, logger);

            TargetNearestTarget.Key = TargetNearestTargetKey;
            TargetNearestTarget.Initialise(addonReader, requirementFactory, logger);

            TargetPet.Key = TargetPetKey;
            TargetPet.Initialise(addonReader, requirementFactory, logger);

            TargetTargetOfTarget.Key = TargetTargetOfTargetKey;
            TargetTargetOfTarget.Initialise(addonReader, requirementFactory, logger);

            PetAttack.Key           = PetAttackKey;
            PetAttack.PressDuration = 10;
            PetAttack.Initialise(addonReader, requirementFactory, logger);

            Mount.Key = MountKey;
            Mount.Initialise(addonReader, requirementFactory, logger);

            GatherFindKeys.ForEach(key =>
            {
                GatherFindKeyConfig.Add(new KeyAction {
                    Key = key
                });
                GatherFindKeyConfig.Last().Initialise(addonReader, requirementFactory, logger);
            });

            OverridePathFilename = overridePathProfileFile;
            if (!string.IsNullOrEmpty(OverridePathFilename))
            {
                PathFilename = OverridePathFilename;
            }

            if (!File.Exists(Path.Join(dataConfig.Path, PathFilename)))
            {
                if (!string.IsNullOrEmpty(OverridePathFilename))
                {
                    throw new Exception($"The `{OverridePathFilename}` path file does not exists!");
                }
                else
                {
                    throw new Exception($"The loaded class config contains not existing `{PathFilename}` path file!");
                }
            }

            CheckConfigConsistency(logger);
        }
        public static ClientBasePacket HandlePacket(byte[] data, int offset, GameSession client)
        {
            // Calculate message size
            var size = (short)((data[offset + 1] << 8) + data[offset]);

            // Copy the packet to a new byte array
            // Skipping the header
            var packet = new byte[size];

            Array.Copy(data, offset, packet, 0, size);

            ClientBasePacket msg;

            // Get the id
            var id = packet[2];

            // Handle the packet
            // TODO: Can we group these into login / game / etc?
            switch (id)
            {
            case 0x00:
                msg = new ProtocolVersion(packet, client);
                break;

            case 0x01:
                msg = new ValidateClient(packet, client);
                break;

            case 0x03:
                msg = new ConnectClient(packet, client);
                break;

            case 0x04:
                msg = new ConnectSwitch(packet, client);
                break;

            case 0x05:
                msg = new SwitchServer(packet, client);
                break;

            case 0x06:
                msg = new ServerTime(packet, client);
                break;

            case 0x07:
                msg = new Message(packet, client);
                break;

            case 0x0d:
                msg = new Log(packet, client);
                break;

            case 0x0c:
                msg = new SyncMoney(packet, client);
                break;

            case 0x11:
                msg = new FactoryModifyUnit(packet, client);
                break;

            case 0x12:
                msg = new FactoryModifyEnd(packet, client);
                break;

            case 0x16:
                msg = new IsValidName(packet, client);
                break;

            case 0x17:
                msg = new FactoryChangeUnitName(packet, client);
                break;

            case 0x18:
                msg = new RequestInventory(packet, client);
                break;

            case 0x19:
                msg = new RequestSearchGame(packet, client);
                break;

            case 0x1b:
                msg = new CreateGame(packet, client);
                break;

            case 0x1c:
                msg = new EnterGame(packet, client);
                break;

            case 0x1f:
                msg = new ListUser(packet, client);
                break;

            case 0x20:
                msg = new Ready(packet, client);
                break;

            case 0x21:
                msg = new Exit(packet, client);
                break;

            case 0x22:
                msg = new StartGame(packet, client);
                break;

            case 0x2b:
                msg = new SelectBase(packet, client);
                break;

            case 0x2c:
                msg = new ReadyGame(packet, client);
                break;

            case 0x2e:
                msg = new RequestPalette(packet, client);
                break;

            case 0x2f:
                msg = new MoveUnit(packet, client);
                break;

            case 0x30:
                msg = new AimUnit(packet, client);
                break;

            case 0x31:
                msg = new StartAttack(packet, client);
                break;

            case 0x32:
                msg = new StopAttack(packet, client);
                break;

            case 0x35:
                msg = new RequestRegain(packet, client);
                break;

            case 0x38:
                msg = new ModeSniper(packet, client);
                break;

            case 0x3a:
                msg = new RequestChangeWeaponset(packet, client);
                break;

            case 0x3b:
                msg = new RequestQuitBattle(packet, client);
                break;

            case 0x3f:
                msg = new BuyList(packet, client);
                break;

            case 0x40:
                msg = new RequestGoodsData(packet, client);
                break;

            case 0x46:
                msg = new RequestAvatarInfo(packet, client);
                break;

            case 0x47:
            case 0x48:
            case 0x49:
            case 0x4a:
            case 0x4b:
            case 0x4c:
            case 0x4d:
                msg = new RequestStatsInfo(packet, client);
                break;

            case 0x4e:
                msg = new RequestBestInfo(packet, client);
                break;

            case 0x57:
                msg = new TutorialSelect(packet, client);
                break;

            case 0x5a:
                msg = new UnAimUnit(packet, client);
                break;

            case 0x63:
                msg = new MsgConnect(packet, client);
                break;

            case 0x64:
                msg = new MsgUserStateInfo(packet, client);
                break;

            case 0x66:
                msg = new MsgUserClanInfo(packet, client);
                break;

            case 0x67:
                msg = new MsgGetBuddyList(packet, client);
                break;

            case 0x69:
                msg = new MsgGetChannelList(packet, client);
                break;

            case 0x6a:
                msg = new MsgJoinChannel(packet, client);
                break;

            case 0x6b:
                msg = new MsgLeaveChannel(packet, client);
                break;

            case 0x6c:
                msg = new MsgChannelChatting(packet, client);
                break;

            case 0x71:
                msg = new RequestOperator(packet, client);
                break;

            case 0x72:
                msg = new SelectOperator(packet, client);
                break;

            default:
                msg = new UnknownPacket(packet, client);
                //Console.WriteLine("Unknown packet id [{0}] from user {1}", id, client.GetUserName());
                break;
            }

            return(msg);
        }
Exemple #5
0
        public void Initialise(DataConfig dataConfig, PlayerReader playerReader, RequirementFactory requirementFactory, ILogger logger, string?overridePathProfileFile)
        {
            SpiritPathFilename = string.Empty;

            Interact.Key  = InteractKey;
            Interact.Name = "Interact";
            Interact.Initialise(playerReader, requirementFactory, logger);

            Approach.Key  = InteractKey;
            Approach.Name = "Approach";
            Approach.Initialise(playerReader, requirementFactory, logger);

            AutoAttack.Key            = InteractKey;
            AutoAttack.Name           = "AutoAttack";
            AutoAttack.DelayAfterCast = 0;
            AutoAttack.Initialise(playerReader, requirementFactory, logger);

            InitializeKeyActions(Pull, Interact, Approach, AutoAttack);
            InitializeKeyActions(Combat, Interact, Approach, AutoAttack);

            Pull.Initialise(playerReader, requirementFactory, logger);
            Combat.Initialise(playerReader, requirementFactory, logger);
            Adhoc.Initialise(playerReader, requirementFactory, logger);
            NPC.Initialise(playerReader, requirementFactory, logger);
            Parallel.Initialise(playerReader, requirementFactory, logger);
            ShapeshiftForm.ForEach(i => i.Initialise(playerReader, requirementFactory, logger));

            Jump.Key = JumpKey;
            Jump.Initialise(playerReader, requirementFactory, logger);

            TargetLastTarget.Key = TargetLastTargetKey;
            TargetLastTarget.Initialise(playerReader, requirementFactory, logger);

            StandUp.Key = StandUpKey;
            StandUp.Initialise(playerReader, requirementFactory, logger);

            ClearTarget.Key = ClearTargetKey;
            ClearTarget.Initialise(playerReader, requirementFactory, logger);

            StopAttack.Key = StopAttackKey;
            StopAttack.Initialise(playerReader, requirementFactory, logger);

            TargetNearestTarget.Key = TargetNearestTargetKey;
            TargetNearestTarget.Initialise(playerReader, requirementFactory, logger);

            TargetPet.Key = TargetPetKey;
            TargetPet.Initialise(playerReader, requirementFactory, logger);

            TargetTargetOfTarget.Key = TargetTargetOfTargetKey;
            TargetTargetOfTarget.Initialise(playerReader, requirementFactory, logger);

            PetAttack.Key = PetAttackKey;
            PetAttack.Initialise(playerReader, requirementFactory, logger);

            GatherFindKeys.ForEach(key =>
            {
                GatherFindKeyConfig.Add(new KeyAction {
                    Key = key
                });
                GatherFindKeyConfig.Last().Initialise(playerReader, requirementFactory, logger);
            });

            OverridePathFilename = overridePathProfileFile;
            if (!string.IsNullOrEmpty(OverridePathFilename))
            {
                PathFilename = OverridePathFilename;
            }

            if (!File.Exists(Path.Join(dataConfig.Path, PathFilename)))
            {
                if (!string.IsNullOrEmpty(OverridePathFilename))
                {
                    throw new Exception($"The `{OverridePathFilename}` path file does not exists!");
                }
                else
                {
                    throw new Exception($"The loaded class config contains not existing `{PathFilename}` path file!");
                }
            }
        }