Ejemplo n.º 1
0
 public override void OverridableEndFight(FightTeam Winners, FightTeam Loosers)
 {
     foreach (var Fighter in Loosers.GetFighters())
     {
         this.myResult.AddResult(Fighter, false);
         if (Fighter is PercepteurFighter)
         {
             this.Map.DestroyActor((Fighter as PercepteurFighter).TaxCollector);
             (Fighter as PercepteurFighter).TaxCollector.Guild.Send(new GuildFightInformationsMesssage((Fighter as PercepteurFighter).TaxCollector.Guild));
             (Fighter as PercepteurFighter).TaxCollector.Guild.Send(new GuildAttackedTaxcollector(AttackedTaxcollectorState.DIED, (Fighter as PercepteurFighter).TaxCollector));
             TaxCollectorTable.TryDeleteTax((Fighter as PercepteurFighter).TaxCollector);
         }
     }
     foreach (var Fighter in Winners.GetFighters())
     {
         this.myResult.AddResult(Fighter, true);
         if (Fighter is PercepteurFighter)
         {
             (Fighter as PercepteurFighter).TaxCollector.Guild.Send(new GuildFightInformationsMesssage((Fighter as PercepteurFighter).TaxCollector.Guild));
             (Fighter as PercepteurFighter).TaxCollector.Guild.Send(new GuildAttackedTaxcollector(AttackedTaxcollectorState.SURVIVED, (Fighter as PercepteurFighter).TaxCollector));
             (Fighter as PercepteurFighter).TaxCollector.inFight      = 0;
             (Fighter as PercepteurFighter).TaxCollector.CurrentFight = null;
             (Fighter as PercepteurFighter).TaxCollector.Map.SpawnActor((Fighter as PercepteurFighter).TaxCollector);
         }
     }
     base.EndFight();
 }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            nextPlayerGuid = CharacterTable.getNextGuid();
            nextPlayerGuid++;
            nextItemGuid = InventoryItemTable.getNextGuid();
            nextItemGuid++;
            nextGuildId = GuildTable.getNextGuid();
            nextGuildId++;
            nextMountId = MountTable.getNextGuid();
            nextMountId++;
            nextSpeakingId = SpeakingTable.getNextGuid();
            nextSpeakingId++;
            SpellTable.Load();
            ExpFloorTable.Load();
            MonsterTable.Load();
            ItemTemplateTable.Load();
            ItemTemplateTable.LoadItemActions();
            ItemSetTable.Load();
            DropTable.Load();
            TitleTable.Load();
            IObjectTemplateTable.Load();
            AreaTable.Load();
            AreaSubTable.Load();
            MapTable.Load();
            MapTable.LoadActions();
            CellActionTable.Load();
            MobGroupFixTable.Load();
            BreedTable.Load();
            NpcTemplateTable.Load();
            NpcTemplateTable.LoadPlaces();
            NpcQuestionTable.Load();
            NpcReplyTable.Load();
            ShopNpcTable.Initialize();
            GuildTable.Load();
            CharactersGuildTable.Load();
            TaxCollectorTable.Load();
            PrismeTable.Load();
            BidHouseTable.Load();
            BidHouseTable.LoadItems();
            MountParkTable.Load();
            StaticMountTable.Load();
            MountTable.Load();//TODO Dynamic load of Character mount
            ZaapTable.Load();
            ZaapiTable.Load();

            var Timer = new System.Timers.Timer(1000 * 60 * 25);

            Timer.Elapsed += delegate(object sender, ElapsedEventArgs e)
            {
                Save();
            };
            Timer.Start();
        }
