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/1UP.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: 1UP Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Music Events
13
private alias 25 : SLOT_MUSICEVENT_CHANGE
14
15
private alias 2 : MUSICEVENT_TRANSITION
16
17
18
// ========================
19
// Function Declarations
20
// ========================
21
22
reserve function 1UP_DebugDraw
23
reserve function 1UP_DebugSpawn
24
25
26
// ========================
27
// Function Definitions
28
// ========================
29
30
private function 1UP_DebugDraw
31
// Bug Details: really minor bug, but
32
// -> This doesn't account for Amy, so Amy's object placement mode shows 1UPs as Warp Blocks
33
// (The object appears properly once it's placed, though, so)
34
DrawSprite(stage.playerListPos)
35
end function
36
37
38
private function 1UP_DebugSpawn
39
temp5 = TypeName[1UP]
40
temp4 = 0
41
CallFunction(DebugMode_PlaceBlock)
42
object[arrayPos0].drawOrder = 4
43
end function
44
45
46
// ========================
47
// Events
48
// ========================
49
50
event ObjectUpdate
51
// Interact with player(s)
52
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
53
54
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
55
if checkResult == true
56
// Make the object disappear
57
object.type = TypeName[Ring Sparkle]
58
59
// Give an extra life
60
if options.gameMode != MODE_TIMEATTACK
61
#platform: USE_STANDALONE
62
player.lives++
63
#endplatform
64
#platform: USE_ORIGINS
65
if game.coinMode == false
66
player.lives++
67
else
68
CallNativeFunction2(NotifyCallback, NOTIFY_ADD_COIN, 1)
69
end if
70
#endplatform
71
PlaySfx(SfxName[Life], false)
72
PauseMusic()
73
ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
74
object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE
75
end if
76
end if
77
next
78
end event
79
80
81
event ObjectDraw
82
CallFunction(SpecialSetup_GetBlockPos)
83
#platform: USE_STANDALONE
84
DrawSpriteXY(stage.playerListPos, temp0, temp1)
85
#endplatform
86
#platform: USE_ORIGINS
87
switch stage.playerListPos
88
case PLAYER_SONIC_A
89
case PLAYER_SONIC_TAILS_A
90
DrawSpriteXY(0, temp0, temp1)
91
break
92
case PLAYER_TAILS_A
93
DrawSpriteXY(1, temp0, temp1)
94
break
95
case PLAYER_KNUCKLES_A
96
case PLAYER_KNUCKLES_TAILS_A // but K+T isn't even in Origins..?
97
DrawSpriteXY(2, temp0, temp1)
98
break
99
case PLAYER_AMY_A
100
DrawSpriteXY(3, temp0, temp1)
101
break
102
end switch
103
#endplatform
104
105
end event
106
107
108
event ObjectStartup
109
LoadSpriteSheet("Special/Objects.gif")
110
111
// Loop through all objects, view this as a foreach
112
arrayPos0 = 0x20
113
while arrayPos0 < 0x420
114
if object[arrayPos0].type == TypeName[1UP]
115
object[arrayPos0].drawOrder = 4
116
end if
117
118
arrayPos0++
119
loop
120
121
// Sprite frames: In order of Sonic icon, Tails icon, Knuckles icon, and Amy icon (Origins Plus)
122
SpriteFrame(-12, -12, 24, 24, 251, 176)
123
SpriteFrame(-12, -12, 24, 24, 351, 276)
124
SpriteFrame(-12, -12, 24, 24, 376, 276)
125
#platform: USE_ORIGINS
126
SpriteFrame(-12, -12, 24, 24, 105, 492)
127
#endplatform
128
129
// Add this object to the stage's debug mode list
130
SetTableValue(TypeName[1UP], DebugMode_ObjCount, DebugMode_TypeTable)
131
SetTableValue(1UP_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
132
SetTableValue(1UP_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
133
DebugMode_ObjCount++
134
end event
135
136
137
// ========================
138
// Editor Events
139
// ========================
140
141
event RSDKDraw
142
DrawSprite(0)
143
end event
144
145
146
event RSDKLoad
147
LoadSpriteSheet("Special/Objects.gif")
148
SpriteFrame(-12, -12, 24, 24, 251, 176)
149
150
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
151
end event
152
153