/
tasking2.as
554 lines (471 loc) · 12.3 KB
/
tasking2.as
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
/*
Adjusted version of tasking.as made for BRB 3
Uses jump for frame advance, works with hudreplace.as to put frame count in place of combo number
http://atlas.dustforce.com/12422/tas-king-returns
*/
class script {
scene@ g;
array <dustman@> players(4, null);
controllable@ man = null;
dustman@ king;
//HANDLING FOR FRAME COUNT UI
canvas@ c;
textfield@ label;
textfield@ count;
bool jump_used = false;
bool taunt_pressed = false;
bool dash_pressed = false;
int heavy_counter = 0;
int light_counter = 0;
bool left_active = false;
bool right_active = false;
bool up_active = false;
bool down_active = false;
bool jump_active = false;
bool dash_active = false;
bool light_active = false;
bool heavy_active = false;
bool advance_active = false;
int time_main = 0;
array <entity@> effects;
int frame_count = 0;
script() {
@g = get_scene();
@c = create_canvas(true, 0, 0);
c.scale_hud(false);
@label = create_textfield();
label.set_font("Caracteres", 26);
label.align_horizontal(-1);
label.align_vertical(1);
label.text("FRAME COUNT");
@count = create_textfield();
count.text("");
count.set_font("Caracteres", 52);
}
// step and step_post handle the freezing and unfreezing of the TAS character
// have to use both advance_active and advance_happening because the "advance" command is sent mid-step
bool advance_happening = false;
void step(int) {
if( king.jump_intent() > 0 ) {
time_main = 1;
man.time_warp(time_main);
if(man.hitbox() !is null)
man.hitbox().time_warp(time_main);
set_intents(@man);
standardize_intents(@man);
king.jump_intent(0);
advance_happening = true;
frame_count++;
}
for(uint i = 0; i < effects.length(); i++) {
effects[i].time_warp(time_main);
}
if (man.as_dustman().dead()) {
king.kill(false);
}
}
void step_post(int) {
if( advance_happening ) {
standardize_intents_post(@man);
time_main = 0;
man.time_warp(time_main);
advance_happening = false;
if(man.hitbox() !is null)
man.hitbox().time_warp(time_main);
}
for(uint i = 0; i < effects.length(); i++) {
effects[i].time_warp(time_main);
}
}
void draw(float sub_frame) {
//FIND CORNER OF SCREEN
float corner_x = (-1.0*(g.hud_screen_width(false)/2));
float corner_y = (g.hud_screen_height(false)/2);
c.draw_text(label, corner_x + 15, corner_y - 110.5, 1, 1, -15);
count.text(""+frame_count);
c.draw_text(count, corner_x + 120, corner_y - 88.5, 1, 1, 0);
}
// this makes sure attack and dash particles from the player are frozen too
void entity_on_add(entity@ e) {
if (e.type_name() == "effect") {
string set = e.as_effect().sprite_set();
if (set == 'vdustman' || set == 'vdustgirl' || set == 'vdustkid' || set == 'vdustworth') {
effects.insertLast(e);
}
}
}
void on_level_start() {
initialize();
}
void checkpoint_load() {
initialize();
}
void initialize() {
for(uint i=0; i < players.length(); i++) {
if (@controller_controllable(i) != null) {
@players[i] = controller_controllable(i).as_dustman();
}
}
@king = players[0];
@man = create_entity("dust_man").as_controllable();
man.as_dustman().character(king.character());
man.x(936);
man.y(-384);
man.time_warp(0);
man.as_controllable().team(1);
man.as_dustman().ai_disabled(true);
man.as_dustman().auto_respawn(false);
g.add_entity(man.as_entity(), false);
king.character("trashking");
king.filth_type(0);
}
// this part takes the inputs from the buttons and turns them into "mode 1" intents
void set_intents(controllable@ man) {
if (man is null)
return;
//direction intents
if (left_active) {
man.x_intent(-1);
} else if (right_active) {
man.x_intent(1);
} else {
man.x_intent(0);
}
if (down_active) {
man.y_intent(1);
} else if (up_active) {
man.y_intent(-1);
} else {
man.y_intent(0);
}
//other intents
if (light_active) {
man.light_intent(10);
} else {
man.light_intent(0);
}
if (heavy_active) {
man.heavy_intent(10);
} else {
man.heavy_intent(0);
}
if (jump_active) {
man.jump_intent(1);
} else {
man.jump_intent(0);
}
if (dash_active) {
man.dash_intent(1);
} else {
man.dash_intent(0);
}
man.fall_intent(0);
}
// all the following code for standardizing intents is courtesy of Skyhawk <3
void standardize_intents(controllable@ player) {
if (player is null)
return;
// dash is only 1 on the first frame it is pressed. after that, return it to 0
int dash = player.dash_intent();
if (dash > 0) {
if (dash_pressed)
player.dash_intent(0);
// if it's the first frame dash is pressed, and the player is holding down
// check if they should dash, fall, or both
else if (player.y_intent() == 1) {
player.fall_intent(1);
if (!player.ground()) {
player.dash_intent(0);
}
}
}
dash_pressed = dash > 0;
// taunt is only 1 on the first frame it is pressed. after that, return it to 0
int taunt = player.taunt_intent();
if (taunt > 0 && taunt_pressed) {
player.taunt_intent(0);
}
taunt_pressed = taunt > 0;
// jump is 1 when held but unused, and 2 when it is held and already used
if (player.jump_intent() > 0 && jump_used)
player.jump_intent(2);
else
jump_used = false;
// attacks are 10 when held but unused, and 11 when held and already used
// when released and unused, attacks buffer by counting down to 0
if (player.light_intent() == 10 && light_counter == 11) {
player.light_intent(11);
}
else if (player.light_intent() == 0) {
if (light_counter == 11)
light_counter = 0;
else if (light_counter > 0) {
light_counter--;
player.light_intent(light_counter);
}
}
if (player.heavy_intent() == 10 && heavy_counter == 11) {
player.heavy_intent(11);
}
else if (player.heavy_intent() == 0) {
if (heavy_counter == 11)
heavy_counter = 0;
else if (heavy_counter > 0) {
heavy_counter--;
player.heavy_intent(heavy_counter);
}
}
}
/**
* Gathers information about which intents were used during the frame in order to correctly
* assign intents during future frames
*/
void standardize_intents_post(controllable@ player) {
if (player is null)
return;
// even though the input mode has changed, the game will still change the intent to 2
// if it was used during this frame
if (player.jump_intent() == 2)
jump_used = true;
// for attacks, if the intent was used, it will be changed to 11. otherwise, it will stay 10
if (player.light_intent() > 9)
light_counter = player.light_intent();
if (player.heavy_intent() > 9)
heavy_counter = player.heavy_intent();
}
}
class Note : trigger_base {
script@ s;
scripttrigger@ self;
scene@ g;
textfield@ note;
void init(script@ s, scripttrigger@ self) {
@this.s = s;
@this.self = @self;
@g = get_scene();
@note = create_textfield();
note.set_font("Caracteres", 36);
note.text("Jump to\nadvance\nframe!");
note.colour(0xFF000000);
}
void editor_draw(float subframe) {
draw_it();
}
void draw(float subframe) {
draw_it();
}
void draw_it() {
float x = self.x();
float y = self.y();
g.draw_quad_world(20, 20, false, x, y, x+172.3, y+30.4, x+142, y+202.7, x-30.4, y+172.3, 0xFFF1E288, 0xFFEFE084, 0xFFF2EBB3, 0xFFF1EB8E);
note.draw_world(20, 20, x+70, y+95, 1, 1, 10);
}
}
[hidden]
class Button : trigger_base {
script@ s;
scripttrigger@ self;
scene@ g;
sprites@ spr;
float x;
float y;
uint32 bg = 0xFFAAAAAA;
uint32 color = 0xFF996600;
void init(script@ s, scripttrigger@ self) {
@this.s = s;
@this.self = @self;
@g = get_scene();
@spr = create_sprites();
spr.add_sprite_set("dustman");
spr.add_sprite_set("props5");
}
bool hitcheck() {
int hits = g.get_entity_collision(y+20, y+80, x+20, x+80, 8);
for (int i = 0; i < hits; i++) {
hitbox@ hb = g.get_entity_collision_index(i).as_hitbox();
if (hb.triggered() && hb.state_timer() == hb.activate_time() && hb.owner().is_same(s.king.as_controllable())) {
return true;
}
}
return false;
}
void editor_step() {
self.x(round(self.x() / 6) * 6);
self.y(round(self.y() / 6) * 6);
}
void editor_draw(float subframe) {
draw_it();
}
void draw(float subframe) {
draw_it();
}
void draw_it() {
x = self.x();
y = self.y();
//EDGES OF THE OCTAGONAL BUTTON
g.draw_quad_world(15, 20, false, x+25, y, x+25, y+5, x+75, y+5, x+75, y, bg, bg, bg, bg);
g.draw_quad_world(15, 20, false, x+25, y+95, x+25, y+100, x+75, y+100, x+75, y+95, bg, bg, bg, bg);
g.draw_quad_world(15, 20, false, x, y+25, x, y+75, x+5, y+75, x+5, y+25, bg, bg, bg, bg);
g.draw_quad_world(15, 20, false, x+95, y+25, x+95, y+75, x+100, y+75, x+100, y+25, bg, bg, bg, bg);
g.draw_quad_world(15, 20, false, x+25, y, x, y+25, x+5, y+27.5, x+27.5, y+5, bg, bg, bg, bg);
g.draw_quad_world(15, 20, false, x+95, y+72.5, x+72.5, y+95, x+75, y+100, x+100, y+75, bg, bg, bg, bg);
g.draw_quad_world(15, 20, false, x, y+75, x+25, y+100, x+27.5, y+95, x+5, y+72.5, bg, bg, bg, bg);
g.draw_quad_world(15, 20, false, x+72.5, y+5, x+95, y+27.5, x+100, y+25, x+75, y, bg, bg, bg, bg);
if (get_activation_state()) {
color = 0xBBFFDD00;
} else {
color = 0xBB996600;
}
//FILL FOR THE OCTAGONAL BUTTON
g.draw_quad_world(15, 20, false, x+27.5, y+5, x+5, y+27.5, x+5, y+72.5, x+27.5, y+95, color, color, color, color);
g.draw_quad_world(15, 20, false, x+27.5, y+5, x+27.5, y+95, x+72.5, y+95, x+72.5, y+5, color, color, color, color);
g.draw_quad_world(15, 20, false, x+72.5, y+5, x+95, y+27.5, x+95, y+72.5, x+72.5, y+95, color, color, color, color);
draw_image();
}
bool get_activation_state() {
return false; // dummy method
}
void draw_image() {
return; // dummy method
}
}
class Left : Button {
void draw_image() {
x = self.x();
y = self.y();
spr.draw_world(16, 19, "symbol_1", 0, 0, x-36, y-48, 180, 1, 1, 0xFFFFFFFF);
}
void step() {
if (hitcheck()) {
if (s.left_active) {
s.left_active = false;
} else {
s.left_active = true;
s.right_active = false;
}
}
}
bool get_activation_state() {
return s.left_active;
}
}
class Right : Button {
void draw_image() {
x = self.x();
y = self.y();
spr.draw_world(16, 19, "symbol_1", 0, 0, x+135, y+145, 0, 1, 1, 0xFFFFFFFF);
}
void step() {
if (hitcheck()) {
if (s.right_active) {
s.right_active = false;
} else {
s.right_active = true;
s.left_active = false;
}
}
}
bool get_activation_state() {
return s.right_active;
}
}
class Up : Button {
void draw_image() {
x = self.x();
y = self.y();
spr.draw_world(16, 19, "symbol_1", 0, 0, x+145, y-35, 270, 1, 1, 0xFFFFFFFF);
}
void step() {
if (hitcheck()) {
if (s.up_active) {
s.up_active = false;
} else {
s.up_active = true;
s.down_active = false;
}
}
}
bool get_activation_state() {
return s.up_active;
}
}
class Down : Button {
void draw_image() {
x = self.x();
y = self.y();
spr.draw_world(16, 19, "symbol_1", 0, 0, x-45, y+135, 90, 1, 1, 0xFFFFFFFF);
}
void step() {
if (hitcheck()) {
if (s.down_active) {
s.down_active = false;
} else {
s.down_active = true;
s.up_active = false;
}
}
}
bool get_activation_state() {
return s.down_active;
}
}
class Jump : Button {
void draw_image() {
x = self.x();
y = self.y();
spr.draw_world(16, 19, "rising", 0, 0, x+50, y+70, 0, 0.6, 0.6, 0xBBFFFFFF);
}
void step() {
if (hitcheck()) {
s.jump_active = !s.jump_active;
}
}
bool get_activation_state() {
return s.jump_active;
}
}
class Dash : Button {
void draw_image() {
x = self.x();
y = self.y();
spr.draw_world(16, 19, "dash", 0, 0, x+35, y+70, 0, 0.6, 0.6, 0xBBFFFFFF);
}
void step() {
if (hitcheck()) {
s.dash_active = !s.dash_active;
}
}
bool get_activation_state() {
return s.dash_active;
}
}
class Light : Button {
void draw_image() {
x = self.x();
y = self.y();
spr.draw_world(16, 19, "dmgroundstrike2", 0, 0, x+30, y+75, 0, 0.4, 0.4, 0xBBFFFFFF);
}
void step() {
if (hitcheck()) {
s.light_active = !s.light_active;
}
}
bool get_activation_state() {
return s.light_active;
}
}
class Heavy : Button {
void draw_image() {
x = self.x();
y = self.y();
spr.draw_world(16, 19, "dmairheavyd", 0, 0, x+35, y+70, 0, 0.3, 0.3, 0xBBFFFFFF);
}
void step() {
if (hitcheck()) {
s.heavy_active = !s.heavy_active;
}
}
bool get_activation_state() {
return s.heavy_active;
}
}