Exemple #1
0
        public Npc[] GetNearbyNpcs(Character ch)
        {
            var map = maps.Where(x => x.MapID == ch.MapId).First() ;
            var nearbyNpcs = map.Npcs.Where(x => (GetDistance(x.X, x.Y, ch.X, ch.Y) < 150));

            return nearbyNpcs.ToArray();
        }
        private void AddPlayerTreeViewItem(Character ch)
        {
            string map = String.Format("Map: {0}", (MapName)ch.MapId);
            TreeNode nodeMap = new TreeNode(map);
            nodeMap.Tag = "Map";
            string posx = String.Format("X: {0}", ch.Position.X);
            TreeNode nodeX = new TreeNode(posx);
            nodeX.Tag = "X";
            string posy = String.Format("Y: {0}", ch.Position.Y);
            TreeNode nodeY = new TreeNode(posy);
            nodeY.Tag = "Y";

            TreeNode mapInfo = new TreeNode("Map Info", new TreeNode[] { nodeMap, nodeX, nodeY });
            mapInfo.Tag = "Info";

            string charId = String.Format("CharacterID: {0}", ch.CharacterId);
            TreeNode nodeID = new TreeNode(charId);
            nodeID.Tag = "ID";
            string accountId = String.Format("AccountID: {0}", ch.AccountId);
            TreeNode nodeAccountID = new TreeNode(accountId);
            nodeAccountID.Tag = "AccountID";
            string level = String.Format("Level: {0}", ch.Level);
            TreeNode nodeLevel = new TreeNode(level);
            nodeLevel.Tag = "Level";

            TreeNode character = new TreeNode(ch.Name, new TreeNode[] { nodeID, nodeAccountID, nodeLevel, mapInfo });
            character.Tag = ch.CharacterId; // this is only so we can update etc..

            playerTreeView.Nodes.Add(character);
        }
Exemple #3
0
    private void OnDeleteChar(Entities.Character character)
    {
        if (!Characters.ContainsKey(character.entityId))
        {
            return;
        }

        if (Characters[character.entityId] == null)
        {
            Characters.Remove(character.entityId);
            return;
        }
        Destroy(Characters[character.entityId]);
        Characters.Remove(character.entityId);
    }
Exemple #4
0
        public BaseItem PickupItem(int mapItemId, Character c)
        {
            MapItem m = null;

            try
            {
                m = mapItems.Where(x => x.MapItemID == mapItemId).First();
            }
            catch (Exception)
            {
                return null;
            }

            BaseItem item = itemDataManager.GetItemByItemID(m.ItemID);

            BagSlot bagSlot = new BagSlot();

            bool added = false;

            for (int i = 0; i < c.Bags.Count; i++)
            {
                if (!added)
                {
                    if (c.Bags[i].PickItem(item, bagSlot))
                    {
                        added = true;
                        bagSlot.Bag = (byte)(i + 1);
                        break;
                    }
                }
            }

            if (!added)
                throw new BagIsFullException(Messages.BAGISFULLEXCEPTION);

            item.Slot = bagSlot.Slot;
            item.Bag = bagSlot.Bag;

            mapItemManager.DeleteMapItem(m.MapItemID);
            mapItems.Remove(m);
            item.OwnerID = c.CharacterId;
            itemDataManager.UpdateItem(item);

            return item;
        }
Exemple #5
0
    private void InitGameObj(Entities.Character character, GameObject go)
    {
        EntityController ec = go.GetComponent <EntityController>();

        if (ec == null)
        {
            ec = go.AddComponent <EntityController>();
        }
        ec.entity   = character;
        ec.isPlayer = character.IsPlayer;
        if (ec.anim == null)
        {
            ec.anim = go.GetComponentInChildren <Animator>();
        }
        if (ec.rb == null)
        {
            ec.rb = go.GetComponentInChildren <Rigidbody>();
        }
        if (ec.isPlayer)
        {
            PlayerInputController pc = go.GetComponent <PlayerInputController>();
            if (pc == null)
            {
                pc = go.AddComponent <PlayerInputController>();
            }
            //MainPlayerCamera.Instance.player = go;
            Models.User.Instance.CurrentCharacterObject = go;
            pc.enabled          = true;
            pc.character        = character;
            pc.entityController = ec;
            if (pc.rb == null)
            {
                pc.rb = ec.rb;
            }
        }
        else
        {
            PlayerInputController pc = go.GetComponent <PlayerInputController>();
            if (pc != null)
            {
                pc.enabled = false;
            }
        }
    }
