Path: blob/master/Sonic 1/Scripts/Global/YBoundAdjust.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Y Bound Adjust Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011// Player aliases12private alias object.xpos : player.xpos13private alias object.ypos : player.ypos141516// ========================17// Events18// ========================1920event ObjectUpdate21if object.propertyValue == 022// Only check if the player's within a 64 pixel range of the object, in terms of X23temp0 = player[0].xpos24temp0 -= object.xpos25Abs(temp0)26if temp0 < 0x20000027stage.newYBoundary2 = object.iypos28stage.deathBoundary = object.ypos29end if30else31// Check if the player's between this object and the next, in terms of Y32if player[0].ypos < object.ypos33if player[0].ypos > object[+1].ypos34temp0 = player[0].xpos35temp0 -= object.xpos36Abs(temp0)37if temp0 < 0x20000038stage.newYBoundary2 = object.iypos39stage.deathBoundary = object.ypos40end if41end if42end if43end if44end event454647event ObjectStartup48foreach (TypeName[Y Bound Adjust], arrayPos0, ALL_ENTITIES)49// Set the initial camera bounds based on where the player spawned50// (This object comes after Lamp Posts in the object order, which is why this can be done already)5152if object[arrayPos0].propertyValue == 053object[arrayPos0].priority = PRIORITY_XBOUNDS54temp0 = player[0].xpos55temp0 -= object[arrayPos0].xpos56Abs(temp0)57if temp0 < 0x20000058stage.curYBoundary2 = object[arrayPos0].iypos59stage.deathBoundary = object[arrayPos0].ypos60end if61else62object[arrayPos0].priority = PRIORITY_XBOUNDS63arrayPos1 = arrayPos064arrayPos1++65if player[0].ypos < object[arrayPos0].ypos66if player[0].ypos > object[arrayPos1].ypos67temp0 = player[0].xpos68temp0 -= object[arrayPos0].xpos69Abs(temp0)70if temp0 < 0x20000071stage.curYBoundary2 = object[arrayPos0].iypos72stage.deathBoundary = object[arrayPos0].ypos73end if74end if75end if76end if77next78end event798081// ========================82// Editor Events83// ========================8485event RSDKEdit86if editor.returnVariable == true87switch editor.variableID88case EDIT_VAR_PROPVAL // property value89checkResult = object.propertyValue90break9192case 0 // type93checkResult = object.propertyValue94break9596end switch97else98switch editor.variableID99case EDIT_VAR_PROPVAL // property value100object.propertyValue = editor.variableValue101break102103case 0 // type104object.propertyValue = editor.variableValue105break106107end switch108end if109end event110111112event RSDKDraw113// The object's tiny, draw a small line to show where the camera's gonna be aligned to114// No specific reason for using yellow, I just think it looks nice115temp0 = object.xpos116temp0 -= 0x1C0000117temp1 = object.xpos118temp1 += 0x1C0000119DrawLine(temp0, object.ypos, temp1, object.ypos, 0xFF, 0xFF, 0x00)120121// Draw the Y icon ontop of the line122DrawSprite(0)123124editor.drawingOverlay = true125126CheckEqual(object.propertyValue, 1)127checkResult &= editor.showGizmos128if temp0 == true129// Draw arrows between the next object too, since that's where the other side of the bounds adjust is130// Using yellow again cuz why not131DrawArrow(object.xpos, object.ypos, object[+1].xpos, object[+1].ypos, 0xFF, 0xFF, 0x00)132DrawArrow(object[+1].xpos, object[+1].ypos, object.xpos, object.ypos, 0xFF, 0xFF, 0x00)133end if134135editor.drawingOverlay = false136end event137138139event RSDKLoad140LoadSpriteSheet("Global/Display.gif")141SpriteFrame(-8, -8, 16, 16, 205, 239) // "Y" (Bounds Adjust)142143AddEditorVariable("type")144SetActiveVariable("type")145AddEnumVariable("Regular Adjust", 0) // adjusts to this YPos146AddEnumVariable("Box Adjust", 1) // adjusts to this YPos, if the player is below this YPos and above the next object slots' YPos147end event148149150