コード例 #1
0
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (player.Guild != "")
         try
         {
             var saytext = string.Join(" ", args);
             if ((from w in player.Manager.Worlds let world = w.Value where w.Key != 0 from i in world.Players.Where(i => i.Value.Guild == player.Guild) select world).Any())
             {
                 if (saytext.Equals(" ") || saytext == "")
                 {
                     player.SendHelp("Usage: /guild <text>");
                     return false;
                 }
                 player.Manager.Chat.SayGuild(player, saytext.ToSafeText());
                 return true;
             }
         }
         catch(Exception e)
         {
             player.SendError(e.ToString());
             player.SendInfo("Cannot guild chat!");
             return false;
         }
     else
         player.SendInfo("You need to be in a guild to use guild chat!");
     return false;
 }
コード例 #2
0
 protected override bool Process(Player player, RealmTime time, string args)
 {
     ConditionEffectIndex effect;
     if (!Enum.TryParse(args, true, out effect))
     {
         player.SendError("Invalid effect!");
         return false;
     }
     if ((player.ConditionEffects & (ConditionEffects)(1 << (int)effect)) != 0)
     {
         //remove
         player.ApplyConditionEffect(new ConditionEffect()
         {
             Effect = effect,
             DurationMS = 0
         });
     }
     else
     {
         //add
         player.ApplyConditionEffect(new ConditionEffect()
         {
             Effect = effect,
             DurationMS = -1
         });
     }
     return true;
 }
コード例 #3
0
ファイル: Command.cs プロジェクト: Jankos132/Server-Source
 static int GetPermissionLevel(Player player)
 {
     if (player.Client.Account.Admin)
         return 1;
     else
         return 0;
 }
コード例 #4
0
ファイル: Stats.cs プロジェクト: smillyz/Valor-Server
        public void SetValue(T value)
        {
            if (_value != null && _value.Equals(value))
            {
                return;
            }
            _value = value;

            var tVal = Transform(value);

            if (_tValue != null && _tValue.Equals(tVal))
            {
                return;
            }
            _tValue = tVal;

            // hacky fix to xp
            if (_owner is Player && _type == StatsType.Experience)
            {
                _owner.InvokeStatChange(_type, (int)(object)tVal - Player.GetLevelExp((_owner as Player).Level), _updateSelfOnly);
            }
            else
            {
                _owner.InvokeStatChange(_type, tVal, _updateSelfOnly);
            }
        }
コード例 #5
0
        private void HandlePortal(Player player, Portal portal)
        {
            if (portal == null || !portal.Usable)
            {
                return;
            }

            using (TimedLock.Lock(portal.CreateWorldLock))
            {
                var world = portal.WorldInstance;

                //if (player.Owner.Opener != player.Name && player.Credits < 1000 &&
                //    (portal.ObjectType == 0x22c3 || portal.ObjectType == 0x63ae || portal.ObjectType == 0x612b || portal.ObjectType == 0x75b3)) {
                //     player.SendError("You do not have enough gold to enter this raid!");
                //      return;
                // }

                // special portal case lookup
                if (world == null && _realmPortals.Contains(portal.ObjectType))
                {
                    world = player.Manager.GetRandomGameWorld();
                    if (world == null)
                    {
                        return;
                    }
                }

                if (world is Realm && !player.Manager.Resources.GameData.ObjectTypeToId[portal.ObjectDesc.ObjectType].Contains("Cowardice"))
                {
                    player.FameCounter.CompleteDungeon(player.Owner.Name);
                }

                if (world != null)
                {
                    player.Reconnect(world);

                    if (portal.WorldInstance?.Invites != null)
                    {
                        portal.WorldInstance.Invites.Remove(player.Name.ToLower());
                    }
                    if (portal.WorldInstance?.Invited != null)
                    {
                        portal.WorldInstance.Invited.Add(player.Name.ToLower());
                    }
                    return;
                }

                // dynamic case lookup
                if (portal.CreateWorldTask == null || portal.CreateWorldTask.IsCompleted)
                {
                    portal.CreateWorldTask = Task.Factory
                                             .StartNew(() => portal.CreateWorld(player))
                                             .ContinueWith(e =>
                                                           Log.Error(e.Exception.InnerException.ToString()),
                                                           TaskContinuationOptions.OnlyOnFaulted);
                }

                portal.WorldInstanceSet += player.Reconnect;
            }
        }
