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/ARZ/LeafSpawner.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Leaf Spawner 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.spawnDelay
13
private alias object.value1 : object.hitboxR
14
private alias object.value2 : object.hitboxL
15
16
// Leaf Aliases
17
private alias object.value1 : leaf.originPos.x
18
private alias object.value2 : leaf.originPos.y
19
private alias object.value3 : leaf.fallAngle
20
private alias object.value4 : leaf.angleVel
21
22
// Player Aliases
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
28
29
// ========================
30
// Function Declarations
31
// ========================
32
33
reserve function LeafSpawner_SpawnLeaf
34
35
36
// ========================
37
// Function Definitions
38
// ========================
39
40
private function LeafSpawner_SpawnLeaf
41
CreateTempObject(TypeName[Leaf], 0, player[currentPlayer].xpos, player[currentPlayer].ypos)
42
43
Rand(temp2, 16)
44
temp2 -= 8
45
temp2 <<= 16
46
object[tempObjectPos].xpos += temp2
47
48
Rand(temp2, 16)
49
temp2 -= 8
50
temp2 <<= 16
51
object[tempObjectPos].ypos += temp2
52
Rand(object[tempObjectPos].frame, 2)
53
54
leaf[tempObjectPos].originPos.x = player[currentPlayer].xpos
55
leaf[tempObjectPos].originPos.y = player[currentPlayer].ypos
56
leaf[tempObjectPos].fallAngle = 2
57
leaf[tempObjectPos].angleVel = 4
58
end function
59
60
61
// ========================
62
// Events
63
// ========================
64
65
event ObjectUpdate
66
if object.spawnDelay == 0
67
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
68
BoxCollisionTest(C_TOUCH, object.entityPos, object.hitboxL, -32, object.hitboxR, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
69
if checkResult == true
70
temp0 = player[currentPlayer].xvel
71
Abs(temp0)
72
temp1 = player[currentPlayer].yvel
73
Abs(temp1)
74
temp0 |= temp1
75
76
if temp0 > 0x20000
77
object.spawnDelay = 15
78
PlaySfx(SfxName[Rustle], false)
79
CallFunction(LeafSpawner_SpawnLeaf)
80
object[tempObjectPos].xvel = -0x8000
81
object[tempObjectPos].yvel = -0x8000
82
83
CallFunction(LeafSpawner_SpawnLeaf)
84
object[tempObjectPos].xvel = 0xC000
85
object[tempObjectPos].yvel = -0x4000
86
87
CallFunction(LeafSpawner_SpawnLeaf)
88
object[tempObjectPos].xvel = -0xC000
89
object[tempObjectPos].yvel = 0x4000
90
91
CallFunction(LeafSpawner_SpawnLeaf)
92
object[tempObjectPos].xvel = 0x8000
93
object[tempObjectPos].yvel = 0x8000
94
end if
95
end if
96
next
97
else
98
object.spawnDelay--
99
end if
100
end event
101
102
103
event ObjectStartup
104
foreach (TypeName[Leaf Spawner], arrayPos0, ALL_ENTITIES)
105
object[arrayPos0].hitboxR = 32
106
object[arrayPos0].hitboxR <<= object[arrayPos0].propertyValue
107
object[arrayPos0].hitboxL = object[arrayPos0].hitboxR
108
FlipSign(object[arrayPos0].hitboxL)
109
next
110
end event
111
112
113
// ========================
114
// Editor Events
115
// ========================
116
117
event RSDKDraw
118
DrawSprite(0)
119
120
if editor.showGizmos == true
121
// Draw the object's hitbox
122
// Intentionally ignoring editor.drawingOveraly here
123
124
temp0 = 32
125
temp0 <<= object.propertyValue
126
temp0 *= 0x2
127
temp1 = temp0
128
temp1 += object.xpos
129
temp2 = object.ypos
130
temp2 -= 32
131
DrawRectOutline(temp1, temp2, temp0, 64, 255, 0, 0, 255)
132
end if
133
end event
134
135
136
event RSDKLoad
137
LoadSpriteSheet("Global/Display.gif")
138
SpriteFrame(-8, -8, 16, 16, 168, 18) // Trigger
139
140
// Goes up in powers of 2, 0 = 32, 1 = 64, 2 = 128, 3 = 256, etc
141
SetVariableAlias(ALIAS_VAR_PROPVAL, "size")
142
end event
143
144