Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Global/YBoundAdjust.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Y Bound Adjust Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Player aliases
13
private alias object.xpos : player.xpos
14
private alias object.ypos : player.ypos
15
16
17
// ========================
18
// Events
19
// ========================
20
21
event ObjectUpdate
22
if object.propertyValue == 0
23
// Only check if the player's within a 64 pixel range of the object, in terms of X
24
temp0 = player[0].xpos
25
temp0 -= object.xpos
26
Abs(temp0)
27
if temp0 < 0x200000
28
stage.newYBoundary2 = object.iypos
29
stage.deathBoundary = object.ypos
30
end if
31
else
32
// Check if the player's between this object and the next, in terms of Y
33
if player[0].ypos < object.ypos
34
if player[0].ypos > object[+1].ypos
35
temp0 = player[0].xpos
36
temp0 -= object.xpos
37
Abs(temp0)
38
if temp0 < 0x200000
39
stage.newYBoundary2 = object.iypos
40
stage.deathBoundary = object.ypos
41
end if
42
end if
43
end if
44
end if
45
end event
46
47
48
event ObjectStartup
49
foreach (TypeName[Y Bound Adjust], arrayPos0, ALL_ENTITIES)
50
// Set the initial camera bounds based on where the player spawned
51
// (This object comes after Lamp Posts in the object order, which is why this can be done already)
52
53
if object[arrayPos0].propertyValue == 0
54
object[arrayPos0].priority = PRIORITY_XBOUNDS
55
temp0 = player[0].xpos
56
temp0 -= object[arrayPos0].xpos
57
Abs(temp0)
58
if temp0 < 0x200000
59
stage.curYBoundary2 = object[arrayPos0].iypos
60
stage.deathBoundary = object[arrayPos0].ypos
61
end if
62
else
63
object[arrayPos0].priority = PRIORITY_XBOUNDS
64
arrayPos1 = arrayPos0
65
arrayPos1++
66
if player[0].ypos < object[arrayPos0].ypos
67
if player[0].ypos > object[arrayPos1].ypos
68
temp0 = player[0].xpos
69
temp0 -= object[arrayPos0].xpos
70
Abs(temp0)
71
if temp0 < 0x200000
72
stage.curYBoundary2 = object[arrayPos0].iypos
73
stage.deathBoundary = object[arrayPos0].ypos
74
end if
75
end if
76
end if
77
end if
78
next
79
end event
80
81
82
// ========================
83
// Editor Events
84
// ========================
85
86
event RSDKEdit
87
if editor.returnVariable == true
88
switch editor.variableID
89
case EDIT_VAR_PROPVAL // property value
90
checkResult = object.propertyValue
91
break
92
93
case 0 // type
94
checkResult = object.propertyValue
95
break
96
97
end switch
98
else
99
switch editor.variableID
100
case EDIT_VAR_PROPVAL // property value
101
object.propertyValue = editor.variableValue
102
break
103
104
case 0 // type
105
object.propertyValue = editor.variableValue
106
break
107
108
end switch
109
end if
110
end event
111
112
113
event RSDKDraw
114
// The object's tiny, draw a small line to show where the camera's gonna be aligned to
115
// No specific reason for using yellow, I just think it looks nice
116
temp0 = object.xpos
117
temp0 -= 0x1C0000
118
temp1 = object.xpos
119
temp1 += 0x1C0000
120
DrawLine(temp0, object.ypos, temp1, object.ypos, 0xFF, 0xFF, 0x00)
121
122
// Draw the Y icon ontop of the line
123
DrawSprite(0)
124
125
editor.drawingOverlay = true
126
127
CheckEqual(object.propertyValue, 1)
128
checkResult &= editor.showGizmos
129
if temp0 == true
130
// Draw arrows between the next object too, since that's where the other side of the bounds adjust is
131
// Using yellow again cuz why not
132
DrawArrow(object.xpos, object.ypos, object[+1].xpos, object[+1].ypos, 0xFF, 0xFF, 0x00)
133
DrawArrow(object[+1].xpos, object[+1].ypos, object.xpos, object.ypos, 0xFF, 0xFF, 0x00)
134
end if
135
136
editor.drawingOverlay = false
137
end event
138
139
140
event RSDKLoad
141
LoadSpriteSheet("Global/Display.gif")
142
SpriteFrame(-8, -8, 16, 16, 205, 239) // "Y" (Bounds Adjust)
143
144
AddEditorVariable("type")
145
SetActiveVariable("type")
146
AddEnumVariable("Regular Adjust", 0) // adjusts to this YPos
147
AddEnumVariable("Box Adjust", 1) // adjusts to this YPos, if the player is below this YPos and above the next object slots' YPos
148
end event
149
150