forked from cleolibrary/CLEO4
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathAudio_Demo.txt
More file actions
327 lines (270 loc) · 9.89 KB
/
Audio_Demo.txt
File metadata and controls
327 lines (270 loc) · 9.89 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
// CLEO5 example script
// Sanny Builder 4
// mode: GTA SA (v1.0 - SBL)
{$CLEO .cs}
const Model_Speaker = 2229
const Model_Toilet = 2984
const Audio_Path = ".\cleo_tests\Audio\Ding.mp3" // this script's file relative location
//const Audio_Path = "https://github.com/cleolibrary/CLEO5/blob/master/tests/cleo_tests/Audio/Speech.mp3?raw=true" // network path
wait 1000
int soundStream, speakerObject
float value, valueCurr
while true
wait 0
print_formatted_now "CLEO5 Audio Plugin DEMO~n~Press key 1 - 8" {time} 0
if
test_cheat "1"
then
print_formatted_now "DEMO 1: Get progress" {time} 10000
if
not soundStream, speakerObject = TEST_SETUP(Model_Speaker)
then
continue
end
set_audio_stream_looped soundStream {state} false
while is_audio_stream_playing soundStream
valueCurr = get_audio_stream_progress soundStream
print_formatted_now "DEMO 1: Get progress: %.2f" {time} 0 {args} valueCurr
wait 0
end
TEST_CLEANUP(soundStream, speakerObject)
end
if
test_cheat "2"
then
print_formatted_now "DEMO 2: Set volume" {time} 10000
if
not soundStream, speakerObject = TEST_SETUP(Model_Speaker)
then
continue
end
TIMERA = 1000
repeat
if
TIMERA >= 1000
then
value = generate_random_float_in_range 0.0 2.0
set_audio_stream_volume soundStream value
TIMERA = 0
end
print_formatted_now "DEMO 2: Set volume: %.2f~n~Press 2 to stop" {time} 0 {args} value
wait 0
until test_cheat "2"
TEST_CLEANUP(soundStream, speakerObject)
end
if
test_cheat "3"
then
print_formatted_now "Set volume with transition" {time} 10000
if
not soundStream, speakerObject = TEST_SETUP(Model_Speaker)
then
continue
end
TIMERA = 2000
repeat
if
TIMERA >= 2000
then
value = generate_random_float_in_range 0.0 2.0
set_audio_stream_volume_with_transition soundStream {volume} value {timeMs} 1000
TIMERA = 0
end
valueCurr = get_audio_stream_volume soundStream
print_formatted_now "DEMO 3: Set volume: %.2f, Transition: 2.0s~n~Current volume: %.2f~n~Press 3 to stop" {time} 0 {args} value valueCurr
wait 0
until test_cheat "3"
TEST_CLEANUP(soundStream, speakerObject)
end
if
test_cheat "4"
then
print_formatted_now "DEMO 4: Set speed" {time} 10000
if
not soundStream, speakerObject = TEST_SETUP(Model_Speaker)
then
continue
end
TIMERA = 1000
repeat
if
TIMERA >= 1000
then
value = generate_random_float_in_range 0.0 2.0
set_audio_stream_speed soundStream value
TIMERA = 0
end
print_formatted_now "DEMO 4: Set speed %.2f~n~Press 4 to stop" {time} 0 {args} value
wait 0
until test_cheat "4"
TEST_CLEANUP(soundStream, speakerObject)
end
if
test_cheat "5"
then
print_formatted_now "DEMO 5: Set speed with transition" {time} 10000
if
not soundStream, speakerObject = TEST_SETUP(Model_Speaker)
then
continue
end
TIMERA = 2000
repeat
if
TIMERA >= 2000
then
value = generate_random_float_in_range 0.0 2.0
set_audio_stream_speed_with_transition soundStream {volume} value {timeMs} 1000
TIMERA = 0
end
valueCurr = get_audio_stream_speed soundStream
print_formatted_now "DEMO 5: Set speed: %.2f, Transition: 2.0s~n~Current speed: %.2f~n~Press 5 to stop" {time} 0 {args} value valueCurr
wait 0
until test_cheat "5"
TEST_CLEANUP(soundStream, speakerObject)
end
if
test_cheat "6"
then
print_formatted_now "DEMO 6: Doppler effect" {time} 10000
if
not soundStream, speakerObject = TEST_SETUP(Model_Speaker)
then
continue
end
int direction = 0
repeat
if
not camera_is_vector_move_running
then
camera_set_vector_track {from} 230.0 2525.0 16.5 {to} 230.0 2525.0 16.5 {time} 2500 {ease} true
if
direction == 0
then
camera_set_vector_move {from} 260.0 2522.0 18.0 {to} 200.0 2522.0 18.0 {time} 2500 {ease} true
else
camera_set_vector_move {from} 200.0 2522.0 18.0 {to} 260.0 2522.0 18.0 {time} 2500 {ease} true
end
direction = 1 - direction
end
wait 0
print_formatted_now "DEMO 6: Doppler effect~n~Press 6 to stop" {time} 0
until test_cheat "6"
TEST_CLEANUP(soundStream, speakerObject)
end
if
test_cheat "7"
then
print_formatted_now "DEMO 7: Game speed" {time} 10000
if
not soundStream, speakerObject = TEST_SETUP(Model_Speaker)
then
continue
end
// walk
clear_char_tasks_immediately $scplayer
set_char_keep_task $scplayer {state} true
set_player_control $player1 {control} false
flush_route
extend_route {xyz} 228.0 2525.0 15.5
extend_route {xyz} 230.0 2523.0 15.5
extend_route {xyz} 232.0 2525.0 15.5
extend_route {xyz} 230.0 2527.0 15.5
task_follow_point_route {handle} $scplayer {speed} MoveState.Run {mode} RouteMode.Loop
task_look_at_object $scplayer {object} speakerObject {time} -1
TIMERA = 2000
repeat
if
TIMERA >= 2000
then
value = generate_random_float_in_range 0.2 3.0
set_time_scale value
TIMERA = 0
end
print_formatted_now "DEMO 7: Game speed: %.2f~n~Press 7 to stop" {time} 0 {args} value
wait 0
until test_cheat "7"
set_time_scale 1.0
clear_char_tasks_immediately $scplayer
set_player_control $player1 {control} true
TEST_CLEANUP(soundStream, speakerObject)
end
if
test_cheat "8"
then
print_formatted_now "DEMO 8: Free mode" {time} 10000
if
not soundStream, speakerObject = TEST_SETUP(Model_Toilet)
then
continue
end
set_object_collision speakerObject {state} true
set_object_dynamic speakerObject {state} true
clear_char_tasks_immediately $scplayer
restore_camera_jumpcut
int modelId = get_weapontype_model {weaponType} WeaponType.Satchel
request_model {modelId} modelId
load_all_models_now
give_weapon_to_char $scplayer {weaponType} WeaponType.Satchel {ammo} 0xFFFFFF
mark_model_as_no_longer_needed {modelId} modelId
modelId = get_weapontype_model {weaponType} WeaponType.Detonator
request_model {modelId} modelId
load_all_models_now
give_weapon_to_char $scplayer {weaponType} WeaponType.Satchel {ammo} 0xFFFFFF
mark_model_as_no_longer_needed {modelId} modelId
display_hud true
repeat
print_formatted_now "DEMO 8: Free mode~n~Press 8 to stop" {time} 0
wait 0
until test_cheat "8"
TEST_CLEANUP(soundStream, speakerObject)
end
end
terminate_this_script
function TEST_SETUP(objectModel: int): int, int
int soundStream
if
not soundStream = load_3d_audio_stream Audio_Path
then
print_help_formatted "~r~Failed to load audio file ~w~`%s`" {args} Audio_Path
cleo_return_with {conditionResult} false {retArgs} -1 -1
end
set_char_coordinates $scplayer {xyz} 230.0 2527.0 15.5
set_char_heading $scplayer {heading} 180.0
set_area_visible 0
set_char_area_visible $scplayer {interiorId} 0
task_scratch_head $scplayer
remove_all_char_weapons $scplayer
set_max_wanted_level 0
clear_wanted_level $player1
set_char_health $scplayer {health} 250
set_char_proofs $scplayer {bulletProof} true {fireProof} true {explosionProof} true {collisionProof} true {meleeProof} true
display_radar false
display_hud false
set_fixed_camera_position {xyz} 230.0 2522.0 18.0 {ypr} 0.0 0.0 0.0
point_camera_at_char $scplayer {mode} CameraMode.Fixed {switchStyle} SwitchType.JumpCut
// create speaker object
request_model {modelId} objectModel
load_all_models_now
int speakerObject = create_object {modelId} objectModel {xyz} 230.25 2525.0 15.8
mark_model_as_no_longer_needed {modelId} objectModel
set_object_collision speakerObject {state} false
set_object_dynamic speakerObject {state} false
point_camera_at_point {xyz} 230.0 2525.0 16.5 {switchStyle} SwitchType.Jumpcut
wait 1000
set_play_3d_audio_stream_at_object soundStream {object} speakerObject
set_audio_stream_looped soundStream true
set_audio_stream_state soundStream AudioStreamAction.Play
cleo_return_with {conditionResult} true {retArgs} soundStream speakerObject
end
function TEST_CLEANUP(soundStream: int, speakerObject: int)
remove_all_char_weapons $scplayer
//set_max_wanted_level 6
set_char_proofs $scplayer {bulletProof} false {fireProof} false {explosionProof} false {collisionProof} false {meleeProof} false
remove_audio_stream soundStream
delete_object speakerObject
camera_reset_new_scriptables
restore_camera
display_hud true
display_radar true
end