예제 #1
0
        public void SendStatusPacket(StatusPacket sp)
        {
            if (!Connected)
            {
                return;
            }
            sp.ID     = ++SPc;
            sendSP.sp = sp;

            UInt16 checksum;

            unsafe
            {
                checksum = Checksum((byte *)&sp, sizeof(StatusPacket));
            }

            sendSP.header.checksum = checksum;

            int size = Marshal.SizeOf(sendSP);

            byte[] arr = new byte[size];

            IntPtr ptr = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(sendSP, ptr, true);
            Marshal.Copy(ptr, arr, 0, size);
            Marshal.FreeHGlobal(ptr);

            sendQueue.Enqueue(arr);
        }
예제 #2
0
        public static void p_Attack_c(InPacket lea, Client c)
        {
            if (c == null || lea.Available < 4)
            {
                return;
            }

            int CharacterID = lea.ReadInt();

            Character find = null;

            foreach (Character findCharacter in MapFactory.AllCharacters)
            {
                if (CharacterID == findCharacter.CharacterID)
                {
                    find = findCharacter;
                    break;
                }
            }

            if (find != null && find.IsHiding == true)
            {
                Map Map = MapFactory.GetMap(find.MapX, find.MapY);
                find.IsHiding = false;
                foreach (Character All in Map.Characters)
                {
                    StatusPacket.Hide(All.Client, find, 0);
                }
            }
        }
예제 #3
0
        private void UpdateInfo()
        {
            StatusPacket sp = new StatusPacket();

            Core.Rcon.SendPacket(sp);
            if (sp.PacketOk)
            {
                latestInfo = sp.Info;
            }
        }
예제 #4
0
파일: GGClient.cs 프로젝트: rolandzpl/gg
        public void LogOut(string description)
        {
            GGStatus status = String.IsNullOrEmpty(description) ? GGStatus.NotAvailable :
                              GGStatus.NotAvailableDescription;
            StatusPacket packet = new StatusPacket(status, description);

            this.packetManager.AddPacket(packet);
            this.State = State.Disconnected;
            this.packetManager.Stop();
            this.connector.Close();
        }
예제 #5
0
        public static void UpdateAvatar(Client gc)
        {
            var chr = gc.Character;
            Map map = MapFactory.GetMap(chr.MapX, chr.MapY);

            InventoryPacket.getInvenEquip(gc);
            StatusPacket.getStatusInfo(gc);
            foreach (Character All in map.Characters)
            {
                InventoryPacket.getAvatar(All.Client, chr);
            }
        }
예제 #6
0
        public static void AbilityRecover_Req(InPacket lea, Client c)
        {
            short Slot = lea.ReadShort();
            short Type = lea.ReadShort();
            var   chr  = c.Character;

            switch (Type)
            {
            case 0:                     // 力量還原本
                if (chr.Str < 4)
                {
                    return;
                }
                chr.Str--;
                chr.AbilityBonus++;
                chr.Items.Remove(3, (byte)Slot, 1);
                break;

            case 1:                     // 精力還原本
                if (chr.Dex < 4)
                {
                    return;
                }
                chr.Dex--;
                chr.AbilityBonus++;
                chr.Items.Remove(3, (byte)Slot, 1);
                break;

            case 2:                     // 氣力還原本
                if (chr.Vit < 4)
                {
                    return;
                }
                chr.Vit--;
                chr.AbilityBonus++;
                chr.Items.Remove(3, (byte)Slot, 1);
                break;

            case 3:                     // 智力還原本
                if (chr.Int < 4)
                {
                    return;
                }
                chr.Int--;
                chr.AbilityBonus++;
                chr.Items.Remove(3, (byte)Slot, 1);
                break;
            }

            InventoryHandler.UpdateInventory(c, 3);
            StatusPacket.getStatusInfo(c);
        }
예제 #7
0
        public void Awake()
        {
            TempR = new IOResource();
            DontDestroyOnLoad(gameObject);
            msg("Starting YARK KSPWebsockIO");

            SP             = new StatusPacket();
            SP.YarkVersion = YARK_VERSION;
            VP             = new VesselPacket();

            server = new TcpListener(IPAddress.Any, Config.TCPPort);
            server.Start();

            inFlight = -1;
        }
예제 #8
0
        static public long SamplePosition(double seconds,
                                          CaptureMask captureDataMask,
                                          ref StatusPacket statusPacket)
        {
            seconds = Math.Max(0, seconds);
            long bytesPerSample = BytesPerSample(captureDataMask);
            long freq           = 1000 * statusPacket.sampleRate;
            long result         = (long)(seconds * freq * bytesPerSample);
            long err            = result % bytesPerSample;

            if (err > 0) // must fall on boundary
            {
                result += (bytesPerSample - err);
            }
            result += sampleOffset;
            return(result);
        }
예제 #9
0
        private void HandlePacket(ClosePacket packet)
        {
            logger.LogDebug("Processing Close SFTP packet, Id={Id}, Handle='{Handle}'.", packet.Id, packet.Handle);

            if (TryGetHandle(packet.Id, packet.Handle, out SftpHandle handle))
            {
                handles.Remove(packet.Handle);

                var status = new StatusPacket
                {
                    Id           = packet.Id,
                    StatusCode   = StatusPacket.Ok,
                    ErrorMessage = "closed"
                };

                Send(status);
            }
        }
예제 #10
0
        public void ReadDir(uint requestId)
        {
            // If the pending items list is null, OpenDir was never called
            if (pendingDirectoryItems == null)
            {
                var packet = new StatusPacket
                {
                    Id           = requestId,
                    StatusCode   = StatusPacket.Failure,
                    ErrorMessage = "directory not open"
                };

                sftp.Send(packet);
            }

            // If the pending items list is empty, we're done - send EOF
            if (pendingDirectoryItems.Count == 0)
            {
                var packet = new StatusPacket
                {
                    Id           = requestId,
                    StatusCode   = StatusPacket.Eof,
                    ErrorMessage = "no more files"
                };

                sftp.Send(packet);
            }
            else
            {
                // We have files to send...send a batch.
                // TODO - keep the batch small enough that we do not exceed the connection's max packet size
                // TODO - implement me!
                var packet = new NamePacket();

                // TODO - parameterize the max entry count (and eventually base it off packet size)
                while ((pendingDirectoryItems.Count > 0) && (packet.Entries.Count < 10))
                {
                    packet.Entries.Add(pendingDirectoryItems.Dequeue().AsPacketEntry());
                }

                sftp.Send(packet);
            }
        }
