Path: blob/master/Sonic 1/Scripts/SLZ/SwingPlat.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Swing Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.propertyValue : object.length1213private alias object.value0 : object.swingAngle14private alias object.value1 : object.drawPos.x15private alias object.value2 : object.drawPos.y16private alias object.value3 : object.collisionOffset.x17private alias object.value4 : object.collisionOffset.y1819// Player Aliases20private alias object.xpos : player.xpos21private alias object.ypos : player.ypos2223private alias object.value17 : debugMode.currentSelection242526// ========================27// Function Declarations28// ========================2930reserve function SwingPlatform_DebugDraw31reserve function SwingPlatform_DebugSpawn323334// ========================35// Static Values36// ========================3738private value SwingPlatform_startDebugID = 0394041// ========================42// Function Definitions43// ========================4445private function SwingPlatform_DebugDraw46temp7 = debugMode[0].currentSelection47temp7 -= SwingPlatform_startDebugID4849// Draw the post50DrawSprite(0)5152// Draw the chains53temp0 = 054temp1 = 1655while temp0 < temp756Cos(temp2, 128)57temp2 *= temp158temp2 <<= 759temp2 += object.xpos60Sin(temp3, 128)61temp3 *= temp162temp3 <<= 763temp3 += object.ypos64DrawSpriteXY(1, temp2, temp3)65temp0++66temp1 += 1667loop6869// Draw the platform itself70temp1 -= 871Cos(temp2, 128)72temp2 *= temp173temp2 <<= 774temp2 += object.xpos7576Sin(temp3, 128)77temp3 *= temp178temp3 <<= 779temp3 += object.ypos8081DrawSpriteXY(2, temp2, temp3)82end function838485private function SwingPlatform_DebugSpawn86temp0 = debugMode[0].currentSelection87temp0 -= SwingPlatform_startDebugID8889CreateTempObject(TypeName[Swing Platform], temp0, object.xpos, object.ypos)90object[tempObjectPos].direction = object.direction91end function929394// ========================95// Events96// ========================9798event ObjectUpdate99// Backup the object's position, as it'll need to be moved for collision checks100temp2 = object.xpos101temp3 = object.ypos102103GetTableValue(object.swingAngle, 12, StageSetup_oscillationTable)104object.swingAngle >>= 8105if object.direction == FLIP_X106object.swingAngle ^= 255107object.swingAngle += 129108end if109object.swingAngle <<= 1110111temp1 = object.length112temp1++113temp1 <<= 4114temp1 -= 8115object.xpos = object.drawPos.x116object.ypos = object.drawPos.y117118Cos(object.collisionOffset.x, object.swingAngle)119object.collisionOffset.x *= temp1120object.collisionOffset.x <<= 7121object.collisionOffset.x += temp2122object.collisionOffset.x &= 0xFFFF0000123object.drawPos.x = object.collisionOffset.x124object.collisionOffset.x -= object.xpos125126Sin(object.collisionOffset.y, object.swingAngle)127object.collisionOffset.y *= temp1128object.collisionOffset.y <<= 7129object.collisionOffset.y += temp3130object.collisionOffset.y &= 0xFFFF0000131object.drawPos.y = object.collisionOffset.y132object.collisionOffset.y -= object.ypos133134foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)135BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -16, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)136if checkResult == true137player[currentPlayer].xpos += object.collisionOffset.x138player[currentPlayer].ypos += object.collisionOffset.y139else140BoxCollisionTest(C_TOUCH, object.entityPos, -32, 0, 32, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)141if checkResult == true142CallFunction(Player_Hit)143else144BoxCollisionTest(C_TOUCH, object.entityPos, -16, 8, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)145if checkResult == true146CallFunction(Player_Hit)147end if148end if149end if150next151// Move the object back to its actual position152object.xpos = temp2153object.ypos = temp3154end event155156157event ObjectDraw158DrawSprite(0)159160temp0 = 0161temp1 = 16162while temp0 < object.length163Cos(temp2, object.swingAngle)164temp2 *= temp1165temp2 <<= 7166temp2 += object.xpos167Sin(temp3, object.swingAngle)168temp3 *= temp1169temp3 <<= 7170temp3 += object.ypos171DrawSpriteXY(1, temp2, temp3)172temp0++173temp1 += 16174loop175176temp1 -= 8 // this line.. doesn't really mean much177DrawSpriteXY(2, object.drawPos.x, object.drawPos.y)178end event179180181event ObjectStartup182LoadSpriteSheet("SLZ/Objects.gif")183SpriteFrame(-8, -8, 16, 16, 173, 141)184SpriteFrame(-8, -8, 16, 16, 173, 158)185SpriteFrame(-44, -16, 88, 46, 84, 141)186187temp0 = 0188SwingPlatform_startDebugID = DebugMode_ObjCount189SwingPlatform_startDebugID--190while temp0 < 8191SetTableValue(TypeName[Swing Platform], DebugMode_ObjCount, DebugMode_TypesTable)192SetTableValue(SwingPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)193SetTableValue(SwingPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)194DebugMode_ObjCount++195temp0++196loop197end event198199200event RSDKDraw201DrawSprite(0)202temp0 = 0203temp1 = 16204205while temp0 < object.length206Cos(temp2, 128)207temp2 *= temp1208temp2 <<= 7209temp2 += object.xpos210Sin(temp3, 128)211temp3 *= temp1212temp3 <<= 7213temp3 += object.ypos214DrawSpriteXY(1, temp2, temp3)215temp0++216temp1 += 16217loop218219temp1 -= 8220Cos(temp2, 128)221temp2 *= temp1222temp2 <<= 7223temp2 += object.xpos224Sin(temp3, 128)225temp3 *= temp1226temp3 <<= 7227temp3 += object.ypos228DrawSpriteXY(2, temp2, temp3)229end event230231232event RSDKLoad233LoadSpriteSheet("SLZ/Objects.gif")234SpriteFrame(-8, -8, 16, 16, 173, 141)235SpriteFrame(-8, -8, 16, 16, 173, 158)236SpriteFrame(-44, -16, 88, 46, 84, 141)237238SetVariableAlias(ALIAS_VAR_PROPVAL, "length")239end event240241242