Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/MCZ/HPZTrigger.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: HPZ Trigger 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 : HPZTRIGGER_BLANK
15
private alias 1 : HPZTRIGGER_PAUSE
16
private alias 2 : HPZTRIGGER_FADEOUT
17
18
// Player Aliases
19
private alias object.state : player.state
20
private alias object.yvel : player.yvel
21
private alias object.animation : player.animation
22
private alias object.value0 : player.rings
23
private alias object.value25 : player.gravityStrength
24
25
// Game Modes
26
private alias 2 : MODE_TIMEATTACK
27
28
29
// ========================
30
// Events
31
// ========================
32
33
event ObjectUpdate
34
// Check if the camera bounds should change now
35
BoxCollisionTest(C_TOUCH, object.entityPos, -68, 0, 68, 5120, 0, 0, 0, 0, 0)
36
if checkResult == true
37
stage.curYBoundary2 = 0x1000
38
stage.deathBoundary = 0x1400
39
stage.deathBoundary <<= 16
40
else
41
stage.curYBoundary2 = 0x800
42
stage.deathBoundary = stage.curYBoundary2
43
stage.deathBoundary <<= 16
44
end if
45
46
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
47
// Check player collision
48
BoxCollisionTest(C_TOUCH, object.entityPos, -68, 512, 68, 5120, currentPlayer, 0, 0, 0, 0)
49
50
if checkResult == true
51
// Player has touched this object, start the transition
52
53
// Make the player start flailing
54
player[currentPlayer].animation = ANI_WATERSLIDE
55
56
// The player might be flying or gliding or climbing or a variety of not-free-falling states, so let's make sure they're falling normally
57
#platform: USE_STANDALONE
58
player[currentPlayer].state = Player_State_Air
59
#endplatform
60
#platform: USE_ORIGINS
61
player[currentPlayer].state = Player_State_Air_NoDropDash
62
#endplatform
63
64
// Enforce maximum Y velocity
65
if player[currentPlayer].yvel >= 0x100000
66
player[currentPlayer].yvel = 0x100000
67
player[currentPlayer].yvel -= player[currentPlayer].gravityStrength
68
end if
69
70
// If P1, switch to main state
71
if currentPlayer == 0
72
if object.state == HPZTRIGGER_BLANK
73
object.state = HPZTRIGGER_PAUSE
74
end if
75
end if
76
end if
77
next
78
79
switch object.state
80
case HPZTRIGGER_PAUSE
81
// Letting the player fall for a second
82
object.timer++
83
if object.timer == 60
84
object.timer = 0
85
object.state++
86
end if
87
break
88
89
case HPZTRIGGER_FADEOUT
90
// Fading out to go to HPZ
91
music.volume -= 2
92
object.timer += 8
93
SetScreenFade(0, 0, 0, object.timer)
94
if object.timer == 384
95
#platform: USE_ORIGINS
96
CallNativeFunction4(NotifyCallback, NOTIFY_STATS_ENEMY, StageStatsUsabilityParam1, StageStatsUsabilityParam2, StageStatsUsabilityParam3)
97
CallNativeFunction2(NotifyCallback, NOTIFY_STATS_RING, player[0].rings)
98
game.stageskipped = true // Set this temporarily
99
CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 1)
100
game.stageskipped = false // See? Temporary!
101
#endplatform
102
starPostID = 0
103
stage.listPos = 20
104
StopMusic()
105
LoadStage()
106
end if
107
break
108
109
end switch
110
end event
111
112
113
event ObjectStartup
114
// Cycle through all HPZ Trigger objects and...
115
foreach (TypeName[HPZ Trigger], arrayPos0, ALL_ENTITIES)
116
if options.gameMode == MODE_TIMEATTACK
117
// Erase it if in time attack, turning this pit into just a normal bottomless pit
118
ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
119
else
120
if options.vsMode == false
121
// Give it the XBOUNDS priority if in single player
122
object[arrayPos0].priority = PRIORITY_XBOUNDS
123
else
124
// Erase it if in 2P mode
125
ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
126
end if
127
end if
128
next
129
end event
130
131
132
// ========================
133
// Editor Events
134
// ========================
135
136
event RSDKDraw
137
DrawSprite(0)
138
139
if editor.showGizmos == true
140
editor.drawingOverlay = true
141
142
// Draw this object's giant hitbox, a lone "T" icon doesn't do this object justice
143
144
temp0 = 68; temp1 = 512; temp2 = 68; temp3 = 5120;
145
CallFunction(EditorHelpers_DrawHitbox)
146
147
editor.drawingOverlay = false
148
end if
149
end event
150
151
152
event RSDKLoad
153
LoadSpriteSheet("Global/Display.gif")
154
SpriteFrame(-8, -8, 16, 16, 168, 18) // "trigger" - #0
155
156
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
157
end event
158
159