Example #1
0
        void RecvCreateActionDisplayAtEntity(IIPSocket conn, BitStream r)
        {
            ActionDisplayID actionDisplayId   = r.ReadActionDisplayID();
            MapEntityIndex  sourceEntityIndex = r.ReadMapEntityIndex();
            bool            hasTarget         = r.ReadBool();
            MapEntityIndex? targetEntityIndex = hasTarget ? r.ReadMapEntityIndex() : (MapEntityIndex?)null;

            // Get the entities
            var sourceEntity = _objGrabber.GetDynamicEntity <Character>(sourceEntityIndex);

            if (sourceEntity == null)
            {
                return;
            }

            var targetEntity = targetEntityIndex.HasValue ? _objGrabber.GetDynamicEntity <Character>(targetEntityIndex.Value) : null;

            // Get the action display
            var ad = ActionDisplayScripts.ActionDisplays[actionDisplayId];

            if (ad == null)
            {
                return;
            }

            // Create
            ad.Execute(Map, sourceEntity, targetEntity);
        }
Example #2
0
        public static PacketWriter CreateActionDisplayAtEntity(ActionDisplayID actionDisplayId, MapEntityIndex sourceEntityIndex, MapEntityIndex? targetEntityIndex = null)
        {
            var pw = GetWriter(ServerPacketID.CreateActionDisplayAtEntity);
            pw.Write(actionDisplayId);
            pw.Write(sourceEntityIndex);

            pw.Write(targetEntityIndex.HasValue);
            if (targetEntityIndex.HasValue)
                pw.Write(targetEntityIndex.Value);

            return pw;
        }
Example #3
0
        public static PacketWriter CharAttack(MapEntityIndex attacker, MapEntityIndex? attacked = null, ActionDisplayID? actionDisplay = null)
        {
            var pw = GetWriter(ServerPacketID.CharAttack);
            pw.Write(attacker);

            pw.Write(attacked.HasValue);
            if (attacked.HasValue)
                pw.Write(attacked.Value);

            pw.Write(actionDisplay.HasValue);
            if (actionDisplay.HasValue)
                pw.Write(actionDisplay.Value);

            return pw;
        }