コード例 #6
0
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (player.HasConditionEffect(ConditionEffects.Paused))
     {
         player.ApplyConditionEffect(new ConditionEffect()
         {
             Effect = ConditionEffectIndex.Paused,
             DurationMS = 0
         });
         player.SendInfo("Game resumed.");
         return true;
     }
     else
     {
         if (player.Owner.EnemiesCollision.HitTest(player.X, player.Y, 8).OfType<Enemy>().Any())
         {
             player.SendError("Not safe to pause.");
             return false;
         }
         else
         {
             player.ApplyConditionEffect(new ConditionEffect()
             {
                 Effect = ConditionEffectIndex.Paused,
                 DurationMS = -1
             });
             player.SendInfo("Game paused.");
             return true;
         }
     }
 }
コード例 #7
0
ファイル: SellableObject.cs プロジェクト: Club559/Mining
 public virtual void Buy(Player player)
 {
     if (ObjectType == 0x0505)   //Vault chest
     {
         //if (new Database().ReadVault(player.Client.Account).Chests.Count < 64)
         //{
             if (TryDeduct(player))
             {
                 var chest = new Database().CreateChest(player.Client.Account);
                 (Owner as Vault).AddChest(chest, this);
                 player.Client.SendPacket(new BuyResultPacket()
                 {
                     Result = 0,
                     Message = "Vault Chest Get!"
                 });
             }
             else
                 player.Client.SendPacket(new BuyResultPacket()
                 {
                     Result = BUY_NO_FAME,
                     Message = "Not enough fame!"
                 });
         /*}
         else
         {
             player.Client.SendPacket(new BuyResultPacket()
             {
                 Result = 0,
                 Message = "You have a full vault!"
             });
         }*/
     }
 }
コード例 #8
0
 public override void EditObject(Player player, ushort type, int x, int y)
 {
     var tile = Map[x, y].Clone();
     if (type != 0 && tile.ObjType != 0)
         return;
     if (type != 0 && !Manager.GameData.ObjectDescs[type].Static)
     {
         if (tile.ObjType != 0)
             tile.ObjType = 0;
         Entity entity = Entity.Resolve(Manager, type);
         entity.Move(x + 0.5f, y + 0.5f);
         EnterWorld(entity);
         return;
     }
     else if (type != 0)
     {
         tile.ObjType = type;
         tile.ObjId = GetNextEntityId();
     }
     else
     {
         Entity entity = GetObjAt(x, y);
         if (entity != null)
             LeaveWorld(entity);
         else
             tile.ObjType = 0;
     }
     Map[x, y] = tile;
 }
コード例 #9
0
        protected override bool Process(Player player, RealmTime time, string args)
        {
            int index = args.IndexOf(' ');
            int num;
            string name = args;

            if (args.IndexOf(' ') > 0 && int.TryParse(args.Substring(0, args.IndexOf(' ')), out num)) //multi
                name = args.Substring(index + 1);
            else
                num = 1;

            ushort objType;
            if (!player.Manager.GameData.IdToObjectType.TryGetValue(name, out objType) ||
                !player.Manager.GameData.ObjectDescs.ContainsKey(objType))
            {
                player.SendError("Unknown entity!");
                return false;
            }

            for (int i = 0; i < num; i++)
            {
                var entity = Entity.Resolve(player.Manager, objType);
                entity.Move(player.X, player.Y);
                player.Owner.EnterWorld(entity);
            }
            return true;
        }
