Path: blob/master/Sonic 2/Scripts/EHZ/VPlatform.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: V Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.centerPos.y12private alias object.value1 : object.collisionOffset.y1314// Player Aliases15private alias object.ypos : player.ypos161718// ========================19// Function Declarations20// ========================2122reserve function VPlatform_DebugDraw23reserve function VPlatform_DebugSpawn242526// ========================27// Function Definitions28// ========================2930private function VPlatform_DebugDraw31DrawSprite(0)32end function333435private function VPlatform_DebugSpawn36CreateTempObject(TypeName[V Platform], 0, object.xpos, object.ypos)37object[tempObjectPos].centerPos.y = object.ypos38object[tempObjectPos].propertyValue = object.direction39end function404142// ========================43// Events44// ========================4546event ObjectUpdate47temp7 = object.ypos4849GetTableValue(temp0, 12, StageSetup_oscillationTable)50if object.propertyValue == 151FlipSign(temp0)52temp0 += 0x400053else54temp0 -= 0x400055end if56temp0 <<= 85758object.ypos = object.centerPos.y59object.ypos -= temp06061temp1 = object.ypos62temp7 &= 0xFFFF000063object.collisionOffset.y = object.ypos64object.collisionOffset.y &= 0xFFFF000065object.collisionOffset.y -= temp76667object.ypos = temp768foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)69BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)70if checkResult == true71player[currentPlayer].ypos += object.collisionOffset.y72end if73next74object.ypos = temp175end event767778event ObjectDraw79DrawSprite(0)80end event818283event ObjectStartup84CheckCurrentStageFolder("Zone01")85if checkResult == true86LoadSpriteSheet("EHZ/Objects.gif")87SpriteFrame(-32, -12, 64, 32, 127, 98)88else89LoadSpriteSheet("MBZ/Objects.gif")90SpriteFrame(-32, -8, 64, 32, 1, 402)91end if9293foreach (TypeName[V Platform], arrayPos0, ALL_ENTITIES)94object[arrayPos0].centerPos.y = object[arrayPos0].ypos95next9697SetTableValue(TypeName[V Platform], DebugMode_ObjCount, DebugMode_TypesTable)98SetTableValue(VPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)99SetTableValue(VPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)100DebugMode_ObjCount++101end event102103104// ========================105// Editor Events106// ========================107108event RSDKEdit109if editor.returnVariable == true110switch editor.variableID111case EDIT_VAR_PROPVAL // property value112checkResult = object.propertyValue113break114115case 0 // startDir116checkResult = object.propertyValue117break118119end switch120else121switch editor.variableID122case EDIT_VAR_PROPVAL // property value123object.propertyValue = editor.variableValue124break125126case 0 // startDir127object.propertyValue = editor.variableValue128break129130end switch131end if132end event133134135event RSDKDraw136DrawSprite(0)137138if editor.showGizmos == true139// Draw some lines and ghosts to indicate where this platform is gonna go and that it's a vertical type140// (Otherwise it's just the generic platform sprite, which is shared between two other objects in EHZ)141142editor.drawingOverlay = true143144object.inkEffect = INK_BLEND145146temp0 = 0x408000147temp0 += object.ypos148DrawSpriteFX(0, FX_INK, object.xpos, temp0)149150temp1 = -0x3F8000151temp1 += object.ypos152DrawSpriteFX(0, FX_INK, object.xpos, temp1)153154object.inkEffect = INK_NONE155DrawArrow(object.xpos, temp0, object.xpos, temp1, 255, 255, 255)156DrawArrow(object.xpos, temp1, object.xpos, temp0, 255, 255, 255)157158editor.drawingOverlay = false159end if160end event161162163event RSDKLoad164CheckCurrentStageFolder("Zone01")165if checkResult == true166LoadSpriteSheet("EHZ/Objects.gif")167SpriteFrame(-32, -12, 64, 32, 127, 98)168else169LoadSpriteSheet("MBZ/Objects.gif")170SpriteFrame(-32, -8, 64, 32, 1, 402)171end if172173AddEditorVariable("startDir")174SetActiveVariable("startDir")175AddEnumVariable("Up", 0)176AddEnumVariable("Down", 1)177end event178179180