|
1
|
function c_walkto_straightc_walkto_straight
function c_walkto_straight(arg0 =
{
x: 0,
y: 0
}, arg1 =
{
x: 40,
y: 40
}, arg2 = 4, arg3 = 0, arg4 = "")
{
var disth = max(round(abs(arg0.x - arg1.x) / arg2), 1);
var distv = max(round(abs(arg0.y - arg1.y) / arg2), 1);
if (arg3 == 0)
{
if (distv > 0)
c_walkdirect(arg0.x, arg1.y, distv);
if (disth > 0)
c_delaywalkdirect(distv + 1, arg1.x, arg1.y, disth);
}
else
{
if (distv > 0)
c_walkdirect(arg1.x, arg0.y, disth);
if (disth > 0)
c_delaywalkdirect(disth + 1, arg1.x, arg1.y, distv);
}
var toface = "-1";
if (is_string(arg4))
{
if (arg4 == "u" || arg4 == "U" || arg4 == "r" || arg4 == "R" || arg4 == "d" || arg4 == "D" || arg4 == "l" || arg4 == "L")
toface = string_lower(arg4);
}
else
{
switch (arg4)
{
case 0:
toface = "d";
break;
case 1:
toface = "r";
break;
case 2:
toface = "u";
break;
case 3:
toface = "l";
break;
}
}
if (toface != "-1")
c_delayfacing(disth + distv + 1, toface);
return disth + distv;
}
function c_walktostraight_list(arg0, arg1 = [], arg2 = "-1", arg3 = 4)
{
var totalwait = 0;
for (var i = 0; i < array_length(arg1); i++)
{
var pref = "h";
if (variable_struct_exists(arg1[i], "pref"))
{
if ((is_string(arg1[i].pref) && (arg1[i].pref == "v" || arg1[i].pref == "V")) || arg1[i].pref == 0)
pref = "v";
}
var st = arg0;
if (i > 0)
st = arg1[i - 1].inst;
var ed = arg1[i].inst;
var thisspd = arg3;
if (variable_struct_exists(arg1[i], "spd"))
thisspd = arg1[i].spd;
var disth = max(round(abs(st.x - ed.x) / thisspd), 0);
var distv = max(round(abs(st.y - ed.y) / thisspd), 0);
if (pref == "h")
{
if (disth > 0)
{
if (totalwait == 0)
c_walkdirect(ed.x, st.y, disth);
else
c_delaywalkdirect(totalwait, ed.x, st.y, disth);
totalwait += disth;
show_debug_message_concat(i, ", distv=", disth);
}
if (distv > 0)
{
if (totalwait == 0)
c_walkdirect(ed.x, ed.y, distv);
else
c_delaywalkdirect(totalwait, ed.x, ed.y, distv);
totalwait += distv;
}
}
else
{
if (distv > 0)
{
if (totalwait == 0)
c_walkdirect(st.x, ed.y, distv);
... (arg0 =
|
|
2
|
{
|
|
3
|
x: 0,
|
|
4
|
y: 0
|
|
5
|
}, arg1 =
|
|
6
|
{
|
|
7
|
x: 40,
|
|
8
|
y: 40
|
|
9
|
}, arg2 = 4, arg3 = 0, arg4 = "")
|
|
10
|
{
|
|
11
|
var disth = max(round(abs(arg0.x - arg1.x) / arg2), 1);
|
|
12
|
var distv = max(round(abs(arg0.y - arg1.y) / arg2), 1);
|
|
13
|
if (arg3 == 0)
|
|
14
|
{
|
|
15
|
if (distv > 0)
|
|
16
|
c_walkdirectc_walkdirect
function c_walkdirect(arg0, arg1, arg2)
{
c_cmd("walkdirect", arg0, arg1, arg2, 0);
} (arg0.x, arg1.y, distv);
|
|
17
|
if (disth > 0)
|
|
18
|
c_delaywalkdirectc_delaywalkdirect
function c_delaywalkdirect(arg0, arg1, arg2, arg3)
{
c_cmd_x("delaycmd", arg0, "walkdirect", arg1, arg2, arg3, 0);
} (distv + 1, arg1.x, arg1.y, disth);
|
|
19
|
}
|
|
20
|
else
|
|
21
|
{
|
|
22
|
if (distv > 0)
|
|
23
|
c_walkdirectc_walkdirect
function c_walkdirect(arg0, arg1, arg2)
{
c_cmd("walkdirect", arg0, arg1, arg2, 0);
} (arg1.x, arg0.y, disth);
|
|
24
|
if (disth > 0)
|
|
25
|
c_delaywalkdirectc_delaywalkdirect
function c_delaywalkdirect(arg0, arg1, arg2, arg3)
{
c_cmd_x("delaycmd", arg0, "walkdirect", arg1, arg2, arg3, 0);
} (disth + 1, arg1.x, arg1.y, distv);
|
|
26
|
}
|
|
27
|
var toface = "-1";
|
|
28
|
if (is_string(arg4))
|
|
29
|
{
|
|
30
|
if (arg4 == "u" || arg4 == "U" || arg4 == "r" || arg4 == "R" || arg4 == "d" || arg4 == "D" || arg4 == "l" || arg4 == "L")
|
|
31
|
toface = string_lower(arg4);
|
|
32
|
}
|
|
33
|
else
|
|
34
|
{
|
|
35
|
switch (arg4)
|
|
36
|
{
|
|
37
|
case 0:
|
|
38
|
toface = "d";
|
|
39
|
break;
|
|
40
|
case 1:
|
|
41
|
toface = "r";
|
|
42
|
break;
|
|
43
|
case 2:
|
|
44
|
toface = "u";
|
|
45
|
break;
|
|
46
|
case 3:
|
|
47
|
toface = "l";
|
|
48
|
break;
|
|
49
|
}
|
|
50
|
}
|
|
51
|
if (toface != "-1")
|
|
52
|
c_delayfacingc_delayfacing
function c_delayfacing(arg0, arg1)
{
c_cmd_x("delaycmd", arg0, "facing", arg1, 0, 0, 0);
} (disth + distv + 1, toface);
|
|
53
|
return disth + distv;
|
|
54
|
}
|
|
55
|
|
|
56
|
function c_walktostraight_list(arg0, arg1 = [], arg2 = "-1", arg3 = 4)
|
|
57
|
{
|
|
58
|
var totalwait = 0;
|
|
59
|
for (var i = 0; i < array_length(arg1); i++)
|
|
60
|
{
|
|
61
|
var pref = "h";
|
|
62
|
if (variable_struct_exists(arg1[i], "pref"))
|
|
63
|
{
|
|
64
|
if ((is_string(arg1[i].pref) && (arg1[i].pref == "v" || arg1[i].pref == "V")) || arg1[i].pref == 0)
|
|
65
|
pref = "v";
|
|
66
|
}
|
|
67
|
var st = arg0;
|
|
68
|
if (i > 0)
|
|
69
|
st = arg1[i - 1].inst;
|
|
70
|
var ed = arg1[i].inst;
|
|
71
|
var thisspd = arg3;
|
|
72
|
if (variable_struct_exists(arg1[i], "spd"))
|
|
73
|
thisspd = arg1[i].spd;
|
|
74
|
var disth = max(round(abs(st.x - ed.x) / thisspd), 0);
|
|
75
|
var distv = max(round(abs(st.y - ed.y) / thisspd), 0);
|
|
76
|
if (pref == "h")
|
|
77
|
{
|
|
78
|
if (disth > 0)
|
|
79
|
{
|
|
80
|
if (totalwait == 0)
|
|
81
|
c_walkdirectc_walkdirect
function c_walkdirect(arg0, arg1, arg2)
{
c_cmd("walkdirect", arg0, arg1, arg2, 0);
} (ed.x, st.y, disth);
|
|
82
|
else
|
|
83
|
c_delaywalkdirectc_delaywalkdirect
function c_delaywalkdirect(arg0, arg1, arg2, arg3)
{
c_cmd_x("delaycmd", arg0, "walkdirect", arg1, arg2, arg3, 0);
} (totalwait, ed.x, st.y, disth);
|
|
84
|
totalwait += disth;
|
|
85
|
show_debug_message_concat(i, ", distv=", disth);
|
|
86
|
}
|
|
87
|
if (distv > 0)
|
|
88
|
{
|
|
89
|
if (totalwait == 0)
|
|
90
|
c_walkdirectc_walkdirect
function c_walkdirect(arg0, arg1, arg2)
{
c_cmd("walkdirect", arg0, arg1, arg2, 0);
} (ed.x, ed.y, distv);
|
|
91
|
else
|
|
92
|
c_delaywalkdirectc_delaywalkdirect
function c_delaywalkdirect(arg0, arg1, arg2, arg3)
{
c_cmd_x("delaycmd", arg0, "walkdirect", arg1, arg2, arg3, 0);
} (totalwait, ed.x, ed.y, distv);
|
|
93
|
totalwait += distv;
|
|
94
|
}
|
|
95
|
}
|
|
96
|
else
|
|
97
|
{
|
|
98
|
if (distv > 0)
|
|
99
|
{
|
|
100
|
if (totalwait == 0)
|
|
101
|
c_walkdirectc_walkdirect
function c_walkdirect(arg0, arg1, arg2)
{
c_cmd("walkdirect", arg0, arg1, arg2, 0);
} (st.x, ed.y, distv);
|
|
102
|
else
|
|
103
|
c_delaywalkdirectc_delaywalkdirect
function c_delaywalkdirect(arg0, arg1, arg2, arg3)
{
c_cmd_x("delaycmd", arg0, "walkdirect", arg1, arg2, arg3, 0);
} (totalwait, st.x, ed.y, distv);
|
|
104
|
totalwait += distv;
|
|
105
|
}
|
|
106
|
if (disth > 0)
|
|
107
|
{
|
|
108
|
if (totalwait == 0)
|
|
109
|
c_walkdirectc_walkdirect
function c_walkdirect(arg0, arg1, arg2)
{
c_cmd("walkdirect", arg0, arg1, arg2, 0);
} (ed.x, ed.y, disth);
|
|
110
|
else
|
|
111
|
c_delaywalkdirectc_delaywalkdirect
function c_delaywalkdirect(arg0, arg1, arg2, arg3)
{
c_cmd_x("delaycmd", arg0, "walkdirect", arg1, arg2, arg3, 0);
} (totalwait, ed.x, ed.y, disth);
|
|
112
|
totalwait += disth;
|
|
113
|
}
|
|
114
|
}
|
|
115
|
}
|
|
116
|
var toface = "-1";
|
|
117
|
if (is_string(arg2))
|
|
118
|
{
|
|
119
|
if (arg2 == "u" || arg2 == "U" || arg2 == "r" || arg2 == "R" || arg2 == "d" || arg2 == "D" || arg2 == "l" || arg2 == "L")
|
|
120
|
toface = string_lower(arg2);
|
|
121
|
}
|
|
122
|
else
|
|
123
|
{
|
|
124
|
switch (arg2)
|
|
125
|
{
|
|
126
|
case 0:
|
|
127
|
toface = "d";
|
|
128
|
break;
|
|
129
|
case 1:
|
|
130
|
toface = "r";
|
|
131
|
break;
|
|
132
|
case 2:
|
|
133
|
toface = "u";
|
|
134
|
break;
|
|
135
|
case 3:
|
|
136
|
toface = "l";
|
|
137
|
break;
|
|
138
|
}
|
|
139
|
}
|
|
140
|
if (toface != "-1")
|
|
141
|
c_delayfacingc_delayfacing
function c_delayfacing(arg0, arg1)
{
c_cmd_x("delaycmd", arg0, "facing", arg1, 0, 0, 0);
} (totalwait + 1, toface);
|
|
142
|
return totalwait;
|
|
143
|
}
|