Esempio n. 1
0
        /// <summary>
        /// Spawn un groupe de monstre qui sera généré en fonction des constantes de générations.
        /// </summary>
        /// <param name="spawns"></param>
        /// <param name="quiet"></param>
        public void AddGeneratedMonsterGroup(AbstractMapInstance instance, MonsterSpawnRecord[] spawns, bool quiet)
        {
            AsyncRandom random = new AsyncRandom();

            MonsterGroup group = new MonsterGroup(instance.Record);

            for (int w = 0; w < random.Next(1, instance.Record.BlueCells.Count + 1); w++)
            {
                int max  = spawns.Sum((MonsterSpawnRecord entry) => entry.Probability);
                int num  = random.Next(0, max);
                int num2 = 0;
                foreach (var monsterRecord in spawns)
                {
                    num2 += monsterRecord.Probability;
                    if (num <= num2)
                    {
                        MonsterRecord template = MonsterRecord.GetMonster(monsterRecord.MonsterId);
                        Monster       monster  = new Monster(template, group, template.RandomGrade(random));
                        group.AddMonster(monster);
                        break;
                    }
                }
            }

            if (quiet)
            {
                instance.AddQuietEntity(group);
            }
            else
            {
                instance.AddEntity(group);
            }
        }
        private ControlableMonsterFighter CreateSummon(CharacterFighter master)
        {
            MonsterRecord template = MonsterRecord.GetMonster(this.Effect.DiceMin);
            sbyte         gradeId  = (sbyte)(template.GradeExist(this.SpellLevel.Grade) ? this.SpellLevel.Grade : template.LastGrade().Id);

            return(new ControlableMonsterFighter(this.Source.Team, template, gradeId, master, this.CastPoint.CellId));
        }
Esempio n. 3
0
        public static SummonedFighter SummonFighter(MonsterRecord template, sbyte gradeId, Fighter source, MapPoint castPoint)
        {
            SummonedFighter fighter = new SummonedFighter(template, gradeId, source, source.Team, castPoint.CellId);

            source.Fight.AddSummon(fighter);
            return(fighter);
        }
Esempio n. 4
0
 private void Summon_AfterDeadEvt(Fighter summon, bool recursiveCall)
 {
     if (!summon.Fight.CheckFightEnd() && !recursiveCall)
     {
         Summon.SummonFighter(MonsterRecord.GetMonster(TREE_SPELLID), (summon as SummonedFighter).GradeId, this.Source, summon.Point);
     }
 }
