Пример #1
0
 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);
 }
Пример #2
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);
 }
Пример #3
0
        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;
        }
Пример #4
0
        public Decoy(Player player, int duration, float tps)
            : base(0x0715, duration, true, true, true)
        {
            this.player = player;
            this.duration = duration;
            this.speed = tps;

            var history = player.TryGetHistory(100);
            if (history == null)
                direction = GetRandDirection();
            else
            {
                direction = new Vector2(player.X - history.Value.X, player.Y - history.Value.Y);
                if (direction.LengthSquared() == 0)
                    direction = GetRandDirection();
                else
                    direction.Normalize();
            }
        }
Пример #5
0
 public override void Buy(Player player)
 {
     using (GameObjects.Database dbx = new GameObjects.Database())
     {
         if (dbx.GetGuild(dbx.GetGuildId(player.Guild)).GuildFame >= this.Price)
         {
             dbx.DetractGuildFame(dbx.GetGuildId(player.Guild), this.Price);
             dbx.ChangeGuildLevel(dbx.GetGuildId(player.Guild), nextLevel);
             player.Client.SendPacket(new svrPackets.BuyResultPacket()
             {
                 Message = "Success! Change will happen on next server restart.",
                 Result = 0
             });
         }
         else
             player.Client.SendPacket(new ServerEngine.svrPackets.BuyResultPacket()
             {
                 Message = "Are you dumb? You don't have enough guild fame...",
                 Result = 9
             });
     }
 }
Пример #6
0
 protected override void BehaveCore(BehaviorCondition cond, RealmTime? time, object state, string msg, Player player)
 {
     if (!adminOnly || player.Client.Account.Rank >= 2)
     {
         foreach (var s in chat)
         {
             if (msg.ToLower() == s.ToLower())
             {
                 foreach (var i in behaves)
                 {
                     i.Tick(Host, (RealmTime)time);
                 }
                 return;
             }
         }
         if (falseBehaves != null)
         {
             foreach (var f in falseBehaves)
             {
                 f.Tick(Host, (RealmTime)time);
             }
         }
     }
 }
Пример #7
0
 public void BroadcastPacket(Packet pkt, Player exclude)
 {
     foreach (var i in Players)
         if (i.Value != exclude)
             i.Value.Client.SendPacket(pkt);
 }
Пример #8
0
        void ShowBags(Random rand, IEnumerable<Item> loots, Player owner)
        {
            int bagType = 0;
            Item[] items = new Item[8];
            int idx = 0;

            short bag;
            Container container;
            foreach (var i in loots)
            {
                if (i.BagType > bagType) bagType = i.BagType;
                items[idx] = i;
                idx++;

                if (idx == 8)
                {
                    bag = 0x0500;
                    switch (bagType)
                    {
                        case 0: bag = 0x0500; break;
                        case 1: bag = 0x0503; break;
                        case 2: bag = 0x0507; break;
                        case 3: bag = 0x0508; break;
                        case 4: bag = 0x0509; break;
                        case 5: bag = 0xffd; break;
                        case 6: bag = 0xffe; break;
                        case 7: bag = 0xfff; break;
                    }
                    container = new Container(bag, 1000 * 60, true);
                    for (int j = 0; j < 8; j++)
                        container.Inventory[j] = items[j];
                    container.BagOwner = owner == null ? (int?)null : owner.AccountId;
                    container.Move(
                        Host.Self.X + (float)((rand.NextDouble() * 2 - 1) * 0.5),
                        Host.Self.Y + (float)((rand.NextDouble() * 2 - 1) * 0.5));
                    container.Size = 80;
                    Host.Self.Owner.EnterWorld(container);

                    bagType = 0;
                    items = new Item[8];
                    idx = 0;
                }
            }

            if (idx > 0)
            {
                bag = 0x0500;
                switch (bagType)
                {
                    case 0: bag = 0x0500; break;
                    case 1: bag = 0x0503; break;
                    case 2: bag = 0x0507; break;
                    case 3: bag = 0x0508; break;
                    case 4: bag = 0x0509; break;
                    case 5: bag = 0xffd; break;
                    case 6: bag = 0xffe; break;
                    case 7: bag = 0xfff; break;
                }
                container = new Container(bag, 1000 * 60, true);
                for (int j = 0; j < idx; j++)
                    container.Inventory[j] = items[j];
                container.BagOwner = owner == null ? (int?)null : owner.AccountId;
                container.Move(
                    Host.Self.X + (float)((rand.NextDouble() * 2 - 1) * 0.5),
                    Host.Self.Y + (float)((rand.NextDouble() * 2 - 1) * 0.5));
                container.Size = 80;
                if (Host.Self.Owner != null) //was null sometimes
                {
                    Host.Self.Owner.EnterWorld(container);
                }
            }
        }
