Ejemplo n.º 1
0
        public override void ActOnUse(WorldObject activator)
        {
            if (!(activator is Player player))
            {
                return;
            }

            // Good PCAP example of using a PetDevice to summon a pet:
            // Asherons-Call-packets-includes-3-towers\pkt_2017-1-30_1485823896_log.pcap lines 27837 - 27843

            if (!PetDeviceToPetMapping.TryGetValue(WeenieClassId, out var petData))
            {
                Console.WriteLine($"PetDevice.UseItem(): couldn't find a matching pet for essence wcid {WeenieClassId}");
                return;
            }

            var wcid       = petData.Item1;
            var damageType = petData.Item2;

            if (SummonCreature(player, wcid, damageType))
            {
                // decrease remaining uses
                if (--Structure <= 0)
                {
                    player.TryConsumeFromInventoryWithNetworking(this, 1);
                }

                player.Session.Network.EnqueueSend(new GameMessagePublicUpdatePropertyInt(this, PropertyInt.Structure, Structure.Value));
            }
            else
            {
                // this would be a good place to send a friendly reminder to install the latest summoning updates from ACE-World-Patch
            }
        }
Ejemplo n.º 2
0
        public override void UseItem(Player player)
        {
            // Good PCAP example of using a PetDevice to summon a pet:
            // Asherons-Call-packets-includes-3-towers\pkt_2017-1-30_1485823896_log.pcap lines 27837 - 27843

            if (!PetDeviceToPetMapping.TryGetValue(WeenieClassId, out var petData))
            {
                Console.WriteLine($"PetDevice.UseItem(): couldn't find a matching pet for essence wcid {WeenieClassId}");
                player.SendUseDoneEvent();
                return;
            }

            if (!CheckRequirements(player))
            {
                return;
            }

            if (!CheckCooldown(player))
            {
                // 'You have used this item too recently' error message?
                player.SendUseDoneEvent();
                return;
            }

            var wcid       = petData.Item1;
            var damageType = petData.Item2;

            if (SummonCreature(player, wcid, damageType))
            {
                // track usage for cooldown
                if (!player.LastUseTracker.ContainsKey(CooldownId.Value))
                {
                    player.LastUseTracker.Add(CooldownId.Value, DateTime.UtcNow);
                }
                else
                {
                    player.LastUseTracker[CooldownId.Value] = DateTime.UtcNow;
                }

                // decrease remaining uses
                if (--Structure <= 0)
                {
                    player.TryConsumeFromInventoryWithNetworking(this, 1);
                }

                player.Session.Network.EnqueueSend(new GameMessagePublicUpdatePropertyInt(this, PropertyInt.Structure, Structure.Value));
            }
            else
            {
                // this would be a good place to send a friendly reminder to install the latest summoning updates from ACE-World-Patch
            }

            player.SendUseDoneEvent();
        }