Path: blob/master/Sonic 2/Scripts/CNZ/TubeSwitch.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Tube Switch Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// This object seems to be unused, but it's just a basic roll object that doesn't really do all that much89// ========================10// Aliases11// ========================1213private alias object.value0 : object.inTube // I dont really know what the point of this variable is but alright I guess1415private alias 0 : TUBESWITCH_R_ENTRY16private alias 1 : TUBESWITCH_L_ENTRY1718// Player Aliases19private alias object.state : player.state20private alias object.speed : player.speed21private alias object.xvel : player.xvel22private alias object.yvel : player.yvel23private alias object.gravity : player.gravity24private alias object.direction : player.direction25private alias object.animation : player.animation26private alias object.value34 : player.collisionDisabled272829// ========================30// Events31// ========================3233event ObjectUpdate34foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)35if player[currentPlayer].collisionDisabled == true36player[currentPlayer].collisionDisabled = false37end if3839CheckEqual(player[currentPlayer].state, Player_State_Death)40temp0 = checkResult41CheckEqual(player[currentPlayer].state, Player_State_LedgePullUp)42temp0 |= checkResult43CheckEqual(player[currentPlayer].state, Player_State_Climb)44temp0 |= checkResult45if temp0 == false46BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)47if checkResult == true48if player[currentPlayer].yvel < 049player[currentPlayer].yvel = 050end if5152switch object.propertyValue53case TUBESWITCH_R_ENTRY // Enter from the right, exit from the left54if player[currentPlayer].xvel > 055if player[currentPlayer].animation != ANI_JUMPING56if player[currentPlayer].state != Player_State_TubeRoll57PlaySfx(SfxName[Rolling], false)58end if59end if6061if player[currentPlayer].state == Player_State_GlideLeft62FlipSign(player[currentPlayer].speed)63end if6465player[currentPlayer].direction = FACING_RIGHT66player[currentPlayer].state = Player_State_TubeRoll67player[currentPlayer].animation = ANI_JUMPING68else69if player[currentPlayer].gravity == GRAVITY_GROUND70if player[currentPlayer].xvel > -0x2000071player[currentPlayer].speed = -0x2000072end if73end if7475player[currentPlayer].state = Player_State_Roll76player[currentPlayer].animation = ANI_JUMPING77end if78break7980case TUBESWITCH_L_ENTRY // Enter from the left, exit from the right81if player[currentPlayer].xvel < 082if player[currentPlayer].animation != ANI_JUMPING83if player[currentPlayer].state != Player_State_TubeRoll84PlaySfx(SfxName[Rolling], false)85end if86end if8788if player[currentPlayer].state == Player_State_GlideLeft89FlipSign(player[currentPlayer].speed)90end if9192player[currentPlayer].direction = FACING_LEFT93player[currentPlayer].state = Player_State_TubeRoll94player[currentPlayer].animation = ANI_JUMPING95else96if player[currentPlayer].gravity == GRAVITY_GROUND97if player[currentPlayer].xvel < 0x2000098player[currentPlayer].speed = 0x2000099end if100end if101102player[currentPlayer].state = Player_State_Roll103player[currentPlayer].animation = ANI_JUMPING104end if105break106end switch107108object.inTube = true109else110object.inTube = false111end if112end if113next114end event115116117// ========================118// Editor Events119// ========================120121event RSDKEdit122if editor.returnVariable == true123switch editor.variableID124case EDIT_VAR_PROPVAL // property value125checkResult = object.propertyValue126break127128case 0 // type129checkResult = object.propertyValue130break131132end switch133else134switch editor.variableID135case EDIT_VAR_PROPVAL // property value136object.propertyValue = editor.variableValue137break138139case 0 // type140object.propertyValue = editor.variableValue141break142143end switch144end if145end event146147148event RSDKDraw149temp0 = object.xpos150temp0 -= 0x80000151temp1 = object.ypos152temp1 -= 0x80000153154DrawSpriteXY(0, temp0, temp1)155156temp0 += 0x100000157DrawSpriteXY(0, temp0, temp1)158159temp1 += 0x100000160DrawSpriteXY(0, temp0, temp1)161162temp0 -= 0x100000163DrawSpriteXY(0, temp0, temp1)164end event165166167event RSDKLoad168LoadSpriteSheet("Global/Display.gif")169SpriteFrame(-8, -8, 16, 16, 168, 18) // "T" (ubeSwitch) - #0170171AddEditorVariable("type")172SetActiveVariable("type")173AddEnumVariable("Enter From Left, Exit From Right", 0)174AddEnumVariable("Enter From Right, Exit From Left", 1)175end event176177178