Пример #9
0
 static void ActivateHealMp(Player player, int amount, List<Packet> pkts)
 {
     int maxMp = player.Stats[1] + player.Boost[1];
     int newMp = Math.Min(maxMp, player.MP + amount);
     if (newMp != player.MP)
     {
         pkts.Add(new ShowEffectPacket()
         {
             EffectType = EffectType.Potion,
             TargetId = player.Id,
             Color = new ARGB(0x0000FF) //was 0xffffffff
         });
         pkts.Add(new NotificationPacket()
         {
             Color = new ARGB(0x0000FF), // changed from ff9000ff to 0xDE825F (prod color)
             ObjectId = player.Id,
             Text = "+" + (newMp - player.MP)
         });
         player.MP = newMp;
         player.UpdateCount++;
     }
 }
Пример #10
0
        public void RequestTrade(RealmTime time, RequestTradePacket pkt)
        {
            if (!NameChosen)
            {
                SendInfo("Unique name is required to trade with others!");
                return;
            }
            if (tradeTarget != null)
            {
                SendError("You're already trading!");
                tradeTarget = null;
                return;
            }
            Player target = Owner.GetUniqueNamedPlayer(pkt.Name);
            if (target == null)
            {
                SendError("Player not found or is offline!");
                return;
            }
            if (target.tradeTarget != null && target.tradeTarget != this)
            {
                SendError(target.Name + " is already trading!");
                return;
            }

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

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

                psr.SendPacket(new TradeStartPacket()
                {
                    MyItems = my,
                    YourName = target.Name,
                    YourItems = your
                });
                target.psr.SendPacket(new TradeStartPacket()
                {
                    MyItems = your,
                    YourName = this.Name,
                    YourItems = my
                });
            }
            else
            {
                target.potentialTrader[this] = 1000 * 20;
                target.psr.SendPacket(new TradeRequestedPacket()
                {
                    Name = Name
                });
                SendInfo("You have requested to trade with " + target.Name);
                return;
            }
        }
Пример #11
0
 protected virtual void BehaveCore(BehaviorCondition cond, RealmTime? time, object state, string msg, Player player)
 {
 }
Пример #12
0
 public StatsManager(Player player)
 {
     this.player = player;
 }
Пример #13
0
        public void HitBy(Player player, 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);
        }
Пример #14
0
 public static Decoy DecoyRandom(Player player, int duration, float tps)
 {
     Decoy d = new Decoy(player, duration, tps);
     d.direction = d.GetRandDirection();
     return d;
 }
Пример #15
0
 public void BroadcastPackets(IEnumerable<Packet> pkts, Player exclude)
 {
     foreach (var i in Players)
         if (i.Value != exclude)
             i.Value.Client.SendPackets(pkts);
 }
Пример #16
0
 public void EnemyKilled(Enemy enemy, Player killer)
 {
     if (Overseer != null)
         Overseer.OnEnemyKilled(enemy, killer);
 }