Exemple #6
0
    private void CreateCharacter(Entities.Character character)
    {
        if (!Characters.ContainsKey(character.entityId) || Characters[character.entityId] == null)
        {
            UnityEngine.Object obj = Resloader.Load <UnityEngine.Object>(character.Define.Resource);
            if (obj == null)
            {
                Debug.LogErrorFormat("Character[{0}] Resource[{1}] not existed.", character.Define.TID, character.Define.Resource);
                return;
            }
            GameObject go = (GameObject)Instantiate(obj, this.transform);
            go.name = "Character_" + character.Info.Id + "_" + character.Info.Name;

            go.transform.position          = GameObjectTool.LogicToWorld(character.position);
            go.transform.forward           = GameObjectTool.LogicToWorld(character.direction);
            Characters[character.entityId] = go;
            UIWorldElementManager.Instance.AddCharacterNameBar(go.transform, character);
        }
        InitGameObj(character, Characters[character.entityId]);
    }
        public void UpdateCharacter(Character ch)
        {
            DbParameter idParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_ID_PARAMETER, ch.CharacterId);
            idParameter.DbType = DbType.Int32;

            DbParameter levelParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_LEVEL_PARAMETER, ch.Level);
            levelParameter.DbType = DbType.Int16;

            DbParameter mapIdParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_MAPID_PARAMETER, ch.MapId);
            mapIdParameter.DbType = DbType.Int32;

            DbParameter curHpParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_CURHP_PARAMETER, ch.CurrentHp);
            curHpParameter.DbType = DbType.Int32;

            DbParameter curManaParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_CURMANA_PARAMETER, ch.CurrentMana);
            curManaParameter.DbType = DbType.Int32;

            DbParameter strParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_STR_PARAMETER, ch.Strength);
            strParameter.DbType = DbType.Int16;

            DbParameter staParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_STA_PARAMETER, ch.Stamina);
            staParameter.DbType = DbType.Int16;

            DbParameter dexParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_DEX_PARAMETER, ch.Dexterity);
            dexParameter.DbType = DbType.Int16;

            DbParameter eneParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_ENE_PARAMETER, ch.Energy);
            eneParameter.DbType = DbType.Int16;

            DbParameter posXParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_POSX_PARAMETER, (short)ch.Map.SpawnX);
            posXParameter.DbType = DbType.Int16;

            DbParameter posYParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_POSY_PARAMETER, (short)ch.Map.SpawnY);
            posYParameter.DbType = DbType.Int16;

            DbParameter fameParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_FAME_PARAMETER, ch.Fame);
            fameParameter.DbType = DbType.Int32;

            DbParameter moneyParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_MONEY_PARAMETER, ch.Money);
            moneyParameter.DbType = DbType.Int32;

            DbParameter statPointParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_STATPOINTS_PARAMETER, ch.StatPoint);
            statPointParameter.DbType = DbType.Int16;

            DbParameter trainingPointParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_TRAININGPOINTS_PARAMETER, ch.TrainingPoint);
            trainingPointParameter.DbType = DbType.Int16;

            DbParameter currentExpParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_CUREXPERIENCE_PARAMETER, ch.CurrentExp);
            currentExpParameter.DbType = DbType.Int64;

            DbParameter rebirthParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_REBIRTH_PARAMETER, ch.Rebirth);
            rebirthParameter.DbType = DbType.Byte;

            DbParameter gainedParameter = _db.CreateParameter(DbNames.UPDATECHARACTER_GAINEDTP_PARAMETER, ch.GainedTrainings);
            gainedParameter.DbType = DbType.Int16;

            DbParameter tpLevelParameter = _db.CreateParameter(DbNames.CHARACTER_TPLEVEL, ch.TpLevel);
            tpLevelParameter.DbType = DbType.Int16;

            _db.Open();

            _db.ExecuteNonQuery(DbNames.UPDATECHARACTER_STOREDPROC,
              System.Data.CommandType.StoredProcedure,
              idParameter,
              levelParameter,
              mapIdParameter,
              curHpParameter,
              curManaParameter,
              strParameter,
              staParameter,
              dexParameter,
              eneParameter,
              posXParameter,
              posYParameter,
              fameParameter,
              moneyParameter,
              statPointParameter,
              trainingPointParameter,
              currentExpParameter,
              rebirthParameter,
              gainedParameter,
              tpLevelParameter);

            _db.Close();
        }
        public Character[] GetAllCharactersByAccountId(int accountId)
        {
            DbParameter accountIdParameter = _db.CreateParameter(DbNames.GETALLCHARACTERSBYACCOUNTID_ACCOUNTID_PARAMETER, accountId);

            accountIdParameter.DbType = DbType.Int32;

            List<Character> characters = new List<Character>();

            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLCHARACTERSBYACCOUNTID_STOREDPROC, CommandType.StoredProcedure, accountIdParameter);

            int ordinalCHARACTER_ID = reader.GetOrdinal(DbNames.CHARACTER_ID);
            int ordinalCHARACTER_ACCOUNTID = reader.GetOrdinal(DbNames.CHARACTER_ACCOUNTID);
            int ordinalCHARACTER_NAME = reader.GetOrdinal(DbNames.CHARACTER_NAME);
            int ordinalCHARACTER_CLASS = reader.GetOrdinal(DbNames.CHARACTER_CLASS);
            int ordinalCHARACTER_LEVEL = reader.GetOrdinal(DbNames.CHARACTER_LEVEL);
            int ordinalCHARACTER_MAPID = reader.GetOrdinal(DbNames.CHARACTER_MAPID);
            int ordinalCHARACTER_CURRENTHP = reader.GetOrdinal(DbNames.CHARACTER_CURRENTHP);
            int ordinalCHARACTER_CURRENTMANA = reader.GetOrdinal(DbNames.CHARACTER_CURRENTMANA);
            int ordinalCHARACTER_STRENGTH = reader.GetOrdinal(DbNames.CHARACTER_STRENGTH);
            int ordinalCHARACTER_STAMINA = reader.GetOrdinal(DbNames.CHARACTER_STAMINA);
            int ordinalCHARACTER_DEXTERITY = reader.GetOrdinal(DbNames.CHARACTER_DEXTERITY);
            int ordinalCHARACTER_ENERGY = reader.GetOrdinal(DbNames.CHARACTER_ENERGY);

            while (reader.Read())
            {
                Character c = new Character
                {
                    CharacterId = reader.GetInt32(ordinalCHARACTER_ID),
                    AccountId = reader.GetInt32(ordinalCHARACTER_ACCOUNTID),
                    Name = reader.GetString(ordinalCHARACTER_NAME),
                    Class = reader.GetByte(ordinalCHARACTER_CLASS),
                    Level = reader.GetInt16(ordinalCHARACTER_LEVEL),
                    MapId = reader.GetInt32(ordinalCHARACTER_MAPID),
                    CurrentHp = reader.GetInt32(ordinalCHARACTER_CURRENTHP),
                    CurrentMana = reader.GetInt32(ordinalCHARACTER_CURRENTMANA),
                    Strength = reader.GetInt16(ordinalCHARACTER_STRENGTH),
                    Stamina = reader.GetInt16(ordinalCHARACTER_STAMINA),
                    Dexterity = reader.GetInt16(ordinalCHARACTER_DEXTERITY),
                    Energy = reader.GetInt16(ordinalCHARACTER_ENERGY)
                };

                characters.Add(c);
            }

            reader.Close();
            _db.Close();

            foreach (Character c in characters)
            {
                //c.Equipments = GetAllItemsInBag(0, c.CharacterId).Cast<Equipment>().ToList();

                var equips = itemDataManager.GetAllItemsInBag(0, c.CharacterId).Cast<Equipment>().ToList();

                var neck = equips.Where(x => x is Necklace);
                var ring = equips.Where(x => x is Ring);
                var head = equips.Where(x => x is Head);
                var body = equips.Where(x => x is Body);
                var feet = equips.Where(x => x is Feet);
                var hand = equips.Where(x => x is Hand);
                var cape = equips.Where(x => x is Cape);
                var charm = equips.Where(x => x.Slot == (byte)Slot.CrystalMirror);
                var mirror = equips.Where(x => x.Slot == (byte)Slot.Mirror);

                c.Necklace = neck.Count() == 0 ? null : neck.First() as Necklace;
                c.Ring = ring.Count() == 0 ? null : ring.First() as Ring;
                c.Head = head.Count() == 0 ? null : head.First() as Head;
                c.Body = body.Count() == 0 ? null : body.First() as Body;
                c.Feet = feet.Count() == 0 ? null : feet.First() as Feet;
                c.Hand = hand.Count() == 0 ? null : hand.First() as Hand;
                c.Cape = cape.Count() == 0 ? null : cape.First() as Cape;
                c.Charm = charm.Count() == 0 ? null : charm.First() as Equipment;
                c.Mirror = mirror.Count() == 0 ? null : mirror.First() as Mirror;

            }

            return characters.ToArray();
        }
        public Client[] GetClientsForChars(Character[] chars)
        {
            List<Client> nearbyClients = new List<Client>();

            for (int i = 0; i < chars.Length; i++)
            {
                Client client = clients.FirstOrDefault(tempClient => tempClient.MyCharacter == chars[i]);
                nearbyClients.Add(client);
            }

            return nearbyClients.ToArray();
        }
 public static byte[] SendCommand(Character ch, CommandInfo ci)
 {
     Packet p = new Packet(200);
     p.WriteInt(ch.CharacterId);
     p.WriteByte(ci.Type);
     p.WriteByte(ci.Action);
     p.WriteByte(ci.Something);
     p.WriteByte(ci.Something2);
     return p.GetWrittenBuffer(PacketIds.SendCommand);
 }
        /// <summary>
        /// Send character list to client
        /// </summary>
        /// <returns></returns>
        public static byte[] SendCharacterList(Character[] characters)
        {
            Packet p = new Packet(200);
            p.WriteByte(characters.Length);

            foreach (Character c in characters)
            {
                p.WriteInt(c.MapId);
                p.WriteInt(c.CharacterId);
                p.WriteString(c.Name);
                p.WriteByte(c.Class);
                p.WriteShort(c.Level);
                p.WriteInt(c.CurrentHp);
                p.WriteInt(c.MaxHp);
                p.WriteInt(c.MaxMana);
                p.WriteShort(c.Strength);
                p.WriteShort(c.Stamina);
                p.WriteShort(c.Dexterity);
                p.WriteShort(c.Energy);
                p.WriteHexString("00 00 00 00 02 00 00 00 00 00 00 00"); // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                foreach (Equipment e in c.GetVisuals())
                {
                    p.WriteShort(e.VisualID);
                    p.WriteByte(e.Plus);
                    p.WriteByte(e.Slvl);
                }

                p.WriteHexString("01 00"); // ending bytes
            }

            return p.GetWrittenBuffer(PacketIds.SendCharacterList);
        }
        public static byte[] SendStats(Character ch)
        {
            Packet p = new Packet(200);
            // p.WriteHexString("02 3A 52 00 01 00 02 00 03 00 04 00 05 00 06 00 00 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 00 0B 05 00 00 00 06 00 00 00 07 00 08 00 09 00 01 00 02 00 02 00 0C 07 00 02 03 00 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
            p.WriteShort(ch.Level);
            p.WriteShort(ch.Strength);
            p.WriteShort(ch.Stamina);
            p.WriteShort(ch.Dexterity);
            p.WriteShort(ch.Energy);
            p.WriteShort(ch.StatPoint); // stat points

            //PLOX FUNCTION OF STATS HERE
            ch.CalculateTotalStats();

            p.WriteHexString("00 00 00 00"); // unknown
            p.WriteInt(ch.TotalDamage); // total damage
            p.WriteInt(ch.TotalDefence); // total defence
            p.WriteInt(ch.TotalAttackRating); // total attack rating

            p.WriteHexString("00 0B"); // unknown
            p.WriteInt(ch.CurrentHp);
            p.WriteInt(ch.MaxHp);
            p.WriteShort(ch.CurrentMana);
            p.WriteShort(ch.MaxMana);

            p.WriteShort(ch.Critical); // critical hit

            p.WriteShort(ch.StatDamage); // damage from stats
            p.WriteShort(ch.StatDefence); // defence from stats
            p.WriteShort(ch.StatAttackRating); // attack rating from stats

            p.WriteHexString("0C 07 01"); // unknown
            p.WriteByte(ch.MovingSpeed); // movement speed
            p.WriteShort(ch.TrainingPoint); // trainings
            p.WriteHexString("00 00 00 00"); // unknown
            p.WriteInt(ch.Fame);
            p.WriteHexString("00"); // gives you green name, luls
            p.WriteByte(ch.Rebirth); // rebirths
            p.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00"); // unknown
            p.WriteInt(ch.RepulationPoint); // repulation points
            return p.GetWrittenBuffer(PacketIds.SendStats);
        }
 public static byte[] SendSpawnPlayers(Character ch)
 {
     Packet p = new Packet(200);
     p.WriteHexString("00");
     p.WriteInt(ch.MapId);
     p.WriteHexString("01 00");
     p.WriteInt(ch.CharacterId);
     p.WriteShort(ch.X);
     p.WriteShort(ch.Y);
     p.WriteHexString("76");
     p.WriteShort(ch.X);
     p.WriteShort(ch.Y);
     p.WriteHexString("76");
     p.WriteHexString("16 B2 00 00");
     p.WriteByte(ch.Class);
     p.WriteString(ch.Name);
     p.WriteInt(ch.Fame);
     p.WriteHexString("00"); // bool selling
     p.WriteString(""); // shopname
     p.WriteString(""); // shopdesc
     p.WriteHexString("00"); // purple name
     p.WriteHexString("00"); // fe
     p.WriteHexString("00"); // fe ring
     p.WriteHexString("00"); // maybe has guild thingy
     //if Character has guild
     //p.WriteHexString("00 00 00 00"); // guild id
     //p.WriteString(""); // guild name
     //p.WriteHexString("00 00 00 00"); // maybe guild position
     //p.WriteHexString("00 00 00 00"); // maybe guild position
     //p.WriteHexString("00 00 00 00 00 00 00 00");
     //p.WriteHexString("00"); // something
     p.WriteHexString("00 00 00 00 00 00 00 00 00"); // else write this
     foreach (Equipment e in ch.GetVisuals())
     {
         p.WriteShort(e.VisualID);
         p.WriteByte(e.Plus);
         p.WriteByte(e.Slvl);
         p.WriteByte(e.RequiredClass);
     }
     p.WriteByte(ch.Rebirth); // rebirth
     p.WriteHexString("00 00 00 00 00");
     return p.GetWrittenBuffer(PacketIds.SendSpawnPlayers);
 }
