EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=621)
-   -   Basic Line of Sight (https://www.eqemulator.org/forums/showthread.php?t=9071)

Wiz 08-13-2003 12:25 AM

Basic Line of Sight
 
This function will use the nodes in .map files to apply line of sight (prevents wall aggro if used right, among other things). It is not perfect yet, as it tends to fail on thin walls, or walls on top of other floors (such as in unrest or hole), but it's a start.

Code:

bool Mob::CheckLos(Mob* other) {
        if (zone->map == 0)
        {
                return true;
        }
        float tmp_x = GetX();
        float tmp_y = GetY();
        float trg_x = other->GetX();
        float trg_y = other->GetY();
        float perwalk_x = 0.2;
        float perwalk_y = 0.2;
        float dist_x = tmp_x - trg_x;
        if (dist_x < 0)
                dist_x *= -1;
        float dist_y = tmp_y - trg_y;
        if (dist_y < 0)
                dist_y *= -1;
        if (dist_x  < dist_y)
                perwalk_x /= (dist_y/dist_x);
        else if (dist_y < dist_x)
                perwalk_y /= (dist_x/dist_y);
        while (1) {
                if (tmp_x < trg_x)
                {
                        if (tmp_x + perwalk_x < trg_x)
                                tmp_x += perwalk_x;
                        else
                                tmp_x = trg_x;
                }
                if (tmp_y < trg_y)
                {
                        if (tmp_y + perwalk_y < trg_y)
                                tmp_y += perwalk_y;
                        else
                                tmp_y = trg_y;
                }
                if (tmp_x > trg_x)
                {
                        if (tmp_x - perwalk_x > trg_x)
                                tmp_x -= perwalk_x;
                        else
                                tmp_x = trg_x;
                }
                if (tmp_y > trg_y)
                {
                        if (tmp_y - perwalk_y > trg_y)
                                tmp_y -= perwalk_y;
                        else
                                tmp_y = trg_y;
                }
                if (tmp_y == trg_y && tmp_x == trg_x)
                {
                        return true;
                }
                PNODE pnode = zone->map->SeekNode( zone->map->GetRoot(), tmp_x, tmp_y );
                if (pnode != 0)
                {
                        int *iface = zone->map->SeekFace( pnode, tmp_x, tmp_y );
                        if (*iface == -1) {
                                return false;
                        }                                                       
                }
        }
        return true;
}


Merth 08-13-2003 02:22 AM

Wow, this is very cool. I can't wait to see this in action.

x-scythe 08-13-2003 01:13 PM

nice
 
nice, now i wont get jumped by 50 mobs at a time in dungeons :) good job

Merth 08-14-2003 11:18 AM

Is there a server available where I can see this is action? I can go both 0.4.x and 0.5.0.

Wiz 08-15-2003 02:33 AM

Well, Winter's Roar, I'd be happy to demonstrate it when the logins come back up.

cokerms 01-05-2004 07:10 AM

Did this code ever get added? I was looking through the code base and didn't see that particular function, but I didn't know if it was added elsewhere. I still get jumped by mobs through walls in najena so I am guessing it didn't.

You guys are still doing a great job. Thanks

Eglin 02-06-2004 08:37 AM

Quote:

Originally Posted by cokerms
Did this code ever get added?

http://cvs.sourceforge.net/viewcvs.p...in&rev=1.1.1.8


All times are GMT -4. The time now is 10:23 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.