Path: blob/master/Sonic 2/Scripts/EHZ/SpiralPath.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Spiral Path Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value1 : object.activePlayers1213// Player Aliases14private alias object.state : player.state15private alias object.xpos : player.xpos16private alias object.ypos : player.ypos17private alias object.xvel : player.xvel18private alias object.yvel : player.yvel19private alias object.speed : player.speed20private alias object.rotation : player.rotation21private alias object.angle : player.angle22private alias object.direction : player.direction23private alias object.gravity : player.gravity24private alias object.frame : player.frame25private alias object.prevAnimation : player.prevAnimation26private alias object.animationSpeed : player.animationSpeed27private alias object.animation : player.animation28private alias object.collisionBottom : player.collisionBottom29private alias object.value42 : player.prevGravity303132// ========================33// Tables34// ========================3536// Used to determine which frame the player should use when corkscrewing37private table SpiralPath_spriteTable386, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 739end table4041// Values for the small player Y Pos offset when corkscrewing42// This is just a cosine table with an amplitude of 32 - same as the original ROM - so it's not much special43private table SpiralPath_offsetTable4432, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 324532, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 314631, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 304730, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 28, 28, 28, 28, 274827, 27, 27, 26, 26, 26, 25, 25, 25, 24, 24, 24, 23, 23, 22, 224921, 21, 20, 20, 19, 18, 18, 17, 16, 16, 15, 14, 14, 13, 12, 125011, 10, 10, 9, 8, 8, 7, 6, 6, 5, 4, 4, 3, 2, 2, 1510, -1, -2, -2, -3, -4, -4, -5, -6, -7, -7, -8, -9, -9, -10, -1052-11, -11, -12, -12, -13, -14, -14, -15, -15, -16, -16, -17, -17, -18, -18, -1953-19, -19, -20, -21, -21, -22, -22, -23, -23, -24, -24, -25, -25, -26, -26, -2754-27, -28, -28, -28, -29, -29, -30, -30, -30, -31, -31, -31, -32, -32, -32, -3355-33, -33, -33, -34, -34, -34, -35, -35, -35, -35, -35, -35, -35, -35, -36, -3656-36, -36, -36, -36, -36, -36, -36, -37, -37, -37, -37, -37, -37, -37, -37, -3757-37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -3758-37, -37, -37, -37, -36, -36, -36, -36, -36, -36, -36, -35, -35, -35, -35, -3559-35, -35, -35, -34, -34, -34, -33, -33, -33, -33, -32, -32, -32, -31, -31, -3160-30, -30, -30, -29, -29, -28, -28, -28, -27, -27, -26, -26, -25, -25, -24, -2461-23, -23, -22, -22, -21, -21, -20, -19, -19, -18, -18, -17, -16, -16, -15, -1462-14, -13, -12, -11, -11, -10, -9, -8, -7, -7, -6, -5, -4, -3, -2, -1630, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 136413, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 216521, 22, 22, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 266627, 27, 27, 27, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 296729, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 316831, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 326932, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 3270end table717273// ========================74// Events75// ========================7677event ObjectUpdate78// Make this object always active, it's larger than the screen is normally so we can't depend on the normal priority system79object.priority = PRIORITY_ACTIVE8081temp2 = 082foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)83temp0 = player[currentPlayer].xpos84temp0 -= object.xpos8586GetBit(temp3, object.activePlayers, temp2)87if temp3 == false88if player[currentPlayer].prevGravity == GRAVITY_GROUND89BoxCollisionTest(C_TOUCH, object.entityPos, -192, 8, 192, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)9091if checkResult == true92SetBit(object.activePlayers, temp2, true)93player[currentPlayer].yvel = 094end if95end if96else97temp0 += 0xD0000098temp1 = player[currentPlayer].xvel99Abs(temp1)100CheckLower(temp1, 0x60000)101102temp3 = checkResult103CheckLower(player[currentPlayer].yvel, -0x40000)104temp3 |= checkResult105CheckLower(temp0, 0)106temp3 |= checkResult107CheckGreater(temp0, 0x19FFFFF)108temp3 |= checkResult109110if temp3 == true111SetBit(object.activePlayers, temp2, false)112if player[currentPlayer].prevGravity == GRAVITY_AIR113if player[currentPlayer].yvel >= 0114if player[currentPlayer].state != Player_State_Carried115if player[currentPlayer].animation != ANI_SKIDDING116player[currentPlayer].animation = ANI_TWIRL117player[currentPlayer].angle = 0118end if119end if120end if121end if122else123player[currentPlayer].yvel = 0124125temp0 >>= 16126127GetTableValue(player[currentPlayer].ypos, temp0, SpiralPath_offsetTable)128129player[currentPlayer].ypos -= player[currentPlayer].collisionBottom130player[currentPlayer].ypos += 19131player[currentPlayer].ypos <<= 16132player[currentPlayer].ypos += object.ypos133134#platform: USE_ORIGINS135if player[currentPlayer].state == Player_State_HammerDash136player[currentPlayer].state = Player_State_Ground137end if138#endplatform139140if player[currentPlayer].state == Player_State_Ground141if player[currentPlayer].gravity == GRAVITY_AIR142143// We're setting prevAnimation too because we don't want frame number to be reset144player[currentPlayer].prevAnimation = ANI_TWIRL145player[currentPlayer].animation = ANI_TWIRL146player[currentPlayer].animationSpeed = 0147player[currentPlayer].direction = FACING_RIGHT148149temp1 = object.xpos150temp1 -= 0xC40000151temp0 = player[currentPlayer].xpos152temp0 -= temp1153temp0 >>= 21154temp0 %= 12155156if player[currentPlayer].speed > 0157player[currentPlayer].frame = temp0158player[currentPlayer].rotation = 0159else160GetTableValue(player[currentPlayer].frame, temp0, SpiralPath_spriteTable)161player[currentPlayer].rotation = 256 // flipY162end if163end if164end if165166player[currentPlayer].gravity = GRAVITY_GROUND167end if168end if169170temp2++171next172173if object.outOfBounds == true174object.priority = PRIORITY_BOUNDS175176temp0 = false177foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)178// Check if any players are still on the Spiral Path179BoxCollisionTest(C_TOUCH, object.entityPos, -192, 8, 192, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)180temp0 |= checkResult181next182183if temp0 == false184// If there aren't any players on it, then reset185object.activePlayers = 0186end if187end if188end event189190191// ========================192// Editor Events193// ========================194195event RSDKDraw196DrawSprite(0)197198if editor.showGizmos == true199editor.drawingOverlay = true200201// Draw the movement path202temp0 = 0203while temp0 < 384204temp1 = temp0205temp1 -= 192206temp1 <<= 16207temp1 += object.xpos208GetTableValue(temp2, temp0, SpiralPath_offsetTable)209temp2 <<= 16210temp2 += object.ypos211212DrawRectWorld(temp1, temp2, 2, 2, 255, 255, 255, 255)213temp0++214loop215216editor.drawingOverlay = false217end if218end event219220221event RSDKLoad222LoadSpriteSheet("Global/Display.gif")223SpriteFrame(-16, -16, 32, 32, 1, 143)224225SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")226end event227228229