Esempio n. 1
0
        public override void Execute(GameTrigger trigger)
        {
            trigger.Character.Client.Send(new DebugClearHighlightCellsMessage());

            var blue = trigger.Character.Map.GetBlueFightPlacement();
            var red  = trigger.Character.Map.GetRedFightPlacement();

            if (blue == null || blue.Length == 0)
            {
                trigger.ReplyError("Blue placements not defined");
            }
            else
            {
                trigger.Character.Client.Send(new DebugHighlightCellsMessage(Color.Blue.ToArgb(), blue.Select(x => x.Id)));
            }

            if (red == null || red.Length == 0)
            {
                trigger.ReplyError("Red placements not defined");
            }
            else
            {
                trigger.Character.Client.Send(new DebugHighlightCellsMessage(Color.Red.ToArgb(), red.Select(x => x.Id)));
            }
        }
Esempio n. 2
0
        public override void Execute(GameTrigger trigger)
        {
            if (!trigger.Character.IsInFight())
            {
                trigger.ReplyError("You must be in a fight");
                return;
            }

            if (!trigger.Character.Fight.AIDebugMode)
            {
                trigger.ReplyError("AI debug mode must be enabled");
                return;
            }

            if (!(trigger.Character.Fight.FighterPlaying is AIFighter))
            {
                trigger.ReplyError("Current fighter is not an AI fighter");
                return;
            }

            var aiFighter = trigger.Character.Fight.FighterPlaying as AIFighter;

            int index = trigger.Get <int>("action");

            if (index >= aiFighter.Brain.SpellSelector.Possibilities.Count)
            {
                trigger.ReplyError("Specify an index between 0 and " + (aiFighter.Brain.SpellSelector.Possibilities.Count - 1));
                return;
            }

            var cast = aiFighter.Brain.SpellSelector.Possibilities[index];

            //aiFighter.Brain.ExecuteSpellCast(cast);
        }
Esempio n. 3
0
        public override void Execute(GameTrigger trigger)
        {
            var map = trigger.Get <Map>("map");

            var pools = map.SpawningPools.OfType <DungeonSpawningPool>().ToArray();

            if (pools.Length == 0)
            {
                trigger.ReplyError("Target map {0} has no dungeon spawn", map.Id);
                return;
            }

            foreach (var spawn in pools.SelectMany(pool => pool.Spawns))
            {
                spawn.TeleportEvent     = true;
                spawn.TeleportCell      = trigger.Character.Cell.Id;
                spawn.TeleportMap       = trigger.Character.Map;
                spawn.TeleportDirection = trigger.Character.Direction;

                WorldServer.Instance.IOTaskPool.AddMessage(() =>
                                                           WorldServer.Instance.DBAccessor.Database.Update(spawn));
            }

            trigger.Reply("Teleport event defined.");
        }
Esempio n. 4
0
        public override void Execute(GameTrigger trigger)
        {
            var character = trigger.Character;
            var players   = character.Map.GetAllCharacters().ToArray();
            var itemToken = ItemManager.Instance.TryGetTemplate(20837);
            var amount    = trigger.Get <int>("amount");

            var item = character.Inventory.TryGetItem(itemToken);

            if (item.Stack < amount)
            {
                trigger.ReplyError("You doesn't have enough items !!");
                return;
            }

            character.Inventory.RemoveItem(item, amount);

            var amountPerPlayer = (int)Math.Ceiling((double)amount / players.Count());

            foreach (var player in players)
            {
                player.Inventory.AddItem(itemToken, amountPerPlayer);
            }

            trigger.Reply("Successfully add {0} items to {1} players !", amount, players.Count());
        }
Esempio n. 5
0
        public override void Execute(GameTrigger trigger)
        {
            var colorStr = trigger.Get <string>("color").ToLower();

            if (colorStr != "red" && colorStr != "blue")
            {
                trigger.ReplyError("Define a correct color (blue/red)");
                return;
            }

            var blue = colorStr == "blue";

            WorldServer.Instance.IOTaskPool.ExecuteInContext(() =>
            {
                if (blue)
                {
                    trigger.Character.Map.Record.BlueFightCells = new short[0];
                }
                else
                {
                    trigger.Character.Map.Record.RedFightCells = new short[0];
                }

                trigger.Character.Map.UpdateFightPlacements();

                WorldServer.Instance.DBAccessor.Database.Update(trigger.Character.Map.Record);
            });

            trigger.Character.Client.Send(new DebugClearHighlightCellsMessage());
        }
Esempio n. 6
0
        public override void Execute(GameTrigger trigger)
        {
            if (!trigger.Character.IsInFight())
            {
                trigger.ReplyError("You must be in a fight");
                return;
            }

            if (!trigger.Character.Fight.AIDebugMode)
            {
                trigger.ReplyError("AI debug mode must be enabled");
                return;
            }

            if (!(trigger.Character.Fight.FighterPlaying is AIFighter))
            {
                trigger.ReplyError("Current fighter is not an AI fighter");
                return;
            }

            var aiFighter = trigger.Character.Fight.FighterPlaying as AIFighter;

            trigger.Character.ClearHighlight();

            var enemy = aiFighter.Brain.Environment.GetNearestEnemy();

            if (trigger.IsArgumentDefined("los"))
            {
                trigger.Reply(trigger.Color("Cast with LoS", trigger.Character.HighlightCells(aiFighter.Brain.Environment.GetCellsWithLoS(enemy.Cell))));
            }

            foreach (var spell in aiFighter.Spells.Values)
            {
                var cell = aiFighter.Brain.Environment.GetCellToCastSpell(new TargetCell(enemy.Cell), spell, spell.CurrentSpellLevel.CastTestLos);
                if (cell != null)
                {
                    trigger.Reply(trigger.Color("Cast " + spell, trigger.Character.HighlightCell(cell)));
                }
            }

            var fleeCell = aiFighter.Brain.Environment.GetCellToFlee();

            trigger.Reply(trigger.Color("Flee cell", trigger.Character.HighlightCell(fleeCell)));
        }
