Ejemplo n.º 1
0
        public static double GetSignedDistanceFromPointToLine(
            double pX, double pZ, double v1X, double v1Z, double v2X, double v2Z, double v3X, double v3Z, int p1Index, int p2Index, bool?misalignmentOffsetNullable = null)
        {
            double[] vX = new double[] { v1X, v2X, v3X };
            double[] vZ = new double[] { v1Z, v2Z, v3Z };

            double p1X = vX[p1Index - 1];
            double p1Z = vZ[p1Index - 1];
            double p2X = vX[p2Index - 1];
            double p2Z = vZ[p2Index - 1];

            double dist                   = MoreMath.GetDistanceFromPointToLine(pX, pZ, p1X, p1Z, p2X, p2Z);
            bool   leftOfLine             = MoreMath.IsPointLeftOfLine(pX, pZ, p1X, p1Z, p2X, p2Z);
            bool   floorTri               = MoreMath.IsPointLeftOfLine(v3X, v3Z, v1X, v1Z, v2X, v2Z);
            bool   onSideOfLineTowardsTri = floorTri == leftOfLine;
            double signedDist             = dist * (onSideOfLineTowardsTri ? 1 : -1);

            bool misalignmentOffset = misalignmentOffsetNullable ?? Config.UseMisalignmentOffsetForDistanceToLine;

            if (misalignmentOffset)
            {
                if (p1X == p2X)
                {
                    bool thirdPointOnLeft = p1Z >= p2Z == floorTri;
                    if ((thirdPointOnLeft && p1X >= 0) || (!thirdPointOnLeft && p1X <= 0))
                    {
                        signedDist += 1;
                    }
                }
                else if (p1Z == p2Z)
                {
                    bool thirdPointOnTop = p1X <= p2X == floorTri;
                    if ((thirdPointOnTop && p1Z >= 0) || (!thirdPointOnTop && p1Z <= 0))
                    {
                        signedDist += 1;
                    }
                }
            }

            return(signedDist);
        }
Ejemplo n.º 2
0
        GetRacingPenguinSpecialVars(uint racingPenguinAddress)
        {
            double marioY     = Config.Stream.GetSingle(Config.Mario.StructAddress + Config.Mario.YOffset);
            double objectY    = Config.Stream.GetSingle(racingPenguinAddress + Config.ObjectSlots.ObjectYOffset);
            double heightDiff = marioY - objectY;

            uint   prevWaypointAddress = Config.Stream.GetUInt32(racingPenguinAddress + Config.ObjectSlots.WaypointOffset);
            short  prevWaypointIndex   = Config.Stream.GetInt16(prevWaypointAddress);
            double effort = Config.Stream.GetSingle(racingPenguinAddress + Config.ObjectSlots.RacingPenguinEffortOffset);

            double effortTarget;
            double effortChange;
            double minHSpeed = 70;

            if (heightDiff > -100 || prevWaypointIndex >= 35)
            {
                if (prevWaypointIndex >= 35)
                {
                    minHSpeed = 60;
                }
                effortTarget = -500;
                effortChange = 100;
            }
            else
            {
                effortTarget = 1000;
                effortChange = 30;
            }
            effort = MoreMath.MoveNumberTowards(effort, effortTarget, effortChange);

            double hSpeedTarget = (effort - heightDiff) * 0.1;

            hSpeedTarget = MoreMath.Clamp(hSpeedTarget, minHSpeed, 150);

            return(effortTarget, effortChange, minHSpeed, hSpeedTarget);
        }
Ejemplo n.º 3
0
 public static ushort GetRngValue(int index)
 {
     index = MoreMath.NonNegativeModulus(index, RNG_COUNT);
     return(IndexToRNGDictionary[index]);
 }