Beispiel #1
0
        public static void LoadSpawns()
        {
            var sw = Stopwatch.StartNew();

            using (var db = new SquigglyContext())
            {
                short counter = 0;
                foreach (var cqSpawn in db.cq_generator.AsQueryable())
                {
                    var spawn = new Spawn
                    {
                        MapId        = cqSpawn.mapid,
                        MobId        = cqSpawn.npctype,
                        BornX        = cqSpawn.born_x,
                        BornY        = cqSpawn.born_y,
                        TimerBegin   = cqSpawn.timer_begin,
                        TimerEnd     = cqSpawn.timer_end,
                        MaxAmount    = cqSpawn.maxnpc,
                        Xstart       = cqSpawn.bound_x,
                        Ystart       = cqSpawn.bound_y,
                        Xend         = cqSpawn.bound_cx,
                        Yend         = cqSpawn.bound_cy,
                        RespawnDelay = cqSpawn.rest_secs,
                        Amount       = cqSpawn.max_per_gen
                    };
                    if (!Collections.Spawns.ContainsKey(counter))
                    {
                        Collections.Spawns.TryAdd(counter, spawn);
                    }
                    counter++;
                }
            }
            sw.Stop();
            Debug.WriteLine($"[SquigglyLite] Loaded {Collections.Spawns.Count}\t Spawns in {sw.Elapsed.TotalMilliseconds}ms");
        }
Beispiel #2
0
        public static cq_portal FindPortal(int portalId, ushort mapid)
        {
            using (var db = new SquigglyContext())
            {
                cq_passway target = null;
                foreach (var cqPassway in db.cq_passway)
                {
                    if (cqPassway.mapid != mapid)
                    {
                        continue;
                    }

                    if (cqPassway.passway_idx == portalId)
                    {
                        target = cqPassway;
                    }
                }

                cq_portal portal = null;
                foreach (var cqportal in db.cq_portal)
                {
                    if (cqportal.mapid != target.passway_mapid)
                    {
                        continue;
                    }
                    if (cqportal.portal_idx == target.passway_mapportal)
                    {
                        portal = cqportal;
                    }
                }

                return(portal);
            }
        }
Beispiel #3
0
 public static void ExecuteAction(Monster target, YiObj attacker)
 {
     using (var db = new SquigglyContext())
     {
         var cqaction = db.cq_action.Find((long)target.CQAction);
         Process(target, attacker, cqaction, db);
     }
 }
Beispiel #4
0
        public static void LoadMobs()
        {
            var sw = Stopwatch.StartNew();

            using (var db = new SquigglyContext())
            {
                foreach (var cqMob in db.cq_monstertype.AsQueryable())
                {
                    var mob = new Monster
                    {
                        Id                    = cqMob.id,
                        Name                  = cqMob.name.Trim(),
                        Look                  = cqMob.lookface,
                        MaximumHp             = cqMob.life,
                        CurrentHp             = cqMob.life,
                        MaximumPhsyicalAttack = cqMob.attack_max,
                        MinimumPhsyicalAttack = cqMob.attack_min,
                        Defense               = cqMob.defence,
                        Dexterity             = cqMob.dexterity,
                        Dodge                 = cqMob.dodge,
                        Drops                 = new Drops
                        {
                            Armet    = cqMob.drop_armet,
                            Armor    = cqMob.drop_armor,
                            Weapon   = cqMob.drop_weapon,
                            Hp       = cqMob.drop_hp,
                            Mp       = cqMob.drop_mp,
                            ItemType = cqMob.drop_itemtype,
                            Money    = cqMob.drop_money,
                            Necklace = cqMob.drop_necklace,
                            Ring     = cqMob.drop_ring,
                            Shield   = cqMob.drop_shield,
                            Shoes    = cqMob.drop_shoes
                        },
                        AttackRange  = cqMob.attack_range,
                        ViewRange    = cqMob.view_range,
                        EscapeLife   = cqMob.escape_life,
                        AttackSpeed  = cqMob.attack_speed,
                        WalkSpeed    = cqMob.move_speed,
                        RunSpeed     = cqMob.run_speed,
                        Level        = cqMob.level,
                        AttackUser   = cqMob.attack_user,
                        CQAction     = cqMob.action,
                        MagicType    = cqMob.magic_type,
                        MagicDefense = cqMob.magic_def,
                        MagicHitRate = cqMob.magic_hitrate,
                        AIType       = cqMob.ai_type,
                    };
                    if (Collections.BaseMonsters.ContainsKey(mob.Id))
                    {
                        continue;
                    }
                    Collections.BaseMonsters.Add(mob.Id, mob);
                }
            }
            sw.Stop();
            Debug.WriteLine($"[SquigglyLite] Loaded {Collections.BaseMonsters.Count}\t BaseMonsters in {sw.Elapsed.TotalMilliseconds}ms");
        }
