Path: blob/master/Sonic 2/Scripts/WFZ/RotatePlatform.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Rotate Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.startPos.x12private alias object.value1 : object.startPos.y13private alias object.value2 : object.drawPos.x14private alias object.value3 : object.drawPos.y15private alias object.value4 : object.hitbox.left16private alias object.value5 : object.hitbox.right17private alias object.value6 : object.stoodPlayers1819// Player Aliases20private alias object.xpos : player.xpos21private alias object.ypos : player.ypos2223private alias object.value17 : debugMode.currentSelection242526// ========================27// Function Declarations28// ========================2930reserve function RotatePlatform_DebugDraw31reserve function RotatePlatform_DebugSpawn323334// ========================35// Static Values36// ========================3738private value RotatePlatform_startDebugID = 0394041// ========================42// Function Definitions43// ========================4445private function RotatePlatform_DebugDraw46temp0 = debugMode[0].currentSelection47temp0 -= RotatePlatform_startDebugID48temp0 >>= 249DrawSprite(temp0)50end function515253private function RotatePlatform_DebugSpawn54temp0 = debugMode[0].currentSelection55temp0 -= RotatePlatform_startDebugID5657temp2 = temp058temp0 &= 359temp2 >>= 260temp0 <<= 461temp1 = object.direction62temp1 <<= 663temp0 += temp164CreateTempObject(TypeName[Rotate Platform], temp0, object.xpos, object.ypos)6566object[tempObjectPos].startPos.x = object.xpos67object[tempObjectPos].startPos.y = object.ypos68object[tempObjectPos].frame = temp269if temp2 == 070object[tempObjectPos].hitbox.left = -3271object[tempObjectPos].hitbox.right = 3272else73object[tempObjectPos].hitbox.left = -2474object[tempObjectPos].hitbox.right = 2475end if76end function777879// ========================80// Events81// ========================8283event ObjectUpdate84temp4 = object.drawPos.x85temp5 = object.drawPos.y8687GetTableValue(temp0, 28, StageSetup_oscillationTable)88temp0 <<= 889temp0 &= 0xFFFF000090temp0 -= 0x4000009192GetTableValue(temp1, 30, StageSetup_oscillationTable)93temp1 <<= 894temp1 &= 0xFFFF000095temp1 -= 0x4000009697GetBit(temp2, object.propertyValue, 5)98if temp2 == true99FlipSign(temp0)100FlipSign(temp1)101end if102103GetBit(temp2, object.propertyValue, 6)104if temp2 == true105FlipSign(temp0)106end if107108GetBit(temp2, object.propertyValue, 4)109if temp2 == false110object.drawPos.x = temp0111object.drawPos.y = temp1112else113FlipSign(temp0)114object.drawPos.x = temp1115object.drawPos.y = temp0116end if117118object.drawPos.x += object.startPos.x119object.drawPos.y += object.startPos.y120121temp6 = object.drawPos.x122temp6 -= temp4123temp7 = object.drawPos.y124temp7 -= temp5125object.xpos = object.drawPos.x126object.ypos = object.drawPos.y127128temp2 = 0129foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)130GetBit(temp0, object.stoodPlayers, temp2)131if temp0 == true132player[currentPlayer].xpos += temp6133player[currentPlayer].ypos += temp7134end if135136SetBit(object.stoodPlayers, temp2, false)137BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitbox.left, -16, object.hitbox.right, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)138if checkResult == true139SetBit(object.stoodPlayers, temp2, true)140end if141temp2++142next143144object.xpos = object.startPos.x145object.ypos = object.startPos.y146end event147148149event ObjectDraw150DrawSpriteXY(object.frame, object.drawPos.x, object.drawPos.y)151end event152153154event ObjectStartup155CheckCurrentStageFolder("Zone11")156if checkResult == true157LoadSpriteSheet("SCZ/Objects.gif")158SpriteFrame(-24, -16, 48, 24, 381, 178) // Small Platform - #0159SpriteFrame(-32, -16, 64, 24, 1, 146) // Wide Platform - #1160else161LoadSpriteSheet("MBZ/Objects.gif")162SpriteFrame(-24, -16, 48, 24, 529, 999) // Small Platform - #0163SpriteFrame(-32, -16, 64, 24, 464, 999) // Wide Platform - #1164end if165166foreach (TypeName[Rotate Platform], arrayPos0, ALL_ENTITIES)167object[arrayPos0].startPos.x = object[arrayPos0].xpos168object[arrayPos0].startPos.y = object[arrayPos0].ypos169170object[arrayPos0].frame = object[arrayPos0].propertyValue171object[arrayPos0].frame &= 0xF172173if object[arrayPos0].frame == 0174object[arrayPos0].hitbox.left = -32175object[arrayPos0].hitbox.right = 32176else177object[arrayPos0].hitbox.left = -24178object[arrayPos0].hitbox.right = 24179end if180next181182temp0 = 0183RotatePlatform_startDebugID = DebugMode_ObjCount184while temp0 < 8185SetTableValue(TypeName[Rotate Platform], DebugMode_ObjCount, DebugMode_TypesTable)186SetTableValue(RotatePlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)187SetTableValue(RotatePlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)188DebugMode_ObjCount++189temp0++190loop191end event192193194// ========================195// Editor Events196// ========================197198event RSDKEdit199if editor.returnVariable == true200switch editor.variableID201case EDIT_VAR_PROPVAL // property value202checkResult = object.propertyValue203break204205case 0 // type206checkResult = object.propertyValue207break208209case 1 // flipMoveX210GetBit(checkResult, object.propertyValue, 6)211break212213case 2 // flipMoveY214GetBit(checkResult, object.propertyValue, 5)215break216217case 3 // flipMoveXY218GetBit(checkResult, object.propertyValue, 4)219break220221end switch222else223switch editor.variableID224case EDIT_VAR_PROPVAL // property value225object.propertyValue = editor.variableValue226break227228case 0 // type229object.propertyValue = editor.variableValue230break231232case 1 // flipMoveX233CheckNotEqual(editor.variableValue, 0)234SetBit(object.propertyValue, 6, checkResult)235break236237case 2 // flipMoveY238CheckNotEqual(editor.variableValue, 0)239SetBit(object.propertyValue, 5, checkResult)240break241242case 3 // flipMoveXY243CheckNotEqual(editor.variableValue, 0)244SetBit(object.propertyValue, 4, checkResult)245break246247end switch248end if249end event250251252event RSDKDraw253object.frame = object.propertyValue254object.frame &= 0xF255256temp6 = object.xpos257temp7 = object.ypos258259temp0 = 0260temp0 &= 0xFFFF0000261temp0 -= 0x500000262263temp1 = 0264temp1 &= 0xFFFF0000265temp1 -= 0x500000266267GetBit(temp2, object.propertyValue, 4)268if temp2 == true269FlipSign(temp0)270FlipSign(temp1)271end if272273GetBit(temp2, object.propertyValue, 6)274if temp2 == true275FlipSign(temp0)276end if277278GetBit(temp2, object.propertyValue, 5)279if temp2 == false280object.drawPos.x = temp0281object.drawPos.y = temp1282else283FlipSign(temp0)284object.drawPos.x = temp1285object.drawPos.y = temp0286end if287object.drawPos.x += temp6288object.drawPos.y += temp7289290// Where the player will see it291if editor.showGizmos == true292editor.drawingOverlay = true293294object.inkEffect = INK_BLEND295DrawSpriteFX(0, FX_INK, object.drawPos.x, object.drawPos.y)296297editor.drawingOverlay = false298end if299300// Actual Position301object.inkEffect = INK_NONE302DrawSprite(object.frame)303end event304305306event RSDKLoad307CheckCurrentStageFolder("Zone11")308if checkResult == true309LoadSpriteSheet("SCZ/Objects.gif")310SpriteFrame(-24, -16, 48, 24, 381, 178) // Small Platform - #0311SpriteFrame(-32, -16, 64, 24, 1, 146) // Wide Platform - #1312else313LoadSpriteSheet("MBZ/Objects.gif")314SpriteFrame(-24, -16, 48, 24, 529, 999) // Small Platform - #0315SpriteFrame(-32, -16, 64, 24, 464, 999) // Wide Platform - #1316end if317318AddEditorVariable("type")319SetActiveVariable("type")320AddEnumVariable("Small Platform", 0)321AddEnumVariable("Wide Platform", 1)322323AddEditorVariable("flipMoveX")324SetActiveVariable("flipMoveX")325AddEnumVariable("false", false)326AddEnumVariable("true", true)327328AddEditorVariable("flipMoveY")329SetActiveVariable("flipMoveY")330AddEnumVariable("false", false)331AddEnumVariable("true", true)332333AddEditorVariable("flipMoveXY")334SetActiveVariable("flipMoveXY")335AddEnumVariable("false", false)336AddEnumVariable("true", true)337end event338339340