Register for your free account! | Forgot your password?

You last visited: Today at 22:56

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



FB/SS

Discussion on FB/SS within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2009
Posts: 47
Received Thanks: 6
FB/SS

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
ipwnudont is offline  
Old 02/16/2010, 02:45   #2
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
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);
        }
    }
}
Arcо is offline  
Thanks
2 Users
Old 02/16/2010, 02:51   #3
 
elite*gold: 0
Join Date: Jan 2009
Posts: 47
Received Thanks: 6
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
ipwnudont is offline  
Old 02/16/2010, 02:59   #4
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
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.
Arcо is offline  
Old 02/16/2010, 03:16   #5
 
elite*gold: 0
Join Date: Jan 2009
Posts: 47
Received Thanks: 6
hmm

i seem to not have
Code:
Hashtable MapMobs = (Hashtable)World.H_Mobs[User.Loc.Map];
ipwnudont is offline  
Old 02/16/2010, 03:17   #6
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
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.
Arcо is offline  
Old 02/16/2010, 03:20   #7
 
elite*gold: 0
Join Date: Jan 2009
Posts: 47
Received Thanks: 6
O.o i feel extra newbeh now xD hidden text?

nvm i found it without the hidden text blah blah
ipwnudont is offline  
Old 02/16/2010, 03:22   #8
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
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.
Arcо is offline  
Old 02/16/2010, 03:23   #9
 
elite*gold: 0
Join Date: Jan 2009
Posts: 47
Received Thanks: 6
edited my post a little late but i found it was there the entire time
ipwnudont is offline  
Old 02/16/2010, 03:24   #10
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
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?
Arcо is offline  
Old 02/16/2010, 03:28   #11
 
elite*gold: 0
Join Date: Jan 2009
Posts: 47
Received Thanks: 6
Just finished gonna test it now
ipwnudont is offline  
Old 02/16/2010, 03:29   #12
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
Quote:
Originally Posted by ipwnudont View Post
Just finished gonna test it now
Alrighty, anymore problems just post here and I'll my best to help.
Arcо is offline  
Old 02/16/2010, 03:32   #13
 
elite*gold: 0
Join Date: Jan 2009
Posts: 47
Received Thanks: 6
i think im debugging wrong or something T.T
ipwnudont is offline  
Old 02/16/2010, 03:41   #14
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
Why what errors you getting?
Arcо is offline  
Old 02/16/2010, 03:42   #15
 
elite*gold: 0
Join Date: Jan 2009
Posts: 47
Received Thanks: 6
nope i debugged and still dont work T.T

no errors or anything just FB/SS doesnt hit shet xD
ipwnudont is offline  
Reply




All times are GMT +1. The time now is 22:57.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.