Path: blob/master/Sonic 2/Scripts/ARZ/LeafSpawner.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Leaf Spawner Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.spawnDelay12private alias object.value1 : object.hitboxR13private alias object.value2 : object.hitboxL1415// Leaf Aliases16private alias object.value1 : leaf.originPos.x17private alias object.value2 : leaf.originPos.y18private alias object.value3 : leaf.fallAngle19private alias object.value4 : leaf.angleVel2021// Player Aliases22private alias object.xpos : player.xpos23private alias object.ypos : player.ypos24private alias object.xvel : player.xvel25private alias object.yvel : player.yvel262728// ========================29// Function Declarations30// ========================3132reserve function LeafSpawner_SpawnLeaf333435// ========================36// Function Definitions37// ========================3839private function LeafSpawner_SpawnLeaf40CreateTempObject(TypeName[Leaf], 0, player[currentPlayer].xpos, player[currentPlayer].ypos)4142Rand(temp2, 16)43temp2 -= 844temp2 <<= 1645object[tempObjectPos].xpos += temp24647Rand(temp2, 16)48temp2 -= 849temp2 <<= 1650object[tempObjectPos].ypos += temp251Rand(object[tempObjectPos].frame, 2)5253leaf[tempObjectPos].originPos.x = player[currentPlayer].xpos54leaf[tempObjectPos].originPos.y = player[currentPlayer].ypos55leaf[tempObjectPos].fallAngle = 256leaf[tempObjectPos].angleVel = 457end function585960// ========================61// Events62// ========================6364event ObjectUpdate65if object.spawnDelay == 066foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)67BoxCollisionTest(C_TOUCH, object.entityPos, object.hitboxL, -32, object.hitboxR, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)68if checkResult == true69temp0 = player[currentPlayer].xvel70Abs(temp0)71temp1 = player[currentPlayer].yvel72Abs(temp1)73temp0 |= temp17475if temp0 > 0x2000076object.spawnDelay = 1577PlaySfx(SfxName[Rustle], false)78CallFunction(LeafSpawner_SpawnLeaf)79object[tempObjectPos].xvel = -0x800080object[tempObjectPos].yvel = -0x80008182CallFunction(LeafSpawner_SpawnLeaf)83object[tempObjectPos].xvel = 0xC00084object[tempObjectPos].yvel = -0x40008586CallFunction(LeafSpawner_SpawnLeaf)87object[tempObjectPos].xvel = -0xC00088object[tempObjectPos].yvel = 0x40008990CallFunction(LeafSpawner_SpawnLeaf)91object[tempObjectPos].xvel = 0x800092object[tempObjectPos].yvel = 0x800093end if94end if95next96else97object.spawnDelay--98end if99end event100101102event ObjectStartup103foreach (TypeName[Leaf Spawner], arrayPos0, ALL_ENTITIES)104object[arrayPos0].hitboxR = 32105object[arrayPos0].hitboxR <<= object[arrayPos0].propertyValue106object[arrayPos0].hitboxL = object[arrayPos0].hitboxR107FlipSign(object[arrayPos0].hitboxL)108next109end event110111112// ========================113// Editor Events114// ========================115116event RSDKDraw117DrawSprite(0)118119if editor.showGizmos == true120// Draw the object's hitbox121// Intentionally ignoring editor.drawingOveraly here122123temp0 = 32124temp0 <<= object.propertyValue125temp0 *= 0x2126temp1 = temp0127temp1 += object.xpos128temp2 = object.ypos129temp2 -= 32130DrawRectOutline(temp1, temp2, temp0, 64, 255, 0, 0, 255)131end if132end event133134135event RSDKLoad136LoadSpriteSheet("Global/Display.gif")137SpriteFrame(-8, -8, 16, 16, 168, 18) // Trigger138139// Goes up in powers of 2, 0 = 32, 1 = 64, 2 = 128, 3 = 256, etc140SetVariableAlias(ALIAS_VAR_PROPVAL, "size")141end event142143144