Example #4
0
        void RecvCharAttack(IIPSocket conn, BitStream r)
        {
            // Read the values
            var attackerID = r.ReadMapEntityIndex();

            MapEntityIndex?attackedID;

            if (r.ReadBool())
            {
                attackedID = r.ReadMapEntityIndex();
            }
            else
            {
                attackedID = null;
            }

            ActionDisplayID?actionDisplayIDNullable;

            if (r.ReadBool())
            {
                actionDisplayIDNullable = r.ReadActionDisplayID();
            }
            else
            {
                actionDisplayIDNullable = null;
            }

            // Get the object references using the IDs provided
            var attacker = _objGrabber.GetDynamicEntity <Character>(attackerID);

            if (attacker == null)
            {
                return;
            }

            DynamicEntity attacked = attackedID.HasValue ? Map.GetDynamicEntity(attackedID.Value) : null;

            // Use the default ActionDisplayID if we were provided with a null value
            ActionDisplayID actionDisplayID = !actionDisplayIDNullable.HasValue ? GameData.DefaultActionDisplayID : actionDisplayIDNullable.Value;

            // Get the ActionDisplay to use and, if valid, execute it
            var actionDisplay = ActionDisplayScripts.ActionDisplays[actionDisplayID];

            if (actionDisplay != null)
            {
                actionDisplay.Execute(Map, attacker, attacked);
            }
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActionDisplay"/> class.
 /// </summary>
 /// <param name="id">The <see cref="ActionDisplayID"/>.</param>
 public ActionDisplay(ActionDisplayID id)
 {
     _id = id;
 }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ItemEntity"/> class.
        /// </summary>
        /// <param name="pos">The pos.</param>
        /// <param name="size">The size.</param>
        /// <param name="templateID">The template ID.</param>
        /// <param name="name">The name.</param>
        /// <param name="desc">The desc.</param>
        /// <param name="type">The type.</param>
        /// <param name="weaponType">Type of the weapon.</param>
        /// <param name="range">The range.</param>
        /// <param name="graphic">The graphic.</param>
        /// <param name="value">The value.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="hp">The hp.</param>
        /// <param name="mp">The mp.</param>
        /// <param name="equippedBody">The equipped body.</param>
        /// <param name="actionDisplayID">The action display ID.</param>
        /// <param name="baseStats">The base stats.</param>
        /// <param name="reqStats">The req stats.</param>
        ItemEntity(Vector2 pos, Vector2 size, ItemTemplateID? templateID, string name, string desc, ItemType type,
                   WeaponType weaponType, ushort range, GrhIndex graphic, int value, byte amount, SPValueType hp, SPValueType mp,
                   string equippedBody, ActionDisplayID? actionDisplayID, IEnumerable<Stat<StatType>> baseStats,
                   IEnumerable<Stat<StatType>> reqStats) : base(pos, size)
        {
            _templateID = templateID;
            _name = name;
            _description = desc;
            _graphicIndex = graphic;
            _value = value;
            _amount = amount;
            _type = type;
            _weaponType = weaponType;
            _range = range;
            _hp = hp;
            _mp = mp;
            _equippedBody = equippedBody;
            _actionDisplayID = actionDisplayID;

            _baseStats = NewItemStats(baseStats, StatCollectionType.Base);
            _reqStats = NewItemStats(reqStats, StatCollectionType.Requirement);

            Resized += ItemEntity_Resized;
        }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ItemTable"/> class.
 /// </summary>
 /// <param name="actionDisplayID">The initial value for the corresponding property.</param>
 /// <param name="amount">The initial value for the corresponding property.</param>
 /// <param name="description">The initial value for the corresponding property.</param>
 /// <param name="equippedBody">The initial value for the corresponding property.</param>
 /// <param name="graphic">The initial value for the corresponding property.</param>
 /// <param name="height">The initial value for the corresponding property.</param>
 /// <param name="hP">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="itemTemplateID">The initial value for the corresponding property.</param>
 /// <param name="mP">The initial value for the corresponding property.</param>
 /// <param name="name">The initial value for the corresponding property.</param>
 /// <param name="range">The initial value for the corresponding property.</param>
 /// <param name="statAgi">The initial value for the corresponding property.</param>
 /// <param name="statDefence">The initial value for the corresponding property.</param>
 /// <param name="statInt">The initial value for the corresponding property.</param>
 /// <param name="statMaxhit">The initial value for the corresponding property.</param>
 /// <param name="statMaxhp">The initial value for the corresponding property.</param>
 /// <param name="statMaxmp">The initial value for the corresponding property.</param>
 /// <param name="statMinhit">The initial value for the corresponding property.</param>
 /// <param name="statReqAgi">The initial value for the corresponding property.</param>
 /// <param name="statReqInt">The initial value for the corresponding property.</param>
 /// <param name="statReqStr">The initial value for the corresponding property.</param>
 /// <param name="statStr">The initial value for the corresponding property.</param>
 /// <param name="type">The initial value for the corresponding property.</param>
 /// <param name="value">The initial value for the corresponding property.</param>
 /// <param name="weaponType">The initial value for the corresponding property.</param>
 /// <param name="width">The initial value for the corresponding property.</param>
 public ItemTable(ActionDisplayID? @actionDisplayID, Byte @amount, String @description, String @equippedBody,
                  GrhIndex @graphic, Byte @height, SPValueType @hP, ItemID @iD, ItemTemplateID? @itemTemplateID,
                  SPValueType @mP, String @name, UInt16 @range, Int16 @statAgi, Int16 @statDefence, Int16 @statInt,
                  Int16 @statMaxhit, Int16 @statMaxhp, Int16 @statMaxmp, Int16 @statMinhit, Int16 @statReqAgi,
                  Int16 @statReqInt, Int16 @statReqStr, Int16 @statStr, ItemType @type, Int32 @value,
                  WeaponType @weaponType, Byte @width)
 {
     ActionDisplayID = @actionDisplayID;
     Amount = @amount;
     Description = @description;
     EquippedBody = @equippedBody;
     Graphic = @graphic;
     Height = @height;
     HP = @hP;
     ID = @iD;
     ItemTemplateID = @itemTemplateID;
     MP = @mP;
     Name = @name;
     Range = @range;
     SetStat(StatType.Agi, @statAgi);
     SetStat(StatType.Defence, @statDefence);
     SetStat(StatType.Int, @statInt);
     SetStat(StatType.MaxHit, @statMaxhit);
     SetStat(StatType.MaxHP, @statMaxhp);
     SetStat(StatType.MaxMP, @statMaxmp);
     SetStat(StatType.MinHit, @statMinhit);
     SetReqStat(StatType.Agi, @statReqAgi);
     SetReqStat(StatType.Int, @statReqInt);
     SetReqStat(StatType.Str, @statReqStr);
     SetStat(StatType.Str, @statStr);
     Type = @type;
     Value = @value;
     WeaponType = @weaponType;
     Width = @width;
 }