public static void HandleAttackRequest(GameRolePlayAttackMonsterRequestMessage message, WorldClient client)
        {
            if (client.Character.Map == null)
            {
                return;
            }
            if (client.Character.CancelMonsterAgression)
            {
                client.Character.CancelMonsterAgression = false;
                return;
            }
            if (!client.Character.Map.IsValid())
            {
                client.Character.Reply("Unable to start placement,this map is not valid");
                return;
            }
            var group = client.Character.Map.Instance.GetMapMonsterGroup(message.monsterGroupId);

            if (group != null)
            {
                FightPvM fight = FightProvider.Instance.CreatePvMFight(group, client.Character.Map, (short)group.CellId);

                fight.BlueTeam.AddFighter(client.Character.CreateFighter(fight.BlueTeam));             // on ajoute le perso

                group.Monsters.ForEach(x => fight.RedTeam.AddFighter(x.CreateFighter(fight.RedTeam))); // on ajoute les monstres

                fight.StartPlacement();
            }
            else
            {
                client.Character.NotificationError("Unable to fight, MonsterGroup dosent exist...");
            }
        }
Esempio n. 2
0
        public static void HandleGameRolePlayAttackMonsterRequest(GameRolePlayAttackMonsterRequestMessage message, WorldClient client)
        {
            if (client.Character.Map != null)
            {
                MonsterGroup group = client.Character.Map.Instance.GetEntity <MonsterGroup>((long)message.monsterGroupId);

                if (group != null && client.Character.CellId == group.CellId)
                {
                    if (client.Character.Map.BlueCells.Count >= group.MonsterCount && client.Character.Map.RedCells.Count() >= client.Character.FighterCount)
                    {
                        client.Character.Map.Instance.RemoveEntity(group);

                        FightPvM fight = FightProvider.Instance.CreateFightPvM(group, client.Character.Map, (short)group.CellId);

                        fight.RedTeam.AddFighter(client.Character.CreateFighter(fight.RedTeam));

                        foreach (var fighter in group.CreateFighters(fight.BlueTeam))
                        {
                            fight.BlueTeam.AddFighter(fighter);
                        }

                        fight.StartPlacement();
                    }
                    else
                    {
                        client.Character.ReplyError("Unable to fight on this map");
                    }
                }
                else
                {
                    client.Character.NoMove();
                }
            }
        }