Beispiel #5
0
        public static void LoadItemBonus()
        {
            var sw = Stopwatch.StartNew();

            using (var db = new SquigglyContext())
            {
                foreach (var cqItemAdd in db.cq_itemaddition.AsQueryable())
                {
                    Collections.ItemBonus.Add(cqItemAdd.id, cqItemAdd);
                }
            }
            sw.Stop();
            Debug.WriteLine($"[SquigglyLite] Loaded {Collections.ItemBonus.Count}\t Item Bonus Stats in {sw.Elapsed.TotalMilliseconds}ms");
        }
Beispiel #6
0
 public static void ExecuteAction(Npc target, Player attacker, long task = 0)
 {
     using (var db = new SquigglyContext())
     {
         if (task == 0)
         {
             var cqtask   = db.cq_task.Find(target.Task0);
             var cqaction = db.cq_action.Find(cqtask.id_next);
             Process(target, attacker, cqaction, db);
         }
         else
         {
             var cqtask   = db.cq_task.Find(task);
             var cqaction = db.cq_action.Find(cqtask.id_next);
             Process(target, attacker, cqaction, db);
         }
     }
 }
Beispiel #7
0
        public static void LoadNpcs()
        {
            var sw = Stopwatch.StartNew();

            using (var db = new SquigglyContext())
            {
                foreach (var cqNpc in db.cq_npc.AsQueryable())
                {
                    if (!GameWorld.Maps.ContainsKey(cqNpc.mapid))
                    {
                        continue;
                    }
                    var npc = new Npc
                    {
                        UniqueId = (int)cqNpc.id,
                        Location =
                        {
                            X = cqNpc.cellx,
                            Y = cqNpc.celly
                        },
                        MapId = cqNpc.mapid,
                        Sort  = cqNpc.sort,
                        Base  = cqNpc.@base,
                        Type  = cqNpc.type,
                        Look  = cqNpc.lookface,
                        Name  = cqNpc.name.Trim(),
                        Task0 = cqNpc.task0,
                        Task1 = cqNpc.task1,
                        Task2 = cqNpc.task2,
                        Task3 = cqNpc.task3,
                        Task4 = cqNpc.task4,
                        Task5 = cqNpc.task5,
                        Task6 = cqNpc.task6,
                        Task7 = cqNpc.task7,
                    };

                    Collections.Npcs.Add(npc.UniqueId, npc);

                    GameWorld.Maps[npc.MapId].LoadInEntity(npc);
                }
            }
            sw.Stop();
            Debug.WriteLine($"[SquigglyLite] Loaded {Collections.Npcs.Count}\t Npcs in {sw.Elapsed.TotalMilliseconds}ms");
        }
Beispiel #8
0
        public static void LoadLevelExp()
        {
            var sw = Stopwatch.StartNew();

            using (var db = new SquigglyContext())
            {
                foreach (var cqLvlExp in db.cq_levexp.AsQueryable())
                {
                    var lvlExp = new LevelExp
                    {
                        AllLevTime = cqLvlExp.up_lev_time,
                        ExpReq     = cqLvlExp.exp
                    };
                    Collections.LevelExps.Add((int)cqLvlExp.level, lvlExp);
                }
            }
            sw.Stop();
            Debug.WriteLine($"[SquigglyLite] Loaded {Collections.LevelExps.Count}\t LevelExps in {sw.Elapsed.TotalMilliseconds}ms");
        }