예제 #11
0
        public static void Char_Damage_Req(InPacket lea, Client c)
        {
            short Damage = lea.ReadShort();
            var   chr    = c.Character;

            if (Damage < 0)
            {
                Damage = short.MaxValue;
            }

            chr.Hp -= Damage;
            if (chr.Hp <= 0)
            {
                chr.IsAlive = false;
                if (!(chr.MapX == 10 && chr.MapY == 60) && !(chr.MapX == 10 && chr.MapY == 61) &&
                    !(chr.MapX == 10 && chr.MapY == 62) && !(chr.MapX == 10 && chr.MapY == 63) &&
                    !(chr.MapX == 10 && chr.MapY == 64))
                {
                    chr.Exp -= (int)(GameConstants.getExpNeededForLevel(chr.Level) * 0.2);
                    if (chr.Exp < 0)
                    {
                        chr.Exp = 0;
                    }
                    StatusPacket.UpdateExp(c);
                }

                MapPacket.userDead(c);
                if (chr.Competitor != null)
                {
                    PvPPacket.PvPEnd(c, chr.Competitor.CharacterID);
                    PvPPacket.PvPEnd(chr.Competitor.Client, chr.Competitor.CharacterID);
                    chr.Competitor            = null;
                    chr.Competitor.Competitor = null;
                }

                chr.Hp = 1;
                chr.Mp = 1;
            }

            StatusPacket.UpdateHpMp(c, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
        }
예제 #12
0
        private bool TryGetHandle(uint requestId, string name, out SftpHandle handle)
        {
            if (handles.ContainsKey(name))
            {
                handle = handles[name];
                return(true);
            }
            else
            {
                handle = null;

                var status = new StatusPacket
                {
                    Id           = requestId,
                    StatusCode   = StatusPacket.Failure,
                    ErrorMessage = "unknown channel"
                };

                Send(status);

                return(false);
            }
        }
예제 #13
0
        private void HandlePacket(OpenDirPacket packet)
        {
            logger.LogDebug("Processing OpenDir SFTP packet, Id={Id}, Path='{Path}'.", packet.Id, packet.Path);

            // If they cannot read the directory, respond with a status packet.
            if (!fileSystem.CanReadDirectory(packet.Path))
            {
                var status = new StatusPacket
                {
                    Id           = packet.Id,
                    StatusCode   = StatusPacket.PermissionDenied,
                    ErrorMessage = "permission denied"
                };

                Send(status);
            }
            else
            {
                // Create a new channel
                // TODO - use a factory to create the handle, so it can get its own logger
                var handleId = Interlocked.Increment(ref nextChannelId).ToString();
                var handle   = new SftpHandle(this, handleId, fileSystem, logger);

                handles.Add(handleId, handle);

                handle.OpenDir(packet.Path);

                var response = new HandlePacket
                {
                    Id     = packet.Id,
                    Handle = handle.Name
                };

                Send(response);
            }
        }
예제 #14
0
 public static long SamplePosition(double seconds,
 CaptureMask captureDataMask,
 ref StatusPacket statusPacket)
 {
     seconds = Math.Max(0, seconds);
     long bytesPerSample = BytesPerSample(captureDataMask);
     long freq = 1000 * statusPacket.sampleRate;
     long result = (long)(seconds * freq * bytesPerSample);
     long err = result % bytesPerSample;
     if (err > 0) // must fall on boundary
         result += (bytesPerSample - err);
     result += sampleOffset;
     return result;
 }
예제 #15
0
 public static void GetSample(long sampleIndex,
 CaptureMask captureDataMask,
 StatusPacket statusPacket,
 BinaryReader reader,
 ref Sample sample)
 {
     // remember the index and time
     sample.sampleIndex = sampleIndex;
     sample.timeStamp = sampleIndex
     / (1000.0 * statusPacket.sampleRate);
     // intial settings for all flags
     sample.mainPresent =
     (captureDataMask & CaptureMask.chanMain) != 0;
     sample.usbPresent =
     (captureDataMask & CaptureMask.chanUsb) != 0;
     sample.auxPresent =
     (captureDataMask & CaptureMask.chanAux) != 0;
     sample.markerPresent = true;
     sample.missing = false;
     // abort if no data was selected
     long bytesPerSample = BytesPerSample(captureDataMask);
     if (bytesPerSample == 0)
         return;
     // remember original position
     long oldPos = reader.BaseStream.Position;
     // position the file to the start of the desired sample
     long newPos = SamplePosition(sampleIndex, captureDataMask);
     if (oldPos != newPos)
         reader.BaseStream.Position = newPos;
     // get default voltages (V) for the three channels
     sample.mainVoltage =
     2.0 + statusPacket.outputVoltageSetting * 0.01;
     sample.usbVoltage =
     (double)statusPacket.initialUsbVoltage * 125 / 1e6f;
     if (statusPacket.hardwareRevision < HardwareRev.revB)
         sample.usbVoltage /= 2;
     sample.auxVoltage =
     (double)statusPacket.initialAuxVoltage * 125 / 1e6f;
     if (statusPacket.hardwareRevision < HardwareRev.revC)
         sample.auxVoltage /= 2;
     // Main current (mA)
     if (sample.mainPresent)
     {
         short raw = reader.ReadInt16();
         sample.missing = sample.missing ||
         raw == missingRawCurrent;
         if (!sample.missing)
         {
             bool coarse = (raw & coarseMask) != 0;
             raw &= ~coarseMask;
             sample.mainCurrent = raw / 1000f; // uA -> mA
             if (coarse)
                 sample.mainCurrent *= 250;
         }
     }
     // Aux1 current (mA)
     if (sample.usbPresent)
     {
         short raw = reader.ReadInt16();
         sample.missing = sample.missing ||
         raw == missingRawCurrent;
         if (!sample.missing)
         {
             bool coarse = (raw & coarseMask) != 0;
             raw &= ~coarseMask;
             sample.usbCurrent = raw / 1000f; // uA -> mA
             if (coarse)
                 sample.usbCurrent *= 250;
         }
     }
     // Aux2 current (mA)
     if (sample.auxPresent)
     {
         short raw = reader.ReadInt16();
         sample.missing = sample.missing ||
         raw == missingRawCurrent;
         if (!sample.missing)
         {
             bool coarse = (raw & coarseMask) != 0;
             raw &= ~coarseMask;
             sample.auxCurrent = raw / 1000f; // uA -> mA
             if (coarse)
                 sample.auxCurrent *= 250;
         }
     }
     // Markers and Voltage (V)
     {
         ushort uraw = reader.ReadUInt16();
         sample.missing = sample.missing ||
         uraw == missingRawVoltage;
         if (!sample.missing)
         {
             // strip out marker bits
             sample.marker0 = (uraw & marker0Mask) != 0;
             sample.marker1 = (uraw & marker1Mask) != 0;
             uraw &= unchecked((ushort)~markerMask);
             // calculate voltage
             double voltage = (double)uraw * 125 / 1e6f;
             // assign the high-res voltage, as appropriate
             if ((statusPacket.leds & Leds.voltageIsAux) != 0)
             {
                 sample.auxVoltage = voltage;
                 if (statusPacket.hardwareRevision
                 < HardwareRev.revC)
                 {
                     sample.auxVoltage /= 2;
                 }
             }
             else
             {
                 sample.mainVoltage = voltage;
                 if (statusPacket.hardwareRevision
                 < HardwareRev.revB)
                 {
                     sample.mainVoltage /= 2;
                 }
             }
         }
     }
     // restore original position, if we moved it earlier
     if (oldPos != newPos)
         reader.BaseStream.Position = oldPos;
 }
예제 #16
0
 public static void ReadStatusPacket(BinaryReader reader,
 ref StatusPacket status)
 {
     // remember origibal position
     long oldPos = reader.BaseStream.Position;
     // move to start of status packet
     reader.BaseStream.Position = statusOffset;
     // read status packet
     status.packetLength = reader.ReadByte();
     status.packetType = (PacketType)reader.ReadByte();
     Debug.Assert(status.packetType == PacketType.status);
     status.firmwareVersion = reader.ReadByte();
     status.protocolVersion = reader.ReadByte();
     Debug.Assert(status.protocolVersion >= 16);
     status.fineObs.mainCurrent = reader.ReadInt16();
     status.fineObs.usbCurrent = reader.ReadInt16();
     status.fineObs.auxCurrent = reader.ReadInt16();
     status.fineObs.voltage = reader.ReadUInt16();
     status.coarseObs.mainCurrent = reader.ReadInt16();
     status.coarseObs.usbCurrent = reader.ReadInt16();
     status.coarseObs.auxCurrent = reader.ReadInt16();
     status.coarseObs.voltage = reader.ReadUInt16();
     status.outputVoltageSetting = reader.ReadByte();
     status.temperature = reader.ReadSByte();
     status.pmStatus = (PmStatus)reader.ReadByte();
     status.reserved = reader.ReadByte();
     status.leds = (Leds)reader.ReadByte();
     status.mainFineResistorOffset = reader.ReadSByte();
     status.serialNumber = reader.ReadUInt16();
     status.sampleRate = reader.ReadByte();
     status.dacCalLow = reader.ReadUInt16();
     status.dacCalHigh = reader.ReadUInt16();
     status.powerupCurrentLimit = reader.ReadUInt16();
     status.runtimeCurrentLimit = reader.ReadUInt16();
     status.powerupTime = reader.ReadByte();
     status.usbFineResistorOffset = reader.ReadSByte();
     status.auxFineResistorOffset = reader.ReadSByte();
     status.initialUsbVoltage = reader.ReadUInt16();
     status.initialAuxVoltage = reader.ReadUInt16();
     status.hardwareRevision = (HardwareRev)reader.ReadByte();
     status.temperatureLimit = reader.ReadByte();
     status.usbPassthroughMode =
     (UsbPassthroughMode)reader.ReadByte();
     status.mainCoarseResistorOffset = reader.ReadSByte();
     status.usbCoarseResistorOffset = reader.ReadSByte();
     status.auxCoarseResistorOffset = reader.ReadSByte();
     status.factoryMainFineResistorOffset = reader.ReadSByte();
     status.factoryUsbFineResistorOffset = reader.ReadSByte();
     status.factoryAuxFineResistorOffset = reader.ReadSByte();
     status.factoryMainCoarseResistorOffset =
     reader.ReadSByte();
     status.factoryUsbCoarseResistorOffset =
     reader.ReadSByte();
     status.factoryAuxCoarseResistorOffset =
     reader.ReadSByte();
     status.eventCode = (EventCode)reader.ReadByte();
     status.eventData = reader.ReadUInt16();
     status.checksum = reader.ReadByte();
     // restore original position
     reader.BaseStream.Position = oldPos;
 }
예제 #17
0
        static public void GetSample(long sampleIndex,
                                     CaptureMask captureDataMask,
                                     StatusPacket statusPacket,
                                     BinaryReader reader,
                                     ref Sample sample)
        {
            // remember the index and time
            sample.sampleIndex = sampleIndex;
            sample.timeStamp   = sampleIndex
                                 / (1000.0 * statusPacket.sampleRate);
            // intial settings for all flags
            sample.mainPresent =
                (captureDataMask & CaptureMask.chanMain) != 0;
            sample.usbPresent =
                (captureDataMask & CaptureMask.chanUsb) != 0;
            sample.auxPresent =
                (captureDataMask & CaptureMask.chanAux) != 0;
            sample.markerPresent = true;
            sample.missing       = false;
            // abort if no data was selected
            long bytesPerSample = BytesPerSample(captureDataMask);

            if (bytesPerSample == 0)
            {
                return;
            }
            // remember original position
            long oldPos = reader.BaseStream.Position;
            // position the file to the start of the desired sample
            long newPos = SamplePosition(sampleIndex, captureDataMask);

            if (oldPos != newPos)
            {
                reader.BaseStream.Position = newPos;
            }
            // get default voltages (V) for the three channels
            sample.mainVoltage =
                2.0 + statusPacket.outputVoltageSetting * 0.01;
            sample.usbVoltage =
                (double)statusPacket.initialUsbVoltage * 125 / 1e6f;
            if (statusPacket.hardwareRevision < HardwareRev.revB)
            {
                sample.usbVoltage /= 2;
            }
            sample.auxVoltage =
                (double)statusPacket.initialAuxVoltage * 125 / 1e6f;
            if (statusPacket.hardwareRevision < HardwareRev.revC)
            {
                sample.auxVoltage /= 2;
            }
            // Main current (mA)
            if (sample.mainPresent)
            {
                short raw = reader.ReadInt16();
                sample.missing = sample.missing ||
                                 raw == missingRawCurrent;
                if (!sample.missing)
                {
                    bool coarse = (raw & coarseMask) != 0;
                    raw &= ~coarseMask;
                    sample.mainCurrent = raw / 1000f; // uA -> mA
                    if (coarse)
                    {
                        sample.mainCurrent *= 250;
                    }
                }
            }
            // Aux1 current (mA)
            if (sample.usbPresent)
            {
                short raw = reader.ReadInt16();
                sample.missing = sample.missing ||
                                 raw == missingRawCurrent;
                if (!sample.missing)
                {
                    bool coarse = (raw & coarseMask) != 0;
                    raw &= ~coarseMask;
                    sample.usbCurrent = raw / 1000f; // uA -> mA
                    if (coarse)
                    {
                        sample.usbCurrent *= 250;
                    }
                }
            }
            // Aux2 current (mA)
            if (sample.auxPresent)
            {
                short raw = reader.ReadInt16();
                sample.missing = sample.missing ||
                                 raw == missingRawCurrent;
                if (!sample.missing)
                {
                    bool coarse = (raw & coarseMask) != 0;
                    raw &= ~coarseMask;
                    sample.auxCurrent = raw / 1000f; // uA -> mA
                    if (coarse)
                    {
                        sample.auxCurrent *= 250;
                    }
                }
            }
            // Markers and Voltage (V)
            {
                ushort uraw = reader.ReadUInt16();
                sample.missing = sample.missing ||
                                 uraw == missingRawVoltage;
                if (!sample.missing)
                {
                    // strip out marker bits
                    sample.marker0 = (uraw & marker0Mask) != 0;
                    sample.marker1 = (uraw & marker1Mask) != 0;
                    uraw          &= unchecked ((ushort)~markerMask);
                    // calculate voltage
                    double voltage = (double)uraw * 125 / 1e6f;
                    // assign the high-res voltage, as appropriate
                    if ((statusPacket.leds & Leds.voltageIsAux) != 0)
                    {
                        sample.auxVoltage = voltage;
                        if (statusPacket.hardwareRevision
                            < HardwareRev.revC)
                        {
                            sample.auxVoltage /= 2;
                        }
                    }
                    else
                    {
                        sample.mainVoltage = voltage;
                        if (statusPacket.hardwareRevision
                            < HardwareRev.revB)
                        {
                            sample.mainVoltage /= 2;
                        }
                    }
                }
            }
            // restore original position, if we moved it earlier
            if (oldPos != newPos)
            {
                reader.BaseStream.Position = oldPos;
            }
        }
예제 #18
0
        public static void Command_Req(InPacket lea, Client gc)
        {
            string[] cmd = lea.ReadString(60).Split(new[] { (char)0x20 }, StringSplitOptions.None);

            if (gc.Account.Master == 0 || cmd.Length < 1)
            {
                return;
            }
            var       chr    = gc.Character;
            Character victim = null;

            switch (cmd[0])
            {
            case "//notice":
                if (cmd.Length != 2)
                {
                    break;
                }
                foreach (Character all in MapFactory.AllCharacters)
                {
                    GamePacket.getNotice(all.Client, 3, cmd[1]);
                }
                break;

            case "//item":
                if (cmd.Length != 2 && cmd.Length != 3)
                {
                    break;
                }

                short Quantity = 1;

                if (cmd.Length == 3)
                {
                    if (int.Parse(cmd[2]) > 100)
                    {
                        Quantity = 100;
                    }
                    else
                    {
                        Quantity = short.Parse(cmd[2]);
                    }
                }

                if (InventoryType.getItemType(int.Parse(cmd[1])) == 1 || InventoryType.getItemType(int.Parse(cmd[1])) == 2)
                {
                    Quantity = 1;
                }

                if (InventoryType.getItemType(int.Parse(cmd[1])) == 5)
                {
                    return;
                }

                chr.Items.Add(new Item(int.Parse(cmd[1]), InventoryType.getItemType(int.Parse(cmd[1])), chr.Items.GetNextFreeSlot((InventoryType.ItemType)InventoryType.getItemType(int.Parse(cmd[1]))), Quantity));
                InventoryHandler.UpdateInventory(gc, InventoryType.getItemType(int.Parse(cmd[1])));
                break;

            case "//money":
                if (cmd.Length != 2)
                {
                    break;
                }
                chr.Money = int.Parse(cmd[1]);
                InventoryPacket.getInvenMoney(gc, chr.Money, int.Parse(cmd[1]));
                break;

            case "//levelup":
                chr.LevelUp();
                break;

            case "//gogo":
                if (cmd.Length != 3)
                {
                    break;
                }
                MapPacket.warpToMapAuth(gc, true, short.Parse(cmd[1]), short.Parse(cmd[2]), short.Parse(cmd[3]), short.Parse(cmd[4]));
                break;

            case "//hp":
                if (cmd.Length != 2)
                {
                    break;
                }

                short Hp = short.Parse(cmd[1]);

                if (Hp > short.MaxValue)
                {
                    Hp = short.MaxValue;
                }

                chr.MaxHp = Hp;
                chr.Hp    = Hp;
                StatusPacket.getStatusInfo(gc);
                break;

            case "//mp":
                short Mp = short.Parse(cmd[1]);

                if (Mp > short.MaxValue)
                {
                    Mp = short.MaxValue;
                }

                chr.MaxMp = Mp;
                chr.Mp    = Mp;
                StatusPacket.getStatusInfo(gc);
                break;

            case "//heal":
                chr.Hp   = chr.MaxHp;
                chr.Mp   = chr.MaxMp;
                chr.Fury = chr.MaxFury;
                StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                break;

            case "//warp":
                if (cmd.Length != 2)
                {
                    break;
                }
                foreach (Character find in MapFactory.AllCharacters)
                {
                    if (find.Name.Equals(cmd[1]))
                    {
                        victim = find;
                    }
                }
                if (victim != null)
                {
                    chr.MapX    = victim.MapX;
                    chr.MapY    = victim.MapY;
                    chr.PlayerX = victim.PlayerX;
                    chr.PlayerY = victim.PlayerY;
                    MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                }
                break;

            case "//ban":
                if (cmd.Length != 2)
                {
                    break;
                }
                foreach (Character find in MapFactory.AllCharacters)
                {
                    if (find.Name.Equals(cmd[1]))
                    {
                        victim = find;
                    }
                }
                if (victim != null)
                {
                    dynamic datum = new Datum("accounts");
                    victim.Client.Account.Banned = 7;
                    victim.Client.Dispose();
                }
                break;

            case "//save":
                for (int i = 0; i < MapFactory.AllCharacters.Count; i++)
                {
                    if (chr.CharacterID == MapFactory.AllCharacters[i].CharacterID)
                    {
                        continue;
                    }
                    MapFactory.AllCharacters[i].Client.Dispose();
                }
                //GameServer.IsAlive = false;
                break;

            case "//skillhack":
                break;

            case "//serverinfo":
                GamePacket.NormalNotice(gc, 1, "I: P:15101 U:1 E:1.00 D:1.00 M:1.00 G:1.00");
                break;

            case "//come":

            case "//oxstate":
                break;

            case "//now":
                DateTime now     = DateTime.Now;
                string   nowtime = string.Format("Server Time Now : [{0}-{1}-{2} {3}:{4}:{5}]", now.Year, now.Month, now.Day.ToString("00.##"), now.Hour.ToString("00.##"), now.Minute.ToString("00.##"), now.Second.ToString("00.##"));
                GamePacket.NormalNotice(gc, 4, nowtime);
                break;

            case "//user":
                break;

            case "//serverdown":
                break;

            case "//test":
                GamePacket.getNotice(gc, 4, "Tes000t");
                break;

            case "//expbuff":
                GamePacket.getNotice(gc, 1, "!@ExpEvent2@!");
                break;

            case "//processlist":
                GamePacket.GmProcessList(gc);
                GamePacket.NormalNotice(gc, 4, "[GM] Process File has saved in game folder.");
                break;

            case "//gameinfo":
                GamePacket.GmGameInfo(gc);
                GamePacket.NormalNotice(gc, 4, "[GM] GAME_INFO has copied to your clipboard.");                         //[GM] Game Log has copied to your clipboard.
                break;

            default:
                break;
            }
        }
예제 #19
0
        public static void Char_Statup_Req(InPacket lea, Client gc)
        {
            int stat = lea.ReadInt();
            var chr  = gc.Character;

            if (chr.AbilityBonus < 1)
            {
                return;
            }

            switch (stat)
            {
            case 1:                     // 力量
                chr.Str++;
                chr.MaxHp += 3;
                if (chr.Str % 5 != 0)
                {
                    chr.MaxAttack += 2;
                }
                else
                {
                    chr.MaxAttack += 3;
                }
                break;

            case 2:                     // 精力
                chr.Dex++;
                if (chr.Dex % 5 != 0)
                {
                    chr.Attack    += 1;
                    chr.MaxAttack += 2;
                }
                else
                {
                    chr.Attack    += 2;
                    chr.MaxAttack += 3;
                }

                break;

            case 3:                     // 氣力
                chr.Vit++;
                chr.Defense += 5;
                chr.MaxHp   += 20;
                break;

            case 4:                     // 智力
                chr.Int++;
                chr.MaxMp += 3;
                if (chr.Int % 5 != 0)
                {
                    chr.Magic    += 2;
                    chr.MaxMagic += 2;
                }
                else
                {
                    chr.Magic    += 3;
                    chr.MaxMagic += 3;
                }

                break;

            default:
                break;
            }

            chr.AbilityBonus--;
            StatusPacket.UpdateStat(gc);
        }
예제 #20
0
        public static void Game_Log_Req(InPacket lea, Client gc)
        {
            //int re = SearchBytes(lea.Content, new byte[] { 0x0 });
            string[]  data            = lea.ReadString(0x100 /*re*/).Split(new[] { (char)0x20 }, StringSplitOptions.None);
            int       encryptKey      = int.Parse(data[1]);
            string    username        = data[2];
            string    password        = data[4];
            int       selectCharacter = lea.ReadByte();
            IPAddress hostid          = lea.ReadIPAddress();

            gc.SetAccount(new Account(gc));

            try
            {
                gc.Account.Load(username);
                //var pe = new PasswordEncrypt(encryptKey);
                //string encryptPassword = pe.encrypt(gc.Account.Password, gc.RetryLoginCount > 0 ? password.ToCharArray() : null);

                if (password.Equals(gc.Account.Password))
                {
                    gc.Dispose();
                    Log.Error("Login Fail!");
                }
                else
                {
                    gc.Account.Characters = new List <Character>();
                    foreach (dynamic datum in new Datums("Characters").PopulateWith("id", "accountId = '{0}' ORDER BY position ASC", gc.Account.ID))
                    {
                        Character character = new Character(datum.id, gc);
                        character.Load(false);
                        character.IP = hostid;
                        gc.Account.Characters.Add(character);
                    }
                    gc.SetCharacter(gc.Account.Characters[selectCharacter]);
                }
                Log.Inform("Password = {0}", password);
                //Log.Inform("encryptKey = {0}", encryptKey);
                //Log.Inform("encryptPassword = {0}", encryptPassword);
            }
            catch (NoAccountException)
            {
                gc.Dispose();
                Log.Error("Login Fail!");
            }

            Character chr = gc.Character;

            chr.CharacterID = gc.CharacterID;
            MapFactory.AllCharacters.Add(chr);

            StatusPacket.UpdateHpMp(gc, 0, 0, 0, 0);
            GamePacket.FW_DISCOUNTFACTION(gc);
            StatusPacket.getStatusInfo(gc);
            InventoryPacket.getCharacterEquip(gc);
            SkillPacket.getSkillInfo(gc, chr.Skills.getSkills());
            QuestPacket.getQuestInfo(gc, chr.Quests.getQuests());
            GamePacket.getQuickSlot(gc, chr.Keymap);
            StoragePacket.getStoreInfo(gc);
            StoragePacket.getStoreMoney(gc);
            MapPacket.enterMapStart(gc);
            InventoryPacket.getInvenCash(gc);
            CashShopPacket.MgameCash(gc);
            CashShopPacket.GuiHonCash(gc);
            InventoryPacket.getInvenEquip(gc);
            InventoryPacket.getInvenEquip1(gc);
            InventoryPacket.getInvenEquip2(gc);
            InventoryPacket.getInvenSpend3(gc);
            InventoryPacket.getInvenOther4(gc);
            InventoryPacket.getInvenPet5(gc);
        }
예제 #21
0
        public static void TradeEventItem(InPacket lea, Client c)
        {
            lea.ReadShort();             // 活動ID ?
            byte Type     = lea.ReadByte();
            byte Slot     = lea.ReadByte();
            int  Quantity = lea.ReadInt();
            var  chr      = c.Character;

            Item Item = null;

            foreach (Item im in chr.Items.getItems())
            {
                if (im.Type == 4 && im.ItemID == 8990049 && im.Quantity >= Quantity)
                {
                    Item = im;
                    break;
                }
            }

            if (Item == null && Quantity <= 100)
            {
                return;
            }

            switch (Quantity)
            {
            case 5:
                chr.Rank += 1;
                StatusPacket.UpdateFame(c, 1);
                break;

            case 8:
                chr.Rank += 2;
                StatusPacket.UpdateFame(c, 2);
                break;

            case 12:
                chr.Rank += 3;
                StatusPacket.UpdateFame(c, 3);
                break;

            case 20:
                chr.Items.Add(new Item(8510071, (byte)InventoryType.ItemType.Equip2,
                                       chr.Items.GetNextFreeSlot(InventoryType.ItemType.Equip2)));
                InventoryHandler.UpdateInventory(c, 2);
                InventoryPacket.ClearDropItem(c, chr.CharacterID, -1, 8510071);
                break;

            case 30:
                chr.Items.Add(new Item(8510081, (byte)InventoryType.ItemType.Equip2,
                                       chr.Items.GetNextFreeSlot(InventoryType.ItemType.Equip2)));
                InventoryHandler.UpdateInventory(c, 2);
                InventoryPacket.ClearDropItem(c, chr.CharacterID, -1, 8510081);
                break;

            case 40:
                chr.Items.Add(new Item(8510091, (byte)InventoryType.ItemType.Equip2,
                                       chr.Items.GetNextFreeSlot(InventoryType.ItemType.Equip2)));
                InventoryHandler.UpdateInventory(c, 2);
                InventoryPacket.ClearDropItem(c, chr.CharacterID, -1, 8510091);
                break;

            case 50:
                chr.Items.Add(new Item(8510101, (byte)InventoryType.ItemType.Equip2,
                                       chr.Items.GetNextFreeSlot(InventoryType.ItemType.Equip2)));
                InventoryHandler.UpdateInventory(c, 2);
                InventoryPacket.ClearDropItem(c, chr.CharacterID, -1, 8510101);
                break;

            case 60:
                chr.Money += 2000000;
                InventoryPacket.getInvenMoney(c, chr.Money, 2000000);
                break;

            case 100:
                chr.Money += 4000000;
                InventoryPacket.getInvenMoney(c, chr.Money, 4000000);
                break;

            case 200:
                chr.Money += 8200000;
                InventoryPacket.getInvenMoney(c, chr.Money, 8200000);
                break;

            case 300:
                chr.Money += 13000000;
                InventoryPacket.getInvenMoney(c, chr.Money, 13000000);
                break;

            case 500:
                chr.Money += 24000000;
                InventoryPacket.getInvenMoney(c, chr.Money, 24000000);
                break;
            }

            if (Quantity > 100)
            {
                Item Target1 = null;
                Item Target2 = null;
                Item Target3 = null;
                Item Target4 = null;
                Item Target5 = null;
                int  i       = 0;
                foreach (Item Target in chr.Items.getItems())
                {
                    if (i == 0 && Target.ItemID == 8990049 && Target.Quantity == 100)
                    {
                        Target1 = Target;
                        i++;
                    }
                    else if (i == 1 && Target.ItemID == 8990049 && Target.Quantity == 100)
                    {
                        Target2 = Target;
                        i++;
                    }
                    else if (i == 2 && (Quantity == 300 || Quantity == 500) && Target.ItemID == 8990049 &&
                             Target.Quantity == 100)
                    {
                        Target3 = Target;
                        i++;
                    }
                    else if (i == 3 && Quantity == 500 && Target.ItemID == 8990049 && Target.Quantity == 100)
                    {
                        Target4 = Target;
                        i++;
                    }
                    else if (i == 4 && Quantity == 500 && Target.ItemID == 8990049 && Target.Quantity == 100)
                    {
                        Target5 = Target;
                        i++;
                    }
                    else if (i == 5)
                    {
                        break;
                    }
                }

                if (Target1 != null)
                {
                    chr.Items.Remove(Target1.Type, Target1.Slot, 100);
                }
                if (Target2 != null)
                {
                    chr.Items.Remove(Target2.Type, Target2.Slot, 100);
                }
                if (Target3 != null)
                {
                    chr.Items.Remove(Target3.Type, Target3.Slot, 100);
                }
                if (Target4 != null)
                {
                    chr.Items.Remove(Target4.Type, Target4.Slot, 100);
                }
                if (Target5 != null)
                {
                    chr.Items.Remove(Target5.Type, Target5.Slot, 100);
                }
            }
            else
            {
                chr.Items.Remove(Type, Slot, Quantity);
            }

            InventoryHandler.UpdateInventory(c, Type);
        }
예제 #22
0
        public static void UseSpend_Req(InPacket lea, Client gc)
        {
            var  chr  = gc.Character;
            byte Type = lea.ReadByte();
            byte Slot = lea.ReadByte();
            Item Item = chr.Items.getItem(Type, Slot);
            Map  map  = MapFactory.GetMap(chr.MapX, chr.MapY);
            var  use  = ItemFactory.useData[Item.ItemID];

            // 使用回復HP 跟 MP 的物品
            switch (Item.ItemID)
            {
            case 8841006:     // 全部還原本
                int Recover = 0;
                Recover           = Recover + (chr.Str - 3);
                Recover           = Recover + (chr.Dex - 3);
                Recover           = Recover + (chr.Vit - 3);
                Recover           = Recover + (chr.Int - 3);
                chr.Str           = 3;
                chr.Dex           = 3;
                chr.Vit           = 3;
                chr.Int           = 3;
                chr.AbilityBonus += (short)Recover;
                StatusPacket.getStatusInfo(gc);
                break;

            case 8850011:     // 回城符
                switch (chr.MapX)
                {
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 22:
                case 23:
                    chr.MapX = 1;
                    chr.MapY = 1;
                    break;

                case 7:
                case 8:
                case 9:
                    chr.MapX = 16;
                    chr.MapY = 1;
                    break;

                case 10:
                case 11:
                case 20:
                    chr.MapX = 10;
                    chr.MapY = 1;
                    break;

                case 12:
                case 13:
                    chr.MapX = 12;
                    chr.MapY = 1;
                    break;

                case 14:
                case 15:
                case 17:
                case 18:
                case 19:
                case 21:
                    chr.MapX = 15;
                    chr.MapY = 1;
                    break;

                case 16:
                    chr.MapX = 16;
                    chr.MapY = 1;
                    break;

                case 24:
                case 25:
                case 26:
                case 31:
                case 32:
                case 33:
                    chr.MapX = 25;
                    chr.MapY = 1;
                    break;

                case 27:
                case 28:
                    chr.MapX = 27;
                    chr.MapY = 1;
                    break;

                default:
                    chr.MapX = 1;
                    chr.MapY = 1;
                    break;
                }
                chr.PlayerX = 0;
                chr.PlayerY = 0;
                MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                break;

            case 8850021:     // 清陰符
                chr.MapX    = 1;
                chr.MapY    = 2;
                chr.PlayerX = 2955;
                chr.PlayerY = 1116;
                MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                break;

            case 8850031:     // 龍林符(龍林城)
                chr.MapX    = 15;
                chr.MapY    = 2;
                chr.PlayerX = 3600;
                chr.PlayerY = 1041;
                MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                break;

            case 8850041:     // 冥珠符
                chr.MapX    = 10;
                chr.MapY    = 3;
                chr.PlayerX = 1645;
                chr.PlayerY = 899;
                MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                break;

            case 8850051:     // 古樂符
                chr.MapX    = 25;
                chr.MapY    = 1;
                chr.PlayerX = 4237;
                chr.PlayerY = 1230;
                MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                break;

            case 8850061:     // 無名符
                chr.MapX    = 16;
                chr.MapY    = 1;
                chr.PlayerX = 2005;
                chr.PlayerY = 1101;
                MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                break;

            case 8850071:     // 龍林符(龍林客棧)
                chr.MapX    = 12;
                chr.MapY    = 1;
                chr.PlayerX = 1040;
                chr.PlayerY = 782;
                MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                break;

            case 8890011:     // 蠟燭
            case 8890021:     // 火把
                InventoryPacket.UseSpendStart(gc, chr, chr.PlayerX, chr.PlayerY, Item.ItemID, (byte)InventoryType.ItemType.Spend3, Slot);
                break;

            case 8899017:     // 逮巴符
                chr.MapX    = 27;
                chr.MapY    = 1;
                chr.PlayerX = 2070;
                chr.PlayerY = 1330;
                MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                break;

            default:
                switch (use.Type)
                {
                case 0:         // 恢復鬼力
                    if ((chr.MaxMp > chr.Mp + use.Recover))
                    {
                        chr.Mp += (short)use.Recover;
                        StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                    }
                    else if (chr.MaxMp - chr.Mp < use.Recover)
                    {
                        chr.Mp = chr.MaxMp;
                        StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                    }
                    break;

                case 1:         // 恢復鬼力(%)
                    if ((chr.MaxMp > chr.Mp + chr.MaxMp * use.Recover / 100))
                    {
                        chr.Mp += (short)(chr.MaxMp * use.Recover / 100);
                        StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                    }
                    else if (chr.MaxMp - chr.Mp < chr.MaxMp * use.Recover / 100)
                    {
                        chr.Mp = chr.MaxMp;
                        StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                    }
                    break;

                case 2:         // 恢復體力
                    if ((chr.MaxHp > chr.Hp + use.Recover))
                    {
                        chr.Hp += (short)use.Recover;
                        StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                    }
                    else if (chr.MaxHp - chr.Hp < use.Recover)
                    {
                        chr.Hp = chr.MaxHp;
                        StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                    }
                    break;

                case 3:         // 恢復體力(%)
                    if ((chr.MaxHp > chr.Hp + chr.MaxHp * use.Recover / 100))
                    {
                        chr.Hp += (short)(chr.MaxHp * use.Recover / 100);
                        StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                    }
                    else if (chr.MaxHp - chr.Hp < chr.MaxHp * use.Recover / 100)
                    {
                        chr.Hp = chr.MaxHp;
                        StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                    }
                    break;

                default:
                    break;
                }
                break;
            }
            chr.Items.Remove(Type, Slot, 1);
            UpdateInventory(gc, Type);
        }
예제 #23
0
        public static void UseSkill_Req(InPacket lea, Client gc)
        {
            byte Type         = lea.ReadByte();
            byte Slot         = lea.ReadByte();
            byte Level        = lea.ReadByte();
            byte NumOfTargets = lea.ReadByte();
            int  Active       = lea.ReadInt();
            var  chr          = gc.Character;

            Map Map = MapFactory.GetMap(chr.MapX, chr.MapY);

            if (Type == 0 || Type == 1 || Type == 2 || Type == 3 || Type == 4)
            {
                Skill Skill = null;
                foreach (Skill sl in chr.Skills.getSkills())
                {
                    if (sl.Type.Equals(Type) && sl.Slot.Equals(Slot) && sl.SkillLevel.Equals(Level))
                    {
                        Skill = sl;
                    }
                }
                switch (Skill.SkillID)
                {
                case 0:
                    break;

                case 1:
                    if (Skill.SkillLevel < 5)
                    {
                        chr.Mp -= 2;
                    }
                    else
                    {
                        chr.Mp -= 4;
                    }
                    break;

                case 2:
                    break;

                case 3:
                    if (Active == 1)
                    {
                        Delay ddl = new Delay(1, false, null);
                        chr.SkillState.Add(Skill.SkillID, ddl);
                        chr.SkillState[Skill.SkillID] = new Delay(8000, true, () =>
                        {
                            int addHp = 0, addMp = 0;
                            if ((chr.Hp + 8) < chr.MaxHp)
                            {
                                addHp = 8;
                            }
                            else
                            {
                                addHp = chr.MaxHp - chr.Hp;
                                if (addHp > 8)
                                {
                                    addHp = 8;
                                }
                            }
                            if ((chr.Mp + 2) < chr.MaxMp)
                            {
                                addMp = 2;
                            }
                            else
                            {
                                addMp = chr.MaxMp - chr.Mp;
                                if (addMp > 2)
                                {
                                    addMp = 2;
                                }
                            }
                            chr.Hp += (short)addHp;
                            chr.Mp += (short)addMp;
                            StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                        }
                                                                  );
                        chr.SkillState[Skill.SkillID].Execute();
                    }
                    else
                    {
                        chr.SkillState[Skill.SkillID].Cancel();
                        chr.SkillState.Remove(Skill.SkillID);
                    }
                    break;

                case 4:
                    chr.Mp -= (short)5;
                    StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                    break;

                case 10104:     // 氣力轉換
                    chr.Hp -= (short)(5 * Skill.SkillLevel);
                    chr.Mp += (short)(16 * Skill.SkillLevel);
                    if (chr.Hp < 0)
                    {
                        chr.Hp = 0;
                    }
                    if (chr.Mp > chr.MaxMp)
                    {
                        chr.Mp = chr.MaxMp;
                    }
                    break;

                case 10107:     // 狂暴怒氣
                    if (chr.SkillState.ContainsKey(10107))
                    {
                        chr.SkillState[10107].Cancel();
                    }

                    short Mp      = 26;
                    short Defense = (short)(chr.Defense * 0.03);
                    short Attack  = (short)(chr.Attack * 0.01);
                    int   Time    = 33;
                    switch (Skill.SkillLevel)
                    {
                    case 1:
                        Mp      = 26;
                        Defense = (short)(chr.Defense * 0.03);
                        Attack  = (short)(chr.Attack * 0.01);
                        Time    = 33;
                        break;

                    case 2:
                        Mp      = 26;
                        Defense = (short)(chr.Defense * 0.06);
                        Attack  = (short)(chr.Attack * 0.02);
                        Time    = 36;
                        break;

                    case 3:
                        Mp      = 26;
                        Defense = (short)(chr.Defense * 0.09);
                        Attack  = (short)(chr.Attack * 0.03);
                        Time    = 39;
                        break;

                    case 4:
                        Mp      = 26;
                        Defense = (short)(chr.Defense * 0.12);
                        Attack  = (short)(chr.Attack * 0.04);
                        Time    = 42;
                        break;

                    case 5:
                        Mp      = 26;
                        Defense = (short)(chr.Defense * 0.15);
                        Attack  = (short)(chr.Attack * 0.05);
                        Time    = 45;
                        break;

                    case 6:
                        Mp      = 52;
                        Defense = (short)(chr.Defense * 0.18);
                        Attack  = (short)(chr.Attack * 0.06);
                        Time    = 48;
                        break;

                    case 7:
                        Mp      = 52;
                        Defense = (short)(chr.Defense * 0.21);
                        Attack  = (short)(chr.Attack * 0.07);
                        Time    = 51;
                        break;

                    case 8:
                        Mp      = 52;
                        Defense = (short)(chr.Defense * 0.24);
                        Attack  = (short)(chr.Attack * 0.08);
                        Time    = 54;
                        break;

                    case 9:
                        Mp      = 52;
                        Defense = (short)(chr.Defense * 0.27);
                        Attack  = (short)(chr.Attack * 0.09);
                        Time    = 57;
                        break;

                    case 10:
                        Mp      = 52;
                        Defense = (short)(chr.Defense * 0.30);
                        Attack  = (short)(chr.Attack * 0.10);
                        Time    = 60;
                        break;

                    case 11:
                        Mp      = 78;
                        Defense = (short)(chr.Defense * 0.33);
                        Attack  = (short)(chr.Attack * 0.11);
                        Time    = 63;
                        break;

                    case 12:
                        Mp      = 78;
                        Defense = (short)(chr.Defense * 0.36);
                        Attack  = (short)(chr.Attack * 0.12);
                        Time    = 66;
                        break;

                    case 13:
                        Mp      = 78;
                        Defense = (short)(chr.Defense * 0.39);
                        Attack  = (short)(chr.Attack * 0.13);
                        Time    = 69;
                        break;

                    case 14:
                        Mp      = 78;
                        Defense = (short)(chr.Defense * 0.42);
                        Attack  = (short)(chr.Attack * 0.14);
                        Time    = 72;
                        break;

                    case 15:
                        Mp      = 78;
                        Defense = (short)(chr.Defense * 0.45);
                        Attack  = (short)(chr.Attack * 0.15);
                        Time    = 75;
                        break;

                    case 16:
                        Mp      = 104;
                        Defense = (short)(chr.Defense * 0.48);
                        Attack  = (short)(chr.Attack * 0.16);
                        Time    = 78;
                        break;

                    case 17:
                        Mp      = 104;
                        Defense = (short)(chr.Defense * 0.51);
                        Attack  = (short)(chr.Attack * 0.17);
                        Time    = 81;
                        break;

                    case 18:
                        Mp      = 104;
                        Defense = (short)(chr.Defense * 0.54);
                        Attack  = (short)(chr.Attack * 0.18);
                        Time    = 84;
                        break;

                    case 19:
                        Mp      = 104;
                        Defense = (short)(chr.Defense * 0.57);
                        Attack  = (short)(chr.Attack * 0.19);
                        Time    = 87;
                        break;

                    case 20:
                        Mp      = 104;
                        Defense = (short)(chr.Defense * 0.60);
                        Attack  = (short)(chr.Attack * 0.20);
                        Time    = 90;
                        break;
                    }
                    chr.Mp -= Mp;
                    if (chr.Mp < 0)
                    {
                        chr.Mp = 0;
                    }

                    if (!chr.SkillState.ContainsKey(10107))
                    {
                        chr.Defense       -= Defense;
                        chr.MaxAttack     += Attack;
                        chr.Attack        += Attack;
                        chr.UpgradeAttack += Attack;
                        if (chr.Defense < 0)
                        {
                            chr.Defense = 0;
                        }
                        chr.SkillAttack_10107  = Attack;
                        chr.SkillDefense_10107 = Defense;
                        chr.SkillState.Add(Skill.SkillID, null);
                        StatusPacket.UpdateStat(gc);
                    }
                    chr.SkillState[Skill.SkillID] = new Delay(Time * 1000, false, () =>
                    {
                        chr.Defense       += Defense;
                        chr.MaxAttack     -= Attack;
                        chr.Attack        -= Attack;
                        chr.UpgradeAttack -= Attack;
                        chr.SkillState.Remove(10107);
                        StatusPacket.UpdateStat(gc);
                    });
                    chr.SkillState[Skill.SkillID].Execute();
                    break;

                case 10207:     // 霧影術
                    chr.IsHiding = true;
                    foreach (Character All in Map.Characters)
                    {
                        StatusPacket.Hide(All.Client, chr, 1);
                    }
                    break;

                case 10309:     // 防護加持
                    if (chr.SkillState.ContainsKey(10309))
                    {
                        chr.SkillState[10309].Cancel();
                    }

                    Mp      = 34;
                    Defense = (short)(chr.Defense * 0.03);
                    Time    = 35;
                    switch (Skill.SkillLevel)
                    {
                    case 1:
                        Mp      = 34;
                        Defense = (short)(chr.Defense * 0.03);
                        Time    = 35;
                        break;

                    case 2:
                        Mp      = 34;
                        Defense = (short)(chr.Defense * 0.06);
                        Time    = 40;
                        break;

                    case 3:
                        Mp      = 34;
                        Defense = (short)(chr.Defense * 0.09);
                        Time    = 45;
                        break;

                    case 4:
                        Mp      = 34;
                        Defense = (short)(chr.Defense * 0.12);
                        Time    = 50;
                        break;

                    case 5:
                        Mp      = 34;
                        Defense = (short)(chr.Defense * 0.15);
                        Time    = 55;
                        break;

                    case 6:
                        Mp      = 68;
                        Defense = (short)(chr.Defense * 0.18);
                        Time    = 60;
                        break;

                    case 7:
                        Mp      = 68;
                        Defense = (short)(chr.Defense * 0.21);
                        Time    = 65;
                        break;

                    case 8:
                        Mp      = 68;
                        Defense = (short)(chr.Defense * 0.24);
                        Time    = 70;
                        break;

                    case 9:
                        Mp      = 68;
                        Defense = (short)(chr.Defense * 0.27);
                        Time    = 75;
                        break;

                    case 10:
                        Mp      = 68;
                        Defense = (short)(chr.Defense * 0.30);
                        Time    = 80;
                        break;

                    case 11:
                        Mp      = 102;
                        Defense = (short)(chr.Defense * 0.33);
                        Time    = 85;
                        break;

                    case 12:
                        Mp      = 102;
                        Defense = (short)(chr.Defense * 0.36);
                        Time    = 90;
                        break;

                    case 13:
                        Mp      = 102;
                        Defense = (short)(chr.Defense * 0.39);
                        Time    = 95;
                        break;

                    case 14:
                        Mp      = 102;
                        Defense = (short)(chr.Defense * 0.42);
                        Time    = 100;
                        break;

                    case 15:
                        Mp      = 102;
                        Defense = (short)(chr.Defense * 0.45);
                        Time    = 105;
                        break;

                    case 16:
                        Mp      = 136;
                        Defense = (short)(chr.Defense * 0.48);
                        Time    = 110;
                        break;

                    case 17:
                        Mp      = 136;
                        Defense = (short)(chr.Defense * 0.51);
                        Time    = 115;
                        break;

                    case 18:
                        Mp      = 136;
                        Defense = (short)(chr.Defense * 0.54);
                        Time    = 120;
                        break;

                    case 19:
                        Mp      = 136;
                        Defense = (short)(chr.Defense * 0.57);
                        Time    = 125;
                        break;

                    case 20:
                        Mp      = 136;
                        Defense = (short)(chr.Defense * 0.60);
                        Time    = 130;
                        break;
                    }
                    chr.Mp -= Mp;
                    if (chr.Mp < 0)
                    {
                        chr.Mp = 0;
                    }

                    if (!chr.SkillState.ContainsKey(10309))
                    {
                        chr.Defense           += Defense;
                        chr.UpgradeDefense    += Defense;
                        chr.SkillDefense_10309 = Defense;
                        chr.SkillState.Add(Skill.SkillID, null);
                        StatusPacket.UpdateStat(gc);
                    }
                    chr.SkillState[Skill.SkillID] = new Delay(Time * 1000, false, () =>
                    {
                        chr.Defense        -= Defense;
                        chr.UpgradeDefense -= Defense;
                        chr.SkillState.Remove(10309);
                        StatusPacket.UpdateStat(gc);
                    });
                    chr.SkillState[Skill.SkillID].Execute();
                    break;

                case 10310:     // 陰陽幻移
                    chr.Hp += (short)(16 * Skill.SkillLevel);
                    chr.Mp -= (short)(5 * Skill.SkillLevel);
                    if (chr.Hp > chr.MaxHp)
                    {
                        chr.Hp = chr.MaxHp;
                    }
                    if (chr.Mp < 0)
                    {
                        chr.Mp = 0;
                    }
                    break;

                default:
                    //Log.Inform("[Use Skill] SkillID = {0}", skill.SkillID);
                    break;
                }
            }
        }
예제 #24
0
        public static void WarpToMapAuth_Req(InPacket lea, Client gc)
        {
            var   chr            = gc.Character;
            short MapX           = lea.ReadShort();
            short MapY           = lea.ReadShort();
            short PositionX      = lea.ReadShort();
            short PositionY      = lea.ReadShort();
            bool  IsAvailableMap = true;

            if (chr.IsAlive == false)
            {
                StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                chr.IsAlive = true;
                switch (MapX)
                {
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 22:
                case 23:
                    MapX = 1;
                    MapY = 1;
                    break;

                case 7:
                case 8:
                case 9:
                    MapX = 16;
                    MapY = 1;
                    break;

                case 10:
                case 11:
                case 20:
                    MapX = 10;
                    if ((chr.MapX == 10 && chr.MapY == 60) || (chr.MapX == 10 && chr.MapY == 61) || (chr.MapX == 10 && chr.MapY == 62) || (chr.MapX == 10 && chr.MapY == 63) || (chr.MapX == 10 && chr.MapY == 64))
                    {
                        MapY = 60;
                    }
                    else
                    {
                        MapY = 1;
                    }
                    break;

                case 12:
                case 13:
                    MapX = 12;
                    MapY = 1;
                    break;

                case 14:
                case 15:
                case 17:
                case 18:
                case 19:
                case 21:
                    MapX = 15;
                    MapY = 1;
                    break;

                case 16:
                    MapX = 16;
                    MapY = 1;
                    break;

                case 24:
                case 25:
                case 26:
                case 31:
                case 32:
                case 33:
                    MapX = 25;
                    MapY = 1;
                    break;

                case 27:
                case 28:
                    MapX = 27;
                    MapY = 1;
                    break;

                default:
                    MapX = 1;
                    MapY = 1;
                    break;
                }
                PositionX = 0;
                PositionY = 0;
            }
            MapPacket.warpToMapAuth(gc, IsAvailableMap, MapX, MapY, PositionX, PositionY);
        }
예제 #25
0
        public static void SkillLevelUp_Req(InPacket lea, Client gc)
        {
            byte Type = lea.ReadByte();
            byte Slot = lea.ReadByte();

            var chr = gc.Character;

            if (chr.SkillBonus < 1)
            {
                return;
            }

            List <Skill> s  = chr.Skills.getSkills();
            Skill        sl = null;

            foreach (Skill skill in s)
            {
                if (skill.Type == Type && skill.Slot == Slot)
                {
                    sl = skill;
                    break;
                }
            }

            if (sl == null || (sl.SkillID == 1 && sl.SkillLevel + 1 > 5) || (sl.SkillID == 2 && sl.SkillLevel + 1 > 10) || (sl.SkillID == 3 && sl.SkillLevel + 1 > 20) || (sl.SkillID == 4 && sl.SkillLevel + 1 > 20) || sl.SkillLevel + 1 > 20)
            {
                return;
            }

            chr.SkillBonus--;
            sl.SkillLevel++;

            if (sl.SkillID == 10101 || sl.SkillID == 10201 || sl.SkillID == 10301 || sl.SkillID == 10401 || sl.SkillID == 10501 || sl.SkillID == 10102 || sl.SkillID == 10202 || sl.SkillID == 10302 || sl.SkillID == 10402 || sl.SkillID == 10502)
            {
                if (chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon] != null)
                {
                    int ItemID    = chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID;
                    int MaxAttack = 5;
                    int Attack    = 3;
                    int MaxMagic  = 4;
                    int Magic     = 4;
                    MaxAttack += ((chr.Str - 3) * 2 + chr.Str / 5);
                    MaxAttack += ((chr.Dex - 3) * 2 + chr.Dex / 5);
                    Attack    += ((chr.Dex - 3) * 1 + chr.Dex / 5);
                    MaxMagic  += ((chr.Int - 3) * 2 + chr.Int / 5);
                    Magic     += ((chr.Int - 3) * 2 + chr.Int / 5);

                    // 技能攻擊力+、魔攻力+
                    if (InventoryType.Is劍(ItemID) && sl.SkillID == 10101)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.02 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.02 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.02 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.02 * sl.SkillLevel);
                    }
                    if (InventoryType.Is刀(ItemID) && sl.SkillID == 10102)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.03 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.03 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.03 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.03 * sl.SkillLevel);
                    }
                    if (InventoryType.Is手套(ItemID) && sl.SkillID == 10201)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.02 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.02 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.02 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.02 * sl.SkillLevel);
                    }
                    if (InventoryType.Is爪(ItemID) && sl.SkillID == 10202)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.03 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.03 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.03 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.03 * sl.SkillLevel);
                    }
                    if (InventoryType.Is扇(ItemID) && sl.SkillID == 10301)
                    {
                        chr.MaxMagic -= (short)(MaxMagic * 0.02 * (sl.SkillLevel - 1));
                        chr.Magic    -= (short)(Magic * 0.02 * (sl.SkillLevel - 1));
                        chr.MaxMagic += (short)(MaxMagic * 0.02 * sl.SkillLevel);
                        chr.Magic    += (short)(Magic * 0.02 * sl.SkillLevel);
                    }
                    if (InventoryType.Is杖(ItemID) && sl.SkillID == 10302)
                    {
                        chr.MaxMagic -= (short)(MaxMagic * 0.03 * (sl.SkillLevel - 1));
                        chr.Magic    -= (short)(Magic * 0.03 * (sl.SkillLevel - 1));
                        chr.MaxMagic += (short)(MaxMagic * 0.03 * sl.SkillLevel);
                        chr.Magic    += (short)(Magic * 0.03 * sl.SkillLevel);
                    }
                    if (InventoryType.Is斧(ItemID) && sl.SkillID == 10401)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.02 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.02 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.02 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.02 * sl.SkillLevel);
                    }
                    if (InventoryType.Is輪(ItemID) && sl.SkillID == 10402)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.03 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.03 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.03 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.03 * sl.SkillLevel);
                    }
                    //if (Skill.ContainsKey(10501) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID))
                    //{

                    //}
                    //if (Skill.ContainsKey(10502) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID))
                    //{

                    //}
                    StatusPacket.UpdateStat(gc);
                }
            }

            SkillPacket.updateSkillLevel(gc, chr.SkillBonus, Type, Slot, sl.SkillLevel);
        }
