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/Special/Bumper.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Bumper Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
14
private alias 0 : BUMPER_IDLE
15
private alias 1 : BUMPER_BUMPED
16
17
// Player aliases
18
private alias object.xpos : player.xpos
19
private alias object.ypos : player.ypos
20
private alias object.speed : player.speed
21
private alias object.gravity : player.gravity
22
private alias object.value1 : player.timer
23
private alias object.value12 : player.worldVelocity.x
24
private alias object.value13 : player.worldVelocity.y
25
26
27
// ========================
28
// Function Declarations
29
// ========================
30
31
reserve function Bumper_DebugDraw
32
reserve function Bumper_DebugSpawn
33
34
35
// ========================
36
// Function Definitions
37
// ========================
38
39
private function Bumper_DebugDraw
40
DrawSprite(0)
41
end function
42
43
44
private function Bumper_DebugSpawn
45
temp5 = TypeName[Bumper]
46
temp4 = 0
47
CallFunction(DebugMode_PlaceBlock)
48
object[arrayPos0].drawOrder = 4
49
end function
50
51
52
// ========================
53
// Events
54
// ========================
55
56
event ObjectUpdate
57
// Animate the object if needed
58
if object.state > BUMPER_IDLE
59
object.frame = object.timer
60
object.frame /= 5
61
object.frame++
62
object.timer++
63
if object.timer > 22
64
object.timer = 0
65
object.state = BUMPER_IDLE
66
object.frame = 0
67
end if
68
end if
69
70
if object.outOfBounds == true
71
object.priority = PRIORITY_BOUNDS
72
end if
73
74
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
75
CallFunction(SpecialSetup_PlayerBlockCol)
76
BoxCollisionTest(C_TOUCH, object.entityPos, -14, -14, 14, 14, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
77
if checkResult == true
78
if object.state == BUMPER_IDLE
79
PlaySfx(SfxName[Bumper], false)
80
end if
81
82
if object.timer > 5
83
PlaySfx(SfxName[Bumper], false)
84
end if
85
86
object.state = BUMPER_BUMPED
87
object.priority = PRIORITY_ACTIVE
88
89
// Find where to send the player
90
temp0 = player[currentPlayer].xpos
91
temp0 -= object.xpos
92
temp1 = player[currentPlayer].ypos
93
temp1 -= object.ypos
94
ATan2(temp2, temp0, temp1)
95
Cos256(temp0, temp2)
96
Sin256(temp1, temp2)
97
temp0 *= 0x700
98
temp1 *= 0x700
99
100
// Bounce the player back
101
player[currentPlayer].timer = 0
102
player[currentPlayer].worldVelocity.x = temp0
103
player[currentPlayer].worldVelocity.y = temp1
104
player[currentPlayer].speed = object.xvel
105
player[currentPlayer].gravity = GRAVITY_AIR
106
end if
107
next
108
end event
109
110
111
event ObjectDraw
112
CallFunction(SpecialSetup_GetBlockPos)
113
DrawSpriteXY(object.frame, temp0, temp1)
114
end event
115
116
117
event ObjectStartup
118
LoadSpriteSheet("Special/Objects.gif")
119
120
// Bumper frames
121
SpriteFrame(-14, -14, 28, 28, 1, 401)
122
SpriteFrame(-12, -12, 24, 24, 1, 430)
123
SpriteFrame(-16, -16, 32, 32, 30, 401)
124
SpriteFrame(-12, -12, 24, 24, 1, 430)
125
SpriteFrame(-16, -16, 32, 32, 30, 401)
126
SpriteFrame(-16, -16, 32, 32, 30, 401)
127
128
// Add this object to the stage's debug mode list
129
SetTableValue(TypeName[Bumper], DebugMode_ObjCount, DebugMode_TypeTable)
130
SetTableValue(Bumper_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
131
SetTableValue(Bumper_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
132
DebugMode_ObjCount++
133
end event
134
135
136
// ========================
137
// Editor Events
138
// ========================
139
140
event RSDKDraw
141
DrawSprite(0)
142
end event
143
144
145
event RSDKLoad
146
LoadSpriteSheet("Special/Objects.gif")
147
SpriteFrame(-14, -14, 28, 28, 1, 401)
148
149
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
150
end event
151
152