Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_camera_advanced_Other_10

(view raw script w/o annotations or w/e)
1
cameraActive = 1;
2
cX = camerax();
3
cY = cameray();
4
cV = currentView;
5
if (ignoreFreezeArea[cV] != -2)
6
    ignoreFreeze = ignoreFreezeArea[cV];
7
if (ignoreFreeze == 0)
8
{
9
    if (global.interact != 0)
10
        cameraActive = 0;
11
}
12
if (ignoreCutscene == 0)
13
{
14
    if (cutscene == 1)
15
        cameraActive = 0;
16
}
17
if (cameraActive == 1)
18
{
19
    xAdd = 0;
20
    yAdd = 0;
21
    cameraFinished = 0;
22
    event_user(2);
23
    if (panStyle[cV] == 0)
24
    {
25
        panSpeed = panSpeedInit[cV];
26
        panDir = point_direction(cX, cY, finalX, finalY);
27
        xAdd = lengthdir_x(panSpeed, panDir);
28
        yAdd = lengthdir_y(panSpeed, panDir);
29
        nextX = cX + xAdd;
30
        nextY = cY + yAdd;
31
    }
32
    if (panStyle[cV] == 1)
33
    {
34
        if (targetObject[cV] != remTargetObject)
35
        {
36
            lerpProgress = 0;
37
        }
38
        else if (targetObject[cV] == -4)
39
        {
40
            if (remFinalX != finalX || remFinalY != finalY)
41
                lerpProgress = 0;
42
        }
43
        if (remCurrentView != cV)
44
            lerpProgress = 0;
45
        if (lerpSmooth[cV] == 0)
46
        {
47
            if (lerpProgress == 0)
48
            {
49
                startLerpX = cX;
50
                startLerpY = cY;
51
            }
52
        }
53
        else
54
        {
55
            startLerpX = cX;
56
            startLerpY = cY;
57
        }
58
        if (lerpTime[cV] != 0)
59
            lerpProgress += (1 / lerpTime[cV]);
60
        else
61
            lerpProgress = lerpForceAmount[cV];
62
        lerpProgress = clamp(lerpProgress, 0, 1);
63
        nextX = lerp(startLerpX, finalX, lerpProgress);
64
        nextY = lerp(startLerpY, finalY, lerpProgress);
65
        if (lerpForceAmount[cV] != 0 && lerpSmooth[cV] == 1)
66
        {
67
            if (abs(nextX - finalX) < 2)
68
                nextX = finalX;
69
            if (abs(nextY - finalY) < 2)
70
                nextY = finalY;
71
        }
72
    }
73
    if (panStyle[cV] == 2)
74
    {
75
        if (remCurrentView != cV || accelInit == 0)
76
        {
77
            panSpeed = panSpeedInit[cV];
78
            panXSpeed = lengthdir_x(panSpeed, panIdealDir);
79
            panYSpeed = lengthdir_y(panSpeed, panIdealDir);
80
            accelInit = 1;
81
        }
82
        panIdealDir = point_direction(cX, cY, finalX, finalY);
83
        panXSpeedMax = lengthdir_x(panSpeedMax[cV], panIdealDir);
84
        panYSpeedMax = lengthdir_y(panSpeedMax[cV], panIdealDir);
85
        panDir = point_direction(0, 0, panXSpeed, panYSpeed);
86
        panXAccel = lengthdir_x(panAccel[cV], panIdealDir);
87
        panYAccel = lengthdir_y(panAccel[cV], panIdealDir);
88
        if (panDecelBool[cV] == 1)
89
        {
90
            if (point_distance(cX, cY, finalX, finalY) < (point_distance(0, 0, panXSpeed, panYSpeed) / panDecelFactor[cV]))
91
            {
92
                panXAccel = -panXAccel;
93
                panYAccel = -panYAccel;
94
                if (sign(panXAccel) == sign(panXSpeed) || panXSpeed == 0)
95
                    panXAccel = 0;
96
                if (sign(panYAccel) == sign(panYSpeed) || panYSpeed == 0)
97
                    panYAccel = 0;
98
            }
99
        }
100
        panXSpeed = clamp(panXSpeed + panXAccel, -abs(panXSpeedMax), abs(panXSpeedMax));
101
        panYSpeed = clamp(panYSpeed + panYAccel, -abs(panYSpeedMax), abs(panYSpeedMax));
102
        xAdd = panXSpeed;
103
        yAdd = panYSpeed;
104
        nextX = cX + xAdd;
105
        nextY = cY + yAdd;
106
    }
107
    if (panStyle[cV] == 3)
108
    {
109
        nextX = finalX;
110
        nextY = finalY;
111
    }
112
    if (xAdd > 0)
113
        nextX = min(nextX, finalX);
114
    if (xAdd < 0)
115
        nextX = max(nextX, finalX);
116
    if (yAdd > 0)
117
        nextY = min(nextY, finalY);
118
    if (yAdd < 0)
119
        nextY = max(nextY, finalY);
120
    cX = nextX;
121
    cY = nextY;
122
    if (cX == finalX || cX < panLimitLeft[cV] || cX > panLimitRight[cV])
123
    {
124
        if (cY == finalY || cY < panLimitTop[cV] || cY > panLimitBottom[cV])
125
            cameraFinished = 1;
126
    }
127
    cX = clamp(cX, panLimitLeft[cV], panLimitRight[cV]);
128
    cY = clamp(cY, panLimitTop[cV], panLimitBottom[cV]);
129
    if (!ignoreX[cV])
130
        camerax_set(cX);
131
    if (!ignoreY[cV])
132
        cameray_set(cY);
133
    remFinalX = finalX;
134
    remFinalY = finalY;
135
    remTargetObject = targetObject[cV];
136
    remCurrentView = cV;
137
}