예제 #26
0
        public static void AttackMonster_Req(InPacket lea, Client gc)
        {
            short CharacterID = lea.ReadShort();
            short OriginalID  = lea.ReadShort();

            lea.ReadShort();
            short   Damage  = lea.ReadShort();
            short   HitX    = lea.ReadShort();
            short   HitY    = lea.ReadShort();
            short   SkillID = lea.ReadShort();
            var     chr     = gc.Character;
            Map     Map     = MapFactory.GetMap(chr.MapX, chr.MapY);
            Monster Monster = Map.getMonsterByOriginalID(OriginalID);

            if (Monster == null)
            {
                return;
            }
            Monster.HP -= Damage;
            switch (SkillID)
            {
            case 10108:                     // 點穴定身
                if (Randomizer.Next(0, 2) == 0)
                {
                    Monster.Effect = 1;
                }
                break;

            case 10204:                     // 餵毒術
                if (Randomizer.Next(0, 2) == 0)
                {
                    Monster.Effect = 2;
                }
                break;

            case 10304:                     // 玄冰擊
            case 10305:                     // 冰凍大地
                if (Randomizer.Next(0, 2) == 0)
                {
                    Monster.Effect = 5;
                }
                break;

            case 10306:                     // 矇蔽蝕眼
                if (Randomizer.Next(0, 2) == 0)
                {
                    Monster.Effect = 3;
                }
                break;

            default:
                //Log.Inform("[Attack Monster] SkillID = {0}", SkillID);
                break;
            }

            if (Monster.HP <= 0)
            {
                //if (Monster.IsAlive == false)
                //    return;
                Monster.State  = 9;
                Monster.Effect = 0;
                //map.Monster.Remove(Monster);
                Monster.IsAlive = false;
                chr.Exp        += Monster.Exp;
                if (chr.Exp >= GameConstants.getExpNeededForLevel(chr.Level))
                {
                    chr.LevelUp();
                }
                StatusPacket.UpdateExp(gc);

                // 加入要掉落物品
                int Max_Count     = 2;             // 設定最大物品掉落數
                int Current_Count = 0;
                foreach (Loot loot in MobFactory.Drop_Data)
                {
                    if (Current_Count == Max_Count)
                    {
                        break;
                    }

                    if (loot.MobID == Monster.MonsterID)
                    {
                        if ((Randomizer.Next(999999) / GameServer.Rates.Loot) < loot.Chance)
                        {
                            Monster.Drops.Add(new Drop(0, loot.ItemID,
                                                       (short)Randomizer.Next(loot.MinimumQuantity, loot.MaximumQuantity)));
                            Current_Count++;
                        }
                    }
                }

                // join to drop soul
                // [Blue Ghost] can restore 20% of ghost power
                // [Green Ghost] Can restore 40% of Ghost Power
                // [Red Ghost] It is used to accumulate the measurement value of anger. When the anger is full, it can be turned into an anger state. The offense and defense will be 1.2
                // [Purple Ghost] can absorb the seal equipment, the more you collect the more you can increase the success rate of the seal synthesis

                // None: 1%
                // 9900001: 20%
                // 9900002: 19%
                // 9900003: 20%
                // 9900004: 40%

                int[] Soul =
                {
                    0,
                    9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001,
                    9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, // 20%
                    9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002,
                    9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002,          // 19%
                    9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003,
                    9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, // 20%
                    9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004,
                    9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004,
                    9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004,
                    9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004                     // 40%
                };

                int rnd = Randomizer.Next(0, 100);
                if (rnd != 0)
                {
                    Monster.Drops.Add(new Drop(0, Soul[rnd], 20));
                }

                //int Max_Soul_Count = 1; // 設定最大物品掉落數
                //int Current_Soul_Count = 0;
                //int[] Soul = new int[] { 15000, 250000, 800000, 650000 };
                //for (int i = 1; i < 5; i++)
                //{
                //    if (Max_Soul_Count == Current_Soul_Count)
                //        break;

                //    if ((Randomizer.Next(999999) / GameServer.Rates.Loot) < Soul[i-1])
                //    {
                //        Monster.Drops.Add(new Drop(0, 9900001 + (i -1), 20));
                //        Current_Soul_Count++;
                //    }
                //}

                short rndMoney = (short)(Monster.Exp + Randomizer.Next(6));

                if (rndMoney != 0 && Monster.MonsterID != 1010002)                                   // rndMoney != 0 (少數怪物未寫入經驗值)
                {
                    Monster.Drops.Add(new Drop(0, InventoryType.getMoneyStyle(rndMoney), rndMoney)); // 錢
                }
                for (int i = 0; i < Monster.Drops.Count; i++)
                {
                    Monster.Drops[i].PositionX = Monster.PositionX;
                    Monster.Drops[i].PositionY = Monster.PositionY - 50;
                    //Item it = new Item(Monster.Drops[i].ItemID, 0x63, 0x63, Monster.Drops[i].Quantity);
                    Monster.Drops[i].ID = Map.ObjectID;
                    Map.Item.Add(Map.ObjectID,
                                 new Drop(Map.ObjectID, Monster.Drops[i].ItemID, Monster.Drops[i].Quantity));
                    Map.ObjectID++;
                }

                foreach (Character All in Map.Characters)
                {
                    MapPacket.MonsterDrop(All.Client, Monster);
                }

                Monster.Drops.Clear();
            }
            else
            {
                Monster.State = 7;
                if (chr.PlayerX < HitX && Monster.Direction == 1)
                {
                    Monster.Direction = 0xFF;
                }
                else if (chr.PlayerX > HitX && Monster.Direction == 0xFF)
                {
                    Monster.Direction = 1;
                }
            }

            foreach (Character All in Map.Characters)
            {
                MonsterPacket.spawnMonster(All.Client, Monster, CharacterID, Damage, HitX, HitY);
            }

            if (Monster.State == 9 && Monster.tmr1 != null)
            {
                Monster.tmr1.Cancel();
                Monster.tmr1 = null;
                return;
            }

            if (Monster.State == 9 && Monster.tmr2 != null)
            {
                Monster.tmr2.Cancel();
                Monster.tmr2 = null;
                return;
            }

            if (Monster.State == 9 && Monster.tmr3 != null)
            {
                Monster.tmr3.Cancel();
                Monster.tmr3 = null;
                return;
            }

            int r = Randomizer.Next(0, 2);

            if (r == 0 && Monster.Effect == 0 && Monster.State == 7 && Monster.AttackType != 0 && Monster.tmr1 == null)
            {
                Monster.tmr1 = new Delay(600, false, () =>
                {
                    if (Monster.State == 9)
                    {
                        Monster.tmr1.Cancel();
                        Monster.tmr2.Cancel();
                        Monster.tmr3.Cancel();
                        Monster.tmr1 = null;
                        Monster.tmr2 = null;
                        Monster.tmr3 = null;
                        return;
                    }

                    Monster.State = 3;
                    foreach (Character All in Map.Characters)
                    {
                        MonsterPacket.spawnMonster(All.Client, Monster, CharacterID, 0, HitX, HitY);
                    }
                    Monster.tmr1 = null;

                    if (Monster.State == 3 && Monster.tmr2 == null)
                    {
                        Monster.tmr2 = new Delay(500, false, () =>
                        {
                            if (Monster.State == 9)
                            {
                                Monster.tmr1.Cancel();
                                Monster.tmr2.Cancel();
                                Monster.tmr3.Cancel();
                                Monster.tmr1 = null;
                                Monster.tmr2 = null;
                                Monster.tmr3 = null;
                                return;
                            }

                            Monster.State = (Monster.MoveType == 0 ? (byte)0 : (byte)1);
                            foreach (Character All in Map.Characters)
                            {
                                MonsterPacket.spawnMonster(All.Client, Monster, 0, 0, 0, 0);
                            }
                            Monster.tmr2 = null;
                        });
                        Monster.tmr2.Execute();
                    }
                });
                Monster.tmr1.Execute();
            }

            if ((r == 1 && Monster.Effect == 0 && Monster.State != 9) ||
                (Monster.State != 9 && Monster.Effect == 0 && Monster.AttackType == 0))
            {
                Monster.tmr2 = new Delay(500, false, () =>
                {
                    Monster.State = (Monster.MoveType == 0 ? (byte)0 : (byte)1);
                    foreach (Character All in Map.Characters)
                    {
                        MonsterPacket.spawnMonster(All.Client, Monster, 0, 0, 0, 0);
                    }
                    Monster.tmr2 = null;
                });
                Monster.tmr2.Execute();
            }

            if (Monster.Effect != 0)
            {
                Monster.tmr3 = new Delay(6000, false, () =>
                {
                    Monster.Effect = 0;
                    Monster.State  = (Monster.MoveType == 0 ? (byte)0 : (byte)1);
                    foreach (Character All in Map.Characters)
                    {
                        MonsterPacket.spawnMonster(All.Client, Monster, 0, 0, 0, 0);
                    }
                    Monster.tmr3 = null;
                });
                Monster.tmr3.Execute();
            }
        }
