1 |
function unstick_from() //gml_Script_unstick_from |
2 |
{ |
3 |
var _dir = 0 |
4 |
var _len = 0 |
5 |
var _x = x |
6 |
var _y = y |
7 |
var _offset = (round(irandom(359) / (360 / argument[0]))) * (360 / argument[0]) |
8 |
while place_meeting(x, y, argument[1]) |
9 |
{ |
10 |
x = _x |
11 |
y = _y |
12 |
x += round(lengthdir_x(_len, (_dir + _offset))) |
13 |
y += round(lengthdir_y(_len, (_dir + _offset))) |
14 |
_dir += (360 / argument[0]) |
15 |
if (_dir >= 360) |
16 |
{ |
17 |
_dir -= 360 |
18 |
_len++ |
19 |
} |
20 |
} |
21 |
if (argument_count > 2 && _len > argument[2]) |
22 |
{ |
23 |
_dir = point_direction(x, y, _x, _y) |
24 |
x = _x |
25 |
y = _y |
26 |
x += round(lengthdir_x(argument[2], _dir)) |
27 |
y += round(lengthdir_y(argument[2], _dir)) |
28 |
} |
29 |
return _len; |
30 |
} |