Path: blob/master/Sonic 1/Scripts/SLZ/RotatePlatform.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Rotate Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value1 : object.drawPos.x12private alias object.value2 : object.drawPos.y1314// Player Aliases15private alias object.xpos : player.xpos16private alias object.ypos : player.ypos1718private alias object.value17 : debugMode.currentSelection192021// ========================22// Function Declarations23// ========================2425reserve function RotatePlatform_DebugDraw26reserve function RotatePlatform_DebugSpawn272829// ========================30// Static Values31// ========================3233private value RotatePlatform_startDebugID = 0343536// ========================37// Function Definitions38// ========================3940private function RotatePlatform_DebugDraw41DrawSprite(0)42end function434445private function RotatePlatform_DebugSpawn46temp0 = debugMode[0].currentSelection47temp0 -= RotatePlatform_startDebugID48temp1 = object.direction49temp1 <<= 250temp0 += temp151CreateTempObject(TypeName[Rotate Platform], temp0, object.xpos, object.ypos)52end function535455// ========================56// Events57// ========================5859event ObjectUpdate60temp6 = object.xpos61temp7 = object.ypos62object.xpos = object.drawPos.x63object.ypos = object.drawPos.y6465GetTableValue(temp0, 16, StageSetup_oscillationTable)66temp0 <<= 867temp0 &= 0xFFFF000068temp0 -= 0x5000006970GetTableValue(temp1, 18, StageSetup_oscillationTable)71temp1 <<= 872temp1 &= 0xFFFF000073temp1 -= 0x5000007475GetBit(temp2, object.propertyValue, 0)76if temp2 == true77FlipSign(temp0)78FlipSign(temp1)79end if8081GetBit(temp2, object.propertyValue, 2)82if temp2 == true83FlipSign(temp0)84end if8586GetBit(temp2, object.propertyValue, 1)87if temp2 == false88object.drawPos.x = temp089object.drawPos.y = temp190else91FlipSign(temp0)92object.drawPos.x = temp193object.drawPos.y = temp094end if95object.drawPos.x += temp696object.drawPos.y += temp79798temp2 = object.drawPos.x99temp2 -= object.xpos100temp3 = object.drawPos.y101temp3 -= object.ypos102foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)103BoxCollisionTest(C_PLATFORM, object.entityPos, -24, -8, 24, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)104if checkResult == true105player[currentPlayer].xpos += temp2106player[currentPlayer].ypos += temp3107end if108next109110object.xpos = temp6111object.ypos = temp7112end event113114115event ObjectDraw116DrawSpriteXY(0, object.drawPos.x, object.drawPos.y)117end event118119120event ObjectStartup121LoadSpriteSheet("SLZ/Objects.gif")122SpriteFrame(-24, -8, 48, 16, 1, 196)123124temp0 = 0125RotatePlatform_startDebugID = DebugMode_ObjCount126RotatePlatform_startDebugID--127while temp0 < 4128SetTableValue(TypeName[Rotate Platform], DebugMode_ObjCount, DebugMode_TypesTable)129SetTableValue(RotatePlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)130SetTableValue(RotatePlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)131DebugMode_ObjCount++132temp0++133loop134end event135136137// ========================138// Editor Events139// ========================140141event RSDKEdit142if editor.returnVariable == true143switch editor.variableID144case EDIT_VAR_PROPVAL // property value145checkResult = object.propertyValue146break147148case 0 // flipMoveX149GetBit(checkResult, object.propertyValue, 2)150break151152case 1 // flipMoveY153GetBit(checkResult, object.propertyValue, 1)154break155156case 2 // flipMoveXY157GetBit(checkResult, object.propertyValue, 0)158break159160end switch161else162switch editor.variableID163case EDIT_VAR_PROPVAL // property value164object.propertyValue = editor.variableValue165break166167case 0 // flipMoveX168CheckNotEqual(editor.variableValue, 0)169SetBit(object.propertyValue, 2, checkResult)170break171172case 1 // flipMoveY173CheckNotEqual(editor.variableValue, 0)174SetBit(object.propertyValue, 1, checkResult)175break176177case 2 // flipMoveXY178CheckNotEqual(editor.variableValue, 0)179SetBit(object.propertyValue, 0, checkResult)180break181182end switch183end if184end event185186187event RSDKDraw188// Actual Position189DrawSprite(0)190191if editor.showGizmos == true192editor.drawingOverlay = true193194// Draw where the player will see the Platform195196temp6 = object.xpos197temp7 = object.ypos198199temp0 = 0200temp0 &= 0xFFFF0000201temp0 -= 0x500000202203temp1 = 0204temp1 &= 0xFFFF0000205temp1 -= 0x500000206207GetBit(temp2, object.propertyValue, 0)208if temp2 == true209FlipSign(temp0)210FlipSign(temp1)211end if212213GetBit(temp2, object.propertyValue, 2)214if temp2 == true215FlipSign(temp0)216end if217218GetBit(temp2, object.propertyValue, 1)219if temp2 == false220object.drawPos.x = temp0221object.drawPos.y = temp1222else223FlipSign(temp0)224object.drawPos.x = temp1225object.drawPos.y = temp0226end if227object.drawPos.x += temp6228object.drawPos.y += temp7229230object.inkEffect = INK_BLEND231DrawSpriteFX(0, FX_INK, object.drawPos.x, object.drawPos.y)232233DrawLine(object.xpos, object.ypos, object.drawPos.x, object.drawPos.y, 0xFF, 0xFF, 0x00)234235editor.drawingOverlay = false236end if237end event238239240event RSDKLoad241LoadSpriteSheet("SLZ/Objects.gif")242SpriteFrame(-24, -8, 48, 16, 1, 196)243244AddEditorVariable("flipMoveX")245SetActiveVariable("flipMoveX")246AddEnumVariable("false", false)247AddEnumVariable("true", true)248249AddEditorVariable("flipMoveY")250SetActiveVariable("flipMoveY")251AddEnumVariable("false", false)252AddEnumVariable("true", true)253254AddEditorVariable("flipMoveXY")255SetActiveVariable("flipMoveXY")256AddEnumVariable("false", false)257AddEnumVariable("true", true)258end event259260261