예제 #27
0
파일: GGClient.cs 프로젝트: rolandzpl/gg
        public void ChangeStatus(GGStatus status, string description)
        {
            StatusPacket packet = new StatusPacket(status, description);

            this.packetManager.AddPacket(packet);
        }
예제 #28
0
        public void LevelUp()
        {
            this.Level++;
            this.Exp = 0;

            switch (this.Class)
            {
            case 1:                     // 武士
                this.MaxHp += 13;
                this.MaxMp += 7;
                break;

            case 2:                     // 刺客
                this.MaxHp += 9;
                this.MaxMp += 12;
                break;

            case 3:                     // 道士
                this.MaxHp += 7;
                this.MaxMp += 14;
                break;

            case 4:                     // 力士
                // 未知
                this.MaxHp += 13;
                this.MaxMp += 7;
                break;

            case 5:                     // 射手
                // 未知
                this.MaxHp += 9;
                this.MaxMp += 12;
                break;

            default:
                this.MaxHp += 10;
                this.MaxMp += 15;
                break;
            }

            this.Hp = this.MaxHp;
            this.Mp = this.MaxMp;

            if (this.Level % 10 != 0)
            {
                this.AbilityBonus += 4;
            }
            else
            {
                this.AbilityBonus += 8;
            }

            this.SkillBonus += 2;

            Map map = MapFactory.GetMap(this.MapX, this.MapY);

            foreach (Character All in map.Characters)
            {
                StatusPacket.LevelUp(All.Client, this, this.Level);
            }
            StatusPacket.getStatusInfo(Client);
        }
