示例#1
0
        public static P_338 New(Client client, short mobId, ulong xpAdd)
        {
            P_338 tmp = new P_338
            {
                Header   = SHeader.New(0x0338, Marshal.SizeOf <P_338>(), client.ClientId),
                CPoint   = client.Character.Mob.CPoint == 0 ? 0 : (int)xpAdd,
                MobId    = mobId,
                ClientId = (short)client.ClientId,
                Exp      = xpAdd
            };

            return(tmp);
        }
示例#2
0
        public static void controller(Client client, short mobId, ulong xpAdd)
        {
            //mata o mob
            client.Send(P_338.New(client, mobId, xpAdd));

            //obtem os itens do mob
            SMobList mob = client.MobView.Where(a => a.Mob.ClientId == mobId).FirstOrDefault();

            //regra de drop:
            //0  a 14 slot sao drop normal      Tx 90%
            //15 a 29 slot drop dificil         Tx 65%
            //30 a 44 slot drop raro            TX 40%
            //45 a 60 slot drop super raro      Tx 15%


            int   TaxaDrop    = new Random().Next(0, 100);
            SItem itemDropado = SItem.New();

            //inicia o slot com 60 pois para dar a probalidade de nao receber nenhum item
            int slot = 60;

            if (TaxaDrop >= 0 && TaxaDrop <= 15)
            {
                slot = new Random().Next(45, GetSlotAvailable(mob.Mob.Inventory, 45, 59));
            }

            if (TaxaDrop >= 16 && TaxaDrop <= 40)
            {
                slot = new Random().Next(30, GetSlotAvailable(mob.Mob.Inventory, 30, 44));
            }

            if (TaxaDrop >= 41 && TaxaDrop <= 65)
            {
                slot = new Random().Next(15, GetSlotAvailable(mob.Mob.Inventory, 15, 29));
            }

            if (TaxaDrop >= 66 && TaxaDrop <= 100)
            {
                slot = new Random().Next(0, GetSlotAvailable(mob.Mob.Inventory, 0, 14));
            }

            itemDropado = mob.Mob.Inventory[slot];

            if (itemDropado.Id != 0)
            {
                int tamanho = 30;
                if (client.Character.Mob.Andarilho[0].Id != 0)
                {
                    tamanho += 15;
                }
                if (client.Character.Mob.Andarilho[1].Id != 0)
                {
                    tamanho += 15;
                }

                //checa se o inventario esta cheio
                if (mob.Mob.Inventory.Where(a => a.Id != 0).Count() == tamanho)
                {
                    client.Send(P_101.New("O inventario esta cheio."));
                }
                else
                {
                    client.Character.Mob.Gold += mob.Mob.Gold < 0 ? mob.Mob.Gold * -1 : mob.Mob.Gold;
                    client.Character.Mob.Inventory.ToList().ForEach(a => { slot = 0; if (a.Id == 0)
                                                                           {
                                                                               return;
                                                                           }
                                                                           else
                                                                           {
                                                                               slot += 1;
                                                                           } });
                    client.Character.Mob.AddItemToCharacter(client, itemDropado, TypeSlot.Inventory, slot);
                }
            }
            Log.Normal($"Teve: {TaxaDrop}% de conseguir algum item");
        }
