forked from cleolibrary/CLEO4
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path0ACD.txt
More file actions
233 lines (182 loc) · 7.52 KB
/
0ACD.txt
File metadata and controls
233 lines (182 loc) · 7.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}
script_name '0ACD'
test("0ACD (print_string_now)", tests)
terminate_this_custom_script
function tests
before_each(@setup)
after_each(@cleanup)
it("should print short string variable", test1)
it("should print long string variable", test2)
it("should print string pointer", test3)
it("should print very long string pointer", test4)
it_cs5("should add CLEO texts to brief history", test5_cs5)
it_cs4("should not add CLEO texts to brief history", test5_cs4)
it_cs5("should reset bAddNextMessageToPreviousBriefs flag after print", test6_cs5)
it_cs4("should not reset bAddNextMessageToPreviousBriefs flag after print", test6_cs4)
it_cs5("should not display message starting with ~z~ with subtitles off", test7_cs5)
it_cs4("should display message starting with ~z~ with subtitles off", test7_cs4)
it("should display NOW message even when game queue is full", test8_queue_full_now)
it_cs5("should dedup brief messages in loop", test9_dedup_loop_cs5)
return
:cleanup
CMessages_ClearPreviousBriefArray()
add_next_message_to_previous_briefs {state} true // restore flag
return
:setup
clear_prints
add_next_message_to_previous_briefs {state} true // restore flag
return
function test1
shortString a = 'From ACD' // 8 characters
shortString b = '12345678'
print_string_now {text} a {time} 100
a = '--VOID--'
wait {time} 0
int str = getCurrSubtitleText()
assert_eqs(str, "From ACD")
end
function test2
longString a = "Message from ACD" // 16 characters
shortString b = '12345678'
print_string_now {text} a {time} 100
a = "--VOID--"
wait {time} 0
int str = getCurrSubtitleText()
assert_eqs(str, "Message from ACD")
end
function test3
int msg = allocate_memory {size} 64
string_format msg = "Hello from 0ACD!"
print_string_now {text} msg {time} 100
string_format msg = "--VOID--"
wait {time} 0
free_memory {address} msg
msg = 0
int str = getCurrSubtitleText()
assert_eqs(str, "Hello from 0ACD!")
end
function test4
int msg = allocate_memory {size} 513
write_memory {address} msg {size} 512 {value} 0x41 {vp} false // fill with A
print_string_now {text} msg {time} 100
string_format msg = "--VOID--"
wait {time} 0
free_memory {address} msg
msg = 0
int expected = allocate_memory {size} 400 // same as game's internal limit
write_memory {address} expected {size} 399 {value} 0x41 {vp} false // fill with A
int str = getCurrSubtitleText()
// assert_eqs(str, expected) // assert error message will not be able to display strings that long
is_text_equal {text} str {another} expected {ignoreCase} false
assert_result_true()
free_memory {address} expected
expected = 0
end
function test5_cs5
print_now {key} 'STAT000' {time} 100 {flag} 1 // add Progress made to brief
print_now {key} 'STAT001' {time} 100 {flag} 1 // add Total progress to brief
print_brief_messages()
assert_brief_at(0, "Brief 0ACD three")
assert_brief_at(1, "Brief 0ACD one")
assert_brief_at(2, "Total progress")
assert_brief_at(3, "Progress made")
end
function test5_cs4
print_now {key} 'STAT013' {time} 100 {flag} 1 // add Weapon Budget to brief
print_now {key} 'STAT014' {time} 100 {flag} 1 // add Fashion Budget to brief
print_now {key} 'STAT015' {time} 100 {flag} 1 // add Property Budget to brief
print_brief_messages()
assert_brief_at(0, "Property Budget")
assert_brief_at(1, "Fashion Budget")
assert_brief_at(2, "Weapon Budget")
end
function test6_cs5
add_next_message_to_previous_briefs {state} false
assert_brief_flag(false)
print_string_now {text} "Flag test ACD" {time} 100
assert_brief_flag(true) // flag must be reset to true after print_string_now
end
function test6_cs4
add_next_message_to_previous_briefs {state} false
assert_brief_flag(false)
print_string_now {text} "Flag test ACD cs4" {time} 100
assert_brief_flag(false) // flag must NOT be reset for legacy scripts
end
function test7_cs5
toggle_subtitles(true)
print_string_now {text} "~z~Subtitle 1" {time} 100
assert_subtitle("~z~Subtitle 1") // should display ~z~ message when subtitles ON
wait 500
toggle_subtitles(false)
print_string_now {text} "~z~Subtitle 2" {time} 100
assert_subtitle(0) // should skip last subtitle when subtitles OFF
wait 500
print_string_now {text} "Regular Text" {time} 100
assert_subtitle("Regular Text") // should display non ~z~ when subtitles OFF
end
function test7_cs4
toggle_subtitles(true)
print_string_now {text} "~z~Subtitle 1" {time} 100
assert_subtitle("~z~Subtitle 1") // should display ~z~ message when subtitles ON
wait 500
toggle_subtitles(false)
print_string_now {text} "~z~Subtitle 2" {time} 100
assert_subtitle("~z~Subtitle 2") // should NOT skip last subtitle when subtitles OFF
wait 500
print_string_now {text} "Regular Text" {time} 100
assert_subtitle("Regular Text") // should display non ~z~ when subtitles OFF
end
function test8_queue_full_now
// Fill all 8 game message queue slots with long-lived messages
print_string {text} "Fill Q 1" {time} 900
print_string {text} "Fill Q 2" {time} 900
print_string {text} "Fill Q 3" {time} 900
print_string {text} "Fill Q 4" {time} 900
print_string {text} "Fill Q 5" {time} 900
print_string {text} "Fill Q 6" {time} 900
print_string {text} "Fill Q 7" {time} 900
print_string {text} "Fill Q 8" {time} 900
// Queue is full; print_string_now must still display (bypasses full-queue check)
print_string_now {text} "Now Bypasses Q" {time} 100
wait 0
// NOW message must jump to front despite full queue
assert_subtitle("Now Bypasses Q")
end
function test9_dedup_loop_cs5
print_string_now "STAT001" 1000
TIMERA = 0
while TIMERA < 1000
wait 0
print_string_now "STAT002" 100
end
assert_brief_at(0, "STAT002")
assert_brief_at(1, "STAT001")
int brief = getBriefTextAt(2)
assert_eq(brief, 0)
end
end
{$INCLUDE_ONCE helpers.inc}
function print_brief_messages
int msg1 = allocate_memory {size} 64
int msg2 = allocate_memory {size} 64
int msg3 = allocate_memory {size} 64
string_format msg1 = "Brief 0ACD one"
string_format msg2 = "Brief 0ACD two"
string_format msg3 = "Brief 0ACD three"
clear_prints
print_string_now {text} msg1 {time} 9000 // msg1 is added to brief
add_next_message_to_previous_briefs {state} false
print_string_now {text} msg2 {time} 9000 // msg2 is NOT added to brief
add_next_message_to_previous_briefs {state} true // no effect as flag is true already
print_string_now {text} msg3 {time} 9000 // msg3 is added to brief
string_format msg1 = "--VOID--"
string_format msg2 = "--VOID--"
string_format msg3 = "--VOID--"
free_memory {address} msg1
free_memory {address} msg2
free_memory {address} msg3
msg1 = 0
msg2 = 0
msg3 = 0
end