예제 #29
0
        public static void PickupItem(InPacket lea, Client gc)
        {
            int OriginalID = lea.ReadInt();
            int ItemID     = lea.ReadInt();

            lea.ReadInt();
            var chr = gc.Character;
            Map Map = MapFactory.GetMap(chr.MapX, chr.MapY);

            // 撿取靈魂
            if (ItemID >= 9900001 && ItemID <= 9900004)
            {
                if (Map.getDropByOriginalID(OriginalID) == null)
                {
                    return;
                }

                switch (ItemID)
                {
                case 9900001:     // Blue
                    chr.Mp += (short)(chr.MaxMp * 0.2);
                    if (chr.Mp > chr.MaxMp)
                    {
                        chr.Mp = chr.MaxMp;
                    }
                    break;

                case 9900002:     // Green
                    chr.Mp += (short)(chr.MaxMp * 0.4);
                    if (chr.Mp > chr.MaxMp)
                    {
                        chr.Mp = chr.MaxMp;
                    }
                    break;

                case 9900003:     // Red
                    int rnd = Randomizer.Next(3, 7);
                    chr.Fury += (short)(chr.MaxFury / 100 * rnd);
                    if (chr.Fury > chr.MaxFury)
                    {
                        chr.Fury = chr.MaxFury;
                    }
                    break;

                case 9900004:     // Purple
                    if (chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Seal] != null)
                    {
                        chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Seal].Spirit++;
                        InventoryPacket.getInvenEquip(gc);
                    }
                    break;
                }
                StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                foreach (Character All in Map.Characters)
                {
                    InventoryPacket.ClearDropItem(All.Client, chr.CharacterID, OriginalID, ItemID);
                }
                return;
            }

            // 撿取錢
            if (ItemID >= 9800001 && ItemID <= 9800005)
            {
                if (Map.getDropByOriginalID(OriginalID) == null)
                {
                    return;
                }
                chr.Money += Map.getDropByOriginalID(OriginalID).Quantity;
                InventoryPacket.getInvenMoney(gc, chr.Money, Map.getDropByOriginalID(OriginalID).Quantity);
                foreach (Character All in Map.Characters)
                {
                    InventoryPacket.ClearDropItem(All.Client, chr.CharacterID, OriginalID, ItemID);
                }
                return;
            }

            if (!Map.Item.ContainsKey(OriginalID))
            {
                return;
            }

            byte Type = InventoryType.getItemType(ItemID);

            Item finditem = null;

            foreach (Item it in gc.Character.Items)
            {
                if (it.ItemID == ItemID)
                {
                    finditem = it;
                }
            }

            if (((Type == (byte)InventoryType.ItemType.Spend3) ||
                 (Type == (byte)InventoryType.ItemType.Other4)) &&
                (finditem != null) &&
                (finditem.Quantity + Map.getDropByOriginalID(OriginalID).Quantity) <= 100)
            {
                // 合併消費物品跟其他物品
                chr.Items[(InventoryType.ItemType)finditem.Type, finditem.Slot].Quantity += Map.getDropByOriginalID(OriginalID).Quantity;
            }
            else
            {
                byte Slot  = gc.Character.Items.GetNextFreeSlot((InventoryType.ItemType)Type);
                Item oItem = new Item(ItemID, Type, Slot, Map.getDropByOriginalID(OriginalID).Quantity);
                chr.Items.Add(oItem);
            }
            foreach (Character All in Map.Characters)
            {
                InventoryPacket.ClearDropItem(All.Client, chr.CharacterID, OriginalID, ItemID);
            }
            Map.Item.Remove(OriginalID);
            UpdateInventory(gc, Type);
        }
