Path: blob/master/Sonic 1/Scripts/MZ/LargePlatform.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Large Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.stood12private alias object.value1 : object.drawPos.y13private alias object.value2 : object.collisionOffset.y14private alias object.value3 : object.spawnedFireballs15private alias object.value4 : object.amplitude.y1617private alias 0 : LARGEPLATFORM_TYPE_ARCH18private alias 1 : LARGEPLATFORM_TYPE_CURVE19private alias 2 : LARGEPLATFORM_TYPE_RECT2021private alias 0 : LARGEPLATFORM_STATIC22private alias 1 : LARGEPLATFORM_MOVE_V_SHORTEST23private alias 2 : LARGEPLATFORM_MOVE_V_SHORT24private alias 3 : LARGEPLATFORM_MOVE_V_LONG25private alias 4 : LARGEPLATFORM_MOVE_V_LONGEST26private alias 5 : LARGEPLATFORM_HASTENSION2728// GrassFireball Aliases29private alias object.value1 : grassFireball.parentSlot30private alias object.value2 : grassFireball.platformPos31private alias object.value3 : grassFireball.parentType3233// Player Aliases34private alias object.xpos : player.xpos35private alias object.ypos : player.ypos3637// Debug Mode Aliases38private alias object.value17 : debugMode.currentSelection394041// ========================42// Function Declarations43// ========================4445reserve function LargePlatform_SetupTypes46reserve function LargePlatform_DebugDraw47reserve function LargePlatform_DebugSpawn484950// ========================51// Static Values52// ========================5354private value LargePlatform_startDebugID = 0555657// ========================58// Tables59// ========================6061public table LargePlatform_heightTableArch62-32, -32, -32, -32, -32, -32, -32, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -32, -32, -32, -32, -32, -32, -3263end table6465public table LargePlatform_heightTableCurved66-33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -4967end table6869private table LargePlatform_debugFrameTable700, 0710, 0722, 2732, 274175end table7677private table LargePlatform_debugStateTable781, 2793, 4801, 2813, 482583end table848586// ========================87// Function Definitions88// ========================8990private function LargePlatform_SetupTypes91if temp0 == 092switch object[arrayPos0].state93case LARGEPLATFORM_MOVE_V_SHORTEST94object[arrayPos0].ypos -= 0x10000095object[arrayPos0].amplitude.y = 0x80096break9798case LARGEPLATFORM_MOVE_V_SHORT99object[arrayPos0].ypos -= 0x180000100object[arrayPos0].amplitude.y = 0xC00101break102103case LARGEPLATFORM_MOVE_V_LONG104object[arrayPos0].ypos -= 0x200000105object[arrayPos0].amplitude.y = 0x1000106break107108case LARGEPLATFORM_MOVE_V_LONGEST109object[arrayPos0].ypos -= 0x300000110object[arrayPos0].amplitude.y = 0x1800111break112113end switch114else115switch object[arrayPos0].state116case LARGEPLATFORM_MOVE_V_SHORTEST117object[arrayPos0].ypos -= 0x100000118object[arrayPos0].amplitude.y = -0x800119break120121case LARGEPLATFORM_MOVE_V_SHORT122object[arrayPos0].ypos -= 0x180000123object[arrayPos0].amplitude.y = -0xC00124break125126case LARGEPLATFORM_MOVE_V_LONG127object[arrayPos0].ypos -= 0x200000128object[arrayPos0].amplitude.y = -0x1000129break130131case LARGEPLATFORM_MOVE_V_LONGEST132object[arrayPos0].ypos -= 0x300000133object[arrayPos0].amplitude.y = -0x1800134break135136end switch137end if138end function139140141private function LargePlatform_DebugDraw142temp0 = debugMode[0].currentSelection143temp0 -= LargePlatform_startDebugID144GetTableValue(temp1, temp0, LargePlatform_debugFrameTable)145DrawSprite(temp1)146end function147148149private function LargePlatform_DebugSpawn150temp0 = debugMode[0].currentSelection151temp0 -= LargePlatform_startDebugID152153CreateTempObject(TypeName[Large Platform], 0, object.xpos, object.ypos)154GetTableValue(object[tempObjectPos].frame, temp0, LargePlatform_debugFrameTable)155GetTableValue(object[tempObjectPos].state, temp0, LargePlatform_debugStateTable)156arrayPos0 = object[tempObjectPos].entityPos157temp0 = object.direction158CallFunction(LargePlatform_SetupTypes)159end function160161162// ========================163// Events164// ========================165166event ObjectUpdate167switch object.state168case LARGEPLATFORM_STATIC169object.angle = 0170object.amplitude.y = 0171break172173case LARGEPLATFORM_MOVE_V_SHORTEST174object.angle = oscillation175object.angle <<= 1176object.angle += 0x10177break178179case LARGEPLATFORM_MOVE_V_SHORT180object.angle = oscillation181object.angle <<= 1182object.angle += 0x30183break184185case LARGEPLATFORM_MOVE_V_LONG186object.angle = oscillation187object.angle <<= 1188object.angle += 0x50189break190191case LARGEPLATFORM_MOVE_V_LONGEST192object.angle = oscillation193object.angle <<= 1194object.angle += 0x70195break196197case LARGEPLATFORM_HASTENSION198if object.stood == true199if object.angle < 128200object.angle += 8201end if202else203if object.angle > 0204object.angle -= 4205end if206end if207208object.amplitude.y = 0x800209if object.angle > 80210if object.spawnedFireballs == false211object.spawnedFireballs = true212CreateTempObject(TypeName[Grass Fireball], 0, object.xpos, object.ypos)213if object.frame < LARGEPLATFORM_TYPE_RECT214object[tempObjectPos].xpos -= 0x380000215else216object[tempObjectPos].xpos -= 0x180000217end if218grassFireball[tempObjectPos].parentSlot = object.entityPos219grassFireball[tempObjectPos].platformPos = 8220object[tempObjectPos].drawOrder = 5221grassFireball[tempObjectPos].parentType = object.frame222end if223end if224break225226end switch227228Sin(object.collisionOffset.y, object.angle)229object.collisionOffset.y *= object.amplitude.y230object.collisionOffset.y += object.ypos231object.collisionOffset.y &= 0xFFFF0000232object.collisionOffset.y -= object.drawPos.y233234object.stood = false235temp0 = object.ypos236object.ypos = object.drawPos.y237foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)238switch object.frame239case LARGEPLATFORM_TYPE_ARCH240temp1 = player[currentPlayer].xpos241temp1 -= object.xpos242temp1 >>= 17243temp1 += 32244if temp1 < 0245temp1 = 0246end if247if temp1 > 63248temp1 = 63249end if250GetTableValue(temp2, temp1, LargePlatform_heightTableArch)251BoxCollisionTest(C_SOLID, object.entityPos, -64, temp2, 64, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)252temp2 -= 3253254BoxCollisionTest(C_PLATFORM, object.entityPos, -64, temp2, 64, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)255if checkResult == true256player[currentPlayer].ypos += 0x40000257player[currentPlayer].ypos += object.collisionOffset.y258object.stood = true259end if260break261262case LARGEPLATFORM_TYPE_CURVE263temp1 = player[currentPlayer].xpos264temp1 -= object.xpos265temp1 >>= 17266temp1 += 32267if temp1 < 0268temp1 = 0269end if270if temp1 > 63271temp1 = 63272end if273GetTableValue(temp2, temp1, LargePlatform_heightTableCurved)274BoxCollisionTest(C_SOLID, object.entityPos, -64, temp2, 64, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)275temp2 -= 3276277BoxCollisionTest(C_PLATFORM, object.entityPos, -64, temp2, 64, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)278if checkResult == true279player[currentPlayer].ypos += 0x40000280player[currentPlayer].ypos += object.collisionOffset.y281object.stood = true282end if283break284285case LARGEPLATFORM_TYPE_RECT286BoxCollisionTest(C_SOLID, object.entityPos, -32, -47, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)287temp2 -= 3288289BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -51, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)290if checkResult == true291player[currentPlayer].ypos += 0x40000292player[currentPlayer].ypos += object.collisionOffset.y293object.stood = true294end if295break296297end switch298next299object.ypos = temp0300301Sin(object.drawPos.y, object.angle)302object.drawPos.y *= object.amplitude.y303object.drawPos.y += object.ypos304object.drawPos.y &= 0xFFFF0000305end event306307308event ObjectDraw309DrawSpriteXY(object.frame, object.xpos, object.drawPos.y)310end event311312313event ObjectStartup314LoadSpriteSheet("MZ/Objects.gif")315SpriteFrame(-64, -48, 128, 80, 1, 324)316SpriteFrame(-64, -64, 128, 96, 317, 396)317SpriteFrame(-32, -48, 64, 96, 446, 396)318319foreach (TypeName[Large Platform], arrayPos0, ALL_ENTITIES)320object[arrayPos0].frame = object[arrayPos0].propertyValue321object[arrayPos0].frame >>= 4322object[arrayPos0].frame %= 3323324object[arrayPos0].state = object[arrayPos0].propertyValue325object[arrayPos0].state &= 7326if object[arrayPos0].state > LARGEPLATFORM_HASTENSION327object[arrayPos0].state = LARGEPLATFORM_STATIC328end if329330temp0 = object[arrayPos0].propertyValue331temp0 &= 15332temp0 >>= 3333CallFunction(LargePlatform_SetupTypes)334335object[arrayPos0].drawOrder = 5336next337338temp0 = 0339LargePlatform_startDebugID = DebugMode_ObjCount340while temp0 < 9341SetTableValue(TypeName[Large Platform], DebugMode_ObjCount, DebugMode_TypesTable)342SetTableValue(LargePlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)343SetTableValue(LargePlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)344DebugMode_ObjCount++345temp0++346loop347end event348349350// ========================351// Editor Events352// ========================353354event RSDKEdit355if editor.returnVariable == true356switch editor.variableID357case EDIT_VAR_PROPVAL // property value358checkResult = object.propertyValue359break360361case 0 // frameID362checkResult = object.propertyValue363checkResult >>= 4364checkResult %= 3365break366367case 1 // type368checkResult = object.propertyValue369checkResult &= 7370if checkResult > LARGEPLATFORM_HASTENSION371checkResult = LARGEPLATFORM_STATIC372end if373break374375case 2 // startDir376GetBit(checkResult, object.propertyValue, 3)377break378379end switch380else381switch editor.variableID382case EDIT_VAR_PROPVAL // property value383object.propertyValue = editor.variableValue384break385386case 0 // frameID387temp1 = 0x70388Not(temp1)389object.propertyValue &= temp1390391editor.variableValue &= 3392editor.variableValue <<= 4393object.propertyValue |= editor.variableValue394break395396case 1 // type397temp1 = 7398Not(temp1)399object.propertyValue &= temp1400401temp0 = editor.variableValue402temp0 &= 7403object.propertyValue |= temp0404break405406case 3 // startDir407CheckNotEqual(editor.variableValue, false)408SetBit(object.propertyValue, 3, checkResult)409break410411end switch412end if413end event414415416event RSDKDraw417object.frame = object.propertyValue418object.frame >>= 4419object.frame %= 3420421DrawSprite(object.frame)422end event423424425event RSDKLoad426LoadSpriteSheet("MZ/Objects.gif")427SpriteFrame(-64, -48, 128, 80, 1, 324)428SpriteFrame(-64, -64, 128, 96, 317, 396)429SpriteFrame(-32, -48, 64, 96, 446, 396)430431AddEditorVariable("frameID")432SetActiveVariable("frameID")433AddEnumVariable("Arch", LARGEPLATFORM_TYPE_ARCH)434AddEnumVariable("Curved", LARGEPLATFORM_TYPE_CURVE)435AddEnumVariable("Rectangular", LARGEPLATFORM_TYPE_RECT)436437AddEditorVariable("moveType")438SetActiveVariable("moveType")439AddEnumVariable("Static", LARGEPLATFORM_STATIC)440AddEnumVariable("Move Vertically (Shortest)", LARGEPLATFORM_MOVE_V_SHORTEST)441AddEnumVariable("Move Vertically (Short)", LARGEPLATFORM_MOVE_V_SHORT)442AddEnumVariable("Move Vertically (Long)", LARGEPLATFORM_MOVE_V_LONG)443AddEnumVariable("Move Vertically (Longest)", LARGEPLATFORM_MOVE_V_LONGEST)444AddEnumVariable("Spawn Fireballs When Stood", LARGEPLATFORM_HASTENSION)445446AddEditorVariable("startDir")447SetActiveVariable("startDir")448AddEnumVariable("Down", 0)449AddEnumVariable("Up", 1)450end event451452453