PostBasic blocked sight

Posts 1–12 of 12 · Page 1 of 1
Basic blocked sight
If you do use this then dont be one of those nubs who doesnt give credit :3

 
In Sight.cs
Note: this could be made better i just 2 lazy
Code:
        public static IntPoint[] Cast(Player player, int radius = 15)
        {
            var ret = new List<IntPoint>();
            var angle = 0;
            while (angle < 360)
            {
                var distance = 0;
                while (distance < radius)
                {
                    var x = (int)(distance * Math.Cos(angle));
                    var y = (int)(distance * Math.Sin(angle));
                    if ((x * x + y * y) <= (radius * radius)){

                        ret.Add(new IntPoint(x, y));

                        ObjectDesc desc;
                        player.Manager.GameData.ObjectDescs.TryGetValue(player.Owner.Map[(int)player.X + x, (int)player.Y + y].ObjType, out desc);
                        if (desc != null)
                            if (desc.BlocksSight)
                                break;

                        ret.Add(new IntPoint(x, y));
                    }
                    distance++;
                }
                angle++;
            }
            return ret.ToArray();
        }
if you have any issues with the code pm me
I hope people understand what it does rather than just use it and not know
Also this wont work if you just put it into your sight.cs, as this needs changes/coding in player.update.cs
Quote Originally Posted by MikeRaarupBirk View Post
Also this wont work if you just put it into your sight.cs, as this needs changes/coding in player.update.cs
it does work, just doesnt hide stuff
Quote Originally Posted by Slendergo View Post
If you do use this then dont be one of those nubs who doesnt give credit :3

 
In Sight.cs
Note: this could be made better i just 2 lazy
Code:
        public static IntPoint[] Cast(Player player, int radius = 15)
        {
            var ret = new List<IntPoint>();
            var angle = 0;
            while (angle < 360)
            {
                var distance = 0;
                while (distance < radius)
                {
                    var x = (int)(distance * Math.Cos(angle));
                    var y = (int)(distance * Math.Sin(angle));
                    if ((x * x + y * y) <= (radius * radius)){

                        ret.Add(new IntPoint(x, y));

                        ObjectDesc desc;
                        player.Manager.GameData.ObjectDescs.TryGetValue(player.Owner.Map[(int)player.X + x, (int)player.Y + y].ObjType, out desc);
                        if (desc != null)
                            if (desc.BlocksSight)
                                break;

                        ret.Add(new IntPoint(x, y));
                    }
                    distance++;
                }
                angle++;
            }
            return ret.ToArray();
        }
if you have any issues with the code pm me
Thanks alot <3 !
mi nub. me nid hlp tu do update in player.update.cs help ples.
Quote Originally Posted by The 7th Hokage View Post
mi nub. me nid hlp tu do update in player.update.cs help ples.
git gud nub
Quote Originally Posted by MikeRaarupBirk View Post
git gud nub
shitpost 10/10
Quote Originally Posted by The 7th Hokage View Post
mi nub. me nid hlp tu do update in player.update.cs help ples.
yu heff 2 just put der u kno it dont replace anythin
Quote Originally Posted by LegumI View Post
yu heff 2 just put der u kno it dont replace anythin
I got errurs in player.update.cs. Slendergo helped me out
Posts 1–12 of 12 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us