예제 #30
0
        static public void ReadStatusPacket(BinaryReader reader,
                                            ref StatusPacket status)
        {
            // remember origibal position
            long oldPos = reader.BaseStream.Position;

            // move to start of status packet
            reader.BaseStream.Position = statusOffset;
            // read status packet
            status.packetLength = reader.ReadByte();
            status.packetType   = (PacketType)reader.ReadByte();
            Debug.Assert(status.packetType == PacketType.status);
            status.firmwareVersion = reader.ReadByte();
            status.protocolVersion = reader.ReadByte();
            Debug.Assert(status.protocolVersion >= 16);
            status.fineObs.mainCurrent   = reader.ReadInt16();
            status.fineObs.usbCurrent    = reader.ReadInt16();
            status.fineObs.auxCurrent    = reader.ReadInt16();
            status.fineObs.voltage       = reader.ReadUInt16();
            status.coarseObs.mainCurrent = reader.ReadInt16();
            status.coarseObs.usbCurrent  = reader.ReadInt16();
            status.coarseObs.auxCurrent  = reader.ReadInt16();
            status.coarseObs.voltage     = reader.ReadUInt16();
            status.outputVoltageSetting  = reader.ReadByte();
            status.temperature           = reader.ReadSByte();
            status.pmStatus = (PmStatus)reader.ReadByte();
            status.reserved = reader.ReadByte();
            status.leds     = (Leds)reader.ReadByte();
            status.mainFineResistorOffset = reader.ReadSByte();
            status.serialNumber           = reader.ReadUInt16();
            status.sampleRate             = reader.ReadByte();
            status.dacCalLow             = reader.ReadUInt16();
            status.dacCalHigh            = reader.ReadUInt16();
            status.powerupCurrentLimit   = reader.ReadUInt16();
            status.runtimeCurrentLimit   = reader.ReadUInt16();
            status.powerupTime           = reader.ReadByte();
            status.usbFineResistorOffset = reader.ReadSByte();
            status.auxFineResistorOffset = reader.ReadSByte();
            status.initialUsbVoltage     = reader.ReadUInt16();
            status.initialAuxVoltage     = reader.ReadUInt16();
            status.hardwareRevision      = (HardwareRev)reader.ReadByte();
            status.temperatureLimit      = reader.ReadByte();
            status.usbPassthroughMode    =
                (UsbPassthroughMode)reader.ReadByte();
            status.mainCoarseResistorOffset        = reader.ReadSByte();
            status.usbCoarseResistorOffset         = reader.ReadSByte();
            status.auxCoarseResistorOffset         = reader.ReadSByte();
            status.factoryMainFineResistorOffset   = reader.ReadSByte();
            status.factoryUsbFineResistorOffset    = reader.ReadSByte();
            status.factoryAuxFineResistorOffset    = reader.ReadSByte();
            status.factoryMainCoarseResistorOffset =
                reader.ReadSByte();
            status.factoryUsbCoarseResistorOffset =
                reader.ReadSByte();
            status.factoryAuxCoarseResistorOffset =
                reader.ReadSByte();
            status.eventCode = (EventCode)reader.ReadByte();
            status.eventData = reader.ReadUInt16();
            status.checksum  = reader.ReadByte();
            // restore original position
            reader.BaseStream.Position = oldPos;
        }