Пример #17
0
        public void OnEnemyKilled(Enemy enemy, Player killer)
        {
            if (enemy.ObjectDesc != null)
            {
                TauntData? dat = null;
                foreach (var i in criticalEnemies)
                    if ((enemy.ObjectDesc.DisplayId ?? enemy.ObjectDesc.ObjectId) == i.Item1)
                    {
                        dat = i.Item2;
                        break;
                    }
                if (dat == null) return;

                if (dat.Value.killed != null)
                {
                    var arr = dat.Value.killed;
                    string msg = arr[rand.Next(0, arr.Length)];
                    while (killer == null && msg.Contains("{PLAYER}"))
                        msg = arr[rand.Next(0, arr.Length)];
                    msg = msg.Replace("{PLAYER}", killer.Name);
                    BroadcastMsg(msg);
                }

                if (rand.NextDouble() < 0.25)
                {
                    var evt = events[rand.Next(0, events.Count)];
                    if (XmlDatas.ObjectDescs[XmlDatas.IdToType[evt.Item1]].PerRealmMax == 1) //more than one avatar spawned and no rock dragon spawned?
                        events.Remove(evt);
                    SpawnEvent(evt.Item2);

                    dat = null;
                    foreach (var i in criticalEnemies)
                        if (evt.Item1 == i.Item1)
                        {
                            dat = i.Item2;
                            break;
                        }
                    if (dat == null) return;

                    if (dat.Value.spawn != null)
                    {
                        var arr = dat.Value.spawn;
                        string msg = arr[rand.Next(0, arr.Length)];
                        BroadcastMsg(msg);
                    }
                }
            }
        }
Пример #18
0
 public void Behave(BehaviorCondition cond, IBehaviorHost host, RealmTime? time, object state, string msg, Player player)
 {
     this.Host = host;
     BehaveCore(cond, time, state, msg, player);
 }
Пример #19
0
 public void OnPlayerEntered(Player player)
 {
     SendMsg(player, "Welcome to the Realm of the Mad God!");
     SendMsg(player, "You are one among many noobs!", "#Oryx the Mad God");
     SendMsg(player, "Ask around if you need assistance.");
     SendMsg(player, "Type \"/help\" for a list of commands.");
 }
Пример #20
0
        public void CancelTrade(RealmTime time, CancelTradePacket pkt)
        {
            this.psr.SendPacket(new TradeDonePacket()
            {
                Result = 1,
                Message = "Trade cancelled."
            });
            tradeTarget.psr.SendPacket(new TradeDonePacket()
            {
                Result = 1,
                Message = "Trade cancelled."
            });

            tradeTarget.tradeTarget = null;
            tradeTarget.trade = null;
            tradeTarget.tradeAccepted = false;
            this.tradeTarget = null;
            this.trade = null;
            this.tradeAccepted = false;
            return;
        }
Пример #21
0
 void SendMsg(Player player, string message, string src = "")
 {
     player.Client.SendPacket(new TextPacket()
     {
         Name = src,
         ObjectId = -1,
         Stars = -1,
         BubbleTime = 0,
         Recipient = "",
         Text = message,
         CleanText = ""
     });
 }