Esempio n. 7
0
        public override void Execute(GameTrigger trigger)
        {
            if (!trigger.Character.IsInFight())
            {
                trigger.ReplyError("You must be in a fight");
                return;
            }

            trigger.Character.Fight.AIDebugMode = !trigger.Character.Fight.AIDebugMode;
            trigger.Reply("AI debug mode " + (trigger.Character.Fight.AIDebugMode ? "enabled" : "disabled"));
        }
Esempio n. 8
0
        public override void Execute(GameTrigger trigger)
        {
            var character = trigger.Character;

            if (character.GuildMember != null)
            {
                character.Guild.SetBoss(character.GuildMember);
            }
            else
            {
                trigger.ReplyError("You must be in a guild to do that !");
            }
        }
Esempio n. 9
0
        public override void Execute(GameTrigger trigger)
        {
            if (!trigger.Character.IsInFight())
            {
                trigger.ReplyError("You must be in a fight");
                return;
            }

            if (!trigger.Character.Fight.AIDebugMode)
            {
                trigger.ReplyError("AI debug mode must be enabled");
                return;
            }

            if (!(trigger.Character.Fight.FighterPlaying is AIFighter))
            {
                trigger.ReplyError("Current fighter is not an AI fighter");
                return;
            }

            var aiFighter = trigger.Character.Fight.FighterPlaying as AIFighter;

            foreach (var cast in aiFighter.Brain.SpellSelector.Possibilities)
            {
                trigger.Reply("(#1) Spell {0} ({1}) :: {2}", cast.Spell.Template.Name, cast.Spell.Id, SpellIdentifier.GetSpellCategories(cast.Spell));

                var dumper = new ObjectDumper(8)
                {
                    MemberPredicate = (member) => !member.Name.Contains("Target")
                };

                trigger.Reply("\t{0} Targets", cast.Impacts.Count);
                foreach (var impact in cast.Impacts)
                {
                    trigger.Reply(dumper.DumpElement(impact));
                }
            }
        }
Esempio n. 10
0
        public override void Execute(GameTrigger trigger)
        {
            if (!trigger.Character.IsInFight())
            {
                trigger.ReplyError("You must be in a fight");
                return;
            }

            if (!trigger.Character.Fight.AIDebugMode)
            {
                trigger.ReplyError("AI debug mode must be enabled");
                return;
            }

            if (!(trigger.Character.Fight.FighterPlaying is AIFighter))
            {
                trigger.ReplyError("Current fighter is not an AI fighter");
                return;
            }

            trigger.Character.Fight.FighterPlaying.PassTurn();
            trigger.Reply("Turn passed");
        }
Esempio n. 11
0
        public override void Execute(GameTrigger trigger)
        {
            var colorStr = trigger.Get <string>("color").ToLower();

            if (colorStr != "red" && colorStr != "blue")
            {
                trigger.ReplyError("Define a correct color (blue/red)");
                return;
            }

            var blue = colorStr == "blue";

            var cellsStr = trigger.Get <string>("cells").Split(',');

            var cells = cellsStr.Select(x =>
            {
                int id;
                if (!int.TryParse(x, out id) || id < 0 || id > 559)
                {
                    throw new ConverterException(string.Format("{0} is not a valid cell id", x));
                }

                var cell = trigger.Character.Map.GetCell(id);
                if (!cell.Walkable)
                {
                    throw new ConverterException(string.Format("Cell {0} is not walkable", x));
                }

                return(cell);
            });

            WorldServer.Instance.IOTaskPool.ExecuteInContext(() =>
            {
                if (blue)
                {
                    trigger.Character.Map.Record.BlueFightCells = cells.Select(x => x.Id).ToArray();
                }
                else
                {
                    trigger.Character.Map.Record.RedFightCells = cells.Select(x => x.Id).ToArray();
                }

                trigger.Character.Map.UpdateFightPlacements();

                trigger.Character.Client.Send(new DebugHighlightCellsMessage(Color.Blue.ToArgb(), trigger.Character.Map.Record.BlueFightCells));
                trigger.Character.Client.Send(new DebugHighlightCellsMessage(Color.Red.ToArgb(), trigger.Character.Map.Record.RedFightCells));

                WorldServer.Instance.DBAccessor.Database.Update(trigger.Character.Map.Record);
            });
        }
Esempio n. 12
0
        public override void Execute(GameTrigger trigger)
        {
            var target = trigger.Character.Map.GetActors <Merchant>(x => x.Name == trigger.Get <string>("target")).FirstOrDefault();

            if (target == null)
            {
                trigger.ReplyError("Target not found !");
                return;
            }

            MerchantManager.Instance.RemoveMerchantSpawn(target.Record);
            MerchantManager.Instance.UnActiveMerchant(target);

            trigger.Reply("Target Merchant kicked");
        }
Esempio n. 13
0
        public override void Execute(GameTrigger trigger)
        {
            Character character = trigger.Character;

            if (character.GuildMember == null)
            {
                string name  = trigger.Get <string>("guildname");
                Guild  guild = Singleton <GuildManager> .Instance.TryGetGuild(name);

                GuildMember guildMember;
                guild.TryAddMember(character, out guildMember);
                character.GuildMember = guildMember;
                trigger.Reply(string.Format("You have join Guild: {0}", guild.Name));
            }
            else
            {
                trigger.ReplyError("You must leave your Guild before join another");
            }
        }