Path: blob/master/Sonic 1/Scripts/Global/PSwitch_H.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Plane Sw H Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.extendLeft12private alias object.value1 : object.extendRight13private alias object.value2 : object.planeR // bottom (rising up), named the same as PSwitch_V for consistency14private alias object.value3 : object.planeL // top (falling down), named the same as PSwitch_V for consistency15private alias object.value4 : object.drawOrderR // bottom (rising up), named the same as PSwitch_V for consistency16private alias object.value5 : object.drawOrderL // top (falling down), named the same as PSwitch_V for consistency17private alias object.value6 : object.onGround1819// Player Aliases20private alias object.state : player.state21private alias object.yvel : player.yvel22private alias object.gravity : player.gravity23private alias object.collisionPlane : player.collisionPlane24private alias object.value18 : player.sortedDrawOrder252627// ========================28// Events29// ========================3031event ObjectUpdate32foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)33CheckEqual(object.onGround, false)34temp0 = checkResult35CheckEqual(player[currentPlayer].gravity, GRAVITY_GROUND)36temp0 |= checkResult37CheckEqual(player[currentPlayer].state, Player_State_Climb)38temp0 |= checkResult3940if temp0 == true41BoxCollisionTest(C_TOUCH, object.entityPos, object.extendLeft, -12, object.extendRight, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)42if checkResult == true43if player[currentPlayer].yvel > 044player[currentPlayer].collisionPlane = object.planeL45player[currentPlayer].sortedDrawOrder = object.drawOrderL46else47player[currentPlayer].collisionPlane = object.planeR48player[currentPlayer].sortedDrawOrder = object.drawOrderR49end if50end if51end if52next53end event545556event ObjectStartup57foreach (TypeName[Plane Sw H], arrayPos0, ALL_ENTITIES)58temp0 = object[arrayPos0].propertyValue59temp0 &= 360temp0 += 261object[arrayPos0].extendLeft = 162object[arrayPos0].extendLeft <<= temp063object[arrayPos0].extendLeft <<= 364object[arrayPos0].extendLeft += 865object[arrayPos0].extendRight = object[arrayPos0].extendLeft66FlipSign(object[arrayPos0].extendLeft)6768GetBit(object[arrayPos0].planeR, object[arrayPos0].propertyValue, 2)69GetBit(object[arrayPos0].planeL, object[arrayPos0].propertyValue, 3)7071GetBit(object[arrayPos0].drawOrderR, object[arrayPos0].propertyValue, 4)72object[arrayPos0].drawOrderR <<= 173object[arrayPos0].drawOrderR += 474GetBit(object[arrayPos0].drawOrderL, object[arrayPos0].propertyValue, 5)75object[arrayPos0].drawOrderL <<= 176object[arrayPos0].drawOrderL += 47778GetBit(object[arrayPos0].onGround, object[arrayPos0].propertyValue, 7)79next80end event818283// ========================84// Editor Events & Aliases85// ========================8687private alias 0 : VAR_ID_SIZE88private alias 1 : VAR_ID_PLANEL89private alias 2 : VAR_ID_PLANER90private alias 3 : VAR_ID_DRAWL91private alias 4 : VAR_ID_DRAWR92private alias 5 : VAR_ID_ONGROUND939495event RSDKEdit96if editor.returnVariable == true97switch editor.variableID98case EDIT_VAR_PROPVAL // property value99checkResult = object.propertyValue100break101102case VAR_ID_SIZE // size103checkResult = object.propertyValue104checkResult &= 3105break106107case VAR_ID_PLANEL // collisionPlaneL108GetBit(checkResult, object.propertyValue, 2)109break110111case VAR_ID_PLANER // collisionPlaneR112GetBit(checkResult, object.propertyValue, 3)113break114115case VAR_ID_DRAWL // drawOrderL116GetBit(checkResult, object.propertyValue, 4)117break118119case VAR_ID_DRAWR // drawOrderR120GetBit(checkResult, object.propertyValue, 5)121break122123case VAR_ID_ONGROUND // onGround124GetBit(checkResult, object.propertyValue, 7)125break126127end switch128else129switch editor.variableID130case EDIT_VAR_PROPVAL // property value131object.propertyValue = editor.variableValue132break133134case VAR_ID_SIZE // size135temp1 = 3136Not(temp1)137object.propertyValue &= temp1138139temp0 = editor.variableValue140temp0 &= 3141object.propertyValue |= temp0142break143144case VAR_ID_PLANEL // collisionPlaneL145CheckNotEqual(editor.variableValue, false)146SetBit(object.propertyValue, 2, checkResult)147break148149case VAR_ID_PLANER // collisionPlaneR150CheckNotEqual(editor.variableValue, false)151SetBit(object.propertyValue, 3, checkResult)152break153154case VAR_ID_DRAWL // drawOrderL155CheckNotEqual(editor.variableValue, false)156SetBit(object.propertyValue, 4, checkResult)157break158159case VAR_ID_DRAWR // drawOrderR160CheckNotEqual(editor.variableValue, false)161SetBit(object.propertyValue, 5, checkResult)162break163164case VAR_ID_ONGROUND // onGround165CheckNotEqual(editor.variableValue, false)166SetBit(object.propertyValue, 7, checkResult)167break168169end switch170end if171end event172173174event RSDKDraw175// Grabbed this from S2's debug view since S1 doesn't have one, works the same though176177temp1 = object.propertyValue178temp1 &= 3179temp1 += 2180temp0 = 1181temp0 <<= temp1182temp1 = temp0183temp0 <<= 19184FlipSign(temp0)185temp0 += object.xpos186temp0 += 0x80000187188GetBit(temp2, object.propertyValue, 7)189temp3 = object.propertyValue190temp3 >>= 2191temp3 &= 15192193temp4 = 0194while temp4 < temp1195if temp2 == true196DrawSpriteXY(16, temp0, object.ypos)197end if198DrawSpriteXY(temp3, temp0, object.ypos)199temp0 += 0x100000200temp4++201loop202203if temp1 == 0204DrawSprite(temp3)205end if206end event207208209event RSDKLoad210LoadSpriteSheet("Global/Display.gif")211212temp0 = 0213temp1 = 46214while temp0 < 8215SpriteFrame(-8, -8, 16, 16, temp1, 158)216temp0++217temp1 += 17218loop219220temp0 = 0221temp1 = 46222while temp0 < 8223SpriteFrame(-8, -8, 16, 16, temp1, 175)224temp0++225temp1 += 17226loop227228SpriteFrame(-8, -8, 16, 16, 182, 141) // #16 - back229230AddEditorVariable("size")231SetActiveVariable("size")232AddEnumVariable("4 Nodes", 0)233AddEnumVariable("8 Nodes", 1)234AddEnumVariable("16 Nodes", 2)235AddEnumVariable("32 Nodes", 3)236237AddEditorVariable("collisionPlaneL")238SetActiveVariable("collisionPlaneL")239AddEnumVariable("Plane A", 0)240AddEnumVariable("Plane B", 1)241242AddEditorVariable("collisionPlaneR")243SetActiveVariable("collisionPlaneR")244AddEnumVariable("Plane A", 0)245AddEnumVariable("Plane B", 1)246247AddEditorVariable("drawOrderL")248SetActiveVariable("drawOrderL")249AddEnumVariable("Low Layer", 0)250AddEnumVariable("High Layer", 1)251252AddEditorVariable("drawOrderR")253SetActiveVariable("drawOrderR")254AddEnumVariable("Low Layer", 0)255AddEnumVariable("High Layer", 1)256257AddEditorVariable("onGround")258SetActiveVariable("onGround")259AddEnumVariable("false", false)260AddEnumVariable("true", true)261end event262263264