Пример #22
0
        private void DoTrade()
        {
            string msg = "Trade Successful!";
            string failmsg = "An error occured while trading, possible exploit detected!";
            var thisItems = new List<Item>();
            var targetItems = new List<Item>();

            // make sure trade targets are valid
            if (tradeTarget == null || Owner == null || tradeTarget.Owner == null || Owner != tradeTarget.Owner)
            {
                if (this != null)
                    psr.SendPacket(new TradeDonePacket
                    {
                        Result = 1,
                        Message = failmsg
                    });

                if (tradeTarget != null)
                    tradeTarget.psr.SendPacket(new TradeDonePacket
                    {
                        Result = 1,
                        Message = failmsg
                    });
                var dir = @"logs"; //start of logging code
                if (!System.IO.Directory.Exists(dir))
                    System.IO.Directory.CreateDirectory(dir);
                using (System.IO.StreamWriter writer = new System.IO.StreamWriter(@"logs\DupeLog.txt", true))
                {
                    writer.WriteLine("[" + DateTime.Now + "]" + nName + " has attempted to dupe with " + tradeTarget.nName);
                } //end of logging code
                //A good idea would to log this to a .txt or have an auto-ban checker such as my anticheat.
                //Just looked at it in-game... it spams you with the failmsg. Working on fix
                return;
            }

            //get trade items
            for (int i = 4; i < Inventory.Length; i++)
            {
                if (trade[i] && !Inventory[i].Soulbound)
                {
                    thisItems.Add(Inventory[i]);
                    Inventory[i] = null;
                    UpdateCount++;

                    //save this trade info
                    if (itemnumber1 == 0)
                    {
                        items1 = items1 + " " + thisItems[itemnumber1].ObjectId;
                    }
                    else if (itemnumber1 > 0)
                    {
                        items1 = items1 + ", " + thisItems[itemnumber1].ObjectId;
                    }
                    itemnumber1++;
                }

                if (tradeTarget.trade[i] && !tradeTarget.Inventory[i].Soulbound)
                {
                    targetItems.Add(tradeTarget.Inventory[i]);
                    tradeTarget.Inventory[i] = null;
                    tradeTarget.UpdateCount++;

                    // save target trade info
                    if (itemnumber2 == 0)
                    {
                        items2 = items2 + " " + targetItems[itemnumber2].ObjectId;
                    }
                    else if (itemnumber2 > 0)
                    {
                        items2 = items2 + ", " + targetItems[itemnumber2].ObjectId;
                    }
                    itemnumber2++;
                }
            }

            // move thisItems -> tradeTarget
            for (int j = thisItems.Count - 1; j >= 0; j--)
                for (int i = 0; i < tradeTarget.Inventory.Length; i++)
                {
                    if ((tradeTarget.SlotTypes[i] == 0 &&
                    tradeTarget.Inventory[i] == null) ||
                    (thisItems[j] != null &&
                    tradeTarget.SlotTypes[i] == thisItems[j].SlotType &&
                    tradeTarget.Inventory[i] == null))
                    {
                        tradeTarget.Inventory[i] = thisItems[j];
                        thisItems.RemoveAt(j);
                        break;
                    }
                }

            //move tradeItems -> this
            for (int j = targetItems.Count - 1; j >= 0; j--)
                for (int i = 0; i < Inventory.Length; i++)
                {
                    if ((SlotTypes[i] == 0 &&
                    Inventory[i] == null) ||
                    (targetItems[j] != null &&
                    SlotTypes[i] == targetItems[j].SlotType &&
                    Inventory[i] == null))
                    {
                        Inventory[i] = targetItems[j];
                        targetItems.RemoveAt(j);
                        break;
                    }
                }

            //check for lingering items
            if (thisItems.Count > 0 ||
            targetItems.Count > 0)
            {
                msg = "An error occured while trading!";
            }

            // trade successful, notify and save
            psr.SendPacket(new TradeDonePacket
            {
                Result = 1,
                Message = msg
            });
            tradeTarget.psr.SendPacket(new TradeDonePacket
            {
                Result = 1,
                Message = msg
            });
            SaveToCharacter();
            psr.Save();
            tradeTarget.SaveToCharacter();
            tradeTarget.psr.Save();

            //clean
            items1 = "";
            items2 = "";
            itemnumber1 = 0;
            itemnumber2 = 0;
            UpdateCount++;
            tradeTarget.UpdateCount++;
            tradeTarget.tradeTarget = null;
            tradeTarget.trade = null;
            tradeTarget.tradeAccepted = false;
            tradeTarget = null;
            trade = null;
            tradeAccepted = false;
        }
Пример #23
0
 static void ActivateHealHp(Player player, int amount, List<Packet> pkts)
 {
     int maxHp = player.Stats[0] + player.Boost[0];
     int newHp = Math.Min(maxHp, player.HP + amount);
     if (newHp != player.HP)
     {
         pkts.Add(new ShowEffectPacket()
         {
             EffectType = EffectType.Potion,
             TargetId = player.Id,
             Color = new ARGB(0xFF0000) //was 0xFFFFFFFF
         });
         pkts.Add(new NotificationPacket()
         {
             Color = new ARGB(0xFF0000), //was 0xFF00FF00 OR 0x00FF00FF
             ObjectId = player.Id,
             Text = "+" + (newHp - player.HP)
         });
         player.HP = newHp;
         player.UpdateCount++;
     }
 }