Ejemplo n.º 3
0
        private static void ProcessGuildPutPerceptorRequest(WorldClient Client, string Packet)
        {
            if (!Client.GetCharacter().HasGuild() || !Client.GetCharacter().getCharacterGuild().Can(GuildRightEnum.RIGHT_PUT_PERCEPTOR) || Client.GetCharacter().GetGuild().CharactersGuildCache.Count < 10)
            {
                Client.Send(new BasicNoOperationMessage());
            }
            else
            {
                short price = (short)(1000 + 10 * Client.GetCharacter().GetGuild().Level);

                if (Client.GetCharacter().Kamas < price)
                {
                    Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 82));
                }
                if (TaxCollectorTable.Cache.Where(x => x.Value.Mapid == Client.Character.myMap.Id).Count() > 0)
                {
                    Client.Send(new ImMessage("1168;1"));
                    return;
                }
                if (Client.Character.myMap.FightCell.Length < 5)
                {
                    Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 13));
                }
                if (TaxCollectorTable.Cache.Values.Where(x => x.GuildID == Client.Character.GetGuild().ID).Count() >= Client.Character.GetGuild().PerceptorMaxCount)
                {
                    return;
                }

                short random1 = (short)Random.Next(1, 39);
                short random2 = (short)Random.Next(1, 71);

                TaxCollector perco = new TaxCollector()
                {
                    ActorId     = TaxCollectorTable.getNextGuid(),
                    Mapid       = Client.Character.myMap.Id,
                    CellId      = Client.Character.CellId,
                    Orientation = 3,
                    GuildID     = Client.Character.GetGuild().ID,
                    N1          = random1,
                    N2          = random2,
                    ItemList    = "",
                    Kamas       = 0L,
                    XP          = 0L,
                };
                TaxCollectorTable.Add(perco);
                Client.Character.myMap.SpawnActor(perco);
                Client.Send(new GameActorShowMessage(GameActorShowEnum.SHOW_SPAWN, perco));
                Client.Send(new GuildFightInformationsMesssage(Client.Character.GetGuild()));
                Client.Character.GetGuild().Send(new GuildTaxCollectorMessage("S" + perco.N1 + "," + perco.N2 + "|" + perco.Mapid + "|" + perco.Map.X + "|" + perco.Map.Y + "|" + Client.Character.Name));
            }
        }
Ejemplo n.º 4
0
        public override bool CloseExchange(bool Success = false)
        {
            Npc.Guild.Send(new GuildFightInformationsMesssage(Npc.Guild));
            Npc.Guild.Send(new GuildTaxCollectorMessage("G" + Npc.N1 + "," + Npc.N2 + "|.|" + Npc.Map.X + "|" + Npc.Map.Y + "|" + myClient.GetCharacter().Name + "|" + Npc.LogXP + ";" + Npc.GetLogItems()));
            Npc.Map.DestroyActor(Npc);
            TaxCollectorTable.TryDeleteTax(Npc);

            this.Finish();

            this.myClient.SetExchange(null);
            this.myClient.Send(new ExchangeLeaveMessage(Success));

            return(true);
        }
Ejemplo n.º 5
0
        private static void ProcesssRemoveTaxCollector(WorldClient Client, string Packet)
        {
            if (!Client.GetCharacter().HasGuild() || !Client.GetCharacter().getCharacterGuild().Can(GuildRightEnum.RIGHT_PUT_PERCEPTOR) || Client.GetFight() != null || Client.GetCharacter().isAaway)
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }
            long TaxID;

            if (!long.TryParse(Packet.Substring(2), out TaxID))
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }
            if (Client.GetCharacter().myMap.GetActor(TaxID) != null && Client.GetCharacter().myMap.GetActor(TaxID).ActorType != World.Maps.GameActorTypeEnum.TYPE_TAX_COLLECTOR)
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }
            var TaxC = Client.GetCharacter().myMap.GetActor(TaxID) as TaxCollector;

            if (TaxC == null || TaxC.inFight > 0)
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            Client.GetCharacter().myMap.DestroyActor(TaxC);
            TaxCollectorTable.TryDeleteTax(TaxC);
            StringBuilder toSend = new StringBuilder("gITM").Append(TaxCollector.parsetoGuild(TaxC.GuildID));

            toSend.Append((char)0x00);
            toSend.Append("gT").Append("R").Append(TaxC.N1).Append(",").Append(TaxC.N2).Append("|");
            toSend.Append(TaxC.Mapid).Append("|");
            toSend.Append(TaxC.Map.X).Append("|").Append(TaxC.Map.Y).Append("|").Append(Client.Character.Name);
            Client.Character.GetGuild().Send(new EmptyMessage(toSend.ToString()));
        }