예제 #31
0
        public static void UpdateCharacterInventoryStatus(Client gc, Item Source, bool Equiped)
        {
            ItemData  idata = ItemFactory.GetItemData(Source.ItemID);
            Character chr   = gc.Character;

            int MaxAttack = 5;
            int Attack    = 3;
            int MaxMagic  = 4;
            int Magic     = 4;

            MaxAttack += ((chr.Str - 3) * 2 + chr.Str / 5);
            MaxAttack += ((chr.Dex - 3) * 2 + chr.Dex / 5);
            Attack    += ((chr.Dex - 3) * 1 + chr.Dex / 5);
            MaxMagic  += ((chr.Int - 3) * 2 + chr.Int / 5);
            Magic     += ((chr.Int - 3) * 2 + chr.Int / 5);

            // 技能攻擊力+、魔攻力+
            Dictionary <int, byte> Skill = new Dictionary <int, byte>();

            foreach (Skill sl in chr.Skills.getSkills())
            {
                Skill.Add(sl.SkillID, sl.SkillLevel);
            }
            if (InventoryType.Is劍(Source.ItemID) && Skill.ContainsKey(10101))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.02 * Skill[10101]);
                    chr.Attack    += (short)(Attack * 0.02 * Skill[10101]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.02 * Skill[10101]);
                    chr.Attack    -= (short)(Attack * 0.02 * Skill[10101]);
                }
            }
            if (InventoryType.Is刀(Source.ItemID) && Skill.ContainsKey(10102))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.03 * Skill[10102]);
                    chr.Attack    += (short)(Attack * 0.03 * Skill[10102]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.03 * Skill[10102]);
                    chr.Attack    -= (short)(Attack * 0.03 * Skill[10102]);
                }
            }
            if (InventoryType.Is手套(Source.ItemID) && Skill.ContainsKey(10201))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.02 * Skill[10201]);
                    chr.Attack    += (short)(Attack * 0.02 * Skill[10201]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.02 * Skill[10201]);
                    chr.Attack    -= (short)(Attack * 0.02 * Skill[10201]);
                }
            }
            if (InventoryType.Is爪(Source.ItemID) && Skill.ContainsKey(10202))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.03 * Skill[10202]);
                    chr.Attack    += (short)(Attack * 0.03 * Skill[10202]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.03 * Skill[10202]);
                    chr.Attack    -= (short)(Attack * 0.03 * Skill[10202]);
                }
            }
            if (InventoryType.Is扇(Source.ItemID) && Skill.ContainsKey(10301))
            {
                if (Equiped)
                {
                    chr.MaxMagic += (short)(MaxMagic * 0.02 * Skill[10301]);
                    chr.Magic    += (short)(Magic * 0.02 * Skill[10301]);
                }
                else
                {
                    chr.MaxMagic -= (short)(MaxMagic * 0.02 * Skill[10301]);
                    chr.Magic    -= (short)(Magic * 0.02 * Skill[10301]);
                }
            }
            if (InventoryType.Is杖(Source.ItemID) && Skill.ContainsKey(10302))
            {
                if (Equiped)
                {
                    chr.MaxMagic += (short)(MaxMagic * 0.03 * Skill[10302]);
                    chr.Magic    += (short)(Magic * 0.03 * Skill[10302]);
                }
                else
                {
                    chr.MaxMagic -= (short)(MaxMagic * 0.03 * Skill[10302]);
                    chr.Magic    -= (short)(Magic * 0.03 * Skill[10302]);
                }
            }
            if (InventoryType.Is斧(Source.ItemID) && Skill.ContainsKey(10401))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.02 * Skill[10401]);
                    chr.Attack    += (short)(Attack * 0.02 * Skill[10401]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.02 * Skill[10401]);
                    chr.Attack    -= (short)(Attack * 0.02 * Skill[10401]);
                }
            }
            if (InventoryType.Is輪(Source.ItemID) && Skill.ContainsKey(10402))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.03 * Skill[10402]);
                    chr.Attack    += (short)(Attack * 0.03 * Skill[10402]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.03 * Skill[10402]);
                    chr.Attack    -= (short)(Attack * 0.03 * Skill[10402]);
                }
            }
            //if (Skill.ContainsKey(10501) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID))
            //{

            //}
            //if (Skill.ContainsKey(10502) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID))
            //{

            //}

            // Hp
            if (idata.Hp != -1)
            {
                if (Equiped)
                {
                    chr.MaxHp += idata.Hp;
                }
                else
                {
                    chr.MaxHp -= idata.Hp;
                }
            }
            // Mp
            if (idata.Mp != -1)
            {
                if (Equiped)
                {
                    chr.MaxMp += idata.Mp;
                }
                else
                {
                    chr.MaxMp -= idata.Mp;
                }
            }
            // 物理攻擊力
            if (idata.Attack != -1)
            {
                if (Equiped)
                {
                    chr.Attack    += idata.Attack;
                    chr.MaxAttack += idata.Attack;
                }
                else
                {
                    chr.Attack    -= idata.Attack;
                    chr.MaxAttack -= idata.Attack;
                }
            }
            // 魔法攻擊力
            if (idata.Magic != -1)
            {
                if (Equiped)
                {
                    chr.Magic    += idata.Magic;
                    chr.MaxMagic += idata.Magic;
                }
                else
                {
                    chr.Magic    -= idata.Magic;
                    chr.MaxMagic -= idata.Magic;
                }
            }

            // 力量
            if (idata.Str != -1)
            {
                if (Equiped)
                {
                    chr.Str        += idata.Str;
                    chr.UpgradeStr += idata.Str;
                    chr.MaxHp      += (short)(3 * idata.Str);
                    chr.MaxAttack  += (short)(2 * idata.Str);
                }
                else
                {
                    chr.Str        -= idata.Str;
                    chr.UpgradeStr -= idata.Str;
                    chr.MaxHp      -= (short)(3 * idata.Str);
                    chr.MaxAttack  -= (short)(2 * idata.Str);
                }
            }
            // 精力
            if (idata.Dex != -1)
            {
                if (Equiped)
                {
                    chr.Dex        += idata.Dex;
                    chr.UpgradeDex += idata.Dex;
                    chr.Attack     += (short)(1 * idata.Dex);
                    chr.MaxAttack  += (short)(2 * idata.Dex);
                }
                else
                {
                    chr.Dex        -= idata.Dex;
                    chr.UpgradeDex -= idata.Dex;
                    chr.Attack     -= (short)(1 * idata.Dex);
                    chr.MaxAttack  -= (short)(2 * idata.Dex);
                }
            }
            // 氣力
            if (idata.Vit != -1)
            {
                if (Equiped)
                {
                    chr.Vit        += idata.Vit;
                    chr.UpgradeVit += idata.Vit;
                    chr.Defense    += (short)(5 * idata.Vit);
                    chr.MaxHp      += (short)(20 * idata.Vit);
                }
                else
                {
                    chr.Vit        -= idata.Vit;
                    chr.UpgradeVit -= idata.Vit;
                    chr.Defense    -= (short)(5 * idata.Vit);
                    chr.MaxHp      -= (short)(20 * idata.Vit);
                }
            }
            // 智力
            if (idata.Int != -1)
            {
                if (Equiped)
                {
                    chr.Int        += idata.Int;
                    chr.UpgradeInt += idata.Int;
                    chr.MaxMp      += (short)(3 * idata.Int);
                    chr.Magic      += (short)(2 * idata.Int);
                    chr.MaxMagic   += (short)(2 * idata.Int);
                }
                else
                {
                    chr.Int        -= idata.Int;
                    chr.UpgradeInt -= idata.Int;
                    chr.MaxMp      -= (short)(3 * idata.Int);
                    chr.Magic      -= (short)(2 * idata.Int);
                    chr.MaxMagic   -= (short)(2 * idata.Int);
                }
            }
            // 迴避率
            if (idata.Avoid != -1)
            {
                if (Equiped)
                {
                    chr.Avoid += idata.Avoid;
                }
                else
                {
                    chr.Avoid -= idata.Avoid;
                }
            }
            // 防禦力
            if (idata.Defense != -1)
            {
                if (Equiped)
                {
                    chr.Defense += idata.Defense;
                }
                else
                {
                    chr.Defense -= idata.Defense;
                }
            }

            // 武器
            if (Source.ItemID / 100000 == 79 || Source.ItemID / 100000 == 80)
            {
                Attack  = 0;
                Attack += Source.Level1 * 10;
                Attack += Source.Level2 * 9;
                Attack += Source.Level3 * 8;
                Attack += Source.Level4 * 7;
                Attack += Source.Level5 * 6;
                Attack += Source.Level6 * 5;
                Attack += Source.Level7 * 4;
                Attack += Source.Level8 * 3;
                Attack += Source.Level9 * 2;
                Attack += Source.Level10 * 1;
                if (Equiped)
                {
                    chr.Attack        += (short)Attack;
                    chr.MaxAttack     += (short)Attack;
                    chr.UpgradeAttack += (short)Attack;
                }
                else
                {
                    chr.Attack        -= (short)Attack;
                    chr.MaxAttack     -= (short)Attack;
                    chr.UpgradeAttack -= (short)Attack;
                }
            }

            // 衣服
            if (Source.ItemID / 100000 == 81 || Source.ItemID / 100000 == 95)
            {
                int Defense = 0;
                Defense += Source.Level1 * 20;
                Defense += Source.Level2 * 18;
                Defense += Source.Level3 * 16;
                Defense += Source.Level4 * 14;
                Defense += Source.Level5 * 12;
                Defense += Source.Level6 * 10;
                Defense += Source.Level7 * 8;
                Defense += Source.Level8 * 6;
                Defense += Source.Level9 * 4;
                Defense += Source.Level10 * 2;
                if (Equiped)
                {
                    chr.Defense        += (short)Defense;
                    chr.UpgradeDefense += (short)Defense;
                }
                else
                {
                    chr.Defense        -= (short)Defense;
                    chr.UpgradeDefense -= (short)Defense;
                }
            }

            if (chr.Hp > chr.MaxHp)
            {
                chr.Hp = chr.MaxHp;
            }
            if (chr.Mp > chr.MaxMp)
            {
                chr.Mp = chr.MaxMp;
            }

            StatusPacket.UpdateStat(gc);
        }
