Path: blob/master/Sonic 2/Scripts/EHZ/HPlatform.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: H 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.centerPos.x13private alias object.value2 : object.centerPos.y14private alias object.value3 : object.collisionOffset.x15private alias object.value4 : object.collisionOffset.y16private alias object.value5 : object.stoodAngle1718// Player Aliases19private alias object.xpos : player.xpos20private alias object.ypos : player.ypos212223// ========================24// Function Declarations25// ========================2627reserve function HPlatform_DebugDraw28reserve function HPlatform_DebugSpawn293031// ========================32// Function Definitions33// ========================3435private function HPlatform_DebugDraw36DrawSprite(0)37end function383940private function HPlatform_DebugSpawn41CreateTempObject(TypeName[H Platform], 0, object.xpos, object.ypos)42object[tempObjectPos].centerPos.x = object.xpos43object[tempObjectPos].centerPos.y = object.ypos44object[tempObjectPos].propertyValue = object.direction45end function464748// ========================49// Events50// ========================5152event ObjectUpdate53temp6 = object.xpos54temp7 = object.ypos5556GetTableValue(temp0, 12, StageSetup_oscillationTable)57if object.propertyValue == 158FlipSign(temp0)59temp0 += 0x400060else61temp0 -= 0x400062end if63temp0 <<= 864object.xpos = object.centerPos.x65object.xpos -= temp06667if object.stood == true68if object.stoodAngle < 6469object.stoodAngle += 470end if71else72if object.stoodAngle > 073object.stoodAngle -= 474end if75end if7677temp0 = object.stoodAngle78temp0 <<= 179Sin(temp1, temp0)80temp1 <<= 981object.ypos = object.centerPos.y82object.ypos += temp18384object.stood = false85temp0 = object.xpos86temp1 = object.ypos87temp6 &= 0xFFFF000088temp7 &= 0xFFFF000089object.collisionOffset.x = object.xpos90object.collisionOffset.x &= 0xFFFF000091object.collisionOffset.x -= temp692object.collisionOffset.y = object.ypos93object.collisionOffset.y &= 0xFFFF000094object.collisionOffset.y -= temp79596object.xpos = temp697object.ypos = temp79899foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)100BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)101if checkResult == true102object.stood = true103player[currentPlayer].xpos += object.collisionOffset.x104player[currentPlayer].ypos += object.collisionOffset.y105end if106next107108object.xpos = temp0109object.ypos = temp1110end event111112113event ObjectDraw114DrawSprite(0)115end event116117118event ObjectStartup119CheckCurrentStageFolder("Zone01")120if checkResult == true121LoadSpriteSheet("EHZ/Objects.gif")122SpriteFrame(-32, -12, 64, 32, 127, 98)123else124LoadSpriteSheet("MBZ/Objects.gif")125SpriteFrame(-32, -8, 64, 32, 1, 402)126end if127128foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)129object[arrayPos0].centerPos.x = object[arrayPos0].xpos130object[arrayPos0].centerPos.y = object[arrayPos0].ypos131next132133SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)134SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)135SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)136DebugMode_ObjCount++137end event138139140// ========================141// Editor Events142// ========================143144event RSDKEdit145if editor.returnVariable == true146switch editor.variableID147case EDIT_VAR_PROPVAL // property value148checkResult = object.propertyValue149break150151case 0 // startDir152checkResult = object.propertyValue153break154155end switch156else157switch editor.variableID158case EDIT_VAR_PROPVAL // property value159object.propertyValue = editor.variableValue160break161162case 0 // startDir163object.propertyValue = editor.variableValue164break165166end switch167end if168end event169170171event RSDKDraw172if editor.showGizmos == true173editor.drawingOverlay = true174175// Draw ghosts of the platform's destination, notably *before* the main platform sprite is drawn176177object.inkEffect = INK_BLEND178179// Right end180temp0 = object.xpos181temp0 += 0x408000182183// Left end184temp1 = object.xpos185temp1 -= 0x408000186187DrawSpriteFX(0, FX_INK, temp0, object.ypos)188DrawSpriteFX(0, FX_INK, temp1, object.ypos)189190object.inkEffect = INK_NONE191192editor.drawingOverlay = false193end if194195DrawSprite(0)196197if editor.showGizmos == true198editor.drawingOverlay = true199200// Now draw some arrows, pulling from the temp values calculated before201DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 255, 255, 255)202DrawArrow(object.xpos, object.ypos, temp1, object.ypos, 255, 255, 255)203204editor.drawingOverlay = false205end if206end event207208209event RSDKLoad210CheckCurrentStageFolder("Zone01")211if checkResult == true212LoadSpriteSheet("EHZ/Objects.gif")213SpriteFrame(-32, -12, 64, 32, 127, 98)214else215LoadSpriteSheet("MBZ/Objects.gif")216SpriteFrame(-32, -8, 64, 32, 1, 402)217end if218219AddEditorVariable("startDir")220SetActiveVariable("startDir")221AddEnumVariable("Left", 0)222AddEnumVariable("Right", 1)223end event224225226