Undertale script viewer

← back to main script listing

gml_Object_obj_targetchoicefist_Step_0

(view raw script w/o annotations or w/e)
1
if (hspeed > 0)
2
{
3
    if (x > (obj_target.x + obj_target.sprite_width))
4
        xxx = 1;
5
}
6
if (hspeed < 0)
7
{
8
    if (x < obj_target.x)
9
        xxx = 1;
10
}
11
mons = global.monsterinstance[global.mytarget];
12
ht = 100;
13
wd = 100;
14
if (instance_exists(mons))
15
    mons.trgtest = id;
16
with (mons)
17
{
18
    trgtest.ht = ht;
19
    trgtest.wd = wd;
20
}
21
if (image_speed >= 0.4 && punchtime < maxpunchtime)
22
{
23
    punchtime += 1;
24
    if (control_check_pressed(0) && punches < maxpunches)
25
    {
26
        if (instance_exists(obj_pressZ))
27
        {
28
            obj_pressZ.visible = false;
29
            obj_pressZ.alarm[0] = 7;
30
            obj_pressZ.alarm[1] = -1;
31
        }
32
        punches += 1;
33
        control_clear(0);
34
        if (punches < maxpunches)
35
            instance_create(mons.x + random(wd), mons.y + random(mons.ht), obj_lightpunch);
36
        if (punches == maxpunches)
37
            instance_create(mons.x + (wd / 2), mons.y + (ht / 2), obj_strongpunch);
38
    }
39
    if (punchtime == maxpunchtime || punches == maxpunches)
40
    {
41
        if (punches == 0)
42
        {
43
            xxx = 1;
44
        }
45
        else
46
        {
47
            global.damagetimer = 10;
48
            punchtime = maxpunchtime + 1;
49
            global.damage = ceil(global.damage * (punches / maxpunches));
50
            with (mons)
51
                takedamage = global.damage;
52
            global.hurtanim[global.mytarget] = 1;
53
            if (instance_exists(obj_pressZ))
54
            {
55
                with (obj_pressZ)
56
                    instance_destroy();
57
            }
58
        }
59
    }
60
}
61
if (image_speed == 0)
62
{
63
    if (control_check_pressed(0))
64
    {
65
        mons = global.monsterinstance[global.mytarget];
66
        hspeed = 0;
67
        script_execute(scr_attackcalc);
68
        global.damage = damage;
69
        global.damage += random(2);
70
        myx = x + (sprite_width / 2);
71
        myperfectx = obj_target.x + (obj_target.sprite_width / 2);
72
        bonusfactor = abs(myx - myperfectx);
73
        if (bonusfactor == 0)
74
            bonusfactor = 1;
75
        global.stretch = (obj_target.sprite_width - bonusfactor) / obj_target.sprite_width;
76
        if (bonusfactor <= 12)
77
            global.damage = round(global.damage * 2.1);
78
        if (bonusfactor > 12)
79
            global.damage = round(global.damage * global.stretch * 2);
80
        image_speed = 0.4;
81
        instance_create(mons.x + (wd / 2), mons.y + (ht / 2), obj_pressZ);
82
    }
83
}
84
if (xxx == 1)
85
{
86
    global.damage = 0;
87
    global.hurtanim[global.mytarget] = 5;
88
    instance_destroy();
89
    exit;
90
}
91
if (global.myfight != 1)
92
    instance_destroy();