Path: blob/master/Sonic 2/Scripts/MBZ/TubePath.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Tube Path Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value1 : object.targetPlayer12private alias object.value2 : object.nextNode1314private alias 0 : TUBEPATH_ENTRY15private alias 1 : TUBEPATH_EXIT16private alias 2 : TUBEPATH_CONTROL1718// Player Aliases19private alias object.state : player.state20private alias object.xpos : player.xpos21private alias object.ypos : player.ypos22private alias object.xvel : player.xvel23private alias object.yvel : player.yvel24private alias object.speed : player.speed25private alias object.gravity : player.gravity26private alias object.animation : player.animation27private alias object.tileCollisions : player.tileCollisions282930// ========================31// Events32// ========================3334event ObjectUpdate35switch object.propertyValue36case TUBEPATH_ENTRY37foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)38if player[currentPlayer].state != Player_State_Static39BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)40if checkResult == true41player[currentPlayer].xpos = object.xpos42player[currentPlayer].state = Player_State_Static43player[currentPlayer].tileCollisions = 044if player[currentPlayer].animation != ANI_JUMPING45PlaySfx(SfxName[Rolling], false)46player[currentPlayer].animation = ANI_JUMPING47end if48CreateTempObject(TypeName[Tube Path], TUBEPATH_CONTROL, object.xpos, object.ypos)49object[tempObjectPos].targetPlayer = currentPlayer50object[tempObjectPos].nextNode = object.entityPos51object[tempObjectPos].nextNode++52end if53end if54next55break5657case TUBEPATH_EXIT58foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)59if player[currentPlayer].state == Player_State_Static60BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, 0, 0, 0, 0)61if checkResult == true62#platform: USE_STANDALONE63player[currentPlayer].state = Player_State_Air64#endplatform65#platform: USE_ORIGINS66player[currentPlayer].state = Player_State_Air_NoDropDash67#endplatform68player[currentPlayer].gravity = GRAVITY_AIR69player[currentPlayer].xpos = object.xpos70player[currentPlayer].ypos = object.ypos71player[currentPlayer].yvel = -0xA000072player[currentPlayer].speed = 073player[currentPlayer].xvel = 074player[currentPlayer].tileCollisions = true75PlaySfx(SfxName[Release], false)76end if77end if78next79break8081case TUBEPATH_CONTROL82currentPlayer = object.targetPlayer83if player[currentPlayer].state == Player_State_Static84arrayPos0 = object.nextNode8586temp0 = player[currentPlayer].xpos87temp0 -= object[arrayPos0].xpos88temp0 >>= 168990temp1 = player[currentPlayer].ypos91temp1 -= object[arrayPos0].ypos92temp1 >>= 1693ATan2(temp2, temp0, temp1)9495Cos256(player[currentPlayer].xvel, temp2)96Sin256(player[currentPlayer].yvel, temp2)97player[currentPlayer].xvel *= -0xC0098player[currentPlayer].yvel *= -0xC0099temp2 = player[currentPlayer].xvel100Abs(temp2)101temp3 = player[currentPlayer].yvel102Abs(temp3)103104if temp2 > temp3105player[currentPlayer].yvel = 0106else107player[currentPlayer].xvel = 0108end if109110if object[arrayPos0].type == TypeName[Blank Object]111temp2 = temp0112temp2 *= temp0113temp0 = temp1114temp0 *= temp1115temp0 += temp2116if temp0 < 256117player[currentPlayer].xpos = object[arrayPos0].xpos118player[currentPlayer].ypos = object[arrayPos0].ypos119player[currentPlayer].xvel = 0120player[currentPlayer].yvel = 0121object.nextNode++122end if123end if124else125object.type = TypeName[Blank Object]126end if127break128129end switch130end event131132133// ========================134// Editor Events135// ========================136137event RSDKEdit138if editor.returnVariable == true139switch editor.variableID140case EDIT_VAR_PROPVAL // property value141checkResult = object.propertyValue142checkResult &= 1143break144145case 0 // isExit146checkResult = object.propertyValue147checkResult &= 1148break149150end switch151else152switch editor.variableID153case EDIT_VAR_PROPVAL // property value154object.propertyValue = editor.variableValue155object.propertyValue &= 1156break157158case 0 // isExit159object.propertyValue = editor.variableValue160object.propertyValue &= 1161break162163end switch164end if165end event166167168event RSDKDraw169DrawSprite(0)170171if editor.showGizmos == true172editor.drawingOverlay = true173174// Draw all the nodes that make up the path175176arrayPos0 = object.entityPos177arrayPos1 = object[+1].entityPos178179while object[arrayPos1].type == 0180DrawArrow(object[arrayPos0].xpos, object[arrayPos0].ypos, object[arrayPos1].xpos, object[arrayPos1].ypos, 0xFF, 0xFF, 0x00)181arrayPos0++182arrayPos1++183loop184185// Final one;186// no checks for type to match in-game behvaiour, but it should be a Tube Path obj with a prop val of 1187DrawArrow(object[arrayPos0].xpos, object[arrayPos0].ypos, object[arrayPos1].xpos, object[arrayPos1].ypos, 0xFF, 0xFF, 0x00)188189editor.drawingOverlay = false190end if191end event192193194event RSDKLoad195LoadSpriteSheet("Global/Display.gif")196SpriteFrame(-8, -8, 16, 16, 168, 18)197198AddEditorVariable("isExit")199SetActiveVariable("isExit")200AddEnumVariable("false", false)201AddEnumVariable("true", true)202end event203204205