viewing paste Unknown #20920 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
Модификация исключает возможность попадания на варп при рандомной телепортации. 
modification doesn't let you random teleport on warp portal
 
by Functor
 
-------------------------------------------------------------------------------------------------------
Open ../src/map/pc.c find function 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));
    }
 
===
change to that:
===
 
    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));
    }
 
===============================
Find function 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 );
 
===
change for:
===
 
    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);
Viewed 878 times, submitted by Guest.