コード例 #1
0
ファイル: LoginHandler.cs プロジェクト: iFeddy/SolarFiesta
 public static void VersionInfo(LoginClient pClient, Packet pPacket)
 {
     ushort year;
     ushort version;
     if (!pPacket.TryReadUShort(out year) ||
         !pPacket.TryReadUShort(out version))
     {
         Log.WriteLine(LogLevel.Warn, "Invalid client version.");
         pClient.Disconnect();
         return;
     }
     Log.WriteLine(LogLevel.Debug, "Client version {0}:{1}.", year, version);
     using (Packet response = new Packet(SH3Type.VersionAllowed))
     {
         response.WriteShort(1);
         pClient.SendPacket(response);
     }
 }
コード例 #2
0
ファイル: Handler9.cs プロジェクト: iFeddy/SolarFiesta
        public static void AttackSkillHandler(ZoneClient client, Packet packet)
        {
            ushort skill;
            if (!packet.TryReadUShort(out skill))
            {
                Log.WriteLine(LogLevel.Warn, "Could not read skillID from attack entity skill function. {0}", client);
                return;
            }

            if (!client.Character.SkillsActive.ContainsKey(skill))
            {
                Log.WriteLine(LogLevel.Warn, "User tried to attack with a wrong skill. {0} {1} ", skill, client);
                return;
            }

            client.Character.AttackSkill(skill, null);
        }
コード例 #3
0
ファイル: Handler8.cs プロジェクト: iFeddy/SolarFiesta
        public static void BeginInteractionHandler(ZoneClient client, Packet packet)
        {
            ushort entityid;
            if (!packet.TryReadUShort(out entityid))
            {
                Log.WriteLine(LogLevel.Warn, "Error reading interaction attempt.");
                return;
            }
            ZoneCharacter character = client.Character;
            MapObject obj;
            if (character.Map.Objects.TryGetValue(entityid, out obj))
            {
                NPC npc = obj as NPC;
                if (npc != null)
                {
                    if (npc.Gate != null)
                    {

                        MapInfo mi = null;
                        if (DataProvider.Instance.MapsByName.TryGetValue(npc.Gate.MapServer, out mi))
                        {
                            Question q = new Question(string.Format("Do you want to move to {0} field?", mi.FullName), new QuestionCallback(AnswerOnGateQuestion), npc);
                            q.Add("Yes", "No");
                            q.Send(character, 500);
                            character.Question = q;
                        }
                        else
                        {
                            character.DropMessage("You can't travel to this place.");
                        }
                    }
                    else
                    {
                        SendNPCInteraction(client, npc.ID);
                    }
                }
            }
            else Log.WriteLine(LogLevel.Warn, "{0} selected invalid object.", character.Name);
        }
コード例 #4
0
ファイル: Handler9.cs プロジェクト: iFeddy/SolarFiesta
        public static void SelectObjectHandler(ZoneClient client, Packet packet)
        {
            ushort id;
            if (!packet.TryReadUShort(out id))
            {
                Log.WriteLine(LogLevel.Warn, "Could not read entity select request.");
                return;
            }

            MapObject mo;
            // Try to see if there is a map object with this ID
            if (!client.Character.Map.Objects.TryGetValue(id, out mo))
            {
                return; // Nothing found. Just return lawl
            }

            mo.SelectedBy.Add(client.Character);

            if (mo is ZoneCharacter || mo is Mob)
            {
                client.Character.SelectedObject = mo;
                SendStatsUpdate(mo, client, false);
            }
        }
コード例 #5
0
ファイル: Handler9.cs プロジェクト: iFeddy/SolarFiesta
        public static void UseSkillWithTargetHandler(ZoneClient client, Packet packet)
        {
            ushort skillid, victimid;
            if (!packet.TryReadUShort(out skillid) || !packet.TryReadUShort(out victimid))
            {
                Log.WriteLine(LogLevel.Warn, "Couldn't read useskill packet {0}", client);
                return;
            }
            Skill skill;
            if (!client.Character.SkillsActive.TryGetValue(skillid, out skill))
            {
                Log.WriteLine(LogLevel.Warn, "User tried to use a wrong skill. {0} {1} ", skillid, client);
                return;
            }

            MapObject victim;
            if (!client.Character.MapSector.Objects.TryGetValue(victimid, out victim))
            {
                Log.WriteLine(LogLevel.Warn, "User tried to do something with an unknown victim. {0} {1} {2}", skillid, victimid, client);
            }
            var self = client.Character;

            if (skill.Info.DemandType == 6)
            {
                if (!(victim is ZoneCharacter)) return;
                var zc = victim as ZoneCharacter;

                // Only Heal has this
                // Some heal calculation here
                uint amount = 12 * (uint)Program.Randomizer.Next(1, 300); //lulz

                if (amount > victim.MaxHP - victim.HP)
                {
                    amount = victim.MaxHP - victim.HP;
                }

                zc.HP += amount;

                ushort id = self.UpdateCounter;
                SendSkillStartSelf(self, skillid, victimid, id);
                SendSkillStartOthers(self, skillid, victimid, id);
                SendSkillOK(self);
                SendSkillAnimationForPlayer(self, skillid, id);
                // Damage as heal val :D
                SendSkill(self, id, victimid, amount, zc.HP, zc.UpdateCounter);
            }
            else
            {
                if (!(victim is Mob)) return;
                uint dmgmin = (uint)self.GetWeaponDamage(true);
                uint dmgmax = (uint)(self.GetWeaponDamage(true) + (self.GetWeaponDamage(true) % 3));
                uint amount = (uint)Program.Randomizer.Next((int)dmgmin, (int)dmgmax);
                if (amount > victim.HP)
                {
                    victim.HP = 0;
                }
                else {
                    victim.HP -= amount;
                }

                ushort id = self.UpdateCounter;
                SendSkillStartSelf(self, skillid, victimid, id);
                SendSkillStartOthers(self, skillid, victimid, id);
                SendSkillOK(self);
                SendSkillAnimationForPlayer(self, skillid, id);
                SendSkill(self, id, victimid, amount, victim.HP, victim.UpdateCounter, 0x01, 0x01);

                if (!victim.IsDead)
                {
                    victim.Attack(self);
                }
            }
        }
