Пример #1
0
        /// <summary>
        /// Gets the square of the area of the triangle defined by three points. This is useful when simply comparing two areas when you don't need to know exactly what the area is.
        /// </summary>
        /// <param name="vertex1">First vertex of triangle.</param>
        /// <param name="vertex2">Second vertex of triangle.</param>
        /// <param name="vertex3">Third vertex of triangle.</param>
        /// <returns>Square of the area of the triangle defined by these three vertices.</returns>
        public static float TriangleAreaSquared(Vector3 vertex1, Vector3 vertex2, Vector3 vertex3)
        {
            float side1         = vertex1.DistanceTo(vertex2);
            float side2         = vertex1.DistanceTo(vertex3);
            float side3         = vertex2.DistanceTo(vertex3);
            float semiPerimeter = (side1 + side2 + side3) / 2f;

            return(semiPerimeter * (semiPerimeter - side1) * (semiPerimeter - side2) * (semiPerimeter - side3));
        }
Пример #2
0
        public override bool OnBeforeCalloutDisplayed()
        {
            spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(215.0f));
            while (spawnPoint.DistanceTo(Game.LocalPlayer.Character.Position) < 30.0f)
            {
                spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(210.0f)).GetSafeCoordinatesForPed();
                GameFiber.Yield();
            }
            if (spawnPoint == Vector3.Zero)
            {
                spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(195.0f));
            }

            suspect = new Ped(spawnPoint);
            if (!suspect.Exists())
            {
                return(false);
            }
            hostage = new Ped(spawnPoint + suspect.ForwardVector * 0.9f);
            if (!hostage.Exists())
            {
                return(false);
            }

            suspect.BlockPermanentEvents = true;
            hostage.BlockPermanentEvents = true;

            hostage.Heading = suspect.Heading = MathHelper.GetRandomSingle(1f, 359f);

            RelationshipGroup hostageRelation = new RelationshipGroup("HOSTAGE");

            hostage.RelationshipGroup = hostageRelation;
            Game.SetRelationshipBetweenRelationshipGroups(hostageRelation, "COP", Relationship.Companion);
            Game.SetRelationshipBetweenRelationshipGroups(hostageRelation, "PLAYER", Relationship.Companion);
            Game.SetRelationshipBetweenRelationshipGroups("COP", hostageRelation, Relationship.Companion);

            RelationshipGroup suspectRelation = new RelationshipGroup("SUSPECT");

            suspect.RelationshipGroup = suspectRelation;
            Game.SetRelationshipBetweenRelationshipGroups(suspectRelation, "COP", Relationship.Dislike);
            Game.SetRelationshipBetweenRelationshipGroups(suspectRelation, "PLAYER", Relationship.Dislike);
            Game.SetRelationshipBetweenRelationshipGroups("COP", suspectRelation, Relationship.Dislike);

            this.ShowCalloutAreaBlipBeforeAccepting(spawnPoint, 17.5f);
            this.AddMinimumDistanceCheck(15.0f, suspect.Position);

            // Set up our callout message and location
            this.CalloutMessage  = "Hostage situation";
            this.CalloutPosition = spawnPoint;

            //Play the police scanner audio for this callout (available as of the 0.2a API)
            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_ASSAULT_CIVILIAN IN_OR_ON_POSITION UNITS_RESPOND_CODE_03", spawnPoint);

            return(base.OnBeforeCalloutDisplayed());
        }
Пример #3
0
    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(float delta)
    {
        bool is_moving = false;

        if (point.DistanceTo(Transform.origin) > 0.1)
        {
            direction = point - Transform.origin;
            direction = direction.Normalized() * speed;
            is_moving = true;
        }
        else
        {
            direction = point - Transform.origin;
            is_moving = false;
        }

        MoveAndSlide(direction);

        string anim = "Robot_Idle";

        if (is_moving)
        {
            anim = "Robot_Walking";

            float   angle    = (float)Atan2(direction.x, direction.z);
            Vector3 char_rot = body.Rotation;
            char_rot.y    = angle;
            body.Rotation = char_rot;
        }
        else if (is_shooting)
        {
            anim = "Robot_Punch";
        }
        else if (health_points_current <= 0)
        {
            anim = "Robot_Death";
        }

        string curr_anim = anim_player.CurrentAnimation;

        if (anim != curr_anim)
        {
            anim_player.Play(anim);
        }

        // if (Input.IsActionJustPressed("ui_down"))
        // {
        //     Vector3 kek = new Vector3(x, 0, z);
        //     deal_damage(kek);
        //     x -= 1;
        //     z += 1;
        //     GD.Print("x is ", x);
        //     GD.Print("z is ", z);
        // }
    }
Пример #4
0
        public static int getShopByPos(Vector3 pos)
        {
            Vector3        i   = null;
            float          d   = 100;
            List <Vector3> lst = mysql.MySQL_POIData.getShops();

            foreach (Vector3 ps in lst)
            {
                if (pos.DistanceTo(ps) < 5)
                {
                    if (pos.DistanceTo(ps) < d)
                    {
                        d = pos.DistanceTo(ps);
                        i = ps;
                    }
                }
            }

            return(mysql.MySQL_POIData.getID(i));
        }