コード例 #10
0
        public void AcceptTrade(Player sender, AcceptTradePacket pkt)
        {
            if (sender == player1)
            {
                if (pkt.MyOffers.SequenceEqual(player1Trades) && pkt.YourOffers.SequenceEqual(player2Trades))
                {
                    player2.Client.SendPacket(new TradeAcceptedPacket
                    {
                        MyOffers = player2Trades,
                        YourOffers = player1Trades
                    });
                    player1Accept = true;
                }
            }
            else
            {
                if (pkt.MyOffers.SequenceEqual(player2Trades) && pkt.YourOffers.SequenceEqual(player1Trades))
                {
                    player1.Client.SendPacket(new TradeAcceptedPacket
                    {
                        MyOffers = player1Trades,
                        YourOffers = player2Trades
                    });
                    player2Accept = true;
                }
            }

            if (player1Accept && player2Accept)
                Trade();
        }
コード例 #11
0
        protected override bool Process(Player player, RealmTime time, string args)
        {
            Command[] cmds = player.Manager.Commands.Commands.Values
                .Where(x => x.HasPermission(player))
                .ToArray();

            int curPage = (args != "") ? Convert.ToInt32(args) : 1;
            double maxPage = Math.Floor((double) cmds.Length/10);

            if (curPage > maxPage + 1)
                curPage = (int) maxPage + 1;
            if (curPage < 1)
                curPage = 1;

            var sb = new StringBuilder(string.Format("Commands <Page {0}/{1}>: \n", curPage, maxPage + 1));

            int y = (curPage - 1) * 10;
            int z = y + 10;

            int commands = cmds.Length;
            if (z > commands)
            {
                z = commands;
            }

            for (int i = y; i < z; i++)
            {
                sb.Append(string.Format("[/{0}{1}]{2}", cmds[i].CommandName, (cmds[i].CommandUsage != "" ? " " + cmds[i].CommandUsage : null), (cmds[i].CommandDesc != "" ? ": " + cmds[i].CommandDesc : null)) + "\n");
            }
            player.SendHelp(sb.ToString());
            return true;
        }
コード例 #12
0
ファイル: Merchants.cs プロジェクト: xzyio/Rotmg-PServer
        public override void Buy(Player player)
        {
            if (ObjectType == 0x01ca)   //Merchant
            {
                if (TryDeduct(player))
                {
                    var Inventory = player.Inventory;
                    for (int i = 0; i < player.Inventory.Length; i++)
                    {
                        XElement ist;
                        XmlDatas.TypeToElement.TryGetValue((short)trueMType, out ist);
                        if (player.Inventory[i] == null && (player.SlotTypes[i] == 0 || player.SlotTypes[i] == Convert.ToInt16(ist.Element("SlotType").Value))) // Exploit fix - No more mnovas as weapons!
                        {
                            player.Inventory[i] = XmlDatas.ItemDescs[(short)trueMType];
                            player.UpdateCount++;
                            break;
                        }
                    }
                    player.Client.SendPacket(new BuyResultPacket()
                    {
                        Result = 0,
                        Message = "Purchase Successful!"
                    });
                    var ItemName = XmlDatas.ItemDescs[(short)trueMType].ObjectId;
                    var dir = @"logs";
                    if (!System.IO.Directory.Exists(dir))
                    System.IO.Directory.CreateDirectory(dir);

                    Console.WriteLine("[{3}]User {0} have bought {1} for {2}", player.nName, ItemName, truePrice, DateTime.Now);
                    using (System.IO.StreamWriter writer = new System.IO.StreamWriter(@"logs\PurchaseLog.txt", true))
                    {
                        writer.WriteLine("[{3}]User {0} have bought {1} for {2}", player.nName, ItemName, truePrice, DateTime.Now);
                    }
                }
                else
                    switch (truePrice.Item2)
                    {
                        case CurrencyType.Gold:
                            player.Client.SendPacket(new BuyResultPacket()
                            {
                                Result = BUY_NO_GOLD,
                                Message = "Not enough gold!"
                            }); break;
                        case CurrencyType.Fame:
                            player.Client.SendPacket(new BuyResultPacket()
                            {
                                Result = BUY_NO_FAME,
                                Message = "Not enough fame!"
                            }); break;
                        case CurrencyType.AccId:
                            player.Client.SendPacket(new BuyResultPacket()
                            {
                                Result = BUY_NO_GOLD,
                                Message = "You are not ID #" + truePrice.Item1.ToString() + "!"
                            }); break;
                    }
            }
            base.Buy(player);
        }