Ejemplo n.º 6
0
        public static void ProcessExchangeRequest(WorldClient Client, string Packet)
        {
            if (!Packet.Contains('|'))
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            var Data = Packet.Substring(2).Split('|');

            if (Data.Length != 2)
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            var  ExchangeType = 0;
            long ActorId      = 0;

            if (!int.TryParse(Data[0], out ExchangeType))
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            if (!Enum.IsDefined(typeof(ExchangeTypeEnum), ExchangeType))
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            if (!long.TryParse(Data[1], out ActorId) && (ExchangeTypeEnum)ExchangeType != ExchangeTypeEnum.EXCHANGE_MOUNT && (ExchangeTypeEnum)ExchangeType != ExchangeTypeEnum.EXCHANGE_BIGSTORE_BUY && (ExchangeTypeEnum)ExchangeType != ExchangeTypeEnum.EXCHANGE_BIGSTORE_SELL)
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            var Actor = Client.Character.myMap.GetActor(ActorId);

            // inexistant ?
            if (Actor == null && (ExchangeTypeEnum)ExchangeType != ExchangeTypeEnum.EXCHANGE_MOUNT && (ExchangeTypeEnum)ExchangeType != ExchangeTypeEnum.EXCHANGE_BIGSTORE_BUY && (ExchangeTypeEnum)ExchangeType != ExchangeTypeEnum.EXCHANGE_BIGSTORE_SELL)
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            // Il peu echanger ?
            if (!Client.CanGameAction(GameActionTypeEnum.EXCHANGE) && !(Client.GetExchange() != null && Client.GetExchange() is MarketSellExchange && ExchangeType == 11))
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            switch ((ExchangeTypeEnum)ExchangeType)
            {
            case ExchangeTypeEnum.EXCHANGE_BIGSTORE_BUY:
                if (Client.Character.Deshonor >= 5)
                {
                    Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 83));
                    Client.Send(new ExchangeLeaveMessage());
                    return;
                }
                if (Client.GetExchange() != null)
                {
                    ProcessExchangeLeaveMessage(Client);
                }
                if (!BidHouseTable.Cache.ContainsKey(Client.Character.Map))
                {
                    //TODO IM Message HDV Not Exist
                    Client.Send(new ExchangeLeaveMessage());
                    return;
                }
                var Market = BidHouseTable.Cache[Client.Character.Map];

                var MbExchange = new MarketBuyExchange(Client, Market);

                Client.AddGameAction(new GameExchange(Client.Character, MbExchange));
                Client.SetExchange(MbExchange);

                Client.Send(new ExchangeCreateMessage(ExchangeTypeEnum.EXCHANGE_BIGSTORE_BUY, "1,10,100;" + Market.CategoriesString + ";" + Market.TaxRate() + ";" + Market.levelMax + ";" + Market.countItem + ";-1;" + Market.sellTime));

                break;

            case ExchangeTypeEnum.EXCHANGE_SHOP:

                // lol ?
                if (Actor.ActorType != GameActorTypeEnum.TYPE_NPC)
                {
                    Client.Send(new BasicNoOperationMessage());
                    return;
                }

                var Npc      = Actor as Npc;
                var Exchange = new NpcExchange(Client, Npc);


                Client.AddGameAction(new GameExchange(Client.Character, Exchange));
                Client.SetExchange(Exchange);

                Client.Send(new ExchangeCreateMessage((ExchangeTypeEnum)ExchangeType, Npc.ActorId.ToString()));
                Client.Send(new ExchangeItemListMessage(Npc));
                break;

            case ExchangeTypeEnum.EXCHANGE_BIGSTORE_SELL:
                if (Client.Character.Deshonor >= 5)
                {
                    Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 83));
                    Client.Send(new ExchangeLeaveMessage());
                    return;
                }
                if (!BidHouseTable.Cache.ContainsKey(Client.Character.Map))
                {
                    //TODO IM Message HDV Not Exist
                    Client.Send(new ExchangeLeaveMessage());
                    return;
                }
                Market = BidHouseTable.Cache[Client.Character.Map];

                var MaExchange = new MarketSellExchange(Client, Market);

                Client.AddGameAction(new GameExchange(Client.Character, MaExchange));
                Client.SetExchange(MaExchange);

                Client.Send(new ExchangeCreateMessage(ExchangeTypeEnum.EXCHANGE_BIGSTORE_SELL, "1,10,100;" + Market.CategoriesString + ";" + Market.TaxRate() + ";" + Market.levelMax + ";" + Market.countItem + ";-1;" + Market.sellTime));
                Client.Send(new ExchangeItemListMessagePerAccount(Client.Account.Data, Market.HdvID));

                break;

            case ExchangeTypeEnum.EXCHANGE_MOUNT:

                var Mount = Client.Character.Mount;

                if (Mount == null)
                {
                    return;
                }

                var MExchange = new MountExchange(Client, Mount);


                Client.AddGameAction(new GameExchange(Client.Character, MExchange));
                Client.SetExchange(MExchange);

                Client.Send(new ExchangeCreateMessage((ExchangeTypeEnum)ExchangeType, Mount.ID.ToString()));
                Client.Send(new ExchangeMountItemListMessage(Mount));
                Client.Send(new MountActualPodMessage(Mount));
                break;

            case ExchangeTypeEnum.EXCHANGE_PLAYER:

                // lol?
                if (Actor.ActorType != GameActorTypeEnum.TYPE_CHARACTER)
                {
                    Client.Send(new BasicNoOperationMessage());
                    return;
                }

                // cast
                var Target = (Actor as Player).Client;

                if (!Target.CanGameAction(GameActionTypeEnum.BASIC_REQUEST) ||
                    Target.Character.HasRestriction(RestrictionEnum.RESTRICTION_CANT_EXCHANGE) ||
                    Client.Character.HasRestriction(RestrictionEnum.RESTRICTION_CANT_EXCHANGE))
                {
                    Client.Send(new BasicNoOperationMessage());
                    return;
                }

                var Request       = new ExchangeRequest(Client, Target);
                var RequestAction = new GameRequest(Client.Character, Request);

                Client.AddGameAction(RequestAction);
                Target.AddGameAction(RequestAction);

                Client.SetBaseRequest(Request);
                Target.SetBaseRequest(Request);

                var Message = new ExchangeRequestMessage(Client.Character.ID, Target.Character.ID);

                Client.Send(Message);
                Target.Send(Message);
                break;

            case ExchangeTypeEnum.EXCHANGE_TAXCOLLECTOR:
                if (Packet.Length < 4 || !Client.Character.HasGuild())
                {
                    Client.Send(new BasicNoOperationMessage());
                    return;
                }
                long         PercepteurID = long.Parse(Packet.Substring(4));
                TaxCollector perco        = TaxCollectorTable.GetPerco(PercepteurID);

                if (perco == null || perco.inFight > 0 || perco.inExchange)
                {
                    Client.Send(new BasicNoOperationMessage());
                    return;
                }

                perco.inExchange = true;

                if (Actor.ActorType != GameActorTypeEnum.TYPE_TAX_COLLECTOR)
                {
                    Client.Send(new BasicNoOperationMessage());
                    return;
                }

                var TC        = Actor as TaxCollector;
                var TExchange = new TaxCollectorExchange(Client, TC);


                Client.AddGameAction(new GameExchange(Client.Character, TExchange));
                Client.SetExchange(TExchange);

                Client.Send(new ExchangeCreateMessage((ExchangeTypeEnum)ExchangeType, TC.ActorId.ToString()));
                Client.Send(new ExchangeTaxItemListMessage(TC.SerializeAsItemList()));

                break;
            }
        }