Пример #5
0
        /// <summary>
        /// Gets nearest vehicle
        /// </summary>
        /// <param name="position">Position for which to get the nearest vehicle</param>
        /// <returns>The vehicle</returns>
        public RPVehicle GetNearestVehicle(Vector3 position)
        {
            if (vehicles.Count == 0) {
                return null;
            }

            RPVehicle nearest = vehicles.First(x => x.spawned);
            float nearestDist = position.DistanceTo(nearest.position);

            foreach (RPVehicle v in vehicles)
            {
                if (v.spawned && position.DistanceTo(v.position) < nearestDist)
                {
                    nearest = v;
                    nearestDist = position.DistanceTo(v.position);
                }
            }

            return nearest;
        }
Пример #6
0
        public static SpawnPoint GetSpawnPoint()
        {
            Vector3 vetSpawnPos = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(190.0f));

            while (vetSpawnPos.DistanceTo(Game.LocalPlayer.Character.Position) < 52.5f)
            {
                vetSpawnPos = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(190.0f));
                GameFiber.Yield();
            }
            return(new SpawnPoint(vetSpawnPos, vetSpawnPos.GetClosestVehicleNodeHeading()));
        }
Пример #7
0
        private void MenuScript_Tick(object sender, EventArgs e)
        {
            lemonPool.Process();
            timerBars.Process();

            hungryBar.Progress = HungryController.ProgressBarStatus;
            waterBar.Progress  = HungryController.WaterBarStatus;
            if (AmmuController.DistanceToAmmu())
            {
                GameUI.DisplayHelp(Strings.AmmuOpenShop);
            }
            if (HungryController.IsPlayerCloseReseller())
            {
                GameUI.DisplayHelp(Strings.FoodOpenShop);
            }
            if (repair.DistanceTo(Game.Player.Character.Position) <= 10f && Game.Player.Character.IsInVehicle())
            {
                GameUI.DisplayHelp(Strings.RepairHelp);
            }
        }
