Path: blob/master/Sonic 2/Scripts/CPZ/HPlatform.txt
1479 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.centerPos.x12private alias object.value1 : object.hitboxL13private alias object.value2 : object.hitboxR14private alias object.value3 : object.stoodPlayers1516// Player Aliases17private alias object.xpos : player.xpos1819private alias object.value17 : debugMode.currentSelection202122// ========================23// Function Declarations24// ========================2526reserve function HPlatform_DebugDraw27reserve function HPlatform_DebugSpawn282930// ========================31// Static Values32// ========================3334private value HPlatform_debugStartID = 0353637// ========================38// Function Definitions39// ========================4041private function HPlatform_DebugDraw42temp0 = debugMode[0].currentSelection43temp0 -= HPlatform_debugStartID44DrawSprite(temp0)45end function464748private function HPlatform_DebugSpawn49temp0 = debugMode[0].currentSelection50temp0 -= HPlatform_debugStartID51CreateTempObject(TypeName[H Platform], temp0, object.xpos, object.ypos)5253object[tempObjectPos].centerPos.x = object.xpos54object[tempObjectPos].direction = object.direction55if object[tempObjectPos].propertyValue == 056object[tempObjectPos].hitboxL = -3257object[tempObjectPos].hitboxR = 3258else59object[tempObjectPos].hitboxL = -2460object[tempObjectPos].hitboxR = 2461end if62end function636465// ========================66// Events67// ========================6869event ObjectUpdate70temp6 = object.xpos71GetTableValue(temp0, 6, StageSetup_oscillationTable)72if object.direction == FLIP_X // (FLIP_XY won't flip the platform, so don't try that)73FlipSign(temp0)74temp0 += 0x600075end if76temp0 <<= 87778object.xpos = object.centerPos.x79object.xpos -= temp080temp6 &= 0xFFFF000081temp7 = object.xpos82temp7 &= 0xFFFF000083temp7 -= temp68485temp2 = 086foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)87GetBit(temp0, object.stoodPlayers, temp2)88if temp0 == true89player[currentPlayer].xpos += temp790end if9192SetBit(object.stoodPlayers, temp2, false)93BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitboxL, -16, object.hitboxR, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)94if checkResult == true95SetBit(object.stoodPlayers, temp2, true)96end if9798temp2++99next100end event101102103event ObjectDraw104DrawSprite(object.propertyValue)105end event106107108event ObjectStartup109LoadSpriteSheet("CPZ/Objects.gif")110SpriteFrame(-32, -16, 64, 27, 136, 155)111SpriteFrame(-24, -16, 48, 26, 136, 183)112113foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)114object[arrayPos0].centerPos.x = object[arrayPos0].xpos115if object[arrayPos0].propertyValue == 0116object[arrayPos0].hitboxL = -32117object[arrayPos0].hitboxR = 32118else119object[arrayPos0].hitboxL = -24120object[arrayPos0].hitboxR = 24121end if122next123124temp0 = 0125HPlatform_debugStartID = DebugMode_ObjCount126while temp0 < 2127SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)128SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)129SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)130DebugMode_ObjCount++131temp0++132loop133end event134135136// ========================137// Editor Events138// ========================139140event RSDKEdit141if editor.returnVariable == true142switch editor.variableID143case EDIT_VAR_PROPVAL // property value144checkResult = object.propertyValue145break146147case 0 // type148checkResult = object.propertyValue149break150151end switch152else153switch editor.variableID154case EDIT_VAR_PROPVAL // property value155object.propertyValue = editor.variableValue156break157158case 0 // type159object.propertyValue = editor.variableValue160break161162end switch163end if164end event165166167event RSDKDraw168DrawSprite(object.propertyValue)169170if editor.showGizmos == true171// Draw arrows to indicate that this is an H platform172173editor.drawingOverlay = true174175temp0 = object.xpos176temp0 -= 0x320000177DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 0, 224, 0)178temp0 = object.xpos179temp0 += 0x320000180DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 0, 224, 0)181182editor.drawingOverlay = false183end if184end event185186187event RSDKLoad188LoadSpriteSheet("CPZ/Objects.gif")189SpriteFrame(-32, -16, 64, 27, 136, 155)190SpriteFrame(-24, -16, 48, 26, 136, 183)191192AddEditorVariable("type")193SetActiveVariable("type")194AddEnumVariable("Large", 0)195AddEnumVariable("Small", 1)196end event197198199