Path: blob/master/Sonic 1/Scripts/GHZ/HPlatform.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// 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 ObjectStartup119LoadSpriteSheet("GHZ/Objects.gif")120SpriteFrame(-32, -14, 64, 32, 50, 18)121122foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)123object[arrayPos0].centerPos.x = object[arrayPos0].xpos124object[arrayPos0].centerPos.y = object[arrayPos0].ypos125next126127SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)128SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)129SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)130DebugMode_ObjCount++131end event132133134// ========================135// Editor Events136// ========================137138event RSDKEdit139if editor.returnVariable == true140switch editor.variableID141case EDIT_VAR_PROPVAL // property value142checkResult = object.propertyValue143break144145case 0 // startDir146checkResult = object.propertyValue147break148149end switch150else151switch editor.variableID152case EDIT_VAR_PROPVAL // property value153object.propertyValue = editor.variableValue154break155156case 0 // startDir157object.propertyValue = editor.variableValue158break159160end switch161end if162end event163164165event RSDKDraw166if editor.showGizmos == true167editor.drawingOverlay = true168169// Draw ghosts of the platform's destination, notably *before* the main platform sprite is drawn170171object.inkEffect = INK_BLEND172173// Right end174temp0 = object.xpos175temp0 += 0x408000176177// Left end178temp1 = object.xpos179temp1 -= 0x408000180181DrawSpriteFX(0, FX_INK, temp0, object.ypos)182DrawSpriteFX(0, FX_INK, temp1, object.ypos)183184editor.drawingOverlay = false185end if186187DrawSprite(0)188189if editor.showGizmos == true190editor.drawingOverlay = true191192// Now draw some arrows, pulling from the temp values calculated before193194DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 255, 255, 255)195DrawArrow(object.xpos, object.ypos, temp1, object.ypos, 255, 255, 255)196197editor.drawingOverlay = false198end if199end event200201202event RSDKLoad203LoadSpriteSheet("GHZ/Objects.gif")204SpriteFrame(-32, -14, 64, 32, 50, 18)205206AddEditorVariable("startDir")207SetActiveVariable("startDir")208AddEnumVariable("Left", 0)209AddEnumVariable("Right", 1)210end event211212213