Esempio n. 3
0
        private bool CanUseIdol(PlayerIdol idol, FightPvM fight)
        {
            if (!idol.Template.IdolSpellId.HasValue)
            {
                return(false);
            }
            else if (ActiveIdols.Count(x => x.Id == idol.Id) > 1)
            {
                return(false);
            }
            else if (fight.MonsterTeam.Fighters.OfType <MonsterFighter>().Any(x => idol.Template.IncompatibleMonsters.Contains(x.Monster.Template.Id)))
            {
                return(false);
            }
            else if (fight.MonsterTeam.Fighters.OfType <MonsterFighter>().Any(x => x.Monster.Template.AllIdolsDisabled))
            {
                return(false);
            }
            else if (idol.Template.GroupOnly && (fight.PlayerTeam.Fighters.Count < 4 || fight.MonsterTeam.Fighters.Count < 4))
            {
                return(false);
            }
            else if (!idol.Owner.Inventory.HasItem(idol.Template.IdolItem))
            {
                return(false);
            }
            else if (!idol.Owner.IsInFight() || idol.Owner.Fight.Id != fight.Id)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        public FightPvM CreateFightPvM(MonsterGroup group, MapRecord map, short cellId)
        {
            FightTeam blueTeam = new FightTeam((sbyte)TeamEnum.TEAM_DEFENDER, map.BlueCells, AlignmentSideEnum.ALIGNMENT_WITHOUT, TeamTypeEnum.TEAM_TYPE_MONSTER);
            FightTeam redTeam  = new FightTeam((sbyte)TeamEnum.TEAM_CHALLENGER, map.RedCells, AlignmentSideEnum.ALIGNMENT_WITHOUT, TeamTypeEnum.TEAM_TYPE_PLAYER);
            var       fight    = new FightPvM(map, blueTeam, redTeam, cellId, group);

            Fights.Add(fight);
            return(fight);
        }
Esempio n. 5
0
        public FightPvM CreatePvMFight(MonsterGroup group, MapRecord map, short cellid)
        {
            FightTeam blueteam = new FightTeam(0, map.BlueCells, TeamColorEnum.BLUE_TEAM, TeamTypeEnum.TEAM_TYPE_PLAYER);
            FightTeam redteam  = new FightTeam(1, map.RedCells, TeamColorEnum.RED_TEAM, TeamTypeEnum.TEAM_TYPE_MONSTER);
            var       fight    = new FightPvM(PopNextFightId(), map, blueteam, redteam, cellid, group);

            m_worldFights.Add(fight);
            return(fight);
        }
Esempio n. 6
0
        public IEnumerable <PlayerIdol> ComputeIdols(FightPvM fight)
        {
            foreach (var idol in ActiveIdols.ToArray())
            {
                if (CanUseIdol(idol, fight))
                {
                    continue;
                }

                Remove(idol);
            }

            if (ActiveIdols.Count > MaxActiveIdols)
            {
                return(new PlayerIdol[0]);
            }

            return(GetIdols());
        }
        public void GeneratePVMLoot()
        {
            if ((Fighter as CharacterFighter).HasLeft)
            {
                return;
            }
            #region VariableDefinitions
            WorldClient client   = (Fighter as CharacterFighter).Client;
            AsyncRandom random   = new AsyncRandom();
            FightPvM    pvmfight = Fighter.Fight as FightPvM;
            #endregion

            #region Kamas & Items Generation
            List <DroppedItem> m_drops = new List <DroppedItem>();
            foreach (var monster in pvmfight.MonsterGroup.Monsters)
            {
                var template = MonsterRecord.GetMonster(monster.MonsterId);
                var grade    = template.GetGrade(monster.ActualGrade);

                #region kamas
                int droppedKamas = random.Next(template.MinKamas, template.MaxKamas + 1);
                FightLoot.kamas += (uint)(droppedKamas * ConfigurationManager.Instance.KamasDropRatio);
                #endregion

                #region items
                List <CharacterFighter> charactersFighters = Fighter.Team.GetFighters().FindAll(x => x is CharacterFighter).ConvertAll <CharacterFighter>(x => (CharacterFighter)x);
                int prospectingSum = charactersFighters.Sum((CharacterFighter entry) => entry.Client.Character.StatsRecord.Prospecting);

                foreach (var item in template.Drops.FindAll(x => x.ProspectingLock <= prospectingSum))
                {
                    int    D = random.Next(0, 201);
                    double dropchancePercent = item.GetDropRate(monster.ActualGrade) + pvmfight.MonsterGroup.AgeBonus / 5 + client.Character.StatsRecord.Prospecting / 100;


                    if (D <= dropchancePercent)
                    {
                        var alreadyDropped = m_drops.FirstOrDefault(x => x.GID == item.ObjectId);
                        if (alreadyDropped == null)
                        {
                            uint dropMax = GetQuantityDropMax();

                            uint Q = (uint)random.Next(1, (int)(dropMax + 1));
                            if (Q > item.Count)
                            {
                                Q = 1;
                            }
                            m_drops.Add(new DroppedItem(item.ObjectId, Q));
                        }
                        else
                        {
                            alreadyDropped.Quantity++;
                        }
                    }
                }


                #endregion
            }

            #endregion

            client.Character.AddKamas((int)FightLoot.kamas);

            foreach (var item in m_drops)
            {
                FightLoot.objects.Add(item.GID);
                FightLoot.objects.Add((ushort)item.Quantity);
                client.Character.Inventory.Add(item.GID, item.Quantity, false, false);
            }

            #region Experience Provider
            List <MonsterData> monsters = new List <MonsterData>();
            foreach (var monster in pvmfight.MonsterGroup.Monsters)
            {
                var grade = MonsterRecord.GetMonster(monster.MonsterId).GetGrade(monster.ActualGrade);
                monsters.Add(new MonsterData(grade.Level, (int)grade.GradeXp));
            }
            var team = Fighter.Team.GetFighters().FindAll(x => x is CharacterFighter).ConvertAll <CharacterFighter>(x => (CharacterFighter)x);;
            ExperienceFormulas formulas = new ExperienceFormulas();
            formulas.InitXpFormula(new PlayerData(client.Character.Record.Level, client.Character.StatsRecord.Wisdom), monsters, team.ConvertAll <GroupMemberData>(x => new GroupMemberData(x.Client.Character.Record.Level, false)), pvmfight.MonsterGroup.AgeBonus);
            if (client.Character.Record.Level >= 200)
            {
                formulas._xpSolo = 0;
            }
            client.Character.AddXp((ulong)formulas._xpSolo);
            PlayerLevel = client.Character.Record.Level;
            var expdatas = new FightResultExperienceData(true, true, true, true, false, false, false, client.Character.Record.Exp, ExperienceRecord.GetExperienceForLevel(client.Character.Record.Level), ExperienceRecord.GetExperienceForLevel((uint)client.Character.Record.Level + 1), (int)formulas._xpSolo, 0, 0, 0);
            AdditionalDatas.Add(expdatas);
            #endregion
            client.Character.Inventory.Refresh();
            client.Character.RefreshShortcuts();
        }