Exemple #1
0
                public static Struct Decoded(byte[] data)
                {
                    var packet = new GamePacket(data);
                    var result = new Struct();

                    packet.Position      = 5;
                    result.UnitNetworkId = packet.ReadInteger();
                    packet.Position      = 184;
                    var b = packet.ReadByte();

                    packet.Position = 81;
                    var b2 = packet.ReadByte();

                    result.Status = RecallStatus.Unknown;

                    var gObject = ObjectManager.GetUnitByNetworkId <GameObject>(result.UnitNetworkId);

                    if (gObject == null || !gObject.IsValid)
                    {
                        return(result);
                    }

                    if (gObject is Obj_AI_Hero)
                    {
                        var unit = (Obj_AI_Hero)gObject;

                        if (!unit.IsValid || unit.Spellbook.GetSpell(SpellSlot.Recall) == null)
                        {
                            return(result);
                        }

                        result.Type = ObjectType.Player;
                        var duration = Utility.GetRecallTime(unit);

                        result.Duration = duration;

                        if (!RecallT.ContainsKey(result.UnitNetworkId))
                        {
                            RecallT.Add(result.UnitNetworkId, 0);
                        }

                        if (!TPT.ContainsKey(result.UnitNetworkId))
                        {
                            TPT.Add(result.UnitNetworkId, 0);
                        }


                        if (b2 != 0 ||
                            TPT.ContainsKey(result.UnitNetworkId) &&
                            Environment.TickCount - TPT[result.UnitNetworkId] < 4500)
                        {
                            if (b2 != 0)
                            {
                                TPT[result.UnitNetworkId] = Environment.TickCount;
                                result.Status             = RecallStatus.TeleportStart;
                            }

                            else if (Environment.TickCount - TPT[result.UnitNetworkId] < 3500)
                            {
                                result.Status             = RecallStatus.TeleportAbort;
                                TPT[result.UnitNetworkId] = 0;
                            }
                            else if (Environment.TickCount - TPT[result.UnitNetworkId] < 4500)
                            {
                                result.Status             = RecallStatus.TeleportEnd;
                                TPT[result.UnitNetworkId] = 0;
                            }
                        }
                        else
                        {
                            switch (b)
                            {
                            case 4:
                                if (RecallT.ContainsKey(result.UnitNetworkId))
                                {
                                    if (Environment.TickCount - RecallT[result.UnitNetworkId] < duration - 1200)
                                    {
                                        result.Status = RecallStatus.RecallAborted;
                                    }
                                    else if (Environment.TickCount - RecallT[result.UnitNetworkId] < duration + 1000)
                                    {
                                        result.Status = RecallStatus.RecallFinished;
                                    }
                                    RecallT[result.UnitNetworkId] = 0;
                                }
                                break;

                            case 6:
                                result.Status = RecallStatus.RecallStarted;
                                RecallT[result.UnitNetworkId] = Environment.TickCount;
                                break;
                            }
                        }
                    }
                    else if (gObject is Obj_AI_Turret)
                    {
                        result.Type   = ObjectType.Turret;
                        result.Status = b2 != 0 ? RecallStatus.TeleportStart : RecallStatus.TeleportEnd;
                    }
                    else if (gObject is Obj_AI_Minion)
                    {
                        result.Type = ObjectType.Object;

                        if (gObject.Name.Contains("Minion"))
                        {
                            result.Type = ObjectType.Minion;
                        }
                        if (gObject.Name.Contains("Ward"))
                        {
                            result.Type = ObjectType.Ward;
                        }

                        result.Status = b2 != 0 ? RecallStatus.TeleportStart : RecallStatus.TeleportEnd;
                    }
                    else
                    {
                        result.Type = ObjectType.Object;
                    }


                    return(result);
                }
Exemple #2
0
 /// <summary>
 ///     Gets the duration.
 /// </summary>
 /// <param name="args">The <see cref="GameObjectTeleportEventArgs" /> instance containing the event data.</param>
 /// <returns>System.Int32.</returns>
 public int GetDuration(GameObjectTeleportEventArgs args)
 {
     return(Utility.GetRecallTime(args.RecallName));
 }