Ejemplo n.º 7
0
        private static void ProcessTaxCollectorJoinFigh(WorldClient Client, string Packet)
        {
            String PercoID = IntHelper.toString(int.Parse(Packet.Substring(1)), 36);
            long   TiD     = -1;

            if (!long.TryParse(PercoID, out TiD))
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }
            var TaxCollector = TaxCollectorTable.GetPerco(TiD);

            if (TaxCollector == null)
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            short MapID = -1;

            try
            {
                MapID = (short)TaxCollector.Mapid;
            }
            catch (Exception e)
            {};

            int CellID = -1;

            try
            {
                CellID = TaxCollector.CellId;
            }
            catch (Exception e)
            {};

            if (TiD == -1 || TaxCollector.CurrentFight == null || MapID == -1 || CellID == -1)
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            if (Client.GetFight() == null && !Client.GetCharacter().isAaway)
            {
                if (Client.GetCharacter().myMap.Id != MapID)
                {
                    Client.GetCharacter().isJoiningTaxFight = true;
                    Client.GetCharacter().OldPosition       = new Couple <Map, int>(Client.Character.myMap, Client.Character.CellId);
                    Client.GetCharacter().Teleport(TaxCollector.Map, CellID);
                    try
                    {
                        System.Threading.Thread.Sleep(700);
                    }
                    catch (Exception e)
                    {
                        Logger.Error(e);
                    }
                }

                if (Client.GetCharacter().HasRestriction(RestrictionEnum.RESTRICTION_IS_TOMBESTONE))
                {
                    Client.Send(new BasicNoOperationMessage());
                    return;
                }

                var Team = TaxCollector.CurrentFight.GetTeam2();

                if (TaxCollector.CurrentFight.CanJoin(Team, Client.GetCharacter()))
                {
                    var Fighter = new CharacterFighter(TaxCollector.CurrentFight, Client);

                    var FightAction = new GameFight(Fighter, TaxCollector.CurrentFight);

                    Client.AddGameAction(FightAction);

                    TaxCollector.CurrentFight.JoinFightTeam(Fighter, Team, false, -1, false);
                }
            }
        }