Пример #8
0
 private static bool IsWithinDistanceTo(Vector3 @new, List <Vector3> existing, double tolerance)
 {
     foreach (var v in existing)
     {
         if (@new.DistanceTo(v) < tolerance)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #9
0
 public static BanqueInfo GetBanqueInfoClosePos(Vector3 Pos, float radius)
 {
     foreach (BanqueInfo Banque in BanqueList)
     {
         if (Pos.DistanceTo(Banque.Pos) <= radius)
         {
             return(Banque);
         }
     }
     return(null);
 }
Пример #10
0
 static private bool IsNearButterflies(Vector3 position)
 {
     foreach (var safeZone in _safeZoneColliders)
     {
         if (position.DistanceTo(safeZone.transform.position) <= safeZone.radius)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #11
0
    public void DrawTrail(Vector3 Start, Vector3 End)     //Must be non-static to be RPC-ed
    {
        var Trail = (HitscanTrail)HitscanTrailScene.Instance();

        World.EntitiesRoot.AddChild(Trail);
        Trail.Translation = (Start + End) / 2;

        Trail.LookAt(End, -End);

        Trail.CallDeferred(nameof(HitscanTrail.ApplyLength), Start.DistanceTo(End));
    }
Пример #12
0
    bool AimingAt(Vector3 point)
    {
        Vector3   hostRot    = host.GetRotationDegrees();
        Transform aimedTrans = host.Transform.LookingAt(point, host.Up());
        Vector3   aimedRot   = aimedTrans.basis.GetEuler();

        aimedRot = Util.ToDegrees(aimedRot);
        float aimAngle = hostRot.DistanceTo(aimedRot);

        return(aimAngle < AimMargin);
    }
Пример #13
0
 public static bool IsOverlapping(Vector3 position, Vector3 rotation)
 {
     foreach (var c in Containers)
     {
         if (position.DistanceTo(c.Position) < 10f)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #14
0
 public static ATMInfo GetATMInfoClosePos(Vector3 Pos, float radius)
 {
     foreach (ATMInfo ATM in ATMList)
     {
         if (Pos.DistanceTo(ATM.Pos) <= radius)
         {
             return(ATM);
         }
     }
     return(null);
 }
Пример #15
0
    public float DistanceToActor(Actor actor)
    {
        if (actor == null)
        {
            GD.Print("Actor.DistanceToActor: actor null");
            return(0.0f);
        }
        Vector3 hostPosition  = host.GetGlobalTransform().origin;
        Vector3 actorPosition = actor.GetGlobalTransform().origin;

        return(hostPosition.DistanceTo(actorPosition));
    }
Пример #16
0
        public void CreateRamp(Vector3 top, Vector3 bottom)
        {
            int     num2    = (int)Math.Ceiling(top.DistanceTo(bottom) / 30f);
            Vector3 vector  = new Vector3((top.X - bottom.X) / num2, (top.Y - bottom.Y) / num2, (top.Z - bottom.Z) / num2);
            Vector3 vector2 = Call <Vector3>("vectortoangles", top - bottom);
            Vector3 angles  = new Vector3(vector2.Z, vector2.Y + 90f, vector2.X);

            for (int i = 0; i <= num2; i++)
            {
                SpawnCrate(bottom + (vector * i), angles);
            }
        }
Пример #17
0
        public static void CGPlayer_C__MoveTo(Vector3 point)
        {
            lock (thisLock)
            {
                MovementsAction.Ascend(false);
                MovementsAction.Descend(false);
                if (!Usefuls.InGame || Usefuls.IsLoading)
                {
                    return;
                }

                Helpful.Timer timer = new Helpful.Timer(2000);
                while (ObjectManager.ObjectManager.Me.GetBaseAddress == 0)
                {
                    if (timer.IsReady)
                    {
                        return;
                    }
                    Thread.Sleep(200);
                }
                Usefuls.UpdateLastHardwareAction();
                if (!point.IsValid)
                {
                    return;
                }

                // Allocate Memory:
                uint posCodecave = Memory.WowMemory.Memory.AllocateMemory(0x4 * 3);
                Memory.WowMemory.Memory.WriteFloat(posCodecave, point.X);
                Memory.WowMemory.Memory.WriteFloat(posCodecave + 0x4, point.Y);
                Memory.WowMemory.Memory.WriteFloat(posCodecave + 0x8, point.Z);
                string[] asm = new[]
                {
                    "push " + posCodecave,
                    "mov ecx, " + ObjectManager.ObjectManager.Me.GetBaseAddress,
                    "call " + (Memory.WowProcess.WowModule + (uint)Addresses.FunctionWow.CGPlayer_C__MoveTo),
                    "retn"
                };

                Memory.WowMemory.InjectAndExecute(asm);
                Memory.WowMemory.Memory.FreeMemory(posCodecave);
                if (cache != point)
                {
                    Logging.WriteNavigator("MoveTo(" + point + ")");
                    if (cache.IsValid && cache.DistanceTo(point) > 500)
                    {
                        Logging.WriteDebug("The two previouses CTM were very far appart from each others, logging CallStack.");
                        Logging.WriteDebug(Hook.CurrentCallStack);
                    }
                    cache = point;
                }
            }
        }
Пример #18
0
        /// <summary>
        /// Find the distance from this point to the line, and output the location
        /// of the closest point on that line.
        /// Using formula from https://diego.assencio.com/?index=ec3d5dfdfc0b6a0d147a656f0af332bd
        /// </summary>
        /// <param name="line">The line to find the distance to.</param>
        /// <param name="closestPoint">The point on the line that is closest to this point.</param>
        public static double DistanceTo(this Vector3 point, Line line, out Vector3 closestPoint)
        {
            var lambda =
                (point - line.Start).Dot(line.End - line.Start) /
                (line.End - line.Start).Dot(line.End - line.Start);

            if (lambda >= 1)
            {
                closestPoint = line.End;
                return(point.DistanceTo(line.End));
            }
            else if (lambda <= 0)
            {
                closestPoint = line.Start;
                return(point.DistanceTo(line.Start));
            }
            else
            {
                closestPoint = (line.Start + lambda * (line.End - line.Start));
                return(point.DistanceTo(closestPoint));
            }
        }
Пример #19
0
        internal static byte Intersect(Vector3 parStart, Vector3 parEnd)
        {
            XYZXYZ points = new XYZXYZ(parStart.X, parStart.Y, parStart.Z,
                                       parEnd.X, parEnd.Y, parEnd.Z);

            points.Z1 += 2;
            points.Z2 += 2;
            Intersection intersection = new Intersection();
            float        distance     = parStart.DistanceTo(parEnd);
            int          flags        = 0x100111;

            return(_Intersect(ref points, ref distance, ref intersection, flags));
        }
Пример #20
0
        public void CreateRamp(Vector3 top, Vector3 bottom)
        {
            float   distance = top.DistanceTo(bottom);
            int     blocks   = (int)Math.Ceiling(distance / 30);
            Vector3 A        = new Vector3((top.X - bottom.X) / blocks, (top.Y - bottom.Y) / blocks, (top.Z - bottom.Z) / blocks);
            Vector3 temp     = Call <Vector3>("vectortoangles", new Parameter(top - bottom));
            Vector3 BA       = new Vector3(temp.Z, temp.Y + 90, temp.X);

            for (int b = 0; b <= blocks; b++)
            {
                spawnCrate(bottom + (A * b), BA);
            }
        }
Пример #21
0
        public static List <Prop> FillArea(int hash, Vector3 x1y1, Vector3 x2y2, float rot, float width, float depth)
        {
            int         wide, length;
            float       radrot;
            Vector3     x1y2, x2y1, currpos, nextInRow, nextInColumn, rowpos;
            List <Prop> spawnedProps;

            spawnedProps = new List <Prop>();
            radrot       = rot * ((float)Math.PI / 180);

            // Calculate the rectangle
            x1y2   = new Vector3(x1y1.X, x2y2.Y, x1y1.Z);
            x2y1   = new Vector3(x2y2.X, x1y1.Y, x1y1.Z);
            wide   = (int)(x1y1.DistanceTo(x2y1) / width);
            length = (int)(x1y1.DistanceTo(x1y2) / depth);

            GTA.UI.Screen.ShowHelpTextThisFrame(wide.ToString() + " " + length.ToString());

            currpos      = x1y1;
            nextInRow    = new Vector3((float)Math.Cos(radrot) * width, (float)Math.Sin(radrot) * width, 0);
            nextInColumn = new Vector3((float)Math.Sin(radrot) * depth, (float)Math.Cos(radrot) * depth, 0);

            // Fill in the rectangle
            for (int i = 0; i < wide; i++)
            {
                rowpos = currpos;
                for (int j = 0; j < length; j++)
                {
                    spawnedProps.Add(Maps.Functions.SpawnProp(hash, rowpos, new Vector3(0, 0, rot), false));
                    //UI.Notify(rowpos.ToString());
                    rowpos.X += nextInRow.X;
                    rowpos.Y += nextInRow.Y;
                }
                currpos.X += nextInColumn.X;
                currpos.Y -= nextInColumn.Y;
            }

            return(spawnedProps);
        }
Пример #22
0
        internal static bool IsPlayerCloseReseller()
        {
            Vector3 player = Game.Player.Character.Position;

            foreach (Vector3 coord in resellers)
            {
                if (player.DistanceTo(coord) <= 1.5f)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #23
0
    public List <Creature> GetCreaturesInRadius(Vector3 position, float radius)
    {
        List <Creature> results = new List <Creature>();

        foreach (var creature in this.creatures)
        {
            if (position.DistanceTo(creature.Translation) < radius)
            {
                results.Add(creature);
            }
        }
        return(results);
    }
Пример #24
0
        public static Player GetClosestPlayer(this Client player, int distance = 20)
        {
            Player  closestPlayer = null;
            Vector3 pPos          = player.position;

            foreach (Player p in Player.PlayerData.Values)
            {
                if (p.Client == player)
                {
                    continue;
                }
                if (closestPlayer == null || pPos.DistanceTo(p.Client.position) < pPos.DistanceTo(closestPlayer.Client.position))
                {
                    if (pPos.DistanceTo(p.Client.position) > distance)
                    {
                        continue;
                    }
                    closestPlayer = p;
                }
            }
            return(closestPlayer);
        }
Пример #25
0
        public static bool SomethingIsBetweenPlayerPositionAnd(Vector3 position)
        {
            if (position.Equals(Vector3.Zero) || Game.Player.Character.IsInRangeOf(position, 50.0f))
            {
                return(false);
            }
            else
            {
                RaycastResult r = World.Raycast(GameplayCamera.Position, position, IntersectOptions.Map);

                return(position.DistanceTo(GameplayCamera.Position + GameplayCamera.Direction * 100.0f) > 100.0f || (r.DitHitAnything && r.HitCoords.DistanceTo(GameplayCamera.Position) < 50.0f));
            }
        }
Пример #26
0
    /// <summary>
    /// After the spawnpoints are defined, some tweaks are required just before the battle begins.
    /// </summary>
    private void SetupBattle()
    {
        Interval              = battleInterval;
        spawnpointsDistance   = spawnpointEnemies.DistanceTo(spawnpointAllies);
        spawnedAlliesCounter  = 0;
        spawnedEnemiesCounter = 0;

        if (noWantedLevel)
        {
            originalWantedLevel = Game.MaxWantedLevel;
            Game.MaxWantedLevel = 0;
        }
    }
Пример #27
0
        public override void Process()
        {
            GameFiber.StartNew(delegate
            {
                if (_SpawnPoint.DistanceTo(Game.LocalPlayer.Character) < 25f && Game.LocalPlayer.Character.IsOnFoot && !_notificationDisplayed)
                {
                    if (_SpawnLocation)
                    {
                        _SpawnLocation.Delete();
                    }

                    Game.DisplayHelp("The ~y~Hostage Rescue Team~w~ is ~g~on scene~w~. ");
                    _notificationDisplayed = true;
                }
                if (_AG1.DistanceTo(Game.LocalPlayer.Character) < 14f)
                {
                    if (_Scene1 == true && _Scene2 == false && _AG1.DistanceTo(Game.LocalPlayer.Character) < 18f)
                    {
                        Game.DisplaySubtitle("~y~Criminal~w~ shhh....I am hearing steps!");

                        _AG1.Tasks.FightAgainst(Game.LocalPlayer.Character);
                        _AG2.Tasks.FightAgainst(Game.LocalPlayer.Character);
                    }
                    if (_Scene2 == true && _Scene1 == false && Game.LocalPlayer.Character.DistanceTo(_AG1) < 18f)
                    {
                        _AG1.Tasks.FightAgainstClosestHatedTarget(1000f);
                        _AG2.Tasks.FightAgainstClosestHatedTarget(1000f);

                        _AG1.Tasks.FightAgainst(Game.LocalPlayer.Character);
                        _AG2.Tasks.FightAgainst(Game.LocalPlayer.Character);
                    }
                }
                if (_AG1 && _AG1.IsDead && _AG2 && _AG2.IsDead)
                {
                    End();
                }
                if (_AG1 && Functions.IsPedArrested(_AG1) && _AG2 && Functions.IsPedArrested(_AG2))
                {
                    End();
                }
                if (Game.IsKeyDown(Settings.EndCall))
                {
                    End();
                }
                if (Game.LocalPlayer.Character.IsDead)
                {
                    End();
                }
            }, "Hostages [UnitedCallouts]");
            base.Process();
        }
Пример #28
0
        public override void Process()
        {
            GameFiber.StartNew(delegate
            {
                if (_SpawnPoint.DistanceTo(Game.LocalPlayer.Character) < 25f && Game.LocalPlayer.Character.IsOnFoot && !_notificationDisplayed)
                {
                    if (_SpawnLocation.Exists())
                    {
                        _SpawnLocation.Delete();
                    }

                    Game.DisplayHelp("Het ~y~Gijzelaar Reddingsteam~w~ is ~g~aangekomen~w~. ");
                    _notificationDisplayed = true;
                }
                if (_AG1.DistanceTo(Game.LocalPlayer.Character) < 14f)
                {
                    if (_Scene1 == true && _Scene2 == false && _AG1.DistanceTo(Game.LocalPlayer.Character) < 18f)
                    {
                        Game.DisplaySubtitle("~y~Crimineel~w~ shhh....Ik hoor voetstappen!");

                        _AG1.Tasks.FightAgainst(Game.LocalPlayer.Character);
                        _AG2.Tasks.FightAgainst(Game.LocalPlayer.Character);
                    }
                    if (_Scene2 == true && _Scene1 == false && Game.LocalPlayer.Character.DistanceTo(_AG1) < 18f)
                    {
                        _AG1.Tasks.FightAgainstClosestHatedTarget(1000f);
                        _AG2.Tasks.FightAgainstClosestHatedTarget(1000f);

                        _AG1.Tasks.FightAgainst(Game.LocalPlayer.Character);
                        _AG2.Tasks.FightAgainst(Game.LocalPlayer.Character);
                    }
                }
                if (_AG1.IsDead && _AG2.IsDead)
                {
                    End();
                }
                if (Functions.IsPedArrested(_AG1) && Functions.IsPedArrested(_AG2))
                {
                    End();
                }
                if (Game.IsKeyDown(Settings.EndCall))
                {
                    End();
                }
                if (Game.LocalPlayer.Character.IsDead)
                {
                    End();
                }
            }, "Gijzelaars [DutchCallouts]");
            base.Process();
        }
Пример #29
0
        private void StartAntiCamp(Entity player)
        {
            if (AnticamperList.Contains(player))
            {
                return;
            }

            AnticamperList.Add(player);

            Vector3 oldPos = player.Origin;

            player.Call("iPrintLnBold", "^1Ruuuuuuuuuuuuuun!");
            PlayLeaderDialog(player, "pushforward");
            AfterDelay(7500, () =>
            {
                player.OnInterval(7500, p =>
                {
                    Vector3 newPos = player.Origin;

                    if (player.CurrentWeapon.Contains("ac130"))
                    {
                        return(true);
                    }

                    if (oldPos.DistanceTo(player.Origin) < 384)
                    {
                        player.Call("iPrintLnBold", "^1Run or die!");

                        PlayLeaderDialog(player, "pushforward");


                        if (player.Health > 200)
                        {
                            Function.Call("RadiusDamage", player.Origin, 10, 100, 100, player, "MOD_EXPLOSIVE", "bomb_site_mp");
                        }

                        if (player.Health <= 100)
                        {
                            Function.Call("RadiusDamage", player.Origin, 10, 20, 20, player, "MOD_EXPLOSIVE", "bomb_site_mp");
                        }


                        return(player.IsAlive && player.GetField <string>("SessionTeam") == "allies");
                    }

                    AfterDelay(250, () => oldPos = player.Origin);

                    return(player.IsAlive && player.GetField <string>("SessionTeam") == "allies");
                });
            });
        }
Пример #30
0
    public void BattleZoneControl()
    {
        API.consoleOutput("" + StartZone + "");
        if (!StartZone)
        {
            ZoneMarker = API.createMarker(1, new Vector3(1404.715, 3255.175, 30), new Vector3(), new Vector3(), new Vector3(Arena, Arena, 100), 255, 255, 0, 0, 0, true);
            StartZone  = true;
        }
        else
        {
            if (Arena <= 50)
            {
            }
            else
            {
                Arena = Arena - 5;
                API.setMarkerScale(ZoneMarker, new Vector3(Arena, Arena, 100));
            }
        }
        Vector3       position   = new Vector3(1404.715, 3255.175, 39);
        float         radius     = 3000;
        List <Client> playerList = API.getPlayersInRadiusOfPosition(radius, position);

        foreach (Client currentPlayer in playerList)
        {
            Vector3 pos       = new Vector3(1404.715, 3255.175, 39);
            Vector3 playerpos = currentPlayer.position;
            float   distance  = pos.DistanceTo(playerpos);
            if (distance <= Arena / 2)
            {
                API.sendChatMessageToPlayer(currentPlayer, playerList.Count + "/" + StartetPlayer + "Alive");
            }
            else
            {
                var health = API.getPlayerHealth(currentPlayer) - 10;
                API.setPlayerHealth(currentPlayer, health);
                API.sendChatMessageToPlayer(currentPlayer, "GO BACK IN ZONE!");
            }
        }
        if (playerList.Count == 1)
        {
            IsGameRunning = false;
            API.sendChatMessageToAll("The Game is Over! You can Join now!");
            foreach (Client currentPlayer in playerList)
            {
                UpdatePlayerDB.WinCount(currentPlayer);
                API.setEntityPosition(currentPlayer, new Vector3(-1266.848, -3324.198, 13.94505));
                API.sendChatMessageToPlayer(currentPlayer, currentPlayer.name + " you are now in the freerome area!");
            }
        }
    }
Пример #31
0
 public static Ped[] GetPeds(Vector3 Position,float length)
 {
     lock (lockObject)
     {
         try
         {
             if (pedList.Length == 0) { return new Ped[0]; }
             //リストから一定距離のものだけを返す
             return pedList.Where(p => p != null).Where(p => p.Exists()).Where(p => Position.DistanceTo(p.Position) <= length).ToArray<Ped>();
         }
         catch
         {
             return new Ped[0];
         }
     }
 }
Пример #32
0
 /// <summary>
 /// Scrapes a dose matrix along the line from startXYZ in mm to endXYZ in mm
 /// </summary>
 /// <param name="startXYZmm">the starting position of the line</param>
 /// <param name="endXYZmm">the end position of the line</param>
 /// <param name="resolution_mm">the resolution to interoplate the line dose (default 2 mm)</param>
 /// <returns>a list of dose values at the specified resolution along the line</returns>
 public List<DoseValue> GetLineDose(Vector3 startXYZmm, Vector3 endXYZmm, double resolution_mm = 2)
 {
     List<DoseValue> values = new List<DoseValue>();
     var pointer = endXYZmm - startXYZmm;
     var length = startXYZmm.DistanceTo(endXYZmm);
     var numPts = (int)Math.Ceiling(length / resolution_mm);
     for (int i = 0; i <= numPts; i++)
     {
         var pt = startXYZmm + ((1 - ((double)i / numPts)) * pointer);
         if (IsInBounds(pt))
         {
             values.Add(GetPointDose(pt));
         }
     }
     values.Reverse();
     return values;
 }
Пример #33
0
        //対象物が画面のどこらへんにあるかを割り出す処理
        //返り値はVector3(x,y,z)
        // x:0.0~1.0
        // y:0.0~1.0
        // z:距離を線形変換。フォントサイズの算出等に使える。
        public Vector3 Analysis(Camera cam, Vector3 TargetPos)
        {
            float x, y, z;
            x = -cam.Rotation.X * (float)Math.PI / 180.0f;
            y = -cam.Rotation.Y * (float)Math.PI / 180.0f;
            z = -cam.Rotation.Z * (float)Math.PI / 180.0f;
            Vector3 Output = TargetPos - cam.Position;  //平行移動
            Vector3 temp;

            //z軸回りに回転
            temp.X = (float)Math.Cos(z) * Output.X - (float)Math.Sin(z) * Output.Y;
            temp.Y = (float)Math.Sin(z) * Output.X + (float)Math.Cos(z) * Output.Y;
            temp.Z = Output.Z;
            Output = temp;

            //y軸回りに回転
            temp.X = (float)Math.Cos(y) * Output.X - (float)Math.Sin(y) * Output.Z;
            temp.Y = Output.Y;
            temp.Z = (float)Math.Sin(y) * Output.X + (float)Math.Cos(y) * Output.Z;
            Output = temp;

            //x軸回りに回転
            temp.X = Output.X;
            temp.Y = (float)Math.Cos(x) * Output.Y - (float)Math.Sin(x)*Output.Z;
            temp.Z = (float)Math.Sin(x) * Output.Y + (float)Math.Cos(x)*Output.Z;
            Output = temp;

            //ベクトルの角度を取得
            Vector2 theta;
            theta.X = (float)Math.Atan2(Output.X*10.0f,10*Output.Y);
            theta.Y = (float)Math.Atan2(10 * Output.Z, 10 * Output.Y);

            //角度より位置を割り出す
            if (Output.Y >= 0.0)
            {
                temp.X = (float)Math.Sin(-theta.X) + 0.5f;
                temp.Y = (float)Math.Sin(-theta.Y) + 0.5f;
            }
            else
            {
                temp.X = -1.0f;
                temp.Y = -1.0f;
            }

            //線形変換
            temp.Z = a * TargetPos.DistanceTo(cam.Position) + b;

            Output = temp;

            return Output;
        }
Пример #34
0
 public static Vehicle[] GetVehicles(Vector3 Position, float length)
 {
     lock (lockObject)
     {
         try
         {
             if (vehicleList.Length == 0) { return new Vehicle[0]; }
             //リストから一定距離のものだけを返す
             return vehicleList.Where(v => v != null).Where(v => v.Exists()).Where(v => Position.DistanceTo(v.Position) <= length).ToArray<Vehicle>();
         }
         catch
         {
             return new Vehicle[0];
         }
     }
 }
Пример #35
0
        public Entity[] CreateRamp(Vector3 top, Vector3 bottom)
        {
            List<Entity> _ents = new List<Entity>();
            int num2 = (int)Math.Ceiling((double)(top.DistanceTo(bottom) / 30f));
            Vector3 vector = new Vector3((top.X - bottom.X) / ((float)num2), (top.Y - bottom.Y) / ((float)num2), (top.Z - bottom.Z) / ((float)num2));
            Vector3 vector2 = base.Call<Vector3>("vectortoangles", new Parameter[] { new Parameter(top - bottom) });
            Vector3 angles = new Vector3(vector2.Z, vector2.Y + 90f, vector2.X);
            for (int i = 0; i <= num2; i++)
            {
                Entity ent = spawnCrateTrap(bottom + (vector * i), angles);
                _ents.Add(ent);
            }

            return _ents.ToArray();
        }
Пример #36
0
        public void updatePed(uint id, UpdateDataStruct data, StreamedPed ped)
        {
            var posnew = new Vector3(data.pos_x, data.pos_y, data.pos_z - 1.0f);
            ped.position = posnew;
            ped.heading = data.heading;
            ped.direction = new Vector3(data.rot_x, data.rot_y, data.rot_z);
            ped.cameraDirection = new Vector3(data.camdir_x, data.camdir_y, data.camdir_z);
            if (ped.IsStreamedIn() && data.vehicle_id == 0)
            {
                if (ped.gameReference.isInVehicle())
                {
                    ped.gameReference.CurrentVehicle.PassengersLeaveVehicle(true);
                    //ped.gameReference.CurrentVehicle.Delete();
                }

                float delta = posnew.DistanceTo(ped.gameReference.Position);
                Vector3 vdelta = posnew - ped.gameReference.Position;
                //ped.gameReference.Weapons.MP5.Ammo = 999;

                int healthDelta = data.ped_health - ped.gameReference.Health;
                ped.gameReference.Health = data.ped_health;
                ped.last_game_health = data.ped_health;

                if (data.weapon > 0)
                {
                    if (ped.gameReference.Weapons.Current != (Weapon)data.weapon)
                    {
                        ped.gameReference.Weapons.FromType((Weapon)data.weapon).Ammo = 999;
                        ped.gameReference.Weapons.FromType((Weapon)data.weapon).AmmoInClip = 999;
                        ped.gameReference.Weapons.Select((Weapon)data.weapon);
                    }
                }
                else
                {
                    ped.gameReference.Weapons.RemoveAll();
                }

                if (healthDelta > 20 && healthDelta < 100)
                {
                    var bpf = new BinaryPacketFormatter(Commands.Player_damage);
                    bpf.Add(id);
                    //Client.instance.chatController.writeChat("damaged " + healthDelta) ;
                    Client.instance.serverConnection.write(bpf.getBytes());
                }

                bool cancelPositionUpdate = false;

                if ((data.state & PlayerState.IsShooting) != 0)
                {
                    ped.animator.playAnimation(PedAnimations.Shoot);
                    cancelPositionUpdate = true;
                }
                else
                    if ((data.state & PlayerState.IsAiming) != 0)
                    {
                        ped.animator.playAnimation(PedAnimations.Aim);
                        cancelPositionUpdate = true;
                    }
                    else
                        if ((data.state & PlayerState.IsRagdoll) != 0 || data.ped_health <= 0)
                        {
                            ped.animator.playAnimation(PedAnimations.Ragdoll);
                            ped.gameReference.Velocity = new Vector3(data.vel_x, data.vel_y, data.vel_z);
                            cancelPositionUpdate = true;
                        }
                        else
                            if ((data.vstate & VehicleState.IsEnteringVehicle) != 0)
                            {
                                ped.animator.playAnimation(PedAnimations.EnterClosestVehicle);
                                cancelPositionUpdate = true;
                            }
                            else
                                if ((data.state & PlayerState.IsCrouching) != 0)
                                {
                                    ped.animator.playAnimation(PedAnimations.Couch);
                                }
                                else
                                {
                                    if ((data.vstate & VehicleState.IsAccelerating) != 0)
                                    {
                                        if ((data.vstate & VehicleState.IsSprinting) != 0)
                                        {
                                            ped.animator.playAnimation(PedAnimations.Run);
                                        }
                                        else
                                        {
                                            ped.animator.playAnimation(PedAnimations.Walk);
                                        }
                                    }
                                    else
                                    {
                                        ped.animator.playAnimation(PedAnimations.StandStill);
                                    }
                                }

                if (!cancelPositionUpdate)
                {
                    ped.gameReference.Position = posnew;
                }
                ped.gameReference.Heading = data.heading;

                //ped.gameReference.Velocity = new Vector3(elemValue.vel_x, elemValue.vel_y, elemValue.vel_z);
                //ped.gameReference.Task.ClearAllImmediately();
            }
        }
Пример #37
0
 public void CreateRamp(Vector3 top, Vector3 bottom)
 {
     float distance = top.DistanceTo(bottom);
     int blocks = (int)Math.Ceiling(distance / 30);
     Vector3 A = new Vector3((top.X - bottom.X) / blocks, (top.Y - bottom.Y) / blocks, (top.Z - bottom.Z) / blocks);
     Vector3 temp = Call<Vector3>("vectortoangles", new Parameter(top - bottom));
     Vector3 BA = new Vector3(temp.Z, temp.Y + 90, temp.X);
     for (int b = 0; b <= blocks; b++)
     {
         spawnCrate(bottom + (A * b), BA);
     }
 }
Пример #38
0
        public float DistanceSquareToSegment(Vector3 v0,Vector3 v1, ref Vector3 optionalPointOnRay, ref Vector3 optionalPointOnSegment)
        {
		// from http://www.geometrictools.com/LibMathematics/Distance/Wm5DistRay3Segment3.cpp
		// It returns the min distance between the ray and the segment
		// defined by v0 and v1
		// It can also set two optional targets :
		// - The closest point on the ray
		// - The closest point on the segment

		var segCenter = v0;
            segCenter.Add( v1 );
            segCenter.Multiply( 0.5f );

		var segDir = v1;
            segDir.Subtract(v0);
            segDir.Normalize();

		var segExtent = v0.DistanceTo( v1 ) / 2;
		var diff = origin;
            diff.Subtract(segCenter );

		var a01 = - direction.Dot( segDir );
		var b0 = diff.Dot( direction );
		var b1 = - diff.Dot( segDir );
		var c = diff.LengthSquared();
		var det = Mathf.Abs( 1 - a01 * a01 );
		var sqrDist = 0f;
            var s0 = 0f;
            var s1 = 0f;

            if ( det >= 0 ) {
			// The ray and segment are not parallel.
			s0 = a01 * b1 - b0;
			s1 = a01 * b0 - b1;
			var extDet = segExtent * det;

			if ( s0 >= 0 ) {

				if ( s1 >= - extDet ) {

					if ( s1 <= extDet ) {

						// region 0
						// Minimum at interior points of ray and segment.

						var invDet = 1 / det;
						s0 *= invDet;
						s1 *= invDet;
						sqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;

					} else {

						// region 1

						s1 = segExtent;
						s0 = Mathf.Max( 0, - ( a01 * s1 + b0 ) );
						sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;

					}

				} else {

					// region 5

					s1 = - segExtent;
					s0 = Mathf.Max( 0, - ( a01 * s1 + b0 ) );
					sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;

				}

			} else {

				if ( s1 <= - extDet ) {

					// region 4

					s0 = Mathf.Max( 0, - ( - a01 * segExtent + b0 ) );
					s1 = ( s0 > 0 ) ? - segExtent : Mathf.Min(Mathf.Max( - segExtent, - b1 ), segExtent );
					sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;

				} else if ( s1 <= extDet ) {

					// region 3

					s0 = 0;
					s1 = Mathf.Min(Mathf.Max( - segExtent, - b1 ), segExtent );
					sqrDist = s1 * ( s1 + 2 * b1 ) + c;

				} else {

					// region 2

					s0 = Mathf.Max( 0, - ( a01 * segExtent + b0 ) );
					s1 = ( s0 > 0 ) ? segExtent : Mathf.Min( Mathf.Max( - segExtent, - b1 ), segExtent );
					sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;

				}

			}

		} else {

			// Ray and segment are parallel.

			s1 = ( a01 > 0 ) ? - segExtent : segExtent;
			s0 = Mathf.Max( 0, - ( a01 * s1 + b0 ) );
			sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;

		}

		optionalPointOnRay = direction;
            optionalPointOnRay.Multiply(s0);
            optionalPointOnRay.Add(origin);

            optionalPointOnSegment = segDir;
            optionalPointOnSegment.Multiply( s1 );
            optionalPointOnSegment.Add( segCenter );

		return sqrDist;

        }
Пример #39
0
 public void CreateRamp2(Vector3 top, Vector3 bottom)
 {
     int num2 = (int)Math.Ceiling((double)(top.DistanceTo(bottom) / 30f));
     Vector3 vector = new Vector3((top.X - bottom.X) / ((float)num2), (top.Y - bottom.Y) / ((float)num2), (top.Z - bottom.Z) / ((float)num2));
     Vector3 vector2 = base.Call<Vector3>("vectortoangles", new Parameter[] { new Parameter(top - bottom) });
     Vector3 angles = new Vector3(vector2.Z, vector2.Y + 90f, vector2.X);
     for (int i = 0; i <= num2; i++)
     {
         spawnCrateRed(bottom + (vector * i), angles);
     }
 }