Path: blob/master/Sonic 2/Scripts/HPZ/TubePath.txt
1479 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_Static39if player[currentPlayer].gravity == GRAVITY_GROUND40BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)41if checkResult == true42player[currentPlayer].state = Player_State_Static43player[currentPlayer].tileCollisions = false44if player[currentPlayer].animation != ANI_JUMPING45PlaySfx(SfxName[Rolling], false)46end if4748CreateTempObject(TypeName[Tube Path], TUBEPATH_CONTROL, object.xpos, object.ypos)49object[tempObjectPos].targetPlayer = currentPlayer50object[tempObjectPos].nextNode = object.entityPos51object[tempObjectPos].nextNode++52end if53end if54end if55next56break5758case TUBEPATH_EXIT59foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)60if player[currentPlayer].state == Player_State_Static61BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, 0, 0, 0, 0)62if checkResult == true63player[currentPlayer].state = Player_State_TubeRoll64player[currentPlayer].xpos = object.xpos65player[currentPlayer].ypos = object.ypos66player[currentPlayer].yvel = 067player[currentPlayer].speed = 0xC000068player[currentPlayer].tileCollisions = true69end if70end if71next72break7374case TUBEPATH_CONTROL75currentPlayer = object.targetPlayer76if player[currentPlayer].state == Player_State_Static77// Glide the player over on to the next node7879arrayPos0 = object.nextNode8081temp0 = player[currentPlayer].xpos82temp0 -= object[arrayPos0].xpos83temp0 >>= 168485temp1 = player[currentPlayer].ypos86temp1 -= object[arrayPos0].ypos87temp1 >>= 168889ATan2(temp2, temp0, temp1)90Cos256(player[currentPlayer].xvel, temp2)91Sin256(player[currentPlayer].yvel, temp2)92player[currentPlayer].xvel *= -0xC0093player[currentPlayer].yvel *= -0xC009495// A non-blank object signifies the end of the chain96if object[arrayPos0].type == TypeName[Blank Object]97temp2 = temp098temp2 *= temp099temp0 = temp1100temp0 *= temp1101temp0 += temp2102if temp0 < 256103object.nextNode++104end if105end if106else107// Player got interrupted somehow, abort108109object.type = TypeName[Blank Object]110end if111break112113end switch114end event115116117// ========================118// Editor Events119// ========================120121event RSDKEdit122if editor.returnVariable == true123switch editor.variableID124case EDIT_VAR_PROPVAL // property value125checkResult = object.propertyValue126checkResult &= 1127break128129case 0 // isExit130checkResult = object.propertyValue131checkResult &= 1132break133134end switch135else136switch editor.variableID137case EDIT_VAR_PROPVAL // property value138object.propertyValue = editor.variableValue139object.propertyValue &= 1140break141142case 0 // isExit143object.propertyValue = editor.variableValue144object.propertyValue &= 1145break146147end switch148end if149end event150151152event RSDKDraw153DrawSprite(0)154155CheckEqual(object.propertyValue, TUBEPATH_ENTRY)156temp0 = checkResult157CheckEqual(editor.showGizmos, true)158temp0 &= checkResult159if temp0 == true160editor.drawingOverlay = true161162// One of my favourite little things in this game, draw all the nodes that make up the path163164arrayPos0 = object.entityPos165arrayPos1 = object[+1].entityPos166167while object[arrayPos1].type == 0168DrawArrow(object[arrayPos0].xpos, object[arrayPos0].ypos, object[arrayPos1].xpos, object[arrayPos1].ypos, 0xFF, 0xFF, 0x00)169arrayPos0++170arrayPos1++171loop172173// Final one;174// no checks for type to match in-game behvaiour, but it should be a Tube Path obj with a prop val of 1175DrawArrow(object[arrayPos0].xpos, object[arrayPos0].ypos, object[arrayPos1].xpos, object[arrayPos1].ypos, 0xFF, 0xFF, 0x00)176177editor.drawingOverlay = false178end if179end event180181182event RSDKLoad183LoadSpriteSheet("Global/Display.gif")184SpriteFrame(-8, -8, 16, 16, 168, 18)185186AddEditorVariable("isExit")187SetActiveVariable("isExit")188AddEnumVariable("false", false)189AddEnumVariable("true", true)190end event191192193