예제 #1
0
        private int?GetNearestVendingHandle()
        {
            foreach (var vendingMachine in VendingMachines)
            {
                var handle = Object.GetClosestObjectOfType(Player.Position.X, Player.Position.Y, Player.Position.Z, 0.6f, vendingMachine, false, false, false);

                if (Entity.IsAnEntity(handle))
                {
                    return(handle);
                }
            }

            return(null);
        }
예제 #2
0
 private Vector3 GetVendingOffsetFromWordCoords(int handle)
 {
     return(Entity.GetOffsetFromEntityInWorldCoords(handle, 0.0f, -0.97f, 0.05f));
 }
예제 #3
0
        private void ActivateVendingMachine()
        {
            if (IsUsingVendingMachine)
            {
                return;
            }

            int?handle = GetNearestVendingHandle();

            if (!handle.HasValue)
            {
                return;
            }

            Vector3 offsetFromWordCoords = GetVendingOffsetFromWordCoords(handle.Value);

            if (offsetFromWordCoords == null)
            {
                return;
            }

            Player.LocalPlayer.SetData("IsUsingVendingMachine", new Dictionary <int, bool> {
                { handle.Value, true }
            });

            Player.SetCurrentWeaponVisible(false, true, true, false);
            Player.SetStealthMovement(false, "DEFAULT_ACTION");
            Player.TaskLookAtEntity(handle.Value, 2000, 2048, 2);
            Player.SetResetFlag(322, true);
            Player.TaskGoStraightToCoord(offsetFromWordCoords.X, offsetFromWordCoords.Y, offsetFromWordCoords.Z, 1f, 20000, Entity.GetEntityHeading(handle.Value), 0.1f);

            while (Ai.GetScriptTaskStatus(Player.Handle, 2106541073) != 7 && !Player.IsAtCoord(offsetFromWordCoords.X, offsetFromWordCoords.Y, offsetFromWordCoords.Z, 0.1f, 0.0f, 0.0f, false, true, 0))
            {
                Invoker.Wait(0);
            }

            VendingAnimation.Start();
        }