| 943 | } |
| 944 | |
| 945 | void entinmap(physent *d) // brute force but effective way to find a free spawn spot in the map |
| 946 | { |
| 947 | vec orig(d->o); |
| 948 | loopi(100) // try max 100 times |
| 949 | { |
| 950 | float dx = (rnd(21)-10)/10.0f*i; // increasing distance |
| 951 | float dy = (rnd(21)-10)/10.0f*i; |
| 952 | d->o.x += dx; |
| 953 | d->o.y += dy; |
| 954 | if(!collide(d, true)) |
| 955 | { |
| 956 | d->resetinterp(); |
| 957 | return; |
| 958 | } |
| 959 | d->o = orig; |
| 960 | } |
| 961 | // leave ent at original pos, possibly stuck |
| 962 | d->resetinterp(); |
| 963 | conoutf("can't find entity spawn spot! (%d, %d)", int(d->o.x), int(d->o.y)); |
| 964 | } |
| 965 |
no test coverage detected