FB/SS

02/16/2010 02:41 ipwnudont#1
ok ive been working on the FB/SS system and ive read arco's release for it but mine doesnt really match and im a noob c# coder atm so was wondering about my current code

My current Math.cs

Code:
{
    public class MyMath
    {
        static Random Rnd = new Random();
        public static double LevelDifference(byte Lev1, byte Lev2)
        {
            if (Lev1 > Lev2)
            {
                double Rt = (Lev1 - Lev2 + 7) / 5;
                return Rt = ((Rt - 1) * 0.8) + 1;
            }
            return 1;
        }
        public static bool ChanceSuccess(double Chance)
        {            
            int e = Rnd.Next(10000000);
            double a = ((double)e / (double)10000000) * 100;
            return Chance >= a;
        }
        public static double PointDirecton(double x1, double y1, double x2, double y2)
        {
            double direction = 0;

            double AddX = x2 - x1;
            double AddY = y2 - y1;
            double r = (double)Math.Atan2(AddY, AddX);

            if (r < 0) r += (double)Math.PI * 2;

            direction = 360 - (r * 180 / (double)Math.PI);
            return direction;
        }
        public static double PointDirectonRad(double x1, double y1, double x2, double y2)
        {
            double AddX = x2 - x1;
            double AddY = y2 - y1;
            double r = (double)Math.Atan2(AddY, AddX);

            return r;
        }
        public static double PointDirecton2(double x1, double y1, double x2, double y2)
        {
            double direction = 0;

            double AddX = x2 - x1;
            double AddY = y2 - y1;
            double r = (double)Math.Atan2(AddY, AddX);

            direction = (r * 180 / (double)Math.PI);
            return direction;
        }
        public static double RadianToDegree(double r)
        {
            if (r < 0) r += (double)Math.PI * 2;

            double direction = 360 - (r * 180 / (double)Math.PI);
            return direction;
        }
        public static double DegreeToRadian(double degr)
        {
            return degr*Math.PI/180;
        }        
        public static int PointDistance(double x1, double y1, double x2, double y2)
        {
            return (int)Math.Sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
        }
        public static bool InBox(double x1, double y1, double x2, double y2, byte Range)
        {
            return (Math.Max(Math.Abs(x1 - x2), Math.Abs(y1 - y2)) <= Range);
        }
    }
}
if you need to know any other codes just reply and ill post them T.T need as much help as i can get
02/16/2010 02:45 Arcо#2
If you want you can replace your entire MyMath.cs with this.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NewestCOServer
{
    public struct coords
    {
        public int X;
        public int Y;

        public coords(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }
    public static class MyMath
    {
        public static bool Contains(this coords[] Coords, coords Check)
        {
            foreach (coords Coord in Coords)
                if (Coord.X == Check.X && Check.Y == Coord.Y)
                    return true;
            return false;
        }
        public static List<coords> LineCoords(ushort userx, ushort usery, ushort shotx, ushort shoty, byte length)
        {
            double dir = Math.Atan2(shoty - usery, shotx - userx);
            double f_x = (Math.Cos(dir) * length) + userx;
            double f_y = (Math.Sin(dir) * length) + usery;

            return bresenham(userx, usery, (int)f_x, (int)f_y);
        }
        public static void Add(this List<coords> Coords, int x, int y)
        {
            coords add = new coords((ushort)x, (ushort)y);
            if (!Coords.Contains(add))
                Coords.Add(add);
        }
        public static List<coords> bresenham(int x0, int y0, int x1, int y1)
        {
            List<coords> ThisLine = new List<coords>();

            int dy = y1 - y0;
            int dx = x1 - x0;
            int stepx, stepy;

            if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
            if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
            dy <<= 1;
            dx <<= 1;

            ThisLine.Add(x0, y0);
            if (dx > dy)
            {
                int fraction = dy - (dx >> 1);
                while (x0 != x1)
                {
                    if (fraction >= 0)
                    {
                        y0 += stepy;
                        fraction -= dx;
                    }
                    x0 += stepx;
                    fraction += dy;
                    ThisLine.Add(x0, y0);
                }
            }
            else
            {
                int fraction = dx - (dy >> 1);
                while (y0 != y1)
                {
                    if (fraction >= 0)
                    {
                        x0 += stepx;
                        fraction -= dy;
                    }
                    y0 += stepy;
                    fraction += dx;
                    ThisLine.Add(x0, y0);
                }
            }
            return ThisLine;
        }
        static Random Rnd = new Random();
        public static double LevelDifference(byte Lev1, byte Lev2)
        {
            if (Lev1 > Lev2)
            {
                double Rt = (Lev1 - Lev2 + 7) / 5;
                return Rt = ((Rt - 1) * 0.8) + 1;
            }
            return 1;
        }
        public static bool ChanceSuccess(double Chance)
        {
            int e = Rnd.Next(10000000);
            double a = ((double)e / (double)10000000) * 100;
            return Chance >= a;
        }
        public static double PointDirecton(double x1, double y1, double x2, double y2)
        {
            double direction = 0;

            double AddX = x2 - x1;
            double AddY = y2 - y1;
            double r = (double)Math.Atan2(AddY, AddX);

            if (r < 0) r += (double)Math.PI * 2;

            direction = 360 - (r * 180 / (double)Math.PI);
            return direction;
        }
        public static double PointDirectonRad(double x1, double y1, double x2, double y2)
        {
            double AddX = x2 - x1;
            double AddY = y2 - y1;
            double r = (double)Math.Atan2(AddY, AddX);

            return r;
        }
        public static double PointDirecton2(double x1, double y1, double x2, double y2)
        {
            double direction = 0;

            double AddX = x2 - x1;
            double AddY = y2 - y1;
            double r = (double)Math.Atan2(AddY, AddX);

            direction = (r * 180 / (double)Math.PI);
            return direction;
        }
        public static double RadianToDegree(double r)
        {
            if (r < 0) r += (double)Math.PI * 2;

            double direction = 360 - (r * 180 / (double)Math.PI);
            return direction;
        }
        public static double DegreeToRadian(double degr)
        {
            return degr * Math.PI / 180;
        }
        public static int PointDistance(double x1, double y1, double x2, double y2)
        {
            return (int)Math.Sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
        }
        public static bool InBox(double x1, double y1, double x2, double y2, byte Range)
        {
            return (Math.Max(Math.Abs(x1 - x2), Math.Abs(y1 - y2)) <= Range);
        }
    }
}
02/16/2010 02:51 ipwnudont#3
ok and this is my first time working on a source so do i gotta debug after that or do i just restart? T.T omg i feel noob but i just started coding
02/16/2010 02:59 Arcо#4
Quote:
Originally Posted by ipwnudont View Post
ok and this is my first time working on a source so do i gotta debug after that or do i just restart? T.T omg i feel noob but i just started coding
Lol after you used my MyMath just go along with the rest of the fb/ss code and then debug.
02/16/2010 03:16 ipwnudont#5
i seem to not have
Code:
Hashtable MapMobs = (Hashtable)World.H_Mobs[User.Loc.Map];
02/16/2010 03:17 Arcо#6
Quote:
Originally Posted by ipwnudont View Post
i seem to not have
Code:
Hashtable MapMobs = (Hashtable)World.H_Mobs[User.Loc.Map];
Hmm, are you sure?
Check hidden text.
02/16/2010 03:20 ipwnudont#7
O.o i feel extra newbeh now xD hidden text?

nvm i found it without the hidden text blah blah
02/16/2010 03:22 Arcо#8
Quote:
Originally Posted by ipwnudont View Post
O.o i feel extra newbeh now xD hidden text?
When you ctrl+f for something.
There should be advanced options or something like that.
Check the box that says hidden text.
02/16/2010 03:23 ipwnudont#9
edited my post a little late but i found it was there the entire time
02/16/2010 03:24 Arcо#10
Quote:
Originally Posted by ipwnudont View Post
edited my post a little late but i found it was there the entire time
Ah lol, so is the problem fixed?
02/16/2010 03:28 ipwnudont#11
Just finished gonna test it now :D
02/16/2010 03:29 Arcо#12
Quote:
Originally Posted by ipwnudont View Post
Just finished gonna test it now :D
Alrighty, anymore problems just post here and I'll my best to help.
02/16/2010 03:32 ipwnudont#13
i think im debugging wrong or something T.T
02/16/2010 03:41 Arcо#14
Why what errors you getting?
02/16/2010 03:42 ipwnudont#15
nope i debugged and still dont work T.T

no errors or anything just FB/SS doesnt hit shet xD