コード例 #13
0
ファイル: Tower.cs プロジェクト: Club559/Travs-Domain-Server
 public override int EnterWorld(Entity entity)
 {
     int ret = base.EnterWorld(entity);
     if (entity is Player && MainPlayer == null)
         if ((entity as Player).Party == null || ((entity as Player).Party.Leader == (entity as Player)))
             Cleared = (MainPlayer = (entity as Player)).Floors >= Floor;
     return ret;
 }
コード例 #14
0
ファイル: Trap.cs プロジェクト: rotmgkillroyx/rotmg_svr_OLD
 public Trap(Player player, float radius, int dmg, ConditionEffectIndex eff, float effDuration)
     : base(0x0711, LIFETIME * 1000, true, true, false)
 {
     this.player = player;
     this.radius = radius;
     this.dmg = dmg;
     this.effect = eff;
     this.duration = (int)(effDuration * 1000);
 }
コード例 #15
0
        private static void Handle(Player player, RealmTime time, int objId)
        {
            if (player?.Owner == null)
            {
                return;
            }

            player.Teleport(time, objId);
        }
コード例 #16
0
        public ItemStacker(Player owner, int slot, ushort objectType, int count, int maxCount)
        {
            Owner    = owner;
            Slot     = slot;
            Item     = Owner.Manager.Resources.GameData.Items[objectType];
            MaxCount = maxCount;

            _count = new SV <int>(owner, GetStatsType(slot), count);
        }
コード例 #17
0
        public static FollowPlayer Instance(Player player)
        {
            var key = player;
            FollowPlayer ret;

            if (!instances.TryGetValue(key, out ret))
                ret = instances[key] = new FollowPlayer();
            return ret;
        }
コード例 #18
0
 private static int GetPermissionLevel(Player player)
 {
     switch (player.Client.Account.Rank)
     {
         case 9001:
             return 0;
         default:
             return player.Client.Account.Rank;
     }
 }
コード例 #19
0
 public FollowPlayer()
 {
     try
     {
         this.player = Host.Self.PlayerOwner;
     }
     catch
     {
         this.player = null;
     }
 }
コード例 #20
0
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (args.Length == 0)
     {
         player.SendHelp("Usage: /announce <saytext>");
         return false;
     }
     foreach (var client in player.Manager.Clients.Values)
         client.Player.SendText("@Announcement", args);
     return true;
 }
コード例 #21
0
 protected override bool Process(Player player, RealmTime time, string args)
 {
     player.Client.Reconnect(new ReconnectPacket()
     {
         Host = "",
         Port = 2050,
         GameId = World.TUT_ID,
         Name = "Tutorial",
         Key = Empty<byte>.Array,
     });
     return true;
 }
コード例 #22
0
        private static void HandleGuildPortal(Player player, GuildHallPortal portal)
        {
            if (portal.ObjectType == 0x072f)
            {
                var proto = player.Manager.Resources.Worlds["GuildHall"];
                var world = player.Manager.GetWorld(proto.id);
                player.Reconnect(world);
                return;
            }

            player.SendInfo("Portal not implemented.");
        }
コード例 #23
0
        protected override bool TickCore(RealmTime time)
        {
            this.player = Host.Self.PlayerOwner;
            if (this.player.Client.Character.Pet == -1 || this.player.Client.Character.Pet != Host.Self.ObjectType)
            {
                try
                {
                    Host.Self.Owner.LeaveWorld(Host.Self);
                }
                catch { }
                return false;
            }
            int count = 0;
            foreach (var i in Host.Self.Owner.Players)
            {
                if (i.Value == this.player)
                    break;
                else
                    count++;
            }
            if (count == Host.Self.Owner.Players.Count)
            {
                try
                {
                    Host.Self.Owner.LeaveWorld(Host.Self);
                }
                catch { }
                return false;
            }

            float dist = 1;
            float ddist = Dist(Host.Self, player);

            Random rand = new Random();
            if ((Entity)player != null && dist < ddist)
            {
                var tx = player.X + rand.Next(-2, 2) / 2f;
                var ty = player.Y + rand.Next(-2, 2) / 2f;
                if (tx != Host.Self.X || ty != Host.Self.Y)
                {
                    var x = Host.Self.X;
                    var y = Host.Self.Y;
                    Vector2 vect = new Vector2(tx, ty) - new Vector2(Host.Self.X, Host.Self.Y);
                    vect.Normalize();
                    vect *= (10 / 1.5f) * (time.thisTickTimes / 1000f); //maybe we can change this to have the same speed as the player?
                    ValidateAndMove(Host.Self.X + vect.X, Host.Self.Y + vect.Y);
                    Host.Self.UpdateCount++;
                }
                return true;
            }
            else return false;
        }
