1 | /* |
1 | /* |
2 | * static char *rcsid_object_c = |
2 | * static char *rcsid_object_c = |
3 | * "$Id: object.c,v 1.6 2006/06/04 19:46:55 root Exp $"; |
3 | * "$Id: object.c,v 1.7 2006/06/23 18:30:22 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
1629 | if (!(flag & INS_ON_TOP) && |
1629 | if (!(flag & INS_ON_TOP) && |
1630 | (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_BLOCKSVIEW) && |
1630 | (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_BLOCKSVIEW) && |
1631 | (op->face && !op->face->visibility)) { |
1631 | (op->face && !op->face->visibility)) { |
1632 | for (last=top; last != floor; last=last->below) |
1632 | for (last=top; last != floor; last=last->below) |
1633 | if (QUERY_FLAG(last, FLAG_BLOCKSVIEW)&&(last->type != EXIT)) break; |
1633 | if (QUERY_FLAG(last, FLAG_BLOCKSVIEW)&&(last->type != EXIT)) break; |
1634 | /* Check to see i we found the object that blocks view, |
1634 | /* Check to see if we found the object that blocks view, |
1635 | * and make sure we have a below pointer for it so that |
1635 | * and make sure we have a below pointer for it so that |
1636 | * we can get inserted below this one, which requires we |
1636 | * we can get inserted below this one, which requires we |
1637 | * set top to the object below us. |
1637 | * set top to the object below us. |
1638 | */ |
1638 | */ |
1639 | if (last && last->below && last != floor) top=last->below; |
1639 | if (last && last->below && last != floor) top=last->below; |
… | |
… | |
2392 | * object, needs to travel toward it. |
2392 | * object, needs to travel toward it. |
2393 | */ |
2393 | */ |
2394 | |
2394 | |
2395 | int find_dir_2(int x, int y) { |
2395 | int find_dir_2(int x, int y) { |
2396 | int q; |
2396 | int q; |
|
|
2397 | |
2397 | if(!y) |
2398 | if(y) |
|
|
2399 | q=x*100/y; |
|
|
2400 | else if (x) |
2398 | q= -300*x; |
2401 | q= -300*x; |
2399 | else |
2402 | else |
2400 | q=x*100/y; |
2403 | return 0; |
|
|
2404 | |
2401 | if(y>0) { |
2405 | if(y>0) { |
2402 | if(q < -242) |
2406 | if(q < -242) |
2403 | return 3 ; |
2407 | return 3 ; |
2404 | if (q < -41) |
2408 | if (q < -41) |
2405 | return 2 ; |
2409 | return 2 ; |
… | |
… | |
2407 | return 1 ; |
2411 | return 1 ; |
2408 | if (q < 242) |
2412 | if (q < 242) |
2409 | return 8 ; |
2413 | return 8 ; |
2410 | return 7 ; |
2414 | return 7 ; |
2411 | } |
2415 | } |
|
|
2416 | |
2412 | if (q < -242) |
2417 | if (q < -242) |
2413 | return 7 ; |
2418 | return 7 ; |
2414 | if (q < -41) |
2419 | if (q < -41) |
2415 | return 6 ; |
2420 | return 6 ; |
2416 | if (q < 41) |
2421 | if (q < 41) |
2417 | return 5 ; |
2422 | return 5 ; |
2418 | if (q < 242) |
2423 | if (q < 242) |
2419 | return 4 ; |
2424 | return 4 ; |
|
|
2425 | |
2420 | return 3 ; |
2426 | return 3 ; |
2421 | } |
2427 | } |
2422 | |
2428 | |
2423 | /* |
2429 | /* |
2424 | * absdir(int): Returns a number between 1 and 8, which represent |
2430 | * absdir(int): Returns a number between 1 and 8, which represent |