Beispiel #9
0
        public static void LoadMaps()
        {
            var sw = Stopwatch.StartNew();

            using (var db = new SquigglyContext())
            {
                foreach (var cqmap in db.cq_map.AsQueryable())
                {
                    var map = new Map
                    {
                        Id              = (ushort)cqmap.id,
                        MapDocId        = (ushort)cqmap.mapdoc,
                        Flags           = (MapFlags)cqmap.type,
                        Name            = cqmap.name.Trim(),
                        RespawnLocation = new Tuple <ushort, ushort, ushort>((ushort)cqmap.portal0_x, (ushort)cqmap.portal0_y, (ushort)cqmap.reborn_map),
                        Width           = cqmap.Width,
                        Height          = cqmap.Height,
                    };
                    if (cqmap.DMAP != null)
                    {
                        MapAccess.MapData.AddOrUpdate((ushort)cqmap.mapdoc, new MapAccess(cqmap.DMAP));
                    }
                    GameWorld.Maps.Add((ushort)cqmap.id, map);
                }
                foreach (var dportal in db.Dmap_Portals)
                {
                    if (GameWorld.Maps.ContainsKey(dportal.MapId))
                    {
                        var passageInfo = new Portal
                        {
                            IdX = dportal.PortalId,
                            X   = dportal.X,
                            Y   = dportal.Y
                        };

                        GameWorld.Maps[dportal.MapId].Portals.Add(dportal.PortalId, passageInfo);
                    }
                }
            }

            sw.Stop();
            Debug.WriteLine($"[SquigglyLite] Loaded {GameWorld.Maps.Count}\t Maps in {sw.Elapsed.TotalMilliseconds}ms");
        }
Beispiel #10
0
        public static void LoadPortals()
        {
            var sw = Stopwatch.StartNew();

            using (var db = new SquigglyContext())
            {
                foreach (var cqPortal in db.cq_portal.AsQueryable())
                {
                    var portal = new Portal
                    {
                        MapId = cqPortal.mapid,
                        X     = cqPortal.portal_x,
                        Y     = cqPortal.portal_y,
                        Id    = cqPortal.id,
                        IdX   = cqPortal.portal_idx
                    };
                    Collections.Portals.Add(portal.Id, portal);
                }
            }
            sw.Stop();
            Debug.WriteLine($"[SquigglyLite] Loaded {Collections.Portals.Count}\t Portals in {sw.Elapsed.TotalMilliseconds}ms");
        }
Beispiel #11
0
        private static void ACTION_ITEM_CHECK(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            var itemId = cqaction.data;

            if (invoker.Inventory.HasItem(itemId))
            {
                Process(target, invoker, db.cq_action.Find(cqaction.id_next),
                        db);
            }
            else
            {
                Process(target, invoker, db.cq_action.Find(cqaction.id_nextfail), db);
            }
        }
Beispiel #12
0
        private static void ACTION_ITEM_MULTICHK(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            var items = cqaction.param.Trim().Split(' ');

            var startId = int.Parse(items[0]);
            var endId   = int.Parse(items[1]);
            var amount  = int.Parse(items[2]);

            var range = Enumerable.Range(startId, (endId - startId) + 1);


            var amountFound = (from id in range from inventoryItem in invoker.Inventory.Items where inventoryItem.Value.ItemId == id select id).Count();

            Process(target, invoker, amountFound >= amount
                ? db.cq_action.Find(cqaction.id_next)
                : db.cq_action.Find(cqaction.id_nextfail), db);
        }