Exemple #14
0
 private void onCreateChar(Entities.Character character)
 {
     CreateCharacter(character);
 }
Exemple #15
0
 public ActiveSkill(DateTime casted, BaseSkill skill, BaseEntity[] targets, Character caster)
 {
     this.CastTime = casted;
     this.Skill = skill;
     this.Caster = caster;
     this.Targets = targets;
 }
Exemple #16
0
        private bool SwapDifferentSize(Character ch, BaseItem one, BaseItem two, int slot)
        {
            bool moved = false;
            int test = Math.Abs(one.Slot - slot);
            if (!IsOnEdge(one, one.Slot)) // so it wont let you stack it with the item
            {
                if (one.Bag == two.Bag)
                {
                    if (test != 1 && test != 6 && test != 7)
                    {
                        if (HasRoom(one))
                        {
                            moved = true;
                        }
                        else
                            moved = false;
                    }
                    else
                        moved = false;
                }
                else
                {
                    if (ch.Bags[one.Bag - 1].HasRoom(one) && ch.Bags[two.Bag - 1].HasRoom(two))
                    {
                        moved = true;
                    }
                    else
                        moved = false;
                }
            }

            return moved;
        }
        private void CharacterGainExperience(Client c, BaseEntity entity, Character ch, bool gainedExp)
        {
            if (ch.Party != null && gainedExp == false)
            {
                foreach (Character m in ch.Party.Members)
                {
                    Client member = GetClientByCharacterID(m.CharacterId);
                    CharacterGainExperience(member, entity, m, true);
                }
                return;
            }
            else if (ch.Level < 200)
            {
                Monster m = null;
                if (entity is Monster)
                    m = entity as Monster;

                long charexp = Math.Abs(ch.CurrentExp - ch.NegativeExp);
                bool leveled = false;
                bool training = false;
                int experience = m.Experience - ch.Level;
                if (experience < 0)
                    experience = 1;
                experience = experience * ExperienceMultiper;

                if (ch.Party != null)
                {
                    float maxExp = 1.0f;
                    float divider = 0.1f;
                    divider = maxExp - (divider * ch.Party.MemberCount);

                    experience = (int)(experience * divider);

                    if (experience < 0)
                        experience = 1;
                }

                if (charexp + experience > ch.ExpToTraining)
                {
                    ch.TrainingPoint++;
                    ch.GainedTrainings++;
                    ch.TpLevel++;
                    ch.ExpToTraining = characterManager.GetExperienceToTpByTpLevel(ch.TpLevel);
                    training = true;

                    c.MyCharacter.CalculateTotalStats();
                    c.MyCharacter.CurrentHp = c.MyCharacter.MaxHp;
                    c.MyCharacter.CurrentMana = c.MyCharacter.MaxMana;
                }
                if (charexp + experience > ch.ExpToLevel)
                {
                    ch.StatPoint += (short)ch.GetStatPointsPerLevel();
                    ch.Level++;
                    ch.ExpToLevel = characterManager.GetExperienceToLevelByLevel(ch.Level);
                    ch.NegativeExp = characterManager.GetNegativeExpByLevel(ch.Level);
                    leveled = true;

                    c.MyCharacter.CalculateTotalStats();
                    c.MyCharacter.CurrentHp = c.MyCharacter.MaxHp;
                    c.MyCharacter.CurrentMana = c.MyCharacter.MaxMana;

                    if (ch.Party != null)
                    {
                        foreach (Character p in c.MyCharacter.Party.Members)
                        {
                            Client playerClient = GetClientByCharacterID(p.CharacterId);
                            playerClient.Send(PacketManager.SendParty(c.MyCharacter.Party));
                        }
                    }
                }

                ch.CurrentExp += experience;

                characterManager.UpdateCharacter(ch);

                byte[] SendExpEffectPacket = PacketManager.SendExpEffectPacket(m);
                c.Send(SendExpEffectPacket);

                byte[] SendExpMaybe = PacketManager.SendExperience(ch, experience, 0, leveled, training);
                c.Send(SendExpMaybe);

                byte[] bufferSendStats = PacketManager.SendStats(c.MyCharacter);
                c.Send(bufferSendStats);
            }
        }
        public void SendCommandHelp(string message, Client c)
        {
            Character fakeChar = new Character { CharacterId = -1, Name = "CONSOLE" };

            ChatMessageInfo msg = new ChatMessageInfo { Message = message, Type = ChatType.Guild, TargetName = "" };
            byte[] packet = PacketManager.SendChatMessage(fakeChar, msg);
            c.Send(packet);
        }
        public void SendChatToAll(string message)
        {
            Character fakeChar = new Character { CharacterId = -1, Name = "CONSOLE" };

            ChatMessageInfo msg = new ChatMessageInfo { Message = message, Type = ChatType.Pipe3, TargetName = "" };
            byte[] packet = PacketManager.SendChatMessage(fakeChar, msg);
            SendToAll(packet);
        }
 public static byte[] SendRemoveCharacter(Character ch)
 {
     Packet p = new Packet(200);
     p.WriteHexString("00");
     p.WriteInt(ch.CharacterId);
     p.WriteHexString("01");
     p.WriteInt(ch.MapId);
     p.WriteHexString("00");
     return p.GetWrittenBuffer(PacketIds.SendRemoveCharacter);
 }
 public static byte[] SendSpawn10(Character Char)
 {
     Packet p = new Packet(200);
     p.WriteByte(0);
     p.WriteInt(Char.MapId);
     p.WriteInt(Char.CharacterId);
     p.WriteByte(Char.Class);
     p.WriteShort(Char.X);
     p.WriteShort(Char.Y);
     p.WriteHexString("00 00 00 00 13 00 00 00 00 00 00 00 00");
     return p.GetWrittenBuffer(PacketIds.SendSpawn);
 }
