Path: blob/master/Sonic 2/Scripts/MPZ/WheelPlatform.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Wheel Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.platformMPos.x12private alias object.value1 : object.platformMPos.y13private alias object.value2 : object.platformLPos.x14private alias object.value3 : object.platformLPos.y15private alias object.value4 : object.platformRPos.x16private alias object.value5 : object.platformRPos.y17private alias object.value6 : object.jointLPos.x18private alias object.value7 : object.jointLPos.y19private alias object.value8 : object.jointRPos.x20private alias object.value9 : object.jointRPos.y21private alias object.value10 : object.indentPos.x22private alias object.value11 : object.indentPos.y23private alias object.value12 : object.stoodPlayers24private alias object.value13 : object.prevPlatformMPos.x25private alias object.value14 : object.prevPlatformMPos.y26private alias object.value15 : object.active2728// Player Aliases29private alias object.xpos : player.xpos30private alias object.ypos : player.ypos31private alias object.gravity : player.gravity323334// ========================35// Function Declarations36// ========================3738reserve function WheelPlatform_DebugDraw39reserve function WheelPlatform_DebugSpawn4041private function WheelPlatform_DebugDraw42DrawSprite(3)4344temp0 = object.xpos45temp0 -= 0x88000046temp1 = object.ypos47temp1 += 0xC000048DrawSpriteXY(2, temp0, temp1)4950temp0 -= 0x38000051DrawSpriteXY(0, temp0, temp1)5253temp0 = object.xpos54temp0 += 0x88000055DrawSpriteXY(2, temp0, temp1)5657temp0 += 0x38000058DrawSpriteXY(1, temp0, temp1)59end function606162private function WheelPlatform_DebugSpawn63CreateTempObject(TypeName[Wheel Platform], 0, object.xpos, object.ypos)64end function656667// ========================68// Events69// ========================7071event ObjectUpdate72object.active = true7374temp0 = object.xpos75temp0 >>= 1676temp0 -= camera[0].xpos77Abs(temp0)78temp0 -= 57679temp1 = object.ypos80temp1 >>= 1681temp1 -= camera[0].ypos82Abs(temp1)83temp1 -= 12884if temp0 >= screen.xcenter85object.active = false86end if8788if temp1 >= screen.ycenter89object.active = false90end if9192if object.active == true93GetTableValue(object.platformMPos.x, 16, StageSetup_oscillationTable)94object.platformMPos.x >>= 895object.indentPos.x = object.platformMPos.x96object.indentPos.x >>= 197object.platformMPos.x -= 5698object.indentPos.x -= 2899100GetTableValue(object.platformMPos.y, 18, StageSetup_oscillationTable)101object.platformMPos.y >>= 8102object.indentPos.y = object.platformMPos.y103object.indentPos.y >>= 1104object.platformMPos.y -= 56105object.indentPos.y -= 28106107GetBit(temp0, object.propertyValue, 0)108if temp0 == true109FlipSign(object.platformMPos.x)110FlipSign(object.platformMPos.y)111object.rotation += 34112else113object.rotation -= 34114end if115116GetBit(temp0, object.propertyValue, 1)117if temp0 == true118FlipSign(object.platformMPos.x)119temp0 = object.platformMPos.x120object.platformMPos.x = object.platformMPos.y121object.platformMPos.y = temp0122end if123object.platformMPos.x <<= 16124object.platformMPos.x += object.xpos125object.platformMPos.y <<= 16126object.platformMPos.y += object.ypos127object.indentPos.x <<= 16128object.indentPos.y <<= 16129FlipSign(object.indentPos.x)130FlipSign(object.indentPos.y)131object.platformLPos.x = object.platformMPos.x132object.platformLPos.x -= 0x880000133object.platformLPos.y = object.platformMPos.y134object.platformLPos.y += 0xC0000135object.platformRPos.x = object.platformMPos.x136object.platformRPos.x += 0x880000137object.platformRPos.y = object.platformLPos.y138object.jointLPos.x = object.platformMPos.x139object.jointLPos.x -= 0xC00000140object.jointLPos.y = object.platformLPos.y141object.jointRPos.x = object.platformMPos.x142object.jointRPos.x += 0xC00000143object.jointRPos.y = object.platformLPos.y144145temp1 = object.platformMPos.x146temp1 -= object.prevPlatformMPos.x147temp2 = object.platformMPos.y148temp2 -= object.prevPlatformMPos.y149150object.prevPlatformMPos.x = object.platformMPos.x151object.prevPlatformMPos.y = object.platformMPos.y152153temp4 = object.xpos154temp5 = object.ypos155object.xpos = object.platformMPos.x156object.ypos = object.platformMPos.y157158temp7 = 0159foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)160GetBit(temp6, object.stoodPlayers, temp7)161if temp6 == true162player[currentPlayer].xpos += temp1163player[currentPlayer].ypos += temp2164end if165SetBit(object.stoodPlayers, temp7, false)166temp0 = 0167168BoxCollisionTest(C_SOLID, object.entityPos, -64, -24, 64, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)169switch checkResult170case COL_TOP171SetBit(object.stoodPlayers, temp7, true)172break173174case COL_BOTTOM175if player[currentPlayer].gravity == 0176CallFunction(Player_Kill)177end if178break179end switch180181BoxCollisionTest(C_SOLID, object.entityPos, -96, -24, -64, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)182switch checkResult183case COL_TOP184SetBit(object.stoodPlayers, temp7, true)185break186187case COL_BOTTOM188if player[currentPlayer].gravity == 0189CallFunction(Player_Kill)190end if191break192end switch193194BoxCollisionTest(C_SOLID, object.entityPos, 64, -24, 96, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)195switch checkResult196case COL_TOP197SetBit(object.stoodPlayers, temp7, true)198break199200case COL_BOTTOM201if player[currentPlayer].gravity == 0202CallFunction(Player_Kill)203end if204break205end switch206207BoxCollisionTest(C_SOLID, object.entityPos, -176, 4, -96, 20, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)208switch checkResult209case COL_TOP210SetBit(object.stoodPlayers, temp7, true)211break212213case COL_BOTTOM214if player[currentPlayer].gravity == 0215CallFunction(Player_Kill)216end if217break218end switch219220BoxCollisionTest(C_SOLID, object.entityPos, 96, 4, 176, 20, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)221switch checkResult222case COL_TOP223SetBit(object.stoodPlayers, temp7, true)224break225226case COL_BOTTOM227if player[currentPlayer].gravity == 0228CallFunction(Player_Kill)229end if230break231end switch232233BoxCollisionTest(C_SOLID, object.entityPos, -208, 0, -176, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)234switch checkResult235case COL_TOP236SetBit(object.stoodPlayers, temp7, true)237break238239case COL_BOTTOM240if player[currentPlayer].gravity == 0241CallFunction(Player_Kill)242end if243break244end switch245246BoxCollisionTest(C_SOLID, object.entityPos, 176, 0, 208, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)247switch checkResult248case COL_TOP249SetBit(object.stoodPlayers, temp7, true)250break251252case COL_BOTTOM253if player[currentPlayer].gravity == 0254CallFunction(Player_Kill)255end if256break257end switch258259temp7++260next261object.xpos = temp4262object.ypos = temp5263end if264end event265266267event ObjectDraw268if object.active == true269temp6 = object.xpos270temp6 -= 0xC00000271temp7 = object.ypos272temp7 += 0xC0000273temp0 = 0274temp2 = object.rotation275276object.rotation >>= 5277object.rotation &= 0x1FF278while temp0 < 8279DrawSpriteFX(5, FX_ROTATE, temp6, temp7)280object.rotation += 0x40281object.rotation &= 0x1FF282temp0++283loop284285temp5 = object.xpos286temp5 += 0xC00000287temp0 = 0288while temp0 < 8289DrawSpriteFX(5, FX_ROTATE, temp5, temp7)290object.rotation += 0x40291object.rotation &= 0x1FF292temp0++293loop294295object.rotation = temp2296temp6 += object.indentPos.x297temp7 += object.indentPos.y298DrawSpriteXY(4, temp6, temp7)299300temp5 += object.indentPos.x301DrawSpriteXY(4, temp5, temp7)302303DrawSpriteXY(3, object.platformMPos.x, object.platformMPos.y)304DrawSpriteXY(2, object.platformLPos.x, object.platformLPos.y)305DrawSpriteXY(0, object.jointLPos.x, object.jointLPos.y)306DrawSpriteXY(2, object.platformRPos.x, object.platformRPos.y)307DrawSpriteXY(1, object.jointRPos.x, object.jointRPos.y)308end if309end event310311312event ObjectStartup313LoadSpriteSheet("MPZ/Objects.gif")314SpriteFrame(-16, -12, 32, 24, 479, 182) // Joint L - #0315SpriteFrame(-16, -12, 32, 24, 479, 133) // Joint R - #1316SpriteFrame(-40, -8, 80, 16, 349, 165) // Side Platforms - #2317SpriteFrame(-96, -24, 192, 48, 319, 207) // Center Platform - #3318SpriteFrame(-12, -12, 24, 24, 487, 157) // Indent - #4319SpriteFrame(-2, -14, 4, 4, 40, 34) // Blank Circle Thingy - #5320321foreach (TypeName[Wheel Platform], arrayPos0, ALL_ENTITIES)322object[arrayPos0].priority = PRIORITY_ACTIVE323next324325SetTableValue(TypeName[Wheel Platform], DebugMode_ObjCount, DebugMode_TypesTable)326SetTableValue(WheelPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)327SetTableValue(WheelPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)328DebugMode_ObjCount++329end event330331332// ========================333// Editor Events334// ========================335336event RSDKEdit337if editor.returnVariable == true338switch editor.variableID339case EDIT_VAR_PROPVAL // property value340checkResult = object.propertyValue341break342343case 0 // flipMoveX344GetBit(checkResult, object.propertyValue, 0)345break346347case 1 // flipMoveY348GetBit(checkResult, object.propertyValue, 1)349break350351end switch352else353switch editor.variableID354case EDIT_VAR_PROPVAL // property value355object.propertyValue = editor.variableValue356break357358case 0 // flipMoveX359CheckNotEqual(editor.variableValue, false)360SetBit(object.propertyValue, 0, checkResult)361break362363case 1 // flipMoveY364CheckNotEqual(editor.variableValue, false)365SetBit(object.propertyValue, 1, checkResult)366break367368end switch369end if370end event371372373event RSDKDraw374DrawSprite(3)375temp0 = object.xpos376temp0 -= 0x880000377temp1 = object.ypos378temp1 += 0xC0000379DrawSpriteXY(2, temp0, temp1)380temp0 -= 0x380000381DrawSpriteXY(0, temp0, temp1)382temp0 = object.xpos383temp0 += 0x880000384DrawSpriteXY(2, temp0, temp1)385temp0 += 0x380000386DrawSpriteXY(1, temp0, temp1)387end event388389390event RSDKLoad391LoadSpriteSheet("MPZ/Objects.gif")392SpriteFrame(-16, -12, 32, 24, 479, 182)393SpriteFrame(-16, -12, 32, 24, 479, 133)394SpriteFrame(-40, -8, 80, 16, 349, 165)395SpriteFrame(-96, -24, 192, 48, 319, 207)396SpriteFrame(-12, -12, 24, 24, 487, 157)397SpriteFrame(-2, -14, 4, 4, 40, 34)398399AddEditorVariable("flipMoveX")400SetActiveVariable("flipMoveX")401AddEnumVariable("false", false)402AddEnumVariable("true", true)403404AddEditorVariable("flipMoveY")405SetActiveVariable("flipMoveY")406AddEnumVariable("false", false)407AddEnumVariable("true", true)408end event409410411