示例#3
0
        public static void controller(Client client, P_39D p39d)
        {
            int tamanho = 0;

            p39d.Damage.ToList().ForEach(a =>
            {
                tamanho += client.MobView.Where(b => a.MobId == b.Mob.ClientId).Count();
            });

            SMobList[] mobList = new SMobList[tamanho];
            for (int i = 0; i < p39d.Damage.Length - 1; i++)
            {
                SMobList dmg = client.MobView.Where(a => a.Mob.ClientId == p39d.Damage[i].MobId).FirstOrDefault();
                if (dmg.Mob.ClientId != 0)
                {
                    mobList[i] = dmg;
                    //remove os mob para que possa ser atualizado com o novo hp ja com o dano recebido depois
                    client.MobView.Remove(dmg);
                }
            }

            //check o modo que esta sendo atacado
            switch (p39d.SkillIndex)
            {
            case 151:   //Arco
            case -1:    //espada ou sem arma
            {
                for (int i = 0; i < mobList.Count(); i++)
                {
                    mobList[i].Mob.GameStatus.CurHP -= client.Character.Mob.GameStatus.Attack;
                    mobList[i].Mob.GameStatus.CurHP += mobList[i].Mob.GameStatus.Defense;

                    for (int a = 0; a < p39d.Damage.Length; a++)
                    {
                        if (p39d.Damage[a].MobId == mobList[i].Mob.ClientId)
                        {
                            p39d.Damage[a].Damage = client.Character.Mob.GameStatus.Attack - mobList[i].Mob.GameStatus.Defense;
                        }
                    }
                }
                break;
            }

            case 27:     // FM: skill Cura
            case 29:     // FM: skill Recuperar
            {
                SSkillList skill   = Config.SkilList[p39d.SkillIndex];
                int        kind    = p39d.SkillIndex % 24 / 8 + 1;
                int        special = client.Character.Mob.GameStatus.Master[kind];
                int        dam     = 0;

                if (p39d.SkillIndex == 27)
                {
                    dam = (special * 2) + skill.InstanceValue;
                }
                else
                {
                    dam = ((special * 3) / 2) + skill.InstanceValue;
                }

                client.Character.Mob.GameStatus.CurHP += dam;


                if (client.Character.Mob.GameStatus.CurHP > client.Character.Mob.GameStatus.MaxHP)
                {
                    client.Character.Mob.GameStatus.CurHP = client.Character.Mob.GameStatus.MaxHP;
                }

                p39d.Damage[0].Damage -= dam;
                break;
            }

            case 32:     // FM: skill Atake de fogo
            case 33:     // FM: skill Ralampago
            case 34:     // FM: skill Lanca de gelo
            case 35:     // FM: skill Meteoro
            case 36:     // FM: skill Nevasca
            case 38:     // FM: skill Fenix
            case 39:     // FM: skill 8
            {
                SSkillList skill = Config.SkilList[p39d.SkillIndex];
                client.Character.Mob.GameStatus.CurMP -= skill.ManaInicial;

                SStatus status = client.Character.Mob.GameStatus;

                int kind    = p39d.SkillIndex % 24 / 8 + 1;
                int special = status.Master[kind];

                switch (client.Character.Mob.ClassInfo)
                {
                case ClassInfo.TK:             // TK Magico
                {
                    client.Character.Mob.MagicIncrement = (short)(special + skill.InstanceValue + status.Master[0] + status.Level + (status.Int / 4) + (status.Int / 40));
                    break;
                }

                case ClassInfo.FM:             // testado
                {
                    client.Character.Mob.MagicIncrement = (short)((status.Int * 0.368) + (skill.InstanceValue / 4.2) + (status.Level / 2) + (1.15 * special));
                    break;
                }

                case ClassInfo.BM:
                {
                    client.Character.Mob.MagicIncrement = (short)((status.Int / 30) + (status.Int / 3) + skill.InstanceValue + 2 * special);
                    break;
                }

                case ClassInfo.HT:
                {
                    client.Character.Mob.MagicIncrement = (short)((3 * status.Master[0]) + (3 * status.Str) + special + skill.InstanceValue);
                    break;
                }
                }
                ;

                for (int i = 0; i < mobList.Count(); i++)
                {
                    mobList[i].Mob.GameStatus.CurHP -= client.Character.Mob.MagicIncrement;
                    mobList[i].Mob.GameStatus.CurHP += mobList[i].Mob.GameStatus.Defense;

                    for (int a = 0; a < p39d.Damage.Length; a++)
                    {
                        if (p39d.Damage[a].MobId == mobList[i].Mob.ClientId)
                        {
                            p39d.Damage[a].Damage = client.Character.Mob.MagicIncrement - mobList[i].Mob.GameStatus.Defense;
                        }
                    }
                }
                break;
            }

            case 37:     // FM: skill Trovao
            case 41:     // FM: skill Velocidade
            case 43:     // FM: skill Escudo Magico
            case 44:     // FM: skill Dano
            case 45:     // FM: skill Toque de Athena
            case 53:     // BM: skill Protecao Elemental
            {
                SSkillList skill = Config.SkilList[p39d.SkillIndex];
                client.Character.Mob.GameStatus.CurMP -= skill.ManaInicial;

                int index = Functions.GetSlotAffect(client, skill.IdSkill);

                client.Character.Mob.Affects[index].Index = (byte)skill.TipoDeEfeito;
                client.Character.Mob.Affects[index].Value = (short)skill.ValorDoEfeito;
                client.Character.Mob.Affects[index].Time  = skill.TempoDoEfeito;
                Functions.GetCurrentScore(client, false);
                break;
            }

            case 56:     // BM: skill Sumona Condor
            case 57:     // BM: skill Sumona javali Selvagem
            case 58:     // BM: skill Sumona Lobo Selvagem
            case 59:     // BM: skill Sumona Urso Selvagem
            case 60:     // BM: skill Sumona Grande Tigre
            case 61:     // BM  skill Sumona Gorila Gigante
            case 62:     // BM  skill Sumona Dragao
            case 63:     // BM  skill Sumona Succubus
            {
                SSkillList skill = Config.SkilList.ToArray()[p39d.SkillIndex - 1];;

                if (skill.InstanceValue >= 1 && skill.InstanceValue <= 50)
                {
                    int summons = 0;

                    if (skill.InstanceValue == 1 || skill.InstanceValue == 2)
                    {
                        summons = client.Character.Mob.GameStatus.Master[2] / 30;
                    }

                    else if (skill.InstanceValue == 3 || skill.InstanceValue == 4 || skill.InstanceValue == 5)
                    {
                        summons = client.Character.Mob.GameStatus.Master[2] / 40;
                    }

                    else if (skill.InstanceValue == 6 || skill.InstanceValue == 7)
                    {
                        summons = client.Character.Mob.GameStatus.Master[2] / 80;
                    }

                    else if (skill.InstanceValue == 8)
                    {
                        summons = 1;
                    }

                    //TODO: Falta fazer meio complexo isso
                    //client.Character.Mob.GenerateSummon(client, skill.InstanceValue - 1, summons);
                }
                break;
            }

            case 64:     // BM: skill Transformacao Lobisomem
            case 66:     // BM: skill Transformacao Urso
            case 68:     // BM: skill Transformacao Astaroth
            case 70:     // BM: skill Transformacao Titan
            case 71:     // BM: skill Transformacao Eden
            {
                SSkillList skill = Config.SkilList[p39d.SkillIndex];
                for (int i = 0; i < client.Character.Mob.Affects.Length; i++)
                {
                    if (client.Character.Mob.Affects[i].Index == 0 || client.Character.Mob.Affects[i].Index == (byte)Affect.Transformacao)
                    {
                        client.Character.Mob.Affects[i].Index = (byte)skill.TipoDeEfeito;
                        client.Character.Mob.Affects[i].Value = (short)skill.ValorDoEfeito;
                        client.Character.Mob.Affects[i].Time  = skill.TempoDoEfeito;
                        Functions.GetCurrentScore(client, false);
                        break;
                    }
                }

                short id = 0;
                switch (p39d.SkillIndex)
                {
                case 64:
                { id = 22; break; }

                case 66:
                { id = 23; break; }

                case 68:
                { id = 24; break; }

                case 70:
                { id = 25; break; }

                case 71:
                { id = 32; break; }
                }

                //troca a face do client para a skill sumonada
                client.Character.Mob.Equip[0].Id = id;

                short[] sanc = new short[16];
                byte[]  anc  = new byte[16];

                for (int i = 0; i < client.Character.Mob.Equip.Length; i++)
                {
                    //obtem os codigos de todos itens
                    sanc[i] = Functions.GetVisualItemCode(client.Character.Mob.Equip[i], i == 14 ? true : false);

                    //obtem os codigos Anct de todos os itens
                    anc[i] = Functions.GetVisualAnctCode(client.Character.Mob.Equip[i]);
                }

                //envia os efeitos
                client.Send(P_36B.New(client, sanc, anc));

                //atualiza o score do client
                Functions.GetCurrentScore(client, false);
                break;
            }
            }

            //Adiciona os mob a list de view com dano Hp reduzido
            client.MobView.AddRange(mobList);

            //envia o dano recebido para o mob
            client.Send(P_39D.New(client, p39d));

            //Varre a lista de mob para ver se alguem morreu
            for (int i = 0; i < mobList.Count(); i++)
            {
                if (mobList[i].Mob.GameStatus.CurHP < 0)
                {
                    //mata o mob e envia o drop se houver
                    P_338.controller(client, mobList[i].Mob.ClientId, mobList[i].Mob.Exp);

                    //trata o recebimento do xp
                    AddXpMob(client, mobList[i].Mob.Exp);
                }
            }

            //Cada atake checa se a experiencia estorou o limite e avanca o lvl a cada atake
            if (client.Character.Mob.Exp >= Rate.Exp_Mortal_Arch[client.Character.Mob.BaseStatus.Level])
            {
                client.Character.Mob.BaseStatus.Level += 1;
                Functions.GetCurrentScore(client, false);
                client.Send(P_36A.New(client, Emotion.LevelUP, 3));
            }
        }