コード例 #24
0
 public static World GetBestDuelArena(Player player)
 {
     // Partner's level must be +/- (5 + 10%) of player and partner must have same max
     // A 5/8 level 40 could only join a 5/8 player between levels 31 - 49
     foreach (var i in QueuedPlayers)
     {
         if (i.Key.Level >= (player.Level - 5) - Math.Floor(player.Level*.1) &&
             i.Key.Level <= (player.Level + 5) + Math.Floor(player.Level*.1) &&
             i.Key.GetMaxed().Count == player.GetMaxed().Count)
             return i.Value;
     }
     return player.Manager.AddWorld(new DuelArena());
 }
コード例 #25
0
 public TradeManager(Player player1, Player player2)
 {
     this.player1Trades = new bool[12];
     this.player2Trades = new bool[12];
     this.player1 = player1;
     this.player2 = player2;
     TradingPlayers.Add(player1);
     TradingPlayers.Add(player2);
     if (CurrentRequests.Contains(new KeyValuePair<Player, Player>(player1, player2)))
         CurrentRequests.Remove(new KeyValuePair<Player, Player>(player1, player2));
     if (CurrentRequests.Contains(new KeyValuePair<Player, Player>(player2, player1)))
         CurrentRequests.Remove(new KeyValuePair<Player, Player>(player2, player1));
 }
コード例 #26
0
ファイル: ChatManager.cs プロジェクト: xzyio/Rotmg-PServer
 public void Say(Player src, string text)
 {
     src.Owner.BroadcastPacket(new TextPacket()
     {
         Name = (src.Client.Account.Admin ? "@" : "") + src.Name,
         ObjectId = src.Id,
         Stars = src.Stars,
         BubbleTime = 5,
         Recipient = "",
         Text = text,
         CleanText = text
     }, null);
 }
コード例 #27
0
        public void HitBy(Player player, RealmTime time, Projectile projectile, int dmg)
        {
            int totalDmg;
            if (!hitters.TryGetValue(player, out totalDmg))
                totalDmg = 0;
            totalDmg += dmg;
            hitters[player] = totalDmg;

            LastProjectile = projectile;
            LastHitter = player;

            player.FameCounter.Hit(projectile, enemy);
        }
コード例 #28
0
 public void Say(Player src, string text)
 {
     src.Owner.BroadcastPacket(new TextPacket()
     {
         Name = (src.Client.Account.Admin ? "@" : "") + src.Name,
         ObjectId = src.Id,
         Stars = src.Stars,
         BubbleTime = 5,
         Recipient = "",
         Text = text,
         CleanText = text
     }, null);
     log.InfoFormat("[{0}({1})] <{2}> {3}", src.Owner.Name, src.Owner.Id, src.Name, text);
 }
コード例 #29
0
        protected override bool Process(Player player, RealmTime time, string args)
        {
            StringBuilder sb = new StringBuilder("Users online: \r\n");
            foreach (var i in player.Manager.Clients.Values)
            {
                if (i.Stage == ProtocalStage.Disconnected) continue;
                sb.AppendFormat("{0}#{1}@{2}\r\n",
                    i.Account.Name,
                    i.Player.Owner.Name,
                    i.Socket.RemoteEndPoint.ToString());
            }

            player.SendInfo(sb.ToString());
            return true;
        }
