| 1882 | } |
| 1883 | |
| 1884 | struct obj * |
| 1885 | buried_ball(coord *cc) |
| 1886 | { |
| 1887 | int odist, bdist = COLNO; |
| 1888 | struct obj *otmp, *ball = 0; |
| 1889 | |
| 1890 | /* FIXME: |
| 1891 | * This is just approximate; if multiple buried balls meet the |
| 1892 | * criterium (within 2 steps of tethered hero's present location) |
| 1893 | * it will find an arbitrary one rather than the one which used |
| 1894 | * to be uball. Once 3.6.{0,1} save file compatibility is broken, |
| 1895 | * we should add svc.context.buriedball_oid and then we can find the |
| 1896 | * actual former uball, which might be extra heavy or christened |
| 1897 | * or not the one buried directly underneath the target spot. |
| 1898 | * |
| 1899 | * [Why does this search within a radius of two when trapmove() |
| 1900 | * only lets hero get one step away from the buried ball?] |
| 1901 | */ |
| 1902 | |
| 1903 | /* u.utrap might have already been cleared, in which case the value |
| 1904 | of u.utraptype is no longer meaningful; if u.utrap is still set |
| 1905 | then u.utraptype needs to be for buried ball */ |
| 1906 | if (!u.utrap || u.utraptype == TT_BURIEDBALL) { |
| 1907 | for (otmp = svl.level.buriedobjlist; otmp; otmp = otmp->nobj) { |
| 1908 | if (otmp->otyp != HEAVY_IRON_BALL) |
| 1909 | continue; |
| 1910 | /* if found at the target spot, we're done */ |
| 1911 | if (otmp->ox == cc->x && otmp->oy == cc->y) |
| 1912 | return otmp; |
| 1913 | /* find nearest within allowable vicinity: +/-2 |
| 1914 | * 4 5 8 |
| 1915 | * 1 2 5 |
| 1916 | * 0 1 4 |
| 1917 | */ |
| 1918 | odist = dist2(otmp->ox, otmp->oy, cc->x, cc->y); |
| 1919 | if (odist <= 8 && (!ball || odist < bdist)) { |
| 1920 | /* remember nearest buried ball but keep checking others */ |
| 1921 | ball = otmp; |
| 1922 | bdist = odist; |
| 1923 | } |
| 1924 | } |
| 1925 | } |
| 1926 | if (ball) { |
| 1927 | /* found, but not at < cc->x, cc->y > */ |
| 1928 | cc->x = ball->ox; |
| 1929 | cc->y = ball->oy; |
| 1930 | } |
| 1931 | return ball; |
| 1932 | } |
| 1933 | |
| 1934 | void |
| 1935 | buried_ball_to_punishment(void) |
no test coverage detected