Path: blob/master/Sonic 2/Scripts/OOZ/VPushSpring.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: V Push Spring Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.propertyValue : object.hasBall1213private alias object.value1 : object.pushOffset14private alias object.value2 : object.collisionOffset.y15private alias object.value3 : object.beingPushed1617// States18private alias 0 : VPUSHSPRING_AWAITPUSH19private alias 1 : VPUSHSPRING_PUSHING20private alias 2 : VPUSHSPRING_RELEASE21private alias 3 : VPUSHSPRING_HASBALL2223// Player Aliases24private alias object.state : player.state25private alias object.ypos : player.ypos26private alias object.yvel : player.yvel27private alias object.gravity : player.gravity28private alias object.animation : player.animation2930private alias object.value1 : player.timer31private alias object.value17 : debugMode.currentSelection32private alias object.value25 : player.gravityStrength3334// PushButton Aliases35private alias object.value0 : pushButton.pressed363738// ========================39// Function Declarations40// ========================4142reserve function VPushSpring_DebugDraw43reserve function VPushSpring_DebugSpawn444546// ========================47// Static Values48// ========================4950private value VPushSpring_startDebugID = 0515253// ========================54// Function Definitions55// ========================5657private function VPushSpring_DebugDraw58temp0 = debugMode[0].currentSelection59temp0 -= VPushSpring_startDebugID6061DrawSprite(0)62if temp0 == 163temp0 = object.ypos64temp0 -= 0x24000065DrawSpriteXY(5, object.xpos, temp0)66end if67end function686970private function VPushSpring_DebugSpawn71temp0 = debugMode[0].currentSelection72temp0 -= VPushSpring_startDebugID73CreateTempObject(TypeName[V Push Spring], 0, object.xpos, object.ypos)7475object[tempObjectPos].xpos &= 0xFFFF000076object[tempObjectPos].ypos &= 0xFFFF000077if temp0 == 178object[tempObjectPos].state = VPUSHSPRING_HASBALL79object[tempObjectPos].pushOffset = 0x12000080end if81end function828384// ========================85// Events86// ========================8788event ObjectUpdate89temp0 = object.pushOffset90temp0 >>= 1691temp0 -= 2092switch object.state93case VPUSHSPRING_AWAITPUSH94object.collisionOffset.y = 095if object.beingPushed == true96object.state = VPUSHSPRING_PUSHING97end if98break99100case VPUSHSPRING_PUSHING101if object.pushOffset < 0x120000102object.pushOffset += 0x20000103object.collisionOffset.y = 0x20000104else105object.state = VPUSHSPRING_RELEASE106object.collisionOffset.y = 0107end if108break109110case VPUSHSPRING_RELEASE111if object.pushOffset > 0112object.pushOffset -= 0x20000113object.collisionOffset.y = -0x20000114else115object.state = VPUSHSPRING_AWAITPUSH116object.collisionOffset.y = 0117end if118break119120case VPUSHSPRING_HASBALL121if pushButton[+1].pressed == true122if object.hasBall == false123object.state = VPUSHSPRING_RELEASE124end if125126PlaySfx(SfxName[Spring], false)127temp1 = object.pushOffset128temp1 += object.ypos129temp1 -= 0x240000130CreateTempObject(TypeName[Checkered Ball], 0, object.xpos, temp1)131object[tempObjectPos].yvel = -0x60000132object[tempObjectPos].gravity = GRAVITY_AIR133end if134break135136end switch137138object.beingPushed = false139foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)140BoxCollisionTest(C_SOLID, object.entityPos, -16, temp0, 16, 20, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)141if checkResult == COL_TOP142object.beingPushed |= true143player[currentPlayer].ypos += object.collisionOffset.y144if object.state == VPUSHSPRING_RELEASE145if object.pushOffset == 0x120000146#platform: USE_STANDALONE147player[currentPlayer].state = Player_State_Air148#endplatform149#platform: USE_ORIGINS150player[currentPlayer].state = Player_State_Air_NoDropDash151#endplatform152player[currentPlayer].animation = ANI_BOUNCING153player[currentPlayer].gravity = GRAVITY_AIR154player[currentPlayer].yvel = -0xA0000155player[currentPlayer].yvel -= player[currentPlayer].gravityStrength156player[currentPlayer].timer = 0157PlaySfx(SfxName[Spring], false)158end if159end if160end if161next162end event163164165event ObjectDraw166if object.pushOffset == 0167DrawSprite(0)168169temp0 = object.ypos170temp0 -= 0x240000171if object.state == VPUSHSPRING_HASBALL172temp0 -= 16 // 16? That's it? This is a 16.16 fixed point position, just "16" alone won't do much...173DrawSpriteXY(5, object.xpos, temp0)174end if175else176temp0 = object.pushOffset177temp0 += object.ypos178DrawSpriteXY(1, object.xpos, temp0)179180if object.state == VPUSHSPRING_HASBALL181temp0 -= 0x240000182DrawSpriteXY(5, object.xpos, temp0)183184object.inkEffect = INK_ADD185object.alpha = 0xA0186DrawSpriteFX(6, FX_INK, object.xpos, temp0)187end if188189temp0 = object.pushOffset190temp0 *= 2191temp0 /= 3192temp0 += object.ypos193DrawSpriteXY(2, object.xpos, temp0)194195temp0 = object.pushOffset196temp0 /= 3197temp0 += object.ypos198DrawSpriteXY(3, object.xpos, temp0)199200DrawSprite(4)201end if202end event203204205event ObjectStartup206LoadSpriteSheet("OOZ/Objects.gif")207SpriteFrame(-16, -20, 32, 40, 239, 140)208SpriteFrame(-16, -20, 32, 16, 239, 140)209SpriteFrame(-16, -4, 32, 8, 239, 156)210SpriteFrame(-16, 4, 32, 8, 239, 164)211SpriteFrame(-16, 12, 32, 8, 239, 172)212SpriteFrame(-16, -16, 32, 32, 429, 190)213SpriteFrame(-16, -16, 32, 32, 396, 190)214215temp0 = 0216VPushSpring_startDebugID = DebugMode_ObjCount217while temp0 < 2218SetTableValue(TypeName[V Push Spring], DebugMode_ObjCount, DebugMode_TypesTable)219SetTableValue(VPushSpring_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)220SetTableValue(VPushSpring_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)221DebugMode_ObjCount++222temp0++223loop224225foreach (TypeName[V Push Spring], arrayPos0, ALL_ENTITIES)226if object[arrayPos0].hasBall == true227object[arrayPos0].state = VPUSHSPRING_HASBALL228object[arrayPos0].pushOffset = 0x120000229end if230next231end event232233234// ========================235// Editor Events236// ========================237238event RSDKEdit239if editor.returnVariable == true240switch editor.variableID241case EDIT_VAR_PROPVAL // property value242checkResult = object.propertyValue243break244245case 0 // hasBall246checkResult = object.propertyValue247checkResult &= 1248break249250end switch251else252switch editor.variableID253case EDIT_VAR_PROPVAL // property value254object.propertyValue = editor.variableValue255break256257case 0 // hasBall258editor.variableValue &= 1259object.propertyValue = editor.variableValue260break261262end switch263end if264end event265266267event RSDKDraw268DrawSprite(0)269270temp0 = object.ypos271temp0 -= 0x240000272if object.hasBall == true273DrawSpriteXY(5, object.xpos, temp0)274end if275end event276277278event RSDKLoad279LoadSpriteSheet("OOZ/Objects.gif")280SpriteFrame(-16, -20, 32, 40, 239, 140)281SpriteFrame(-16, -20, 32, 16, 239, 140)282SpriteFrame(-16, -4, 32, 8, 239, 156)283SpriteFrame(-16, 4, 32, 8, 239, 164)284SpriteFrame(-16, 12, 32, 8, 239, 172)285SpriteFrame(-16, -16, 32, 32, 429, 190)286SpriteFrame(-16, -16, 32, 32, 396, 190)287288AddEditorVariable("hasBall")289SetActiveVariable("hasBall")290AddEnumVariable("false", false)291AddEnumVariable("true", true)292end event293294295