Beispiel #13
0
 private static void ACTION_ITEM_ADD(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
 {
     invoker.Inventory.AddItem(ItemFactory.Create(721189));
     Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
 }
Beispiel #14
0
 private static void ACTION_ITEM_LEAVESPACE(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
 {
     if (invoker.Inventory.Count + cqaction.data < 40)
     {
         Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
     }
     else
     {
         Process(target, invoker, db.cq_action.Find(cqaction.id_nextfail), db);
     }
 }
Beispiel #15
0
        private static void ACTION_MST_DROPITEM(YiObj target, YiObj attacker, cq_action cqaction, SquigglyContext db)
        {
            var condition = cqaction.param.Trim();
            var what      = condition.Split(' ')[0];

            switch (what)
            {
            case "dropmoney":
            {
                var maxAmount = int.Parse(condition.Split(' ')[1]);
                var chance    = int.Parse(condition.Split(' ')[2]) / 100;


                if (YiCore.Success(chance))
                {
                    //Output.WriteLine($"{type}:{(int) type} -> {maxAmount} {chance}", ConsoleColor.Green);
                    Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    FloorItemSystem.DropMoney(attacker, target, maxAmount);
                }
                else
                {
                    //Output.WriteLine($"{type}:{(int) type} -> {maxAmount} {chance}", ConsoleColor.Red);
                    Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                }

                break;
            }

            case "dropitem":
            {
                var id = int.Parse(condition.Split(' ')[1]);
                //Output.WriteLine($"{type}:{(int) type} -> {id}", ConsoleColor.Green);
                Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                FloorItemSystem.Drop(attacker, target, ItemFactory.Create(id));
                Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                break;
            }
            }
        }
Beispiel #16
0
        private static void ACTION_RAND(YiObj target, YiObj attacker, cq_action cqaction, SquigglyContext db)
        {
            var amount     = float.Parse(cqaction.param.Trim().Split(' ')[0]);
            var afterKills = float.Parse(cqaction.param.Trim().Split(' ')[1]);

            if (YiCore.Success(afterKills / amount))
            {
                //Output.WriteLine($"{type}:{(int) type} -> Chance: {afterKills/amount}", ConsoleColor.Green);
                Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
            }
            else
            {
                //Output.WriteLine($"{type}:{(int) type} -> Chance: {afterKills / amount}", ConsoleColor.Red);
                Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
            }
        }
Beispiel #17
0
        private static void Process(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            if (cqaction == null || cqaction.id == 0)
            {
                return;
            }

            invoker.CurrentAction = cqaction;
            var type = (Cq_ActionId)cqaction.type;

            //Output.WriteLine($"Mob Action -> Type: {type}:{(int) type} Data: {cqaction.data} Param: {cqaction.param.Trim()}");

            switch (type)
            {
            default:
            {
                Output.WriteLine($"Unknown Cq_ActionId -> {cqaction}", ConsoleColor.Blue);
                break;
            }

            case Cq_ActionId.ACTION_MENUTEXT:
            {
                if (invoker is Player player)
                {
                    player.Send(LegacyPackets.NpcSay(cqaction.param.Trim().Replace("~", " ")));
                    if (cqaction.id_next == 0)
                    {
                        player.Send(LegacyPackets.NpcFinish());
                    }
                    else
                    {
                        Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
                    }
                }

                break;
            }

            case Cq_ActionId.ACTION_MENULINK:
            {
                if (invoker is Player player)
                {
                    var option   = cqaction.param.Trim().Split(' ')[0];
                    var sControl = cqaction.param.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                    var control  = int.Parse(sControl[1]);

                    player.NpcTasks.Add((byte)player.NpcTasks.Count, (int)control);

                    player.Send(LegacyPackets.NpcLink(option.Replace("~", " "), (byte)(player.NpcTasks.Count - 1)));
                    if (cqaction.id_next == 0)
                    {
                        player.Send(LegacyPackets.NpcFinish());
                    }
                    else
                    {
                        Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
                    }
                }

                break;
            }

            case Cq_ActionId.ACTION_MENUPIC:
            {
                if (invoker is Player player)
                {
                    var faceId = byte.Parse(cqaction.param.Trim().Split(' ')[2]);
                    player.Send(LegacyPackets.NpcFace(faceId));
                    if (cqaction.id_next == 0)
                    {
                        player.Send(LegacyPackets.NpcFinish());
                    }
                    else
                    {
                        Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
                    }
                }
                break;
            }

            case Cq_ActionId.ACTION_MENUCREATE:
            {
                if (invoker is Player player)
                {
                    player.Send(LegacyPackets.NpcFinish());
                }
                break;
            }

            case Cq_ActionId.ACTION_USER_SEX:
            {
                if (cqaction.id_nextfail == 0 && cqaction.id_next == 0)
                {
                    return;
                }

                //If male next_id else nextid_fail

                break;
            }

            case Cq_ActionId.ACTION_ITEM_CHECK:
            {
                ACTION_ITEM_CHECK(target, invoker, cqaction, db);
                break;
            }

            case Cq_ActionId.ACTION_MST_DROPITEM:
            {
                ACTION_MST_DROPITEM(target, invoker, cqaction, db);
                break;
            }

            case Cq_ActionId.ACTION_RAND:
            {
                ACTION_RAND(target, invoker, cqaction, db);
                break;
            }

            case Cq_ActionId.ACTION_USER_ATTR:
            {
                ACTION_USER_ATTR(target, invoker, cqaction, db);
                break;
            }

            case Cq_ActionId.ACTION_RANDACTION:
            {
                ACTION_RANDACTION(target, invoker, cqaction, db);
                break;
            }

            case Cq_ActionId.ACTION_USER_TALK:
            {
                invoker.GetMessage("SYSTEM", invoker.Name.Trim(), cqaction.param.Trim().Replace("~", ""), (MsgTextType)cqaction.data);
                break;
            }

            case Cq_ActionId.ACTION_USER_HAIR:
            {
                ACTION_USER_HAIR(target, invoker, cqaction, db);
                break;
            }

            case Cq_ActionId.ACTION_USER_MEDIAPLAY:
            {
                ACTION_USER_MEDIAPLAY(target, invoker, cqaction, db);
                break;
            }

            case Cq_ActionId.ACTION_USER_EFFECT:
            {
                ACTION_USER_EFFECT(target, invoker, cqaction, db);
                break;
            }

            case Cq_ActionId.ACTION_USER_CHGMAP:
            {
                ACTION_USER_CHGMAP(target, invoker, cqaction, db);
                break;
            }

            case Cq_ActionId.ACTION_ITEM_LEAVESPACE:
                ACTION_ITEM_LEAVESPACE(target, invoker, cqaction, db);
                break;

            case Cq_ActionId.ACTION_ITEM_ADD:
                ACTION_ITEM_ADD(target, invoker, cqaction, db);
                break;

            case Cq_ActionId.ACTION_ITEM_MULTICHK:
                ACTION_ITEM_MULTICHK(target, invoker, cqaction, db);
                break;

            case Cq_ActionId.ACTION_ITEM_MULTIDEL:
                ACTION_ITEM_MULTIDEL(target, invoker, cqaction, db);
                break;

            case Cq_ActionId.ACTION_CHKTIME:
                ACTION_CHKTIME(target, invoker, cqaction, db);
                break;

            case Cq_ActionId.ACTION_USER_MAGIC:
                ACTION_USER_MAGIC(target, invoker, cqaction, db);
                break;
            }
        }
Beispiel #18
0
        private static void ACTION_ITEM_MULTIDEL(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            var items = cqaction.param.Trim().Split(' ');

            var startId = int.Parse(items[0]);
            var endId   = int.Parse(items[1]);
            var amount  = int.Parse(items[2]);

            var range = Enumerable.Range(startId, (endId - startId) + 1);


            var amountFound = (from id in range from inventoryItem in invoker.Inventory.Items where inventoryItem.Value.ItemId == id select id).Count();
            var removed     = 0;

            foreach (var inventoryItem in invoker.Inventory.Items)
            {
                if (removed == amount)
                {
                    break;
                }
                if (range.Contains(inventoryItem.Value.ItemId))
                {
                    invoker.Inventory.RemoveItem(inventoryItem.Value);
                    removed++;
                }
            }


            Process(target, invoker, amountFound >= amount
                ? db.cq_action.Find(cqaction.id_next)
                : db.cq_action.Find(cqaction.id_nextfail), db);
        }
Beispiel #19
0
        private static void ACTION_USER_HAIR(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            var nextIds = cqaction.param.Trim().Split(' ');

            invoker.Hair = uint.Parse(nextIds[1]);
            Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
        }
Beispiel #20
0
        private static void ACTION_USER_MEDIAPLAY(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            var nextIds = cqaction.param.Trim().Split(' ');

            //Send Sound Packet here
            Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
        }
Beispiel #21
0
        private static void ACTION_USER_EFFECT(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            var nextIds = cqaction.param.Trim().Split(' ');

            (invoker as Player)?.Send(LegacyPackets.Effect(invoker, nextIds[1]));
            Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
        }
Beispiel #22
0
        private static void ACTION_USER_CHGMAP(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            var nextIds = cqaction.param.Trim().Split(' ');
            var map     = ushort.Parse(nextIds[0]);
            var x       = ushort.Parse(nextIds[1]);
            var y       = ushort.Parse(nextIds[2]);

            invoker.Teleport(x, y, map);
            Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
        }
Beispiel #23
0
        private static void ACTION_USER_MAGIC(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            var param   = cqaction.param.Trim().Split(' ');
            var skillId = ushort.Parse(param[1]);

            switch (param[0])
            {
            case "learn":
            {
                (invoker as Player)?.AddSkill(new Skill(skillId, 0, 0));
                break;
            }
            }
            Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
        }
Beispiel #24
0
        private static void ACTION_USER_ATTR(YiObj target, YiObj attacker, cq_action cqaction, SquigglyContext db)
        {
            var condition = cqaction.param.Trim();
            var what      = condition.Split(' ')[0];

            switch (what)
            {
            case "level":
            {
                var op  = condition.Split(' ')[1];
                var val = condition.Split(' ')[2];

                switch (op)
                {
                case "<=":
                {
                    if (attacker.Level <= byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">=":
                {
                    if (attacker.Level >= byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "<":
                {
                    if (attacker.Level < byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">":
                {
                    if (attacker.Level > byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "==":
                {
                    if (attacker.Level == byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                default:
                    Console.WriteLine("Unknown Operator for " + what + " -> " + op);
                    break;
                }

                break;
            }

            case "life":
            {
                var op  = condition.Split(' ')[1];
                var val = condition.Split(' ')[2];

                switch (op)
                {
                case "<=":
                {
                    if (attacker.CurrentHp <= int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next),
                                db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">=":
                {
                    if (attacker.CurrentHp >= int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "<":
                {
                    if (attacker.CurrentHp < int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">":
                {
                    if (attacker.CurrentHp > int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "==":
                {
                    if (attacker.CurrentHp == int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                default:
                    Console.WriteLine("Unknown Operator for " + what + " -> " + op);
                    break;
                }

                break;
            }

            case "metempsychosis":
            {
                var op  = condition.Split(' ')[1];
                var val = condition.Split(' ')[2];

                switch (op)
                {
                case "<=":
                {
                    if (attacker.Reborn <= byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">=":
                {
                    if (attacker.Reborn >= byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "<":
                {
                    if (attacker.Reborn < byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">":
                {
                    if (attacker.Reborn > byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "==":
                {
                    if (attacker.Reborn == byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next),
                                db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int) type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker,
                                db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                default:
                    Console.WriteLine("Unknown Operator for " + what + " -> " + op);
                    break;
                }

                break;
            }

            case "profession":
            {
                var op  = condition.Split(' ')[1];
                var val = condition.Split(' ')[2];

                switch (op)
                {
                case "<=":
                {
                    if (attacker.Class <= byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "<":
                {
                    if (attacker.Class < byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">=":
                {
                    if (attacker.Class >= byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">":
                {
                    if (attacker.Class > byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "==":
                {
                    if (attacker.Class == byte.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                default:
                    Console.WriteLine("Unknown Operator for " + what + " -> " + op);
                    break;
                }

                break;
            }

            case "money":
            {
                var op  = condition.Split(' ')[1];
                var val = condition.Split(' ')[2];

                switch (op)
                {
                case "+=":
                {
                    attacker.Money += int.Parse(val);
                    Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    break;
                }

                case "<=":
                {
                    if (attacker.Money <= int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "<":
                {
                    if (attacker.Money < int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">=":
                {
                    if (attacker.Money >= int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case ">":
                {
                    if (attacker.Money > int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                case "==":
                {
                    if (attacker.Money == int.Parse(val))
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Green);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    }
                    else
                    {
                        //Output.WriteLine($"{type}:{(int)type} -> {condition}", ConsoleColor.Red);
                        Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                    }

                    break;
                }

                default:
                    Console.WriteLine("Unknown Operator for " + what + " -> " + op);
                    break;
                }

                break;
            }

            default:
            {
                Console.WriteLine("Unknown ACTION_USER_ATTR -> " + what);
                break;
            }
            }
        }
Beispiel #25
0
        private static void ACTION_RANDACTION(YiObj target, YiObj attacker, cq_action cqaction, SquigglyContext db)
        {
            var nextIds = cqaction.param.Trim().Split(' ');

            var nextIndex = SafeRandom.Next(nextIds.Length);

            var nextId = long.Parse(nextIds[nextIndex]);

            cqaction = db.cq_action.Find(nextId);
            //Output.WriteLine($"Mob Action -> Data: {cqaction.data} Param: {cqaction.param.Trim()}",ConsoleColor.Green);

            var dropId = cqaction.param.Trim().Split(' ')[1];
            var item   = ItemFactory.Create(int.Parse(dropId));

            FloorItemSystem.Drop(attacker, target, item);
        }
Beispiel #26
0
        private static void ACTION_CHKTIME(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db)
        {
            if (cqaction.data == 3)
            {
                var param          = cqaction.param.Trim().Split(' ');
                var startDayOfWeek = int.Parse(param[0]);
                var startTime      = param[1];
                var endDayOfWeek   = int.Parse(param[2]);
                var endTime        = param[3];

                if (((int)DateTime.Now.DayOfWeek) >= startDayOfWeek && ((int)DateTime.Now.DayOfWeek) <= endDayOfWeek)
                {
                    var startDT = DateTime.ParseExact(startTime, "H:mm", null, System.Globalization.DateTimeStyles.None);
                    var endDT   = DateTime.ParseExact(endTime, "H:mm", null, System.Globalization.DateTimeStyles.None);

                    if (DateTime.Now.Hour >= startDT.Hour && DateTime.Now.Hour <= endDT.Hour)
                    {
                        Process(target, invoker, db.cq_action.Find(cqaction.id_next), db);
                        return;
                    }
                }
            }
            Process(target, invoker, db.cq_action.Find(cqaction.id_nextfail), db);
        }