Exemple #22
0
        public bool MoveItem(Character ch, BaseItem item, byte slot, out BaseItem swappedItem)
        {
            bool moved = false;
            List<BaseItem> conflictingItems = null;
            swappedItem = null;

            if (!IsSlotValid(item, slot))
            {
                throw new InvalidItemSlotException("NO PUT ON EDGE PUJJ");
            }

            if (!HasNoRoom(item, slot, out conflictingItems))
            {
                moved = true;
                //if (!this.items.Any(x => x.ItemID == item.ItemID))
                //    this.AddItem(item);
            }
            else //later add swapping
            {
                BaseItem conflict = null;

                if (conflictingItems.Count == 1)
                {
                    conflict = conflictingItems.First();

                    if (conflict == item)
                        moved = true;

                    if (conflict.Slot == slot)
                    {
                        if (conflict.SizeX == item.SizeX)
                        {
                            moved = true;
                            swappedItem = conflict;
                        }
                        else
                        {
                            moved = SwapDifferentSize(ch, item, conflict, slot);
                            swappedItem = conflict;
                        }
                    }
                    else
                    {
                        if (item.SizeX > 1)
                        {
                            if (slot + 1 != conflict.Slot && slot + 6 != conflict.Slot && slot + 7 != conflict.Slot && slot - 5 != conflict.Slot) // so it wont let you overlay stuff from left to right
                                moved = true;
                        }
                        else
                        {
                            if (slot - 1 != conflict.Slot && slot - 6 != conflict.Slot && slot - 7 != conflict.Slot) // so it wont let you overlay stuff from left to right
                                moved = true;

                            //    moved = false;
                            //no room plx
                        }
                    }
                }
                else
                {
                    var q = conflictingItems.Where(x => x.Slot == item.Slot ||
                                                                  x.Slot + 1 == item.Slot ||
                                                                  x.Slot + 6 == item.Slot ||
                                                                  x.Slot + 7 == item.Slot);

                    moved = false;

                    //if(conflict.SizeX == 1 && conflict.SizeX >1)
                    //{
                    //}
                    //else
                    //{
                    //    //no room plx
                    //}
                }

            }

            return moved;
        }
        // something about repulation, current hp/mana, stats
        public static byte[] SendSpawnStats(Character ch)
        {
            Packet p = new Packet(200);
            p.WriteShort(ch.Level);
            p.WriteShort(ch.Strength);
            p.WriteShort(ch.Stamina);
            p.WriteShort(ch.Dexterity);
            p.WriteShort(ch.Energy);
            p.WriteHexString("01 01 01 01"); // unknown :(, maybe base stats?: D
            p.WriteShort(ch.MaxMana);
            p.WriteShort(ch.CurrentMana);
            p.WriteInt(ch.MaxHp);
            p.WriteInt(ch.CurrentHp);
            p.WriteLong(ch.CurrentExp); // cur exp
            p.WriteHexString("00 00 00 00 00 00 00 00"); // curxp to next training
            p.WriteLong(1200000); // exp to level
            p.WriteHexString("00 00 00 00 00 00 00 00"); // xp to next training
            p.WriteHexString("00 00");
            p.WriteHexString("04 00 00 00");
            p.WriteHexString("00 00");
            p.WriteHexString("08 00 00 00");
            p.WriteShort(ch.StatPoint); // stat points
            p.WriteHexString("6B 00 00 00"); // total trainings?
            p.WriteShort(ch.TrainingPoint); // current trainings
            p.WriteHexString("7C 00"); // damage from stats
            p.WriteHexString("C5 00 00 00"); // total damage (from items, skills etc)
            p.WriteHexString("11 00"); // defence from stats
            p.WriteHexString("12 00 00 00"); // total defence (from items, skills etc)
            p.WriteHexString("13 00"); // attack rating from stats
            p.WriteHexString("14 00 00 00"); // total attack rating (from items, skills etc)
            p.WriteHexString("07 00"); // attack range or speed
            p.WriteHexString("0B 0B"); // animation speed (the speed hax thingy in xiah 2827)
            p.WriteHexString("0B"); // movement speed, from shoes ^_ ^
            p.WriteHexString("00 00 00 00 00");
            p.WriteInt(ch.Money);
            p.WriteHexString("02 00");  // Critical
            p.WriteHexString("1A 00");
            p.WriteInt(ch.Fame);
            p.WriteShort(ch.FiveElementPoint); // five element points (unused)
            p.WriteInt(ch.CurrentFEExp); // current fe experience
            p.WriteHexString("02 00 00 00"); // fe experience to point, 40000 each level
            p.WriteHexString("00 00 00 00"); // that other five element skill experience :S
            p.WriteHexString("00 00"); // fire fe level
            p.WriteHexString("00 00"); // water fe level
            p.WriteHexString("00 00"); // wood fe level
            p.WriteHexString("00 00"); // steel fe level
            p.WriteHexString("00 00"); // soil fe level
            p.WriteByte(ch.Rebirth); // rebirths
            p.WriteInt(ch.RepulationPoint); // Repulation points, the points near stat ones :U

            return p.GetWrittenBuffer(PacketIds.SendSpawnStats);
        }
