Path: blob/master/Sonic 2/Scripts/MPZ/CogPlatform.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Cog Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.startPos.x1213// Player Aliases14private alias object.state : player.state15private alias object.xpos : player.xpos16private alias object.animation : player.animation1718private alias object.value1 : player.timer19private alias object.value17 : debugMode.currentSelection2021// Path ID Aliases22private alias 0 : PATH_A232425// ========================26// Function Declarations27// ========================2829reserve function CogPlatform_DebugDraw30reserve function CogPlatform_DebugSpawn313233// ========================34// Static Values35// ========================3637private value CogPlatform_startDebugID = 0383940// ========================41// Function Definitions42// ========================4344private function CogPlatform_DebugDraw45DrawSprite(0)46end function474849private function CogPlatform_DebugSpawn50temp0 = debugMode[0].currentSelection51temp0 -= CogPlatform_startDebugID52CreateTempObject(TypeName[Cog Platform], temp0, object.xpos, object.ypos)53object[tempObjectPos].direction = object.direction54end function555657// ========================58// Events59// ========================6061event ObjectUpdate62temp0 = object.xpos63temp0 &= 0xFFFF00006465object.xpos += object.xvel66if object.direction == FLIP_NONE67ObjectTileCollision(CSIDE_LWALL, 64, 0, PATH_A)68else69ObjectTileCollision(CSIDE_RWALL, -64, 0, PATH_A)70end if7172if checkResult == true73if object.propertyValue == 074object.xvel = 075MPZSetup_cogTimer = 076MPZSetup_cogFrame = 077else78object.direction ^= FLIP_X79FlipSign(object.xvel)80FlipSign(MPZSetup_cogFrame)81end if82end if8384temp4 = object.xpos85temp2 = object.xpos86temp2 &= 0xFFFF000087temp2 -= temp08889object.xpos = temp090foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)91BoxCollisionTest(C_SOLID, object.entityPos, -64, -12, 64, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)92switch checkResult93case COL_TOP94if object.xvel == 095object.priority = PRIORITY_ACTIVE96if object.direction == FLIP_NONE97object.xvel = 0x2000098MPZSetup_cogTimer = -199else100object.xvel = -0x20000101MPZSetup_cogTimer = 1102end if103end if104player[currentPlayer].xpos += temp2105break106107case COL_LEFT108case COL_RIGHT109if player[currentPlayer].state == Player_State_Climb110player[currentPlayer].timer = 0111player[currentPlayer].animation = ANI_GLIDING_DROP112player[currentPlayer].state = Player_State_GlideDrop113end if114break115116end switch117next118119object.xpos = temp4120121if object.outOfBounds == true122if object.startPos.x == 0 // It will only be 0 if the Platform was spawned via Debug Mode123object.type = TypeName[Blank Object]124else125object.xpos = object.startPos.x126if object.outOfBounds == false127object.xpos = temp4128else129object.priority = PRIORITY_BOUNDS130object.xvel = 0131MPZSetup_cogTimer = 0132MPZSetup_cogFrame = 0133end if134end if135end if136end event137138139event ObjectDraw140DrawSprite(0)141end event142143144event ObjectStartup145LoadSpriteSheet("MPZ/Objects.gif")146SpriteFrame(-64, -12, 128, 24, 350, 182)147148// Nothing too notable but normally setup foreaches are before the Debug Mode table additions, but here they're switched around in order149150temp0 = 0151CogPlatform_startDebugID = DebugMode_ObjCount152while temp0 < 2153SetTableValue(TypeName[Cog Platform], DebugMode_ObjCount, DebugMode_TypesTable)154SetTableValue(CogPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)155SetTableValue(CogPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)156DebugMode_ObjCount++157temp0++158loop159160foreach (TypeName[Cog Platform], arrayPos0, ALL_ENTITIES)161object[arrayPos0].startPos.x = object[arrayPos0].xpos162next163end event164165166// ========================167// Editor Events168// ========================169170event RSDKEdit171if editor.returnVariable == true172switch editor.variableID173case EDIT_VAR_PROPVAL // property value174checkResult = object.propertyValue175break176177case 0 // type178checkResult = object.propertyValue179break180181end switch182else183switch editor.variableID184case EDIT_VAR_PROPVAL // property value185object.propertyValue = editor.variableValue186break187188case 0 // type189object.propertyValue = editor.variableValue190break191192end switch193end if194end event195196197event RSDKDraw198DrawSprite(0)199end event200201202event RSDKLoad203LoadSpriteSheet("MPZ/Objects.gif")204SpriteFrame(-64, -12, 128, 24, 350, 182)205206AddEditorVariable("type")207SetActiveVariable("type")208AddEnumVariable("Stop On Contact", 0)209AddEnumVariable("Swap Direction On Contact", 1)210end event211212213