コード例 #30
0
ファイル: LootBehavior.cs プロジェクト: Club559/Mining
 public void BehaveWall(Player killer, Wall w, World wallWorld)
 {
     this.Host = w;
     BehaviorCondition cond = BehaviorCondition.OnDeath;
     if (cond == BehaviorCondition.OnDeath)
     {
         wOwner = wallWorld;
         var dat = new Tuple<Player, int>[]{
                 new Tuple<Player, int>(killer, 500)
             };
         Dictionary<Player, List<Item>> items = new Dictionary<Player, List<Item>>();
         ProcessPublicBags(rand, dat);
         ProcessSoulBags(rand, dat);
     }
 }
コード例 #31
0
ファイル: Enemy.cs プロジェクト: xzyio/Rotmg-PServer
        public int Damage(Player from, RealmTime time, int dmg, bool noDef, params ConditionEffect[] effs)
        {
            if (stat) return 0;
            if (HasConditionEffect(ConditionEffects.Invincible))
                return 0;
            if (!HasConditionEffect(ConditionEffects.Paused) &&
                !HasConditionEffect(ConditionEffects.Stasis))
            {
                var def = this.ObjectDesc.Defense;
                if (noDef)
                    def = 0;
                dmg = (int)StatsManager.GetDefenseDamage(this, dmg, def);
                int effDmg = dmg;
                if (effDmg > HP)
                    effDmg = HP;
                if (!HasConditionEffect(ConditionEffects.Invulnerable))
                    HP -= dmg;
                ApplyConditionEffect(effs);
                Owner.BroadcastPacket(new DamagePacket()
                {
                    TargetId = this.Id,
                    Effects = 0,
                    Damage = (ushort)dmg,
                    Killed = HP < 0,
                    BulletId = 0,
                    ObjectId = from.Id
                }, null);

                foreach (var i in CondBehaviors)
                    if ((i.Condition & BehaviorCondition.OnHit) != 0)
                        i.Behave(BehaviorCondition.OnHit, this, time, null);
                counter.HitBy(from, null, dmg);

                if (HP < 0)
                {
                    foreach (var i in CondBehaviors)
                        if ((i.Condition & BehaviorCondition.OnDeath) != 0)
                            i.Behave(BehaviorCondition.OnDeath, this, time, counter);
                    counter.Death();
                    if (Owner != null)
                        Owner.LeaveWorld(this);
                }

                UpdateCount++;
                return effDmg;
            }
            return 0;
        }
コード例 #32
0
        public Party(Player leader)
        {
            ID = Party.nextID++;
            if (Party.nextID == int.MaxValue)
                Party.nextID = 0;
            Leader = leader;
            Members = new List<Player>();
            Invitations = new List<int>();

            World = Leader.Owner;

            Parties.Add(ID, this);
            AccountStorage.Add(Leader.AccountId, ID);
            Leader.SendInfo("Created new party!");
            Leader.SendInfo("Type \"/party help\" for party commands.");
        }
コード例 #33
0
ファイル: SellableObject.cs プロジェクト: lcnvdl/rotmg-server
 public virtual void Buy(Player player)
 {
     if (ObjectType == 0x0505)   //Vault chest
     {
         if (TryDeduct(player))
         {
             var chest = player.Client.Database.CreateChest(player.Client.Account);
             (Owner as Vault).AddChest(chest, this);
             player.Client.SendPacket(new BuyResultPacket()
             {
                 Result = 0,
                 Message = "Vault chest purchased!"
             });
         }
         else
             player.Client.SendPacket(new BuyResultPacket()
             {
                 Result = BUY_NO_GOLD,
                 Message = "Not enough gold!"
             });
     }
     else
     {
         if (TryDeduct(player))
         {
             for (int i = 0; i < player.Inventory.Length; i++)
             if (player.Inventory[i] == null && i != 0 && i != 1 && i != 2 && i != 3)
             {
                 player.Inventory[i] = XmlDatas.ItemDescs[ObjectType];
                 UpdateCount++;
                 return;
             }
             player.Client.SendPacket(new BuyResultPacket()
             {
                 Result = BUY_NO_GOLD,
                 Message = "Not enough inventory space!"
             });
         }
         else
             player.Client.SendPacket(new BuyResultPacket()
             {
                 Result = BUY_NO_GOLD,
                 Message = "Not enough gold!"
             });
     }
 }