Exemple #24
0
        public Monster[] GetMonstersByRange(Character ch, int distance)
        {
            try
            {
                //var map = maps.Where(x => x.MapID == ch.MapId).First();
                var monsters = Map.Monsters.Where(x => x.Alive && GetDistance(x.Position.X, x.Position.Y, ch.Position.X, ch.Position.Y) < distance);

                return monsters.ToArray();
            }
            catch
            {
                return null;
            }
        }
        public static Character RecvCreateCharacter(Packet p)
        {
            p.Skip(2);
            byte cClass = p.ReadByte();
            string name = p.ReadString();

            Character c = new Character()
            {
                Class = cClass,
                Name = name
            };

            return c;
        }
Exemple #26
0
        public Npc[] GetNearbyNpcs(Character ch)
        {
            try
            {
                //var map = maps.Where(x => x.MapID == ch.MapId).First();
                var nearbyNpcs = Map.Npcs.Where(x => (GetDistance(x.Position.X, x.Position.Y, ch.Position.X, ch.Position.Y) < 150));

                return nearbyNpcs.ToArray();
            }
            catch
            {
                return null;
            }
        }
 public static byte[] SendChatMessage(Character ch, ChatMessageInfo cmi)
 {
     Packet p = new Packet(200);
     p.WriteInt(ch.CharacterId);
     p.WriteByte((byte)cmi.Type); // chat type probably
     p.WriteString(cmi.Message);
     p.WriteString(ch.Name);
     if (cmi.Type == ChatType.Whisper)
     {
         p.WriteInt(cmi.TargetID);
         p.WriteString(cmi.TargetName);
     }
     return p.GetWrittenBuffer(PacketIds.SendChatMessage);
 }
