Path: blob/master/Sonic 1/Scripts/GHZ/TubeSwitch.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Tube Switch Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.inTube // I dont really know what the point of this variable is but alright I guess1213private alias 0 : TUBESWITCH_R_ENTRY14private alias 1 : TUBESWITCH_L_ENTRY1516// Player Aliases17private alias object.state : player.state18private alias object.speed : player.speed19private alias object.xvel : player.xvel20private alias object.yvel : player.yvel21private alias object.gravity : player.gravity22private alias object.direction : player.direction23private alias object.animation : player.animation24private alias object.value34 : player.collisionDisabled252627// ========================28// Events29// ========================3031event ObjectUpdate32foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)33if player[currentPlayer].collisionDisabled == true34player[currentPlayer].collisionDisabled = false35end if3637CheckEqual(player[currentPlayer].state, Player_State_Death)38temp0 = checkResult39CheckEqual(player[currentPlayer].state, Player_State_LedgePullUp)40temp0 |= checkResult41CheckEqual(player[currentPlayer].state, Player_State_Climb)42temp0 |= checkResult43if temp0 == 044BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)45if checkResult == true4647if player[currentPlayer].yvel < 048player[currentPlayer].yvel = 049end if5051switch object.propertyValue52case TUBESWITCH_R_ENTRY // Enter from the right, exit from the left53if player[currentPlayer].xvel > 054if player[currentPlayer].animation != ANI_JUMPING55if player[currentPlayer].state != Player_State_TubeRoll56PlaySfx(SfxName[Rolling], false)57end if58end if5960if player[currentPlayer].state == Player_State_GlideLeft61FlipSign(player[currentPlayer].speed)62end if6364player[currentPlayer].direction = FACING_RIGHT65player[currentPlayer].state = Player_State_TubeRoll66player[currentPlayer].animation = ANI_JUMPING67else68if player[currentPlayer].gravity == 069if player[currentPlayer].xvel > -0x2000070player[currentPlayer].speed = -0x2000071end if72end if7374player[currentPlayer].state = Player_State_Roll75player[currentPlayer].animation = ANI_JUMPING76end if77break7879case TUBESWITCH_L_ENTRY // Enter from the left, exit from the right80if player[currentPlayer].xvel < 081if player[currentPlayer].animation != ANI_JUMPING82if player[currentPlayer].state != Player_State_TubeRoll83PlaySfx(SfxName[Rolling], false)84end if85end if8687if player[currentPlayer].state == Player_State_GlideLeft88FlipSign(player[currentPlayer].speed)89end if9091player[currentPlayer].direction = FACING_LEFT92player[currentPlayer].state = Player_State_TubeRoll93player[currentPlayer].animation = ANI_JUMPING94else95if player[currentPlayer].gravity == 096if player[currentPlayer].xvel < 0x2000097player[currentPlayer].speed = 0x2000098end if99end if100101player[currentPlayer].state = Player_State_Roll102player[currentPlayer].animation = ANI_JUMPING103end if104break105106end 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 RSDKDraw149// object doesn't have a debug view, this is custom150151temp0 = object.xpos152temp0 -= 0x80000153temp1 = object.ypos154temp1 -= 0x80000155156DrawSpriteXY(0, temp0, temp1)157158temp0 += 0x100000159DrawSpriteXY(0, temp0, temp1)160161temp1 += 0x100000162DrawSpriteXY(0, temp0, temp1)163164temp0 -= 0x100000165DrawSpriteXY(0, temp0, temp1)166167168// editor.drawingOverlay is intentionally being skipped over here169170// draw the tubeswitch hitbox size171temp0 = 16; temp1 = 16; temp2 = 16; temp3 = 16;172CallFunction(EditorHelpers_DrawHitbox)173end event174175176event RSDKLoad177LoadSpriteSheet("Global/Display.gif")178SpriteFrame(-8, -8, 16, 16, 239, 239)179180AddEditorVariable("type")181SetActiveVariable("type")182AddEnumVariable("Enter From Right, Exit From Left", 0)183AddEnumVariable("Enter From Left, Exit From Right", 1)184end event185186187