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/Mission/MissionWindCurrent.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Wind Current Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// This Object is used in Mission "Quick Step" - M050 - Mission_Zone11
9
10
// ========================
11
// Aliases
12
// ========================
13
14
private alias object.value0 : object.minPos.x
15
private alias object.value1 : object.minPos.y
16
private alias object.value2 : object.maxPos.x
17
private alias object.value3 : object.maxPos.y
18
19
// Player Aliases
20
private alias object.gravity : player.gravity
21
private alias object.animation : player.animation
22
private alias object.speed : player.speed
23
private alias object.xpos : player.xpos
24
private alias object.ypos : player.ypos
25
private alias object.xvel : player.xvel
26
private alias object.yvel : player.yvel
27
private alias object.state : player.state
28
private alias object.tileCollisions : player.tileCollisions
29
private alias object.up : player.up
30
private alias object.down : player.down
31
private alias object.left : player.left
32
private alias object.right : player.right
33
34
35
// ========================
36
// Function declarations
37
// ========================
38
39
reserve function WindCurrent_State_Clinging
40
41
42
// ========================
43
// Function Definitions
44
// ========================
45
46
// Copy of WFZSetup_State_Clinging, just with those xvel and speed values' signs flipped
47
private function WindCurrent_State_Clinging
48
player.gravity = GRAVITY_AIR
49
50
if player.animation != ANI_CLINGING
51
player.xvel = 0x80000
52
player.speed = 0x80000
53
else
54
player.xvel = 0
55
player.speed = 0
56
end if
57
58
if player.up == true
59
player.ypos -= 0x10000
60
else
61
if player.down == true
62
player.ypos += 0x10000
63
end if
64
end if
65
66
player.yvel = 0
67
end function
68
69
70
// ========================
71
// Events
72
// ========================
73
74
75
event ObjectUpdate
76
temp6 = PRIORITY_XBOUNDS
77
78
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
79
CheckLower(player[currentPlayer].xpos, object.minPos.x)
80
temp0 = checkResult
81
CheckGreater(player[currentPlayer].xpos, object.minPos.y)
82
temp0 |= checkResult
83
CheckLower(player[currentPlayer].ypos, object.maxPos.x)
84
temp0 |= checkResult
85
CheckGreater(player[currentPlayer].ypos, object.maxPos.y)
86
temp0 |= checkResult
87
if temp0 == false
88
temp6 = PRIORITY_ACTIVE
89
90
CheckEqual(player[currentPlayer].state, Player_State_GotHit)
91
temp0 = checkResult
92
CheckEqual(player[currentPlayer].state, Player_State_Hurt)
93
temp0 |= checkResult
94
CheckEqual(player[currentPlayer].state, Player_State_Death)
95
temp0 |= checkResult
96
CheckEqual(player[currentPlayer].state, Player_State_Drown)
97
temp0 |= checkResult
98
CheckEqual(player[currentPlayer].state, WindCurrent_State_Clinging)
99
temp0 |= checkResult
100
if temp0 == false
101
player[currentPlayer].state = WindCurrent_State_Clinging
102
player[currentPlayer].animation = ANI_FANROTATE
103
player[currentPlayer].tileCollisions = true
104
end if
105
106
if player[currentPlayer].animation == ANI_FANROTATE
107
if player[currentPlayer].xvel == 0
108
temp1 = object.maxPos.y
109
temp1 -= object.maxPos.x
110
temp1 >>= 1
111
temp1 += object.maxPos.x
112
if player[currentPlayer].ypos < temp1
113
player[currentPlayer].ypos += 0x40000
114
else
115
player[currentPlayer].ypos -= 0x40000
116
end if
117
end if
118
end if
119
else
120
if player[currentPlayer].state == WindCurrent_State_Clinging
121
player[currentPlayer].state = Player_State_Air_NoDropDash
122
player[currentPlayer].xvel = 0x40000 // these values are normally negative in the original Wind Current script, the Mission ver flips them
123
player[currentPlayer].speed = 0x40000
124
end if
125
end if
126
next
127
128
object.priority = temp6
129
if object.propertyValue == 0
130
object[+1].priority = temp6
131
else
132
object[-1].priority = temp6
133
end if
134
end event
135
136
137
event ObjectStartup
138
foreach (TypeName[Wind Current], arrayPos0, ALL_ENTITIES)
139
if object[arrayPos0].propertyValue == 0
140
arrayPos1 = arrayPos0
141
arrayPos1++
142
object[arrayPos0].minPos.x = object[arrayPos0].xpos
143
object[arrayPos0].minPos.y = object[arrayPos1].xpos
144
temp1 = object[arrayPos0].ypos
145
temp2 = object[arrayPos1].ypos
146
else
147
arrayPos1 = arrayPos0
148
arrayPos1--
149
object[arrayPos0].minPos.x = object[arrayPos1].xpos
150
object[arrayPos0].minPos.y = object[arrayPos0].xpos
151
temp1 = object[arrayPos1].ypos
152
temp2 = object[arrayPos0].ypos
153
end if
154
155
if temp1 < temp2
156
object[arrayPos0].maxPos.x = temp1
157
object[arrayPos0].maxPos.y = temp2
158
else
159
object[arrayPos0].maxPos.x = temp2
160
object[arrayPos0].maxPos.y = temp1
161
end if
162
163
object[arrayPos0].priority = PRIORITY_XBOUNDS
164
next
165
end event
166
167
168
// ========================
169
// Editor Events
170
// ========================
171
172
event RSDKEdit
173
if editor.returnVariable == true
174
switch editor.variableID
175
case EDIT_VAR_PROPVAL // property value
176
checkResult = object.propertyValue
177
break
178
179
case 0 // childType
180
checkResult = object.propertyValue
181
break
182
183
end switch
184
else
185
switch editor.variableID
186
case EDIT_VAR_PROPVAL // property value
187
object.propertyValue = editor.variableValue
188
break
189
190
case 0 // childType
191
object.propertyValue = editor.variableValue
192
break
193
194
end switch
195
end if
196
end event
197
198
199
event RSDKDraw
200
DrawSprite(0)
201
end event
202
203
204
event RSDKLoad
205
LoadSpriteSheet("Global/Display.gif")
206
SpriteFrame(-16, -16, 32, 32, 1, 143)
207
208
AddEditorVariable("childType")
209
SetActiveVariable("childType")
210
AddEnumVariable("Next Slot", 0)
211
AddEnumVariable("Previous Slot", 1)
212
end event
213
214