/// <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); } }
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 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(); }
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); } }
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)); }
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); } }
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); }
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); }
public Barn(BrainFighter fighter) : base(fighter) { this.GradeRandomizer = new AsyncRandom(); fighter.Fight.FightStartEvt += Fight_FightStart; fighter.OnDamageTaken += fighter_OnDamageTaken; this.SummonedTemplate = MonsterRecord.GetMonster(SummonedMonsterId); }
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 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; }
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); } }
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); }
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); }
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); }
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}"); } }
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)); }
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); }
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 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; } }
// [StartupInvoke("Monster Spawns Module",StartupInvokePriority.Modules)] public static void SyncMonstersSpawns() { foreach (var subarea in SubareaRecord.Subareas) { foreach (var monster in subarea.Monsters) { sbyte probability = 0; var template = MonsterRecord.GetMonster(monster); switch ((MonsterRaceEnum)template.Race) { case MonsterRaceEnum.Boss: probability = 2; break; case MonsterRaceEnum.NPCs: probability = 3; break; case MonsterRaceEnum.TerritoryQuestMonsters: probability = 3; break; case MonsterRaceEnum.TutorialMonsters: probability = 3; break; case MonsterRaceEnum.Wanted: probability = 3; break; case MonsterRaceEnum.QuestMonsters: probability = 3; break; case MonsterRaceEnum.KwismasMonsters: probability = 5; break; case MonsterRaceEnum.Archmonsters: probability = 3; break; case MonsterRaceEnum.FrigostWantedMonsters: probability = 2; break; case MonsterRaceEnum.FrigostQuestMonsters: probability = 2; break; case MonsterRaceEnum.TESTTest: probability = 1; break; case MonsterRaceEnum.Undefined: probability = 1; break; case MonsterRaceEnum.OldVersions: probability = 10; break; case MonsterRaceEnum.MonstersfromVulkaniaQuest: probability = 2; break; case MonsterRaceEnum.MonstersfromNowelQuest: probability = 2; break; case MonsterRaceEnum.Undefined2: probability = 1; break; case MonsterRaceEnum.Undefined3: probability = 1; break; case MonsterRaceEnum.MonstersfromAlignQuests: probability = 5; break; case MonsterRaceEnum.IncarnamQuestMonsters: probability = 20; break; default: probability = 100; break; } int id = (int)MonsterSpawnRecord.MonsterSpawns.DynamicPop(x => x.Id); new MonsterSpawnRecord(id, monster, subarea.Id, probability).AddInstantElement(); } logger.White("Subarea: " + subarea.Name + " fixed!"); } }
private static void AddDrop(WorldClient client, string[] args) { if (args.Length < 4) { client.Character.Reply("Add a drop to a set of monsters"); client.Character.Reply("» .drops adddrop|ad $ItemId $DropRateG1[,$G2,$G3,G4,G5] $MinPP $MinCount $MaxCount [$MonsterId ...]"); client.Character.Reply(" - <b>$ItemId</b> ⇒ The ID of the item."); client.Character.Reply(" - <b>$DropRateG1</b> ⇒ The drop percent [0, 100]. "); client.Character.Reply(" - <b>$G2,3,4,5</b> ⇒ The drop percent [0, 100] for each grade. "); 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."); client.Character.Reply(" - <b>$MonsterId</b> ⇒ The ID of the monster."); return; } ushort itemId = ushort.Parse(args[1]); string rates = args[2]; int pp = int.Parse(args[3]); int minCount = int.Parse(args[4]); int maxCount = int.Parse(args[5]); string[] ratesSplit = rates.Split(','); short g1 = short.Parse(ratesSplit[0]); short g2 = (short)(g1 + 2); short g3 = (short)(g1 + 4); short g4 = (short)(g1 + 6); short g5 = (short)(g1 + 8); if (ratesSplit.Length == 5) { g2 = short.Parse(ratesSplit[1]); g3 = short.Parse(ratesSplit[2]); g4 = short.Parse(ratesSplit[3]); g5 = short.Parse(ratesSplit[4]); } ItemRecord item = ItemRecord.GetItem(itemId); int nextDropId = MonsterRecord.GetNextDropId(); for (int i = 6; i < args.Length; i++) { ushort monsterId = ushort.Parse(args[i]); MonsterRecord monster = MonsterRecord.GetMonster(monsterId); MonsterDrop drop = new MonsterDrop() { ItemId = itemId, Count = minCount, DropId = nextDropId, DropLimit = maxCount, HasCriteria = false, PercentDropForGrade1 = g1, PercentDropForGrade2 = g2, PercentDropForGrade3 = g3, PercentDropForGrade4 = g4, PercentDropForGrade5 = g5, ProspectingLock = pp }; monster.Drops.Add(drop); // TODO: check if necessary. monster.UpdateInstantElement(); client.Character.Reply($"Added drop '{item.Name}' ({itemId}) to monster '{monster.Name}' ({monsterId}) with drop rates {g1},{g2},{g3},{g4},{g5} (DropId={nextDropId})."); nextDropId++; } }
public async void fight(short monsterId) { var action = new Action(() => { var newFight = FightProvider.Instance.CreateFreeFightInstancePvM(new MonsterRecord[] { MonsterRecord.GetMonster((ushort)monsterId) }, Character.Map); FightTeam characterTeam = newFight.GetTeam(TeamTypeEnum.TEAM_TYPE_PLAYER); FightTeam monsterTeam = newFight.GetTeam(TeamTypeEnum.TEAM_TYPE_MONSTER); characterTeam.AddFighter(Character.CreateFighter(characterTeam)); foreach (var monster in newFight.Group.CreateFighters(monsterTeam)) { monsterTeam.AddFighter(monster); } }); await Execute(action); }
public void SpawnBomb(Fighter master,short templateid,sbyte grade,short cellid,FightTeam team) { BombFighter bomb = new BombFighter(master,team,MonsterRecord.GetMonster((ushort)templateid),cellid,grade); Send(new GameActionFightSummonMessage(181,bomb.ContextualId,bomb.FighterInformations)); bomb.CheckWalls(); }
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(); }
public MonsterRecord GetTemplate() { return(MonsterRecord.GetMonster(this.MonsterId)); }