Ejemplo n.º 8
0
        public override void OverridableEndFight(FightTeam Winners, FightTeam Loosers)
        {
            /*foreach (var Chal in Challanges)
             * {
             *  if (Chal.State && !Chal.Signaled)
             *      Chal.Ok();
             * }*/

            var WinChallenges      = Challanges.Where(c => c.State).ToList();
            var ChallengeXpBonus   = 1;
            var ChallengeDropBonus = 1;

            if (WinChallenges.Count > 0)
            {
                ChallengeXpBonus   = (int)Math.Round(Convert.ToDouble((100 + WinChallenges.Sum(c => c.BasicXpBonus + c.TeamXpBonus)) / 100));
                ChallengeDropBonus = (int)Math.Round(Convert.ToDouble((100 + WinChallenges.Sum(c => c.BasicDropBonus + c.TeamDropBonus)) / 100));
            }


            var WinnersCount       = Winners.GetFighters().Count;
            var LoosersCount       = Loosers.GetFighters().Count;
            var WinnersLevel       = Winners.GetFighters().Sum(x => x.Level);
            var LoosersLevel       = Loosers.GetFighters().Sum(x => x.Level);
            var WinnersProspection = Winners.GetFighters().Sum(x => x.Stats.GetTotal(EffectEnum.AddProspection));
            var MonsterWon         = Winners.Leader.ActorType == GameActorTypeEnum.TYPE_MONSTER;

            var  PossibleItemLoot  = new List <ItemLoot>();
            long PossibleKamasLoot = 0;
            var  PossibleDrops     = new Dictionary <Drop, int>();
            var  MinKamas          = 0;
            var  MaxKamas          = 0;
            long BaseXp            = 0;

            // Les monstres perdent ?
            if (!MonsterWon)
            {
                PossibleItemLoot.AddRange(this.MonsterGroup.ItemLoot);
                PossibleKamasLoot = this.MonsterGroup.KamasLoot;
            }

            foreach (var Fighter in Loosers.GetFighters())
            {
                switch (Fighter.ActorType)
                {
                case GameActorTypeEnum.TYPE_MONSTER:
                    var Monster = Fighter as MonsterFighter;

                    // Ajout des drops et kamas
                    MinKamas += Monster.Grade.Monster.MinKamas;
                    MaxKamas += Monster.Grade.Monster.MaxKamas;
                    BaseXp   += Monster.Grade.BaseXP;

                    // On augmente le Taux si possible
                    foreach (var Drop in Monster.Grade.Monster.DropsCache)
                    {
                        if (Drop.ItemTemplateCache != null)
                        {
                            if (!PossibleDrops.ContainsKey(Drop))
                            {
                                if (Drop.Seuil <= WinnersProspection)
                                {
                                    var Taux = (int)((WinnersProspection * Drop.Taux * Settings.AppSettings.GetIntElement("Rate.Drop") * ChallengeDropBonus / 100));

                                    PossibleDrops.Add(Drop, Taux);
                                }
                                else
                                {
                                    PossibleDrops.Add(Drop, (int)Drop.Taux);
                                }
                            }
                        }
                    }
                    break;
                }

                this.myResult.AddResult(Fighter, false);
            }

            var WinnersOrderedByProspect = Winners.GetFighters().OrderByDescending(x => x.Stats.GetTotal(EffectEnum.AddProspection));
            var AlreadyDropItems         = new Dictionary <int, int>();
            var ItemLootPerFighter       = PossibleItemLoot.Count / WinnersCount;
            var KamasLootPerFighter      = PossibleKamasLoot / WinnersCount;
            var Modulo = PossibleItemLoot.Count % (this.Map.GetActors().Where(x => x.ActorType == GameActorTypeEnum.TYPE_TAX_COLLECTOR).Count() > 0  ? WinnersCount + 1 : WinnersCount);

            foreach (var Drop in PossibleDrops)
            {
                if (!AlreadyDropItems.ContainsKey(Drop.Key.ItemTemplateCache.ID))
                {
                    AlreadyDropItems.Add(Drop.Key.ItemTemplateCache.ID, 0);
                }
            }

            foreach (var Fighter in WinnersOrderedByProspect)
            {
                long WinXp    = 0;
                long WinKamas = 0;
                var  Drops    = new Dictionary <int, int>();

                if (!Fighter.Left)
                {
                    switch (Fighter.ActorType)
                    {
                    case GameActorTypeEnum.TYPE_CHARACTER:
                        var Character = Fighter as CharacterFighter;

                        WinXp     = Algo.CalculatePVMXp(Character, Winners.GetFighters(), Loosers.GetFighters(), LoosersLevel, WinnersLevel, BaseXp);
                        WinXp    *= ChallengeXpBonus;
                        WinKamas  = Algo.CalculatePVMKamas(MaxKamas, MinKamas);
                        WinKamas += KamasLootPerFighter;
                        WinKamas *= ChallengeDropBonus;

                        try
                        {
                            Character.Character.BeginCachedBuffer();

                            Character.Character.InventoryCache.AddKamas(WinKamas);
                            Character.Character.AddExperience(WinXp);

                            foreach (var Drop in PossibleDrops)
                            {
                                var Taux = Drop.Value * 100;
                                var Jet  = Algo.Random(0, 100 * 100);

                                if (Jet < Taux)
                                {
                                    if (AlreadyDropItems[Drop.Key.TemplateId] < Drop.Key.Max)
                                    {
                                        if (Drops.ContainsKey(Drop.Key.TemplateId))
                                        {
                                            Drops[Drop.Key.TemplateId]++;
                                        }
                                        else
                                        {
                                            Drops.Add(Drop.Key.TemplateId, 1);
                                        }
                                    }
                                }
                            }

                            foreach (var Drop in Drops)
                            {
                                InventoryItemTable.TryCreateItem(Drop.Key, Character.Character, Drop.Value);
                            }

                            for (int i = 0; i < ItemLootPerFighter; i++)
                            {
                                if (Drops.ContainsKey(PossibleItemLoot[i].TemplateId))
                                {
                                    Drops[PossibleItemLoot[i].TemplateId]++;
                                }
                                else
                                {
                                    Drops.Add(PossibleItemLoot[i].TemplateId, PossibleItemLoot[i].Quantity);
                                }

                                InventoryItemTable.TryCreateItem(PossibleItemLoot[i].TemplateId, Character.Character, PossibleItemLoot[i].Quantity, Stats: PossibleItemLoot[i].ItemStats.ToItemStats());
                            }

                            if (ItemLootPerFighter > 0)
                            {
                                PossibleItemLoot.RemoveRange(0, ItemLootPerFighter);
                            }

                            if (Modulo > 0)
                            {
                                if (Drops.ContainsKey(PossibleItemLoot[0].TemplateId))
                                {
                                    Drops[PossibleItemLoot[0].TemplateId]++;
                                }
                                else
                                {
                                    Drops.Add(PossibleItemLoot[0].TemplateId, PossibleItemLoot[0].Quantity);
                                }

                                InventoryItemTable.TryCreateItem(PossibleItemLoot[0].TemplateId, Character.Character, PossibleItemLoot[0].Quantity, Stats: PossibleItemLoot[0].ItemStats.ToItemStats());

                                PossibleItemLoot.RemoveAt(0);
                                Modulo--;
                            }

                            // Fin de la mise en cache
                            Character.Character.EndCachedBuffer();
                        }
                        catch (Exception exc)
                        {
                            Logger.Error("MonsterFight::EndFight() " + exc.ToString());
                        }

                        // Ajout du resultat
                        this.myResult.AddResult(Fighter, true, WinKamas, WinXp, WinItems: Drops);

                        break;

                    case GameActorTypeEnum.TYPE_MONSTER:
                        var Monster = Fighter as MonsterFighter;

                        WinKamas += KamasLootPerFighter;

                        for (int i = 0; i < ItemLootPerFighter; i++)
                        {
                            if (Drops.ContainsKey(PossibleItemLoot[i].TemplateId))
                            {
                                Drops[PossibleItemLoot[i].TemplateId]++;
                            }
                            else
                            {
                                Drops.Add(PossibleItemLoot[i].TemplateId, PossibleItemLoot[i].Quantity);
                            }
                        }

                        if (ItemLootPerFighter > 0)
                        {
                            PossibleItemLoot.RemoveRange(0, ItemLootPerFighter);
                        }

                        if (Modulo > 0)
                        {
                            if (Drops.ContainsKey(PossibleItemLoot[0].TemplateId))
                            {
                                Drops[PossibleItemLoot[0].TemplateId]++;
                            }
                            else
                            {
                                Drops.Add(PossibleItemLoot[0].TemplateId, PossibleItemLoot[0].Quantity);
                            }

                            PossibleItemLoot.RemoveAt(0);
                            Modulo--;
                        }

                        this.myResult.AddResult(Fighter, true, WinKamas, WinXp, WinItems: Drops);

                        break;
                    }
                }
            }


            if (!MonsterWon && this.Map.GetActors().Where(x => x.ActorType == GameActorTypeEnum.TYPE_TAX_COLLECTOR).Count() > 0)
            {
                var  TCollector = this.Map.GetActors().Where(x => x.ActorType == GameActorTypeEnum.TYPE_TAX_COLLECTOR).First() as TaxCollector;
                long winxp      = (int)Math.Floor((double)Algo.CalculateXpWinPerco(TCollector, Winners.GetFighters(), Loosers.GetFighters(), BaseXp) / 100);
                long winkamas   = (int)Math.Floor((double)Algo.CalculatePVMKamas(MinKamas, MaxKamas) / 100);
                TCollector.XP    += winxp;
                TCollector.Kamas += winkamas;
                var Drops = new Dictionary <int, int>();

                foreach (var Drop in PossibleDrops)
                {
                    var Taux = Drop.Value * 100;
                    var Jet  = Algo.Random(0, 100 * 100);

                    if (Jet < Taux)
                    {
                        if (AlreadyDropItems[Drop.Key.TemplateId] < Drop.Key.Max)
                        {
                            if (Drops.ContainsKey(Drop.Key.TemplateId))
                            {
                                Drops[Drop.Key.TemplateId]++;
                            }
                            else
                            {
                                Drops.Add(Drop.Key.TemplateId, 1);
                            }
                        }
                    }
                }

                foreach (var Drop in Drops)
                {
                    InventoryItemTable.TryCreateItem(Drop.Key, TCollector, Drop.Value);
                }

                for (int i = 0; i < ItemLootPerFighter; i++)
                {
                    if (Drops.ContainsKey(PossibleItemLoot[i].TemplateId))
                    {
                        Drops[PossibleItemLoot[i].TemplateId]++;
                    }
                    else
                    {
                        Drops.Add(PossibleItemLoot[i].TemplateId, PossibleItemLoot[i].Quantity);
                    }

                    InventoryItemTable.TryCreateItem(PossibleItemLoot[i].TemplateId, TCollector, PossibleItemLoot[i].Quantity, Stats: PossibleItemLoot[i].ItemStats.ToItemStats());
                }

                if (ItemLootPerFighter > 0)
                {
                    PossibleItemLoot.RemoveRange(0, ItemLootPerFighter);
                }

                if (Modulo > 0)
                {
                    if (Drops.ContainsKey(PossibleItemLoot[0].TemplateId))
                    {
                        Drops[PossibleItemLoot[0].TemplateId]++;
                    }
                    else
                    {
                        Drops.Add(PossibleItemLoot[0].TemplateId, PossibleItemLoot[0].Quantity);
                    }

                    InventoryItemTable.TryCreateItem(PossibleItemLoot[0].TemplateId, TCollector, PossibleItemLoot[0].Quantity, Stats: PossibleItemLoot[0].ItemStats.ToItemStats());

                    PossibleItemLoot.RemoveAt(0);
                    Modulo--;
                }

                this.myResult.TCollectorResult = new Tera.WorldServer.World.Fights.GameFightEndResult.TaxCollectorResult()
                {
                    TaxCollector = TCollector,
                    WinExp       = winxp,
                    WinKamas     = winkamas,
                    WinItems     = Drops
                };

                TaxCollectorTable.Update(TCollector);
            }

            if (!MonsterWon)
            {
                this.Map.SpawnMonsterGroup(1);
            }
            else if (!MonsterGroup.IsFix)
            {
                this.Map.SpawnActor(this.MonsterGroup);
            }

            base.EndFight();
        }
