Path: blob/master/Sonic 2/Scripts/CPZ/SpeedBooster.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Speed Booster Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.boostSpeed12private alias object.value1 : object.timer1314// Player Aliases15private alias object.state : player.state16private alias object.speed : player.speed17private alias object.direction : player.direction18private alias object.gravity : player.gravity19private alias object.animation : player.animation20private alias object.controlLock : player.controlLock2122private alias object.value1 : player.timer23private alias object.value14 : player.skidding24private alias object.value17 : debugMode.currentSelection252627// ========================28// Function Declarations29// ========================3031reserve function SpeedBooster_DebugDraw32reserve function SpeedBooster_DebugSpawn333435// ========================36// Static Values37// ========================3839private value SpeedBooster_startDebugID = 0404142// ========================43// Function Definitions44// ========================4546private function SpeedBooster_DebugDraw47DrawSprite(0)48end function495051private function SpeedBooster_DebugSpawn52CreateTempObject(TypeName[Speed Booster], 0, object.xpos, object.ypos)5354GetBit(temp0, object.direction, 0)55if temp0 == FLIP_NONE56object[tempObjectPos].direction = FLIP_NONE57else58object[tempObjectPos].direction = FLIP_X59end if6061temp0 = debugMode[0].currentSelection62temp0 -= SpeedBooster_startDebugID63if temp0 == 064object[tempObjectPos].boostSpeed = 0x10000065else66object[tempObjectPos].boostSpeed = 0x0A000067end if6869object[tempObjectPos].drawOrder = 570end function717273// ========================74// Events75// ========================7677event ObjectUpdate78if object.timer != 079object.timer--80end if8182foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)83BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, 0, 0, 0, 0)84if checkResult == true85if player[currentPlayer].gravity == GRAVITY_GROUND86if object.timer == 087object.timer = 288PlaySfx(SfxName[Spring], false)89end if9091temp1 = false92temp0 = object.boostSpeed93if object.direction == FLIP_X94FlipSign(object.boostSpeed)95if player[currentPlayer].speed > temp096temp1 = true97end if98else99if player[currentPlayer].speed < temp0100temp1 = true101end if102end if103104if temp1 == true105player[currentPlayer].state = Player_State_Ground106if player[currentPlayer].animation != ANI_JUMPING107if player[currentPlayer].animation != ANI_RUNNING108player[currentPlayer].animation = ANI_WALKING109end if110end if111112player[currentPlayer].timer = 0113player[currentPlayer].controlLock = 0114player[currentPlayer].skidding = 0115player[currentPlayer].controlLock = 15116player[currentPlayer].speed = object.boostSpeed117player[currentPlayer].direction = object.direction118if object.direction == FLIP_X119FlipSign(player[currentPlayer].speed)120end if121end if122end if123end if124next125end event126127128event ObjectDraw129GetBit(temp0, oscillation, 1)130if temp0 == false131DrawSprite(0)132end if133end event134135136event ObjectStartup137// Note - the majority of the speed booster sprite is built into the level tiles itself138// All that's drawn here is the overlay spinning frame, and even then, it's only drawn sometimes139140CheckCurrentStageFolder("Zone02")141if checkResult == true142LoadSpriteSheet("CPZ/Objects.gif")143SpriteFrame(-24, -8, 48, 16, 91, 25)144else145LoadSpriteSheet("MBZ/Objects.gif")146SpriteFrame(-24, -8, 48, 16, 474, 321)147end if148149foreach (TypeName[Speed Booster], arrayPos0, ALL_ENTITIES)150if object[arrayPos0].propertyValue == 0151object[arrayPos0].boostSpeed = 0x100000152else153object[arrayPos0].boostSpeed = 0x0A0000154end if155156object[arrayPos0].drawOrder = 5157next158159temp0 = 0160SpeedBooster_startDebugID = DebugMode_ObjCount161while temp0 < 2162SetTableValue(TypeName[Speed Booster], DebugMode_ObjCount, DebugMode_TypesTable)163SetTableValue(SpeedBooster_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)164SetTableValue(SpeedBooster_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)165DebugMode_ObjCount++166temp0++167loop168end event169170171// ========================172// Editor Events173// ========================174175event RSDKEdit176if editor.returnVariable == true177switch editor.variableID178case EDIT_VAR_PROPVAL // property value179checkResult = object.propertyValue180break181182case 0 // boostSpeed183GetBit(checkResult, object.propertyValue, 0)184break185186end switch187else188switch editor.variableID189case EDIT_VAR_PROPVAL // property value190object.propertyValue = editor.variableValue191break192193case 0 // boostSpeed194CheckNotEqual(editor.variableValue, 0)195SetBit(object.propertyValue, 0, checkResult)196break197198end switch199end if200end event201202203event RSDKDraw204DrawSprite(0)205end event206207208event RSDKLoad209CheckCurrentStageFolder("Zone02")210if checkResult == true211LoadSpriteSheet("CPZ/Objects.gif")212SpriteFrame(-24, -8, 48, 16, 91, 25)213else214LoadSpriteSheet("MBZ/Objects.gif")215SpriteFrame(-24, -8, 48, 16, 474, 321)216end if217218AddEditorVariable("boostSpeed")219SetActiveVariable("boostSpeed")220AddEnumVariable("Faster", 0)221AddEnumVariable("Slower", 1)222end event223224225