Ejemplo n.º 1
0
        public static void Update()
        {
            Ped[] peds = World.GetNearbyPeds(Game.Player.Character, 1000.0f);

            VehicleController.GetNearbyVehiclesByFilter(Game.Player.Character.Position,
                                                        Filters.IsVehicleDestroyedByPlayer
                                                        ).ForEach(
                veh => {
                if (!VehiclesDestroyed.Contains(veh.GetHashCode()))
                {
                    int killReward = 0;

                    if (Filters.IsPoliceVehicle(veh))
                    {
                        killReward = 100;
                    }
                    else
                    {
                        killReward = 5;
                    }

                    Game.Player.Money += killReward;
                    VehiclesDestroyed.Add(veh.GetHashCode());
                }
            }
                );

            // TODO: PedTracker.cs
            for (int i = 0; i < peds.Length; i++)
            {
                if (peds[i].Exists() && peds[i].HasBeenDamagedBy(Game.Player.Character) && peds[i].IsDead)
                {
                    if (!PedsKilled.Contains(peds[i].GetHashCode()))
                    {
                        PedsKilled.Add(peds[i].GetHashCode());

                        int killReward = 0;

                        if (peds[i].Model == PedHash.Cop01SMY || peds[i].Model == PedHash.Cop01SFY)
                        {
                            killReward = 10;
                        }
                        else
                        {
                            killReward = 5;
                        }

                        if (peds[i].IsInCombat)
                        {
                            killReward += 2;
                        }
                        if (peds[i].IsInFlyingVehicle)
                        {
                            killReward += 15;
                        }
                        else if (peds[i].IsInBoat)
                        {
                            killReward += 10;
                        }
                        else if (peds[i].IsInPoliceVehicle)
                        {
                            killReward += 2;
                        }
                        else if (peds[i].IsInVehicle())
                        {
                            killReward += 5;
                        }

                        if (peds[i].IsVaulting || peds[i].IsFleeing || peds[i].IsAimingFromCover ||
                            peds[i].IsGoingIntoCover)
                        {
                            killReward += 2;
                        }

                        Game.Player.Money += killReward;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void UpdateHUD()
        {
            VehicleController.GetNearbyVehiclesByFilter(Game.Player.Character.Position, Filters.IsPoliceVehicle).ForEach(
                veh => {
                if (veh.Exists() &&
                    !UIElements.ContainsKey(veh.GetHashCode().ToString() + "_bg") &&
                    veh.IsOnScreen
                    )
                {
                    var background = new UIElementController(
                        new NativeUI.Elements.NativeSprite("vehicle_warfare", "vehicleHealthBarBackground", new Point(0, 0), new Size(96, 18)),
                        (that) => {
                        var parent           = (UIElementController)that;
                        parent.IsDrawable    = true;
                        float verticalOffset = 1.2f;

                        if (veh.Exists() && veh.IsDriveable)
                        {
                            var distance = World.GetDistance(Game.Player.Character.Position, veh.Position);
                            if (distance > 100.0f)
                            {
                                parent.IsDrawable = false;
                                return;
                            }

                            // Calculate verticaloffset based off distance
                            if (distance > 20.0f)
                            {
                                verticalOffset = distance / 25.0f;
                            }
                            else if (distance < 20.0f)
                            {
                                verticalOffset = 1.2f;
                            }

                            parent.UIElement = new NativeUI.Elements.NativeSprite("vehicle_warfare", "vehicleHealthBarBackground", new Point(0, 0), new Size(48, 9));
                            Function.Call(Hash.SET_DRAW_ORIGIN, veh.Position.X, veh.Position.Y, veh.Position.Z + verticalOffset, 0);
                            parent.UIElement.Position = new Point(-24, 0);
                        }
                        else
                        {
                            parent.IsDrawable = false;
                        }
                    }
                        );
                    var bar = new UIElementController(
                        new NativeUI.Elements.NativeRectangle(new Point(0, 0), new Size(88, 4), Color.White),
                        (that) => {
                        var parent           = (UIElementController)that;
                        parent.IsDrawable    = true;
                        float verticalOffset = 1.2f;

                        if (veh.Exists() && veh.IsDriveable)
                        {
                            var distance = World.GetDistance(Game.Player.Character.Position, veh.Position);
                            if (distance > 100.0f)
                            {
                                parent.IsDrawable = false;
                                return;
                            }

                            var width = (int)Math.Round(
                                ((veh.Health + 100.0f) / (veh.MaxHealth + 100.0f)) * 44.0f,
                                0
                                );
                            if (width < 0)
                            {
                                width = 0;
                            }


                            // Calculate verticaloffset based off distance
                            if (distance > 30.0f)
                            {
                                verticalOffset = distance / 25.0f;
                            }
                            else if (distance < 30.0f)
                            {
                                verticalOffset = 1.2f;
                            }

                            parent.UIElement = new NativeUI.Elements.NativeRectangle(new Point(0, 0), new Size(width, 2), Color.White);
                            GTA.Native.Function.Call(Hash.SET_DRAW_ORIGIN, veh.Position.X, veh.Position.Y, veh.Position.Z + verticalOffset, 0);
                            parent.UIElement.Position = new Point(-22, 3);
                        }
                        else
                        {
                            parent.IsDrawable = false;
                        }
                    }
                        );

                    UIElements.Add(veh.GetHashCode().ToString() + "_bg", background);
                    UIElements.Add(veh.GetHashCode().ToString() + "_bar", bar);
                }
            }
                );
        }