Exemplo n.º 1
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);
            });
        }
Exemplo n.º 2
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.");
        }
Exemplo n.º 3
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);
        }
Exemplo 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());
        }
Exemplo 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());
        }
Exemplo n.º 6
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");
        }
Exemplo n.º 7
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");
            }
        }