Path: blob/master/Sonic 1/Scripts/Global/YellowSpring.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Yellow Spring Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer12private alias object.value1 : object.isPlatform13private alias object.value2 : object.extraVelocity14// [a whole lot of skipped values]15private alias object.value7 : object.enabledInAir1617// Player aliases18private alias object.state : player.state19private alias object.direction : player.direction20private alias object.xvel : player.xvel21private alias object.yvel : player.yvel22private alias object.speed : player.speed23private alias object.angle : player.angle24private alias object.controlLock : player.controlLock25private alias object.pushing : player.pushing26private alias object.animation : player.animation27private alias object.animationSpeed : player.animationSpeed28private alias object.gravity : player.gravity29private alias object.collisionMode : player.collisionMode30private alias object.tileCollisions : player.tileCollisions31private alias object.value1 : player.timer32private alias object.value10 : player.animationReserve // Used by springs to store what animation will play after the bounce animation33private alias object.value17 : debugMode.currentSelection3435// ========================36// Function Declarations37// ========================3839reserve function YellowSpring_DebugDraw40reserve function YellowSpring_DebugSpawn414243// ========================44// Static Values45// ========================4647private value YellowSpring_startDebugID = 0484950// ========================51// Function Definitions52// ========================5354private function YellowSpring_DebugDraw55temp0 = debugMode[0].currentSelection56temp0 -= YellowSpring_startDebugID57DrawSprite(temp0)58temp0 += 459DrawSprite(temp0)60end function616263private function YellowSpring_DebugSpawn64temp0 = debugMode[0].currentSelection65temp0 -= YellowSpring_startDebugID66CreateTempObject(TypeName[Yellow Spring], temp0, object.xpos, object.ypos)67end function686970// ========================71// Events72// ========================7374event ObjectUpdate75foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)76switch object.propertyValue77case 0 // Up78temp0 = object.isPlatform79if player[currentPlayer].gravity == GRAVITY_AIR80temp0 = true81end if8283if player[currentPlayer].collisionMode > CMODE_FLOOR84if player[currentPlayer].yvel < 085temp0 = true86end if87end if8889if temp0 == false90BoxCollisionTest(C_SOLID, object.entityPos, -14, -8, 14, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)9192BoxCollisionTest(C_TOUCH, object.entityPos, -14, -10, 14, -6, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)93if checkResult == true94player[currentPlayer].animationReserve = ANI_WALKING95if player[currentPlayer].animation == ANI_RUNNING96player[currentPlayer].animationReserve = ANI_RUNNING97end if9899if player[currentPlayer].animation == ANI_PEELOUT100player[currentPlayer].animationReserve = ANI_PEELOUT101end if102103object.timer = 1104#platform: USE_STANDALONE105player[currentPlayer].state = Player_State_Air106#endplatform107#platform: USE_ORIGINS108player[currentPlayer].state = Player_State_Air_NoDropDash109#endplatform110player[currentPlayer].tileCollisions = true111player[currentPlayer].gravity = GRAVITY_AIR112player[currentPlayer].speed = player[currentPlayer].xvel113player[currentPlayer].yvel = -0xA0000114player[currentPlayer].yvel += object.extraVelocity115player[currentPlayer].animation = ANI_BOUNCING116player[currentPlayer].timer = 0117PlaySfx(SfxName[Spring], false)118end if119else120if player[currentPlayer].yvel >= 0121BoxCollisionTest(C_PLATFORM, object.entityPos, -14, -8, 14, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)122123BoxCollisionTest(C_TOUCH, object.entityPos, -14, -10, 14, -6, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)124if checkResult == true125player[currentPlayer].animationReserve = ANI_WALKING126if player[currentPlayer].animation == ANI_RUNNING127player[currentPlayer].animationReserve = ANI_RUNNING128end if129if player[currentPlayer].animation == ANI_PEELOUT130player[currentPlayer].animationReserve = ANI_PEELOUT131end if132133object.timer = 1134#platform: USE_STANDALONE135player[currentPlayer].state = Player_State_Air136#endplatform137#platform: USE_ORIGINS138player[currentPlayer].state = Player_State_Air_NoDropDash139#endplatform140player[currentPlayer].tileCollisions = true141player[currentPlayer].gravity = GRAVITY_AIR142player[currentPlayer].speed = player[currentPlayer].xvel143player[currentPlayer].yvel = -0xA0000144player[currentPlayer].yvel += object.extraVelocity145player[currentPlayer].animation = ANI_BOUNCING146player[currentPlayer].timer = 0147PlaySfx(SfxName[Spring], false)148end if149end if150end if151break152153case 1 // Right154BoxCollisionTest(C_SOLID, object.entityPos, -8, -14, 8, 14, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)155if player[currentPlayer].gravity == GRAVITY_GROUND156BoxCollisionTest(C_TOUCH, object.entityPos, 6, -14, 10, 14, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)157if checkResult == true158object.timer = 1159player[currentPlayer].tileCollisions = true160player[currentPlayer].speed = 0xA0000161player[currentPlayer].collisionMode = CMODE_FLOOR162player[currentPlayer].pushing = 0163player[currentPlayer].direction = FACING_RIGHT164player[currentPlayer].controlLock = 15165PlaySfx(SfxName[Spring], false)166167if player[currentPlayer].state != Player_State_Roll168player[currentPlayer].state = Player_State_Ground169player[currentPlayer].animation = ANI_RUNNING170end if171end if172else173if object.enabledInAir == true174BoxCollisionTest(C_TOUCH, object.entityPos, 6, -4, 11, 4, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)175if checkResult == true176object.timer = 1177player[currentPlayer].tileCollisions = true178player[currentPlayer].speed = 0xA0000179player[currentPlayer].yvel = 0180player[currentPlayer].collisionMode = CMODE_FLOOR181player[currentPlayer].pushing = 0182player[currentPlayer].direction = FACING_RIGHT183player[currentPlayer].controlLock = 15184PlaySfx(SfxName[Spring], false)185186if player[currentPlayer].state != Player_State_RollJump187player[currentPlayer].animation = ANI_BOUNCING188if player[currentPlayer].animation != ANI_JUMPING189player[currentPlayer].animation = ANI_RUNNING190end if191192object.animationSpeed = object.speed193player[currentPlayer].animationSpeed *= 80194player[currentPlayer].animationSpeed /= 0x60000195end if196end if197end if198end if199break200201case 2 // Left202BoxCollisionTest(C_SOLID, object.entityPos, -8, -14, 8, 14, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)203if player[currentPlayer].gravity == GRAVITY_GROUND204BoxCollisionTest(C_TOUCH, object.entityPos, -10, -14, -6, 14, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)205if checkResult == true206object.timer = 1207player[currentPlayer].tileCollisions = true208player[currentPlayer].speed = -0xA0000209player[currentPlayer].collisionMode = CMODE_FLOOR210player[currentPlayer].pushing = 0211player[currentPlayer].direction = FACING_LEFT212player[currentPlayer].controlLock = 15213PlaySfx(SfxName[Spring], false)214if player[currentPlayer].state != Player_State_Roll215player[currentPlayer].state = Player_State_Ground216player[currentPlayer].animation = ANI_RUNNING217end if218end if219else220if object.enabledInAir == true221BoxCollisionTest(C_TOUCH, object.entityPos, -10, -14, -6, 14, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)222if checkResult == true223object.timer = 1224player[currentPlayer].tileCollisions = true225player[currentPlayer].speed = -0xA0000226player[currentPlayer].yvel = 0227player[currentPlayer].collisionMode = CMODE_FLOOR228player[currentPlayer].pushing = 0229player[currentPlayer].direction = FACING_LEFT230player[currentPlayer].controlLock = 15231PlaySfx(SfxName[Spring], false)232233if player[currentPlayer].state != Player_State_RollJump234player[currentPlayer].animation = ANI_BOUNCING235if player[currentPlayer].animation != ANI_JUMPING236player[currentPlayer].animation = ANI_RUNNING237end if238239object.animationSpeed = object.speed240FlipSign(player[currentPlayer].animationSpeed)241player[currentPlayer].animationSpeed *= 80242player[currentPlayer].animationSpeed /= 0x60000243end if244end if245end if246end if247break248249case 3 // Down250BoxCollisionTest(C_SOLID, object.entityPos, -14, -8, 14, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)251252BoxCollisionTest(C_TOUCH, object.entityPos, -14, 6, 14, 10, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)253if checkResult == true254object.timer = 1255if player[currentPlayer].collisionMode == CMODE_ROOF256FlipSign(player[currentPlayer].speed)257FlipSign(player[currentPlayer].xvel)258end if259260#platform: USE_STANDALONE261player[currentPlayer].state = Player_State_Air262#endplatform263#platform: USE_ORIGINS264player[currentPlayer].state = Player_State_Air_NoDropDash265#endplatform266player[currentPlayer].tileCollisions = true267player[currentPlayer].gravity = GRAVITY_AIR268player[currentPlayer].speed = player[currentPlayer].xvel269player[currentPlayer].yvel = 0xA0000270player[currentPlayer].timer = 0271PlaySfx(SfxName[Spring], false)272end if273break274275end switch276next277end event278279280event ObjectDraw281if object.timer == 0282temp1 = object.propertyValue283DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)284285temp1 += 4286DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)287else288switch object.timer289case 2290case 3291temp1 = object.propertyValue292DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)293temp1 += 4294DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)295break296297case 1298temp1 = object.propertyValue299temp1 += 8300DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)301break302303case 4304case 5305case 6306case 7307case 8308case 9309temp1 = object.propertyValue310temp1 += 12311DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)312temp1 += 4313DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)314break315316end switch317318object.timer++319if object.timer >= 10320object.timer = 0321end if322end if323end event324325326event ObjectStartup327LoadSpriteSheet("Global/Items.gif")328329SpriteFrame(-16, 0, 32, 8, 84, 9)330SpriteFrame(-8, -16, 8, 32, 141, 26)331SpriteFrame(0, -16, 8, 32, 141, 59)332SpriteFrame(-16, -8, 32, 8, 150, 101)333334SpriteFrame(-16, -8, 32, 8, 84, 18)335SpriteFrame(0, -16, 8, 32, 133, 26)336SpriteFrame(-8, -16, 8, 32, 149, 59)337SpriteFrame(-16, 0, 32, 8, 150, 92)338339SpriteFrame(-16, 0, 32, 8, 84, 18)340SpriteFrame(-8, -16, 8, 32, 133, 26)341SpriteFrame(0, -16, 8, 32, 149, 59)342SpriteFrame(-16, -8, 32, 8, 150, 92)343344SpriteFrame(-16, -16, 32, 24, 117, 1)345SpriteFrame(-8, -16, 24, 32, 158, 26)346SpriteFrame(-16, -16, 24, 32, 158, 59)347SpriteFrame(-16, -8, 32, 24, 150, 1)348349SpriteFrame(-16, -24, 32, 8, 84, 18)350SpriteFrame(16, -16, 8, 32, 133, 26)351SpriteFrame(-24, -16, 8, 32, 149, 59)352SpriteFrame(-16, 16, 32, 8, 150, 92)353354foreach (TypeName[Yellow Spring], arrayPos0, ALL_ENTITIES)355// for when you need some extra spring in your step356if object[arrayPos0].propertyValue == 5357object[arrayPos0].propertyValue = 0358object[arrayPos0].extraVelocity = -0x4000359end if360next361362temp0 = 0363YellowSpring_startDebugID = DebugMode_ObjCount364while temp0 < 4365SetTableValue(TypeName[Yellow Spring], DebugMode_ObjCount, DebugMode_TypesTable)366SetTableValue(YellowSpring_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)367SetTableValue(YellowSpring_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)368DebugMode_ObjCount++369temp0++370loop371end event372373374// ========================375// Editor Events376// ========================377378event RSDKEdit379if editor.returnVariable == true380switch editor.variableID381case EDIT_VAR_PROPVAL // property value382checkResult = object.propertyValue383break384385case 0 // flipFlags386checkResult = object.propertyValue387break388389end switch390else391switch editor.variableID392case EDIT_VAR_PROPVAL // property value393object.propertyValue = editor.variableValue394break395396case 0 // flipFlags397object.propertyValue = editor.variableValue398break399400end switch401end if402end event403404405event RSDKDraw406temp1 = object.propertyValue407if temp1 == 5408temp1 = 0409end if410411DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)412temp1 += 4413DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)414end event415416417event RSDKLoad418LoadSpriteSheet("Global/Items.gif")419SpriteFrame(-16, 0, 32, 8, 84, 9)420SpriteFrame(-8, -16, 8, 32, 141, 26)421SpriteFrame(0, -16, 8, 32, 141, 59)422SpriteFrame(-16, -8, 32, 8, 150, 101)423424SpriteFrame(-16, -8, 32, 8, 84, 18)425SpriteFrame(0, -16, 8, 32, 133, 26)426SpriteFrame(-8, -16, 8, 32, 149, 59)427SpriteFrame(-16, 0, 32, 8, 150, 92)428429SpriteFrame(-16, 0, 32, 8, 84, 18)430SpriteFrame(-8, -16, 8, 32, 133, 26)431SpriteFrame(0, -16, 8, 32, 149, 59)432SpriteFrame(-16, -8, 32, 8, 150, 92)433434SpriteFrame(-16, -16, 32, 24, 117, 1)435SpriteFrame(-8, -16, 24, 32, 158, 26)436SpriteFrame(-16, -16, 24, 32, 158, 59)437SpriteFrame(-16, -8, 32, 24, 150, 1)438439SpriteFrame(-16, -24, 32, 8, 84, 18)440SpriteFrame(16, -16, 8, 32, 133, 26)441SpriteFrame(-24, -16, 8, 32, 149, 59)442SpriteFrame(-16, 16, 32, 8, 150, 92)443444AddEditorVariable("flipFlag")445SetActiveVariable("flipFlag")446AddEnumVariable("Up", 0)447AddEnumVariable("Right", 1)448AddEnumVariable("Left", 2)449AddEnumVariable("Down", 3)450AddEnumVariable("Up (Slightly Stronger)", 5)451452SetVariableAlias(ALIAS_VAR_VAL1, "isPlatform")453SetVariableAlias(ALIAS_VAR_VAL2, "extraVelocity")454end event455456457