Exemple #28
0
 public StrengthenMonster(DateTime casted, BaseSkill skill, Pet target, Character caster)
     : base(casted, skill, target, caster)
 {
 }
        public List<GuildMember> GetGuildMembersByGuildID(int guildID)
        {
            DbParameter guildIdParameter = _db.CreateParameter(DbNames.GETGUILDMEMBERSBYID_GUILDID, guildID);
            guildIdParameter.DbType = DbType.Int32;

            List<GuildMember> members = new List<GuildMember>();

            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETGUILDMEMBERSBYID, CommandType.StoredProcedure, guildIdParameter);

            int ordinalGUILDMEMBER_TITLE = reader.GetOrdinal(DbNames.GUILDMEMBER_TITLE);
            int ordinalGUILDMEMBER_RANK = reader.GetOrdinal(DbNames.GUILDMEMBER_RANK);
            int ordinalCHARACTER_ID = reader.GetOrdinal(DbNames.CHARACTER_ID);
            int ordinalCHARACTER_ACCOUNTID = reader.GetOrdinal(DbNames.CHARACTER_ACCOUNTID);
            int ordinalCHARACTER_NAME = reader.GetOrdinal(DbNames.CHARACTER_NAME);
            int ordinalCHARACTER_CLASS = reader.GetOrdinal(DbNames.CHARACTER_CLASS);
            int ordinalCHARACTER_LEVEL = reader.GetOrdinal(DbNames.CHARACTER_LEVEL);
            int ordinalCHARACTER_MAPID = reader.GetOrdinal(DbNames.CHARACTER_MAPID);
            int ordinalCHARACTER_CURRENTHP = reader.GetOrdinal(DbNames.CHARACTER_CURRENTHP);
            int ordinalCHARACTER_CURRENTMANA = reader.GetOrdinal(DbNames.CHARACTER_CURRENTMANA);
            int ordinalCHARACTER_STRENGTH = reader.GetOrdinal(DbNames.CHARACTER_STRENGTH);
            int ordinalCHARACTER_STAMINA = reader.GetOrdinal(DbNames.CHARACTER_STAMINA);
            int ordinalCHARACTER_DEXTERITY = reader.GetOrdinal(DbNames.CHARACTER_DEXTERITY);
            int ordinalCHARACTER_ENERGY = reader.GetOrdinal(DbNames.CHARACTER_ENERGY);
            int ordinalCHARACTER_X = reader.GetOrdinal(DbNames.CHARACTER_X);
            int ordinalCHARACTER_Y = reader.GetOrdinal(DbNames.CHARACTER_Y);
            int ordinalCHARACTER_FAME = reader.GetOrdinal(DbNames.CHARACTER_FAME);
            int ordinalCHARACTER_MONEY = reader.GetOrdinal(DbNames.CHARACTER_MONEY);
            int ordinalCHARACTER_STATPOINT = reader.GetOrdinal(DbNames.CHARACTER_STATPOINT);
            int ordinalCHARACTER_TRAININGPOINT = reader.GetOrdinal(DbNames.CHARACTER_TRAININGPOINT);
            int ordinalCHARACTER_GAINEDTRAININGS = reader.GetOrdinal(DbNames.CHARACTER_GAINEDTRAININGS);
            int ordinalCHARACTER_TPLEVEL = reader.GetOrdinal(DbNames.CHARACTER_TPLEVEL);
            int ordinalCHARACTER_FIVEELEMENTPOINT = reader.GetOrdinal(DbNames.CHARACTER_FIVEELEMENTPOINT);
            int ordinalCHARACTER_REPULATIONPOINT = reader.GetOrdinal(DbNames.CHARACTER_REPULATIONPOINT);
            int ordinalCHARACTER_CURRENTEXP = reader.GetOrdinal(DbNames.CHARACTER_CURRENTEXP);
            int ordinalCHARACTER_CURRENTFEEXP = reader.GetOrdinal(DbNames.CHARACTER_CURRENTFEEXP);
            int ordinalCHARACTER_REBIRTH = reader.GetOrdinal(DbNames.CHARACTER_REBIRTH);

            while (reader.Read())
            {
                Character c = new Character();

                byte ClassType = reader.GetByte(ordinalCHARACTER_CLASS);

                switch (ClassType)
                {
                    case 1:
                        c = new Swordman();
                        break;
                    case 2:
                        c = new Mage();
                        break;
                    case 3:
                        c = new Warrior();
                        break;
                    case 4:
                        c = new GhostFighter();
                        break;
                    default:
                        break;
                }

                c.CharacterId = reader.GetInt32(ordinalCHARACTER_ID);
                c.AccountId = reader.GetInt32(ordinalCHARACTER_ACCOUNTID);
                c.Name = reader.GetString(ordinalCHARACTER_NAME);
                c.Class = ClassType; //ofc nn for that
                c.Level = reader.GetInt16(ordinalCHARACTER_LEVEL);
                c.MapId = reader.GetInt32(ordinalCHARACTER_MAPID);
                c.CurrentHp = reader.GetInt32(ordinalCHARACTER_CURRENTHP);
                c.CurrentMana = reader.GetInt32(ordinalCHARACTER_CURRENTMANA);
                c.Strength = reader.GetInt16(ordinalCHARACTER_STRENGTH);
                c.Stamina = reader.GetInt16(ordinalCHARACTER_STAMINA);
                c.Dexterity = reader.GetInt16(ordinalCHARACTER_DEXTERITY);
                c.Energy = reader.GetInt16(ordinalCHARACTER_ENERGY);
                c.Position = new Position();
                c.Position.X = reader.GetInt16(ordinalCHARACTER_X);
                c.Position.Y = reader.GetInt16(ordinalCHARACTER_Y);
                c.Fame = reader.GetInt32(ordinalCHARACTER_FAME);
                c.Money = reader.GetInt32(ordinalCHARACTER_MONEY);
                c.StatPoint = reader.GetInt16(ordinalCHARACTER_STATPOINT);
                c.TrainingPoint = reader.GetInt16(ordinalCHARACTER_TRAININGPOINT);
                c.GainedTrainings = reader.GetInt16(ordinalCHARACTER_GAINEDTRAININGS);
                c.TpLevel = reader.GetInt16(ordinalCHARACTER_TPLEVEL);
                c.FiveElementPoint = reader.GetInt16(ordinalCHARACTER_FIVEELEMENTPOINT);
                c.RepulationPoint = reader.GetInt32(ordinalCHARACTER_REPULATIONPOINT);
                c.CurrentExp = reader.GetInt64(ordinalCHARACTER_CURRENTEXP);
                c.CurrentFEExp = reader.GetInt32(ordinalCHARACTER_CURRENTFEEXP);
                c.Rebirth = reader.GetByte(ordinalCHARACTER_REBIRTH);

                string title = reader.GetString(ordinalGUILDMEMBER_TITLE);
                GuildOrder rank = (GuildOrder)reader.GetInt32(ordinalGUILDMEMBER_RANK);

                members.Add(new GuildMember(title, rank, c));
            }

            reader.Close();
            _db.Close();

            return members;
        }
Exemple #30
0
 public void IncementPlayerCount(Character character, bool scale)
 {
     ++_playerCount;
     if (scale)
     {
         //scale ai for players
     }
     ++_playerByRaceCount[character.GetRace()]; // race
 }
Exemple #31
0
        public MapItem[] GetNearbyMapItems(Character ch)
        {
            var nearbyMapItems = mapItems.Where(x => (GetDistance(x.MapX, x.MapY, ch.Position.X, ch.Position.Y) < 150));

            return nearbyMapItems.ToArray();
        }
 public ClientCharacterCreateInfoEventArgs(Character createCharacterDetails, Packet p)
 {
     this.createCharacter = createCharacterDetails;
 }
Exemple #33
0
 public static bool IsWalkableTile(Character ch)
 {
     return ch.Map.WalkableTiles[(short)ch.Position.X, (short)ch.Position.Y];
 }
 public HazeDamageCastedEventArgs(BaseEntity[] targets, Character caster)
 {
     this.targets = targets;
     this.caster = caster;
 }