Esempio n. 5
0
 public BrainFighter(FightTeam team, ushort mapCellId, MonsterRecord template, sbyte gradeId)
     : base(team, mapCellId)
 {
     this.Template = template;
     this.GradeId  = gradeId;
     this.Grade    = Template.GetGrade(this.GradeId);
 }
        public static void SpawnMonsters(DelayedAction action)
        {
            ushort[] monsterIds = Array.ConvertAll(action.Record.Value1.Split(','), x => ushort.Parse(x));

            MonsterRecord[] templates = new MonsterRecord[monsterIds.Length];

            for (int i = 0; i < monsterIds.Length; i++)
            {
                templates[i] = MonsterRecord.GetMonster(monsterIds[i]);
            }

            MapRecord targetedMap;

            if (action.Record.Value2 != string.Empty)
            {
                targetedMap = MapRecord.GetMap(int.Parse(action.Record.Value2));
            }
            else
            {
                targetedMap = MapRecord.RandomOutdoorMap();
            }

            if (!MonsterSpawnManager.Instance.GroupExist(targetedMap.Instance, templates))
            {
                MonsterSpawnManager.Instance.AddFixedMonsterGroup(targetedMap.Instance, templates, false);
            }
        }
        public static bool SpawnMonster(Character character, EffectDice effect)
        {
            MonsterRecord template = MonsterRecord.GetMonster(effect.Const);

            if (template != null && template.GradeExist((sbyte)effect.Min))
            {
                if (character.Map.Instance.MonsterGroupCount < MonsterSpawnManager.MaxMonsterGroupPerMap && MapNoSpawnRecord.AbleToSpawn(character.Map.Id))
                {
                    MonsterSpawnManager.Instance.AddFixedMonsterGroup(character.Map.Instance,
                                                                      new MonsterRecord[] { template },
                                                                      new sbyte[] { (sbyte)effect.Min },
                                                                      false);

                    return(true);
                }
                else
                {
                    character.ReplyError("Impossible de spawn le monstre ici...");

                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public static void MonsterFight(Character character, NpcReplyRecord reply)
        {
            List <MonsterRecord> templates = new List <MonsterRecord>();

            foreach (var monsterId in reply.Value1.FromCSV <ushort>())
            {
                templates.Add(MonsterRecord.GetMonster(monsterId));
            }

            List <MonsterRecord> allyTemplates = new List <MonsterRecord>();

            foreach (var monsterId in reply.Value2.FromCSV <ushort>())
            {
                allyTemplates.Add(MonsterRecord.GetMonster(monsterId));
            }

            FightInstancePvM fight = FightProvider.Instance.CreateFightInstancePvM(templates.ToArray(), character.Map);

            fight.RedTeam.AddFighter(character.CreateFighter(fight.RedTeam));

            var random = new AsyncRandom();

            foreach (var ally in allyTemplates)
            {
                fight.RedTeam.AddFighter(new MonsterFighter(fight.RedTeam, ally, ally.RandomGrade(random), character.CellId));
            }

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

            fight.StartPlacement();
        }
Esempio n. 9
0
        public override bool Apply(Fighter[] targets)
        {
            var template = MonsterRecord.GetMonster(Effect.DiceMin);

            SummonFighter(template, (sbyte)(template.GradeExist(SpellLevel.Grade) ? SpellLevel.Grade : template.LastGrade().Id),
                          Source, CastPoint);
            return(true);
        }
 public MonsterFighter(MonsterSpawnMapRecord spawn, FightTeam team)
     : base(team)
 {
     this.SpawnRecord  = spawn;
     this.Template     = MonsterRecord.GetMonster(SpawnRecord.MonsterId);
     this.ReadyToFight = true;
     this.Brain        = new MonsterBrain(this, Template.IAActions);
 }
Esempio n. 11
0
        public static void MinationCommand(string value, WorldClient client)
        {
            CharacterItemRecord mination = MinationLoot.CreateMinationItem(ItemRecord.GetItem(MinationLoot.MinationBossItemId),
                                                                           1,
                                                                           client.Character.Id,
                                                                           MonsterRecord.GetMonster(ushort.Parse(value)),
                                                                           1);

            client.Character.Inventory.AddItem(mination);
        }
Esempio n. 12
0
        public Barn(BrainFighter fighter)
            : base(fighter)
        {
            this.GradeRandomizer         = new AsyncRandom();
            fighter.Fight.FightStartEvt += Fight_FightStart;

            fighter.OnDamageTaken += fighter_OnDamageTaken;

            this.SummonedTemplate = MonsterRecord.GetMonster(SummonedMonsterId);
        }
Esempio n. 13
0
        public MonsterFighter AddSummon(Fighter master, short monsterid, sbyte grade, short cellid, FightTeam team)
        {
            MonsterFighter summoned = new MonsterFighter(MonsterRecord.GetMonster((ushort)monsterid),
              team, grade, cellid, master.ContextualId);
            if (summoned.Template.UseSummonSlot && !summoned.Template.UseBombSlot)
            TimeLine.Insert(summoned, master);
            Send(new GameActionFightSummonMessage(181, summoned.ContextualId, summoned.FighterInformations));
            Send(new GameFightTurnListMessage(TimeLine.GenerateTimeLine(false), new int[0]));
            return summoned;

        }
 public BombFighter(Fighter master, FightTeam team, MonsterRecord monsterTemplate, short cellid, sbyte grade) : base(team)
 {
     this.MonsterTemplate = monsterTemplate;
     this.ReadyToFight    = true;
     this.Team            = team;
     this.Team.AddBomb(this);
     this.Master = master;
     this.Grade  = grade;
     this.InitializeBomb(master.ContextualId, cellid);
     this.BombWallRecord = BombWallRecord.GetWallRecord(monsterTemplate.Id);
 }
Esempio n. 15
0
        public override void Execute()
        {
            var effect   = Level.Effects.First();
            var template = MonsterRecord.GetMonster(effect.DiceMin);

            this.SummonedTree = Summon.SummonFighter(template, (sbyte)(template.GradeExist(Level.Grade) ? Level.Grade : template.LastGrade().Id),
                                                     Source, CastPoint);

            SpellLevelRecord upgradeLevel = UpgradedTreeSpellRecord.GetLevel(Level.Grade);

            Source.OnTurnStartEvt += OnTurnStarted;
        }
Esempio n. 16
0
 /// <summary>
 /// For summons
 /// </summary>
 /// <param name="template"></param>
 /// <param name="team"></param>
 public MonsterFighter(MonsterRecord template, FightTeam team, sbyte grade, short cellid, int summonerid)
     : base(team)
 {
     this.Template = template;
     this.ReadyToFight = true;
     this.Brain = new MonsterBrain(this, Template.IAActions);
     this.SpawnRecord = new MonsterSpawnMapRecord(0, template.Id, -1, 0);
     this.SpawnRecord.ActualGrade = grade;
     this.Team = team;
     this.Team.AddSummon(this);
     InitializeSummon(summonerid, cellid);
 }
 /// <summary>
 /// For summons
 /// </summary>
 /// <param name="template"></param>
 /// <param name="team"></param>
 public MonsterFighter(MonsterRecord template, FightTeam team, sbyte grade, short cellid, int summonerid)
     : base(team)
 {
     this.Template                = template;
     this.ReadyToFight            = true;
     this.Brain                   = new MonsterBrain(this, Template.IAActions);
     this.SpawnRecord             = new MonsterSpawnMapRecord(0, template.Id, -1, 0);
     this.SpawnRecord.ActualGrade = grade;
     this.Team = team;
     this.Team.AddSummon(this);
     InitializeSummon(summonerid, cellid);
 }
Esempio n. 18
0
        public override bool Apply(Fighter[] targets)
        {
            MonsterRecord template = MonsterRecord.GetMonster(Effect.DiceMin);

            if (template != null && Source is CharacterFighter)
            {
                ExplosiveControlableMonster fighter = new ExplosiveControlableMonster(Source.Team, template, SpellLevel.Grade,
                                                                                      Source as CharacterFighter, CastPoint.CellId);
                Fight.AddSummon(fighter, (CharacterFighter)Source);
            }
            return(true);
        }
        public static void Followed(Character character, short delta)
        {
            var monsterTemplate = MonsterRecord.GetMonster((ushort)Math.Abs(delta));

            if (delta > 0)
            {
                character.AddFollower(monsterTemplate.Look);
            }
            else
            {
                character.RemoveFollower(monsterTemplate.Look);
            }
        }
Esempio n. 20
0
 public void AppendFight(Character character, int mapId, ushort[] monsterIds)
 {
     if (monsterIds.Length == 0)
     {
         throw new Exception("there must be one monster minimum in a PvMFight...");
     }
     MonsterRecord[] templates = new MonsterRecord[monsterIds.Length];
     for (int i = 0; i < monsterIds.Length; i++)
     {
         templates[i] = MonsterRecord.GetMonster(monsterIds[i]);
     }
     this.AppendFight(character, mapId, templates);
 }
Esempio n. 21
0
        public SummonedFighter Summon(Fighter source, ushort monsterId, short cellId)
        {
            SummonedFighter summon = this.CreateSummoned(source, MonsterRecord.GetMonster(monsterId), cellId);

            bool sequence = this.Fighter.Fight.SequencesManager.StartSequence(SequenceTypeEnum.SEQUENCE_SPELL);

            this.Fighter.Fight.AddSummon(summon);

            if (sequence)
            {
                this.Fighter.Fight.SequencesManager.EndSequence(SequenceTypeEnum.SEQUENCE_SPELL);
            }

            return(summon);
        }
Esempio n. 22
0
        public override bool Apply(Fighter[] targets)
        {
            var target = Fight.GetFighter(CastPoint);

            if (target != null)
            {
                SpellBombRecord record = SpellBombRecord.GetSpellBombRecord(SpellLevel.SpellId);
                var             level  = SpellRecord.GetSpellRecord(record.CibleExplosionSpellId).GetLevel(SpellLevel.Grade);
                Source.ForceSpellCast(level, CastPoint.CellId);
            }
            else
            {
                MonsterRecord record  = MonsterRecord.GetMonster(Effect.DiceMin);
                BombFighter   fighter = new BombFighter(record, Source, Source.Team, CastPoint.CellId, SpellLevel.Grade, SpellLevel);
                Fight.AddBomb(fighter, Source);
            }
            return(true);
        }
Esempio n. 23
0
        private static void RemoveDrop(WorldClient client, string[] args)
        {
            if (args.Length < 2)
            {
                client.Character.Reply("Remove a drop from a monster");
                client.Character.Reply("» .drops rmdrop|rm|rd $ItemId $MonsterId");
                client.Character.Reply("- <b>$ItemId</b> ⇒ The ID of the item.");
                client.Character.Reply("- <b>$MonsterId</b> ⇒ The ID of the monster.");
                return;
            }

            ushort     itemId = ushort.Parse(args[1]);
            ItemRecord item   = ItemRecord.GetItem(itemId);

            if (args.Length != 3)
            {
                int count = 0;
                foreach (MonsterRecord monster in MonsterRecord.Monsters)
                {
                    MonsterDrop drop = monster.Drops.Find(d => d.ItemId == itemId);
                    if (drop != null)
                    {
                        monster.Drops.Remove(drop);
                        count++;
                        client.Character.Reply($" - Removed drop from monster {monster.Name} ({monster.Id}).");

                        monster.UpdateInstantElement();
                    }
                }

                client.Character.Reply($"Removed drop '{item.Name}' ({item.Id}) from {count} monsters.");
            }
            else
            {
                ushort monsterId = ushort.Parse(args[2]);

                MonsterRecord monsterRecord = MonsterRecord.GetMonster(monsterId);
                monsterRecord.Drops.RemoveAll(d => d.ItemId == itemId);

                monsterRecord.UpdateInstantElement();

                client.Character.Reply($"Successfully removed drop '{item.Name}' ({item.Id}) from monster '{monsterRecord.Name}' {monsterId}");
            }
        }
Esempio n. 24
0
        public static GameRolePlayGroupMonsterInformations GetActorInformations(MapRecord map, MonsterGroup group)
        {
            var random               = new AsyncRandom();
            var firstMonster         = group.Monsters[0];
            var firstMonsterTemplate = MonsterRecord.GetMonster(firstMonster.MonsterId);
            var light = new MonsterInGroupLightInformations(firstMonsterTemplate.Id, (sbyte)random.Next(1, 6));
            List <MonsterInGroupInformations> monstersinGroup = new List <MonsterInGroupInformations>();

            for (int i = 1; i < group.Monsters.Count; i++)
            {
                var mob      = group.Monsters[i];
                var template = MonsterRecord.GetMonster(mob.MonsterId);
                monstersinGroup.Add(new MonsterInGroupInformations(mob.MonsterId, mob.ActualGrade, template.RealLook.ToEntityLook()));
            }
            var staticInfos = new GroupMonsterStaticInformations(light, monstersinGroup);

            return(new GameRolePlayGroupMonsterInformations(group.MonsterGroupId, firstMonsterTemplate.RealLook.ToEntityLook(),
                                                            new EntityDispositionInformations((short)group.CellId, 3), false, false, false, staticInfos, group.AgeBonus, 0, 0));
        }
Esempio n. 25
0
        static void AddDrop(ushort monsterId, ushort itemId, int dropPercent)
        {
            var monster = MonsterRecord.GetMonster(monsterId);

            var drop = new MonsterDrop()
            {
                ItemId               = itemId,
                Count                = 1,
                DropId               = 0,
                DropLimit            = 1,
                HasCriteria          = false,
                PercentDropForGrade1 = (short)(dropPercent),
                PercentDropForGrade2 = (short)(dropPercent + 2),
                PercentDropForGrade3 = (short)(dropPercent + 4),
                PercentDropForGrade4 = (short)(dropPercent + 6),
                PercentDropForGrade5 = (short)(dropPercent + 8),
                ProspectingLock      = 100
            };

            monster.Drops.Add(drop);
        }
Esempio n. 26
0
 public BombFighter(MonsterRecord template, Fighter owner, FightTeam team, short summonCellId, sbyte gradeId, SpellLevelRecord summonSpellLevel)
     : base(team, 0)
 {
     this.Owner                 = owner;
     this.Template              = template;
     this.GradeId               = gradeId;
     this.Grade                 = Template.GetGrade(gradeId);
     this.SummonCellId          = summonCellId;
     this.BeforeSlideEvt       += BombFighter_BeforeSlideEvt;
     this.Owner.OnTurnStartEvt += OnOwnerTurnStart;
     this.AfterSlideEvt        += BombFighter_OnSlideEvt;
     this.OnTeleportEvt        += BombFighter_OnTeleportEvt;
     this.AfterDeadEvt         += BombFighter_AfterDeadEvt;
     this.OnDamageTaken        += BombFighter_OnDamageTaken;
     this.BeforeDeadEvt        += BombFighter_OnDeadEvt;
     this.Walls                 = new List <Wall>();
     this.SummonSpellLevel      = summonSpellLevel;
     this.SpellBombRecord       = SpellBombRecord.GetSpellBombRecord(summonSpellLevel.SpellId);
     this.WallSpellLevel        = SpellRecord.GetSpellRecord(SpellBombRecord.WallSpellId).GetLevel(GradeId);
     this.BuffTurnCount         = BUFF_TURN_COUNT;
 }
Esempio n. 27
0
        private static void UpdateDrop(WorldClient client, string[] args)
        {
            if (args.Length < 6)
            {
                client.Character.Reply("Add a drop to a set of monsters");
                client.Character.Reply("» .drops updatedrop|ud $ItemId $MonsterId $DropRate $MinPP $MinCount $MaxCount");
                client.Character.Reply(" - <b>$ItemId</b> ⇒ The ID of the item.");
                client.Character.Reply(" - <b>$MonsterId</b> ⇒ The ID of the item.");
                client.Character.Reply(" - <b>$DropRate</b> ⇒ The drop percent [0, 100].");
                client.Character.Reply(" - <b>$MinPP</b> ⇒ The min PP value0.");
                client.Character.Reply(" - <b>$MinCount</b> ⇒ Minimum number of dropped items.");
                client.Character.Reply(" - <b>$MaxCount</b> ⇒ Maximum number of dropped items.");

                return;
            }

            ushort itemId    = ushort.Parse(args[1]);
            ushort monsterId = ushort.Parse(args[2]);
            short  dropRate  = short.Parse(args[3]);
            int    pp        = int.Parse(args[4]);
            int    minCount  = int.Parse(args[5]);
            int    maxCount  = int.Parse(args[6]);

            ItemRecord    item          = ItemRecord.GetItem(itemId);
            MonsterRecord monsterRecord = MonsterRecord.GetMonster(monsterId);
            MonsterDrop   monsterDrop   = monsterRecord.Drops.Find(d => d.ItemId == itemId);

            monsterDrop.PercentDropForGrade1 = dropRate;
            monsterDrop.PercentDropForGrade2 = (short)(dropRate + 2);
            monsterDrop.PercentDropForGrade3 = (short)(dropRate + 4);
            monsterDrop.PercentDropForGrade4 = (short)(dropRate + 6);
            monsterDrop.PercentDropForGrade5 = (short)(dropRate + 8);
            monsterDrop.Count           = minCount;
            monsterDrop.DropLimit       = maxCount;
            monsterDrop.ProspectingLock = pp;

            monsterRecord.UpdateInstantElement();

            client.Character.Reply($"Successfully removed drop '{item.Name}' ({item.Id}) from monster '{monsterRecord.Name}' {monsterId}");
        }
        public ControlableMonsterFighter(FightTeam team, MonsterRecord template, sbyte gradeId, CharacterFighter owner,
                                         short summonCellId)
            : base(team, 0)
        {
            this.Template = template;
            this.GradeId  = gradeId;
            this.Owner    = owner;
            this.Owner.OnLeavePreFightEvt += Owner_OnLeavePreFight;
            this.Owner.OnTurnEndEvt       += Owner_TurnEnd;
            this.OnTurnEndEvt             += ControlableMonsterFighter_TurnEnd;
            this.AfterDeadEvt             += ControlableMonsterFighter_OnDead;
            this.SummonCellId              = summonCellId;
            this.Spells = Array.ConvertAll(template.SpellRecords.ToArray(), x => new CharacterSpell(x.Id, x.GetLastLevelGrade()));

            this.Shortcuts = new ShortcutSpell[Spells.Length];

            for (int i = 0; i < Spells.Length; i++)
            {
                Shortcuts[i] = new ShortcutSpell((sbyte)i, Spells[i].SpellId);
            }
            this.IsReady = true;
        }
        public static void MonstersSub(DelayedAction action)
        {
            ushort[] monsterIds = Array.ConvertAll(action.Record.Value1.Split(','), x => ushort.Parse(x));

            MonsterRecord[] templates = new MonsterRecord[monsterIds.Length];

            for (int i = 0; i < monsterIds.Length; i++)
            {
                templates[i] = MonsterRecord.GetMonster(monsterIds[i]);
            }

            if (action.Value != null)
            {
                MapRecord map = (MapRecord)action.Value;
                if (MonsterSpawnManager.Instance.GroupExist(map.Instance, templates))
                {
                    MonsterSpawnManager.Instance.RemoveGroup(map.Instance, templates);
                }
            }

            MapRecord targetedMap;

            int subAreaId = int.Parse(action.Record.Value2);

            var maps = MapRecord.GetSubAreaMaps(subAreaId).ConvertAll <MapRecord>(x => MapRecord.GetMap(x)).FindAll(w => !MonsterSpawnManager.Instance.GroupExist(w.Instance, templates));

            if (maps.Count > 0)
            {
                targetedMap = maps.Random();

                MonsterSpawnManager.Instance.AddFixedMonsterGroup(targetedMap.Instance, templates, false);


                action.Value = targetedMap;
            }
        }
Esempio n. 30
0
 public MinationMonsterFighter(FightTeam team, MonsterRecord template, sbyte gradeId, ushort minationLevel, CharacterFighter owner, short summonCellId) : base(team, template, gradeId, owner, summonCellId)
 {
     this.MinationLevel = minationLevel;
 }
Esempio n. 31
0
 public MonsterFighter(FightTeam team, MonsterRecord template, sbyte gradeId, ushort mapCellId)
     : base(
         team, mapCellId, template, gradeId)
 {
 }