Path: blob/master/Sonic 2/Scripts/HTZ/TubeSwitch.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// 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.active // Gets set a few times, but seems to never be used otherwise?1213private alias 0 : TUBESWITCH_L_ENTRY14private alias 1 : TUBESWITCH_R_ENTRY1516// Player Aliases17private alias object.state : player.state18private alias object.xvel : player.xvel19private alias object.yvel : player.yvel20private alias object.speed : player.speed21private alias object.direction : player.direction22private alias object.gravity : player.gravity23private alias object.animation : player.animation2425private alias object.value34 : player.collisionDisabled262728// ========================29// Events30// ========================3132event ObjectUpdate33foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)34if player[currentPlayer].collisionDisabled == true35// Player should collide with stuff while in a tube36player[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_L_ENTRY54if 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_R_ENTRY81if 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 if105break106107end switch108109object.active = true110else111object.active = false112end if113end if114next115end event116117118// ========================119// Editor Events120// ========================121122event RSDKEdit123if editor.returnVariable == true124switch editor.variableID125case EDIT_VAR_PROPVAL // property value126checkResult = object.propertyValue127break128129case 0 // type130checkResult = object.propertyValue131break132133end switch134else135switch editor.variableID136case EDIT_VAR_PROPVAL // property value137object.propertyValue = editor.variableValue138break139140case 0 // type141object.propertyValue = editor.variableValue142break143144end switch145end if146end event147148149event RSDKDraw150temp0 = object.xpos151temp0 -= 0x80000152temp1 = object.ypos153temp1 -= 0x80000154155DrawSpriteXY(0, temp0, temp1)156157temp0 += 0x100000158DrawSpriteXY(0, temp0, temp1)159160temp1 += 0x100000161DrawSpriteXY(0, temp0, temp1)162163temp0 -= 0x100000164DrawSpriteXY(0, temp0, temp1)165end event166167168event RSDKLoad169LoadSpriteSheet("Global/Display.gif")170SpriteFrame(-8, -8, 16, 16, 168, 18) // "T" (ubeSwitch) - #0171172AddEditorVariable("type")173SetActiveVariable("type")174AddEnumVariable("Enter From Left, Exit From Right", 0)175AddEnumVariable("Enter From Right, Exit From Left", 1)176end event177178179