コード例 #6
0
ファイル: Handler9.cs プロジェクト: iFeddy/SolarFiesta
        public static void UseSkillWithPositionHandler(ZoneClient client, Packet packet)
        {
            ushort skillid;
            uint x, y;
            if (!packet.TryReadUShort(out skillid) || !packet.TryReadUInt(out x) || !packet.TryReadUInt(out y))
            {
                Log.WriteLine(LogLevel.Warn, "Couldn't read UseSkillWithPosition packet. {0} ", client);
                return;
            }

            Skill skill;
            if (!client.Character.SkillsActive.TryGetValue(skillid, out skill))
            {
                Log.WriteLine(LogLevel.Warn, "User tried to use a wrong skill. {0} {1} ", skillid, client);
                return;
            }

            var self = client.Character;
            var block = self.Map.Block;

            if (x == 0 || y == 0 || x > block.Width || y > block.Height)
            {
                Log.WriteLine(LogLevel.Warn, "User tried to use skill out of map boundaries. {0} {1} {2} {3}", x, y, skillid, client);
                return;
            }

            var pos = new Vector2((int)x, (int)y);

            if (skill.Info.MaxTargets <= 1)
            {
                // No AoE skill :s
                Log.WriteLine(LogLevel.Warn, "User tried to use skill with no MaxTargets or less than 1. {0} {1}", skillid, client);
                return;
            }

            self.AttackSkillAoE(skillid, x, y);
        }
コード例 #7
0
ファイル: Handler6.cs プロジェクト: iFeddy/SolarFiesta
        public static void TransferKeyHandler(ZoneClient client, Packet packet)
        {
            ushort randomID;
            string characterName, checksums; //TODO: check in securityclient
            if (!packet.TryReadUShort(out randomID) || !packet.TryReadString(out characterName, 16) ||
                !packet.TryReadString(out checksums, 832))
            {
                Log.WriteLine(LogLevel.Warn, "Invalid game transfer.");
                return;
            }
            ClientTransfer transfer = ClientManager.Instance.GetTransfer(characterName);
            if (transfer == null || transfer.HostIP != client.Host || transfer.RandID != randomID)
            {
                Log.WriteLine(LogLevel.Warn, "{0} tried to login without a valid client transfer.", client.Host);
                //Handler3.SendError(client, ServerError.INVALID_CREDENTIALS);
                Handler4.SendConnectError(client, ConnectErrors.RequestedCharacterIDNotMatching);
                return;
            }

            try
            {
                ClientManager.Instance.RemoveTransfer(characterName);
                ZoneCharacter character = new ZoneCharacter(characterName);
                if (character.AccountID != transfer.AccountID)
                {
                    Log.WriteLine(LogLevel.Warn, "Character is logging in with wrong account ID.");
                    Handler4.SendConnectError(client, ConnectErrors.RequestedCharacterIDNotMatching);
                    //Handler3.SendError(client, ServerError.INVALID_CREDENTIALS);
                    return;
                }
                client.Authenticated = true;
                client.Admin = transfer.Admin;
                client.AccountID = transfer.AccountID;
                client.Username = transfer.Username;
                client.Character = character;
                character.Client = client;
                if (ClientManager.Instance.AddClient(client))
                {
                    character.SendGetIngameChunk(); //TODO: world server notification over WCF?
                    Log.WriteLine(LogLevel.Debug, "{0} logged in successfully!", character.Name);
                }
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogLevel.Exception, "Error loading character {0}: {1} - {2}", characterName, ex.ToString(), ex.StackTrace);
                Handler4.SendConnectError(client, ConnectErrors.ErrorInCharacterInfo);
            }
        }
コード例 #8
0
ファイル: Handler12.cs プロジェクト: iFeddy/SolarFiesta
 public static void LootHandler(ZoneClient client, Packet packet)
 {
     ushort id;
     if (!packet.TryReadUShort(out id))
     {
         Log.WriteLine(LogLevel.Warn, "Invalid loot request.");
         return;
     }
     client.Character.LootItem(id);
 }