コード例 #34
0
 public void AddMember(Player member)
 {
     Members.Add(member);
     member.Party = this;
     SendPacket(new TextPacket
     {
         BubbleTime = 0,
         Stars = -1,
         Name = "",
         Recipient = "*Party*",
         Text = member.Name + " has joined the party"
     }, null);
     member.UpdateCount++;
     AccountStorage.Add(member.AccountId, ID);
     if (Invitations.Contains(member.AccountId))
         Invitations.Remove(member.AccountId);
 }
コード例 #35
0
        public void OnChatReceived(Player player, string text)
        {
            var rgx = (_ignoreCase)
                ? new Regex(_regex, RegexOptions.IgnoreCase)
                : new Regex(_regex);

            var match = rgx.Match(text);

            if (!match.Success)
            {
                _transition = false;
                _player     = null;
                return;
            }

            _transition = true;
            _player     = player;
        }
コード例 #36
0
 protected override bool Process(Player player, RealmTime time, string args)
 {
     ushort objType;
     if (!player.Manager.GameData.IdToObjectType.TryGetValue(args, out objType))
     {
         player.SendError("Unknown item type!");
         return false;
     }
     for (int i = 0; i < player.Inventory.Length; i++)
         if (player.Inventory[i] == null)
         {
             player.Inventory[i] = player.Manager.GameData.Items[objType];
             player.UpdateCount++;
             return true;
         }
     player.SendError("Not enough space in inventory!");
     return false;
 }
コード例 #37
0
        private static void Handle(Player player)
        {
            var cli = player.Client;

            if (cli.Account.RaidToken < 1)
            {
                player.SendError("You do not have an Alert to launch.");
                return;
            }

            if (cli.Account.Credits < 1000)
            {
                player.SendError("You do not have the required amount of gold to launch an Alert.");
                return;
            }

            var rnd = new Random();

            cli.Manager.Database.UpdateAlertToken(cli.Account, -1);
            player.AlertToken--;
            player.ForceUpdate(player.AlertToken);

            player.SendHelp("Launching Alert... Good luck!");
            var alertArea = player.Owner.Manager.Resources.Worlds[AlertAreas[rnd.Next(AlertAreas.Length)]];

            DynamicWorld.TryGetWorld(alertArea, player.Client, out var world);
            world = player.Owner.Manager.AddWorld(world ?? new World(alertArea));

            player.Owner.Timers.Add(new WorldTimer(8000, (w, t) => {
                player.Client.Reconnect(new Reconnect {
                    Host        = "",
                    Port        = 2050,
                    GameId      = world.Id,
                    Name        = world.SBName,
                    IsFromArena = false
                });
            }));
        }