Ejemplo n.º 9
0
        public override bool MoveItem(Network.WorldClient Client, Database.Models.InventoryItemModel Item, ushort Quantity, bool Add = false)
        {
            if (!Add)
            {
                if (!Npc.Items.ContainsKey(Item.ID))
                {
                    return(false);
                }
                InventoryItemModel ObjectEqualize = Client.Character.InventoryCache.getSimilarInventoryItem(Item);
                int    newQua = Item.Quantity - Quantity;
                String str;

                if (ObjectEqualize == null)
                {
                    if (newQua <= 0)
                    {
                        Npc.Items.Remove(Item.ID);
                        if (Client.Character.InventoryCache.TryMergeItem(Item.TemplateID, Item.GetStats().ToItemStats(), Item.Slot, Item.Quantity))
                        {
                            InventoryItemTable.removeItem(Item.ID);
                        }
                        else
                        {
                            Client.Character.InventoryCache.Add(Item);
                        }
                        str = "O-" + Item.ID;
                    }
                    else
                    {
                        ObjectEqualize = InventoryItemTable.TryCreateItem(Item.TemplateID, Client.Character, Quantity, Stats: Item.Effects);
                        Item.Quantity  = newQua;
                        str            = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                    }
                }
                else if (newQua <= 0)
                {
                    Npc.Items.Remove(Item.ID);
                    ObjectEqualize.Quantity += Item.Quantity;
                    Client.Send(new ObjectQuantityMessage(ObjectEqualize.ID, ObjectEqualize.Quantity));
                    InventoryItemTable.removeItem(Item.ID);
                    str = "O-" + Item.ID;
                    InventoryItemTable.Update(ObjectEqualize);
                }
                else
                {
                    Item.Quantity            = newQua;
                    ObjectEqualize.Quantity += Quantity;
                    Client.Send(new ObjectQuantityMessage(ObjectEqualize.ID, ObjectEqualize.Quantity));
                    str = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                    InventoryItemTable.Update(ObjectEqualize);
                }
                Client.Send(new BankUpdateMessage(str));
                Client.Send(new InventoryWeightMessage(0, 2000)); // TODO PODS
                TaxCollectorTable.Update(Npc);

                Npc.LogItems.Add(Item.ID, Item);
            }
            Client.GetCharacter().AddExperience(Npc.XP);
            Npc.LogXP += Npc.XP;
            Npc.XP     = 0;
            TaxCollectorTable.Update(Npc);

            return(true);
        }