예제 #32
0
        public static void AttackMonster_Req(InPacket lea, Client gc)
        {
            short CharacterID = lea.ReadShort();
            short OriginalID  = lea.ReadShort();

            lea.ReadShort();
            short   Damage  = lea.ReadShort();
            short   HitX    = lea.ReadShort();
            short   HitY    = lea.ReadShort();
            short   SkillID = lea.ReadShort();
            var     chr     = gc.Character;
            Map     Map     = MapFactory.GetMap(chr.MapX, chr.MapY);
            Monster Monster = Map.getMonsterByOriginalID(OriginalID);

            if (Monster == null)
            {
                return;
            }
            Monster.HP -= Damage;
            switch (SkillID)
            {
            case 10108:     // 點穴定身
                if (Randomizer.Next(0, 2) == 0)
                {
                    Monster.Effect = 1;
                }
                break;

            case 10204:     // 餵毒術
                if (Randomizer.Next(0, 2) == 0)
                {
                    Monster.Effect = 2;
                }
                break;

            case 10304:     // 玄冰擊
            case 10305:     // 冰凍大地
                if (Randomizer.Next(0, 2) == 0)
                {
                    Monster.Effect = 5;
                }
                break;

            case 10306:     // 矇蔽蝕眼
                if (Randomizer.Next(0, 2) == 0)
                {
                    Monster.Effect = 3;
                }
                break;

            default:
                //Log.Inform("[Attack Monster] SkillID = {0}", SkillID);
                break;
            }
            if (Monster.HP <= 0)
            {
                //if (Monster.IsAlive == false)
                //    return;
                Monster.State  = 9;
                Monster.Effect = 0;
                //map.Monster.Remove(Monster);
                Monster.IsAlive = false;
                chr.Exp        += Monster.Exp;
                if (chr.Exp >= GameConstants.getExpNeededForLevel(chr.Level))
                {
                    chr.LevelUp();
                }
                StatusPacket.UpdateExp(gc);

                // 加入要掉落物品
                int Max_Count     = 2; // 設定最大物品掉落數
                int Current_Count = 0;
                foreach (Loot loot in MobFactory.Drop_Data)
                {
                    if (Current_Count == Max_Count)
                    {
                        break;
                    }

                    if (loot.MobID == Monster.MonsterID)
                    {
                        if ((Randomizer.Next(999999) / GameServer.Rates.Loot) < loot.Chance)
                        {
                            Monster.Drops.Add(new Drop(0, loot.ItemID, (short)Randomizer.Next(loot.MinimumQuantity, loot.MaximumQuantity)));
                            Current_Count++;
                        }
                    }
                }

                // 加入要掉落靈魂
                //【藍色鬼魂】能恢復20%的鬼力值
                //【綠色鬼魂】能恢復40%的鬼力值
                //【紅色鬼魂】累積憤怒計量值用,當憤怒計滿之後能轉為憤怒狀態,攻防都會*1.2倍
                //【紫色鬼魂】能吸收到封印裝備,蒐集越多越能增加封印物合成的成功機率

                // 無 : 1%
                // 9900001 : 20%
                // 9900002 : 19%
                // 9900003 : 20%
                // 9900004 : 40%

                int[] Soul =
                {
                    0,
                    9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001, 9900001,                                                                                                                                                                                    // 20%
                    9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002, 9900002,                                                                                                                                                                                             // 19%
                    9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003, 9900003,                                                                                                                                                                                    // 20%
                    9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004, 9900004 // 40%
                };

                int rnd = Randomizer.Next(0, 100);
                if (rnd != 0)
                {
                    Monster.Drops.Add(new Drop(0, Soul[rnd], 20));
                }

                //int Max_Soul_Count = 1; // 設定最大物品掉落數
                //int Current_Soul_Count = 0;
                //int[] Soul = new int[] { 15000, 250000, 800000, 650000 };
                //for (int i = 1; i < 5; i++)
                //{
                //    if (Max_Soul_Count == Current_Soul_Count)
                //        break;

                //    if ((Randomizer.Next(999999) / GameServer.Rates.Loot) < Soul[i-1])
                //    {
                //        Monster.Drops.Add(new Drop(0, 9900001 + (i -1), 20));
                //        Current_Soul_Count++;
                //    }
                //}

                short rndMoney = (short)(Monster.Exp + Randomizer.Next(6));

                if (rndMoney != 0 && Monster.MonsterID != 1010002)                                   // rndMoney != 0 (少數怪物未寫入經驗值)
                {
                    Monster.Drops.Add(new Drop(0, InventoryType.getMoneyStyle(rndMoney), rndMoney)); // 錢
                }
                for (int i = 0; i < Monster.Drops.Count; i++)
                {
                    Monster.Drops[i].PositionX = Monster.PositionX;
                    Monster.Drops[i].PositionY = Monster.PositionY - 50;
                    //Item it = new Item(Monster.Drops[i].ItemID, 0x63, 0x63, Monster.Drops[i].Quantity);
                    Monster.Drops[i].ID = Map.ObjectID;
                    Map.Item.Add(Map.ObjectID, new Drop(Map.ObjectID, Monster.Drops[i].ItemID, Monster.Drops[i].Quantity));
                    Map.ObjectID++;
                }
                foreach (Character All in Map.Characters)
                {
                    MapPacket.MonsterDrop(All.Client, Monster);
                }
                Monster.Drops.Clear();
            }
            else
            {
                Monster.State = 7;
                if (chr.PlayerX < HitX && Monster.Direction == 1)
                {
                    Monster.Direction = 0xFF;
                }
                else if (chr.PlayerX > HitX && Monster.Direction == 0xFF)
                {
                    Monster.Direction = 1;
                }
            }

            foreach (Character All in Map.Characters)
            {
                MonsterPacket.spawnMonster(All.Client, Monster, CharacterID, Damage, HitX, HitY);
            }

            if (Monster.State == 9 && Monster.tmr1 != null)
            {
                Monster.tmr1.Cancel();
                Monster.tmr1 = null;
                return;
            }

            if (Monster.State == 9 && Monster.tmr2 != null)
            {
                Monster.tmr2.Cancel();
                Monster.tmr2 = null;
                return;
            }

            if (Monster.State == 9 && Monster.tmr3 != null)
            {
                Monster.tmr3.Cancel();
                Monster.tmr3 = null;
                return;
            }

            int r = Randomizer.Next(0, 2);

            if (r == 0 && Monster.Effect == 0 && Monster.State == 7 && Monster.AttackType != 0 && Monster.tmr1 == null)
            {
                Monster.tmr1 = new Delay(600, false, () =>
                {
                    if (Monster.State == 9)
                    {
                        Monster.tmr1.Cancel();
                        Monster.tmr2.Cancel();
                        Monster.tmr3.Cancel();
                        Monster.tmr1 = null;
                        Monster.tmr2 = null;
                        Monster.tmr3 = null;
                        return;
                    }
                    Monster.State = 3;
                    foreach (Character All in Map.Characters)
                    {
                        MonsterPacket.spawnMonster(All.Client, Monster, CharacterID, 0, HitX, HitY);
                    }
                    Monster.tmr1 = null;

                    if (Monster.State == 3 && Monster.tmr2 == null)
                    {
                        Monster.tmr2 = new Delay(500, false, () =>
                        {
                            if (Monster.State == 9)
                            {
                                Monster.tmr1.Cancel();
                                Monster.tmr2.Cancel();
                                Monster.tmr3.Cancel();
                                Monster.tmr1 = null;
                                Monster.tmr2 = null;
                                Monster.tmr3 = null;
                                return;
                            }
                            Monster.State = (Monster.MoveType == 0 ? (byte)0 : (byte)1);
                            foreach (Character All in Map.Characters)
                            {
                                MonsterPacket.spawnMonster(All.Client, Monster, 0, 0, 0, 0);
                            }
                            Monster.tmr2 = null;
                        });
                        Monster.tmr2.Execute();
                    }
                });
                Monster.tmr1.Execute();
            }

            if ((r == 1 && Monster.Effect == 0 && Monster.State != 9) || (Monster.State != 9 && Monster.Effect == 0 && Monster.AttackType == 0))
            {
                Monster.tmr2 = new Delay(500, false, () =>
                {
                    Monster.State = (Monster.MoveType == 0 ? (byte)0 : (byte)1);
                    foreach (Character All in Map.Characters)
                    {
                        MonsterPacket.spawnMonster(All.Client, Monster, 0, 0, 0, 0);
                    }
                    Monster.tmr2 = null;
                });
                Monster.tmr2.Execute();
            }

            if (Monster.Effect != 0)
            {
                Monster.tmr3 = new Delay(6000, false, () =>
                {
                    Monster.Effect = 0;
                    Monster.State  = (Monster.MoveType == 0 ? (byte)0 : (byte)1);
                    foreach (Character All in Map.Characters)
                    {
                        MonsterPacket.spawnMonster(All.Client, Monster, 0, 0, 0, 0);
                    }
                    Monster.tmr3 = null;
                });
                Monster.tmr3.Execute();
            }
        }
예제 #33
0
        public static void Command_Req(InPacket lea, Client gc)
        {
            string[] cmd = lea.ReadString(60).Split(new[] { (char)0x20 }, StringSplitOptions.None);

            if (gc.Account.Master == 0 || cmd.Length < 1)
            {
                return;
            }
            var       chr    = gc.Character;
            Character victim = null;

            switch (cmd[0])
            {
            case "//1":
            case "//公告":
            case "//notice":
                if (cmd.Length != 2)
                {
                    break;
                }
                foreach (Character all in MapFactory.AllCharacters)
                {
                    GamePacket.getNotice(all.Client, 3, cmd[1]);
                }
                break;

            case "//item":
                if (cmd.Length != 2 && cmd.Length != 3)
                {
                    break;
                }

                short Quantity = 1;

                if (cmd.Length == 3)
                {
                    if (int.Parse(cmd[2]) > 100)
                    {
                        Quantity = 100;
                    }
                    else
                    {
                        Quantity = short.Parse(cmd[2]);
                    }
                }

                if (InventoryType.getItemType(int.Parse(cmd[1])) == 1 || InventoryType.getItemType(int.Parse(cmd[1])) == 2)
                {
                    Quantity = 1;
                }

                if (InventoryType.getItemType(int.Parse(cmd[1])) == 5)
                {
                    return;
                }

                chr.Items.Add(new Item(int.Parse(cmd[1]), InventoryType.getItemType(int.Parse(cmd[1])), chr.Items.GetNextFreeSlot((InventoryType.ItemType)InventoryType.getItemType(int.Parse(cmd[1]))), Quantity));
                InventoryHandler.UpdateInventory(gc, InventoryType.getItemType(int.Parse(cmd[1])));
                break;

            case "//money":
                if (cmd.Length != 2)
                {
                    break;
                }
                chr.Money = int.Parse(cmd[1]);
                InventoryPacket.getInvenMoney(gc, chr.Money, int.Parse(cmd[1]));
                break;

            case "//levelup":
                chr.LevelUp();
                break;

            case "//gogo":
                if (cmd.Length != 3)
                {
                    break;
                }
                MapPacket.warpToMapAuth(gc, true, short.Parse(cmd[1]), short.Parse(cmd[2]), -1, -1);
                break;

            case "//hp":
                if (cmd.Length != 2)
                {
                    break;
                }

                short Hp = short.Parse(cmd[1]);

                if (Hp > short.MaxValue)
                {
                    Hp = short.MaxValue;
                }

                chr.MaxHp = Hp;
                chr.Hp    = Hp;
                StatusPacket.getStatusInfo(gc);
                break;

            case "//mp":
                short Mp = short.Parse(cmd[1]);

                if (Mp > short.MaxValue)
                {
                    Mp = short.MaxValue;
                }

                chr.MaxMp = Mp;
                chr.Mp    = Mp;
                StatusPacket.getStatusInfo(gc);
                break;

            case "//heal":
                chr.Hp   = chr.MaxHp;
                chr.Mp   = chr.MaxMp;
                chr.Fury = chr.MaxFury;
                StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury);
                break;

            case "//warp":
                if (cmd.Length != 2)
                {
                    break;
                }
                foreach (Character find in MapFactory.AllCharacters)
                {
                    if (find.Name.Equals(cmd[1]))
                    {
                        victim = find;
                    }
                }
                if (victim != null)
                {
                    chr.MapX    = victim.MapX;
                    chr.MapY    = victim.MapY;
                    chr.PlayerX = victim.PlayerX;
                    chr.PlayerY = victim.PlayerY;
                    MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY);
                }
                break;

            case "//ban":
                if (cmd.Length != 2)
                {
                    break;
                }
                foreach (Character find in MapFactory.AllCharacters)
                {
                    if (find.Name.Equals(cmd[1]))
                    {
                        victim = find;
                    }
                }
                if (victim != null)
                {
                    dynamic datum = new Datum("accounts");
                    victim.Client.Account.Banned = 1;
                    victim.Client.Dispose();
                }
                break;

            case "//save":
                for (int i = 0; i < MapFactory.AllCharacters.Count; i++)
                {
                    if (chr.CharacterID == MapFactory.AllCharacters[i].CharacterID)
                    {
                        continue;
                    }
                    MapFactory.AllCharacters[i].Client.Dispose();
                }
                //GameServer.IsAlive = false;
                break;

            case "//選擇正派":
                Quest Quest = new Quest(60);
                Quest.QuestState = 0x31;
                chr.Quests.Add(Quest);
                QuestPacket.getQuestInfo(gc, chr.Quests.getQuests());
                chr.Items.Add(new Item(8990019, 4, chr.Items.GetNextFreeSlot(InventoryType.ItemType.Other4)));
                break;

            case "//選擇邪派":
                Quest            = new Quest(64);
                Quest.QuestState = 0x31;
                chr.Quests.Add(Quest);
                QuestPacket.getQuestInfo(gc, chr.Quests.getQuests());
                chr.Items.Add(new Item(8990020, 4, chr.Items.GetNextFreeSlot(InventoryType.ItemType.Other4)));
                break;

            //case "//test":
            //    PartyPacket.PartyInvite(gc);
            //    break;
            //case "//test2":
            //    PartyPacket.PartyInvite(gc, 1, 1);
            //    break;
            //case "//test3":
            //    PartyPacket.PartyInvite(gc, 1 , 0);
            //    break;
            default:
                break;
            }
        }