コード例 #38
0
        public void RequestTrade(string name)
        {
            if (Owner is Test)
            {
                return;
            }

            Manager.Database.ReloadAccount(_client.Account);
            var acc = _client.Account;

            if (!acc.NameChosen)
            {
                SendError("A unique name is required before trading with others!");
                return;
            }

            if (tradeTarget != null)
            {
                SendError("Already trading!");
                return;
            }

            if (Database.GuestNames.Contains(name))
            {
                SendError(name + " needs to choose a unique name first!");
                return;
            }

            var target = Owner.GetUniqueNamedPlayer(name);

            if (target == null || !target.CanBeSeenBy(this))
            {
                SendError(name + " not found!");
                return;
            }

            if (target == this)
            {
                SendError("You can't trade with yourself!");
                return;
            }

            if (target._client.Account.IgnoreList.Contains(AccountId))
            {
                return; // account is ignored
            }
            if (target.tradeTarget != null)
            {
                SendError(target.Name + " is already trading!");
                return;
            }

            if (!target.Client.Account.Admin)
            {
                if (potentialTrader.ContainsKey(target))
                {
                    tradeTarget          = target;
                    trade                = new bool[12];
                    tradeAccepted        = false;
                    target.tradeTarget   = this;
                    target.trade         = new bool[12];
                    target.tradeAccepted = false;
                    potentialTrader.Clear();
                    target.potentialTrader.Clear();

                    // shouldn't be needed since there is checks on
                    // invswap, invdrop, and useitem packets for trading
                    //MonitorTrade();
                    //target.MonitorTrade();

                    var my = new TradeItem[12];
                    for (int i = 0; i < 12; i++)
                    {
                        my[i] = new TradeItem()
                        {
                            Item      = this.Inventory[i] == null ? -1 : this.Inventory[i].ObjectType,
                            SlotType  = this.SlotTypes[i],
                            Included  = false,
                            Tradeable = (this.Inventory[i] != null && i >= 4) && !this.Inventory[i].Soulbound
                        }
                    }
                    ;
                    var your = new TradeItem[12];
                    for (int i = 0; i < 12; i++)
                    {
                        your[i] = new TradeItem()
                        {
                            Item      = target.Inventory[i] == null ? -1 : target.Inventory[i].ObjectType,
                            SlotType  = target.SlotTypes[i],
                            Included  = false,
                            Tradeable = (target.Inventory[i] != null && i >= 4) && !target.Inventory[i].Soulbound
                        }
                    }
                    ;

                    this._client.SendPacket(new TradeStart()
                    {
                        MyItems   = my,
                        YourName  = target.Name,
                        YourItems = your
                    });
                    target._client.SendPacket(new TradeStart()
                    {
                        MyItems   = your,
                        YourName  = this.Name,
                        YourItems = my
                    });
                }
                else
                {
                    target.potentialTrader[this] = 1000 * 20;
                    target._client.SendPacket(new TradeRequested()
                    {
                        Name = Name
                    });
                    SendInfo("You have sent a trade request to " + target.Name + "!");
                    return;
                }
            }
            else
            {
                SendError("The player you want to trade with is an admin.");
                return;
            }
        }
コード例 #39
0
        void Handle(Player player, RealmTime time, UnboxRequest packet)
        {
            var acc = player.Client.Account;

            switch (packet.lootboxType)
            {
            case 1:
                if (player.BronzeLootbox >= 1)
                {
                    player.Client.Manager.Database.UpdateBronzeLootbox(acc, -1);
                    player.BronzeLootbox -= 1;
                    player.ForceUpdate(player.BronzeLootbox);
                    player.Unbox(1);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open!");
                }
                break;

            case 2:
                if (player.SilverLoootbox >= 1)
                {
                    player.Client.Manager.Database.UpdateSilverLootbox(acc, -1);
                    player.SilverLoootbox -= 1;
                    player.ForceUpdate(player.SilverLoootbox);
                    player.Unbox(2);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open!");
                }
                break;

            case 3:
                if (player.GoldLootbox >= 1)
                {
                    player.Client.Manager.Database.UpdateGoldLootbox(acc, -1);
                    player.GoldLootbox -= 1;
                    player.ForceUpdate(player.GoldLootbox);
                    player.Unbox(3);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open!");
                }
                break;

            case 4:
                if (player.EliteLootbox >= 1 && player.Onrane >= 5)
                {
                    player.Client.Manager.Database.UpdateEliteLootbox(acc, -1);
                    player.Client.Manager.Database.UpdateOnrane(acc, -5);
                    player.EliteLootbox -= 1;
                    player.Onrane        = player.Client.Account.Onrane - 5;
                    player.ForceUpdate(player.Onrane);
                    player.ForceUpdate(player.EliteLootbox);
                    player.Unbox(4);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open or you don't have the sufficient amount of onrane!");
                }
                break;

            case 5:
                if (player.Kantos >= 600)
                {
                    player.Client.Manager.Database.UpdateKantos(acc, -600);
                    player.Kantos = player.Client.Account.Kantos - 600;
                    player.ForceUpdate(player.Kantos);
                    player.Unbox(5);
                }
                else
                {
                    player.SendError("You do not have the sufficient amount of Kantos to open this box.");
                }
                break;
            }
        }