Модификация исключает возможность попадания на варп при рандомной телепортации.
by Functor
-------------------------------------------------------------------------------------------------------
Открываем ../src/map/pc.c и в функции pc_setpos меняем:
if( x == 0 && y == 0 )
{// pick a random walkable cell
do {
x=rnd()%(map[m].xs-2)+1;
y=rnd()%(map[m].ys-2)+1;
} while(map_getcell(m,x,y,CELL_CHKNOPASS));
}
===
на:
===
if (x == 0 && y == 0)
{// pick a random walkable cell
do
{
// by Functor
int k, npc_x, npc_y, npc_xs, npc_ys;
x = rnd() % (map[m].xs-2) + 1;
y = rnd() % (map[m].ys-2) + 1;
if (map[m].npc_num <= 0)
continue;
for (k = 0; k < map[m].npc_num; ++k)
{
if (map[m].npc[k]->subtype != WARP)
continue;
npc_x = map[m].npc[k]->bl.x;
npc_y = map[m].npc[k]->bl.y;
npc_xs = map[m].npc[k]->u.warp.xs;
npc_ys = map[m].npc[k]->u.warp.ys;
if (x >= (npc_x - npc_xs) && x <= (npc_x + npc_xs) && y >= (npc_y - npc_ys) && y <= (npc_y + npc_ys))
{
x = -1;
break;
}
}
} while (map_getcell(m, x, y, CELL_CHKNOPASS));
}
===============================
В функции pc_randomwarp меняем:
===============================
do{
x=rnd()%(map[m].xs-2)+1;
y=rnd()%(map[m].ys-2)+1;
}while(map_getcell(m,x,y,CELL_CHKNOPASS) && (i++)<1000 );
===
на:
===
do
{
// by Functor
int k, npc_x, npc_y, npc_xs, npc_ys;
x = rnd() % (map[m].xs-2) + 1;
y = rnd() % (map[m].ys-2) + 1;
if (map[m].npc_num <= 0)
continue;
for (k = 0; k < map[m].npc_num; ++k)
{
if (map[m].npc[k]->subtype != WARP)
continue;
npc_x = map[m].npc[k]->bl.x;
npc_y = map[m].npc[k]->bl.y;
npc_xs = map[m].npc[k]->u.warp.xs;
npc_ys = map[m].npc[k]->u.warp.ys;
if (x >= (npc_x - npc_xs) && x <= (npc_x + npc_xs) && y >= (npc_y - npc_ys) && y <= (npc_y + npc_ys))
{
x = -1;
break;
}
}
} while (map_getcell(m, x, y, CELL_CHKNOPASS) && (i++) < 1000);