Path: blob/master/Sonic 2/Scripts/MCZ/HPlatform.txt
1483 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.timer12private alias object.value1 : object.drawPos.x13private alias object.value2 : object.collisionOffset.x1415// Player Aliases16private alias object.xpos : player.xpos171819// ========================20// Function Declarations21// ========================2223reserve function HPlatform_DebugDraw24reserve function HPlatform_DebugSpawn252627// ========================28// Function Definitions29// ========================3031private function HPlatform_DebugDraw32DrawSprite(0)33end function343536private function HPlatform_DebugSpawn37CreateTempObject(TypeName[H Platform], 0, object.xpos, object.ypos)38object[tempObjectPos].drawPos.x = object[tempObjectPos].xpos39if object.direction == FLIP_NONE40object[tempObjectPos].drawPos.x += 0x68000041object[tempObjectPos].xvel = -0x1000042object[tempObjectPos].timer = 10443else44object[tempObjectPos].drawPos.x -= 0x68000045object[tempObjectPos].xvel = 0x1000046object[tempObjectPos].timer = -10447end if48end function495051// ========================52// Events53// ========================5455event ObjectUpdate56object.drawPos.x += object.xvel57object.collisionOffset.x = object.xvel5859if object.xvel > 060object.timer++61if object.timer == 10462FlipSign(object.xvel)63end if64else65object.timer--66if object.timer == -10467FlipSign(object.xvel)68end if69end if7071// Backup the object's XPos and temporarily move it for hitbox tests72temp0 = object.xpos73object.xpos = object.drawPos.x74foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)75BoxCollisionTest(C_PLATFORM, object.entityPos, -24, -8, 24, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)76if checkResult == true77player[currentPlayer].xpos += object.collisionOffset.x78end if79next8081// Move the object back82object.xpos = temp083end event848586event ObjectDraw87DrawSpriteXY(0, object.drawPos.x, object.ypos)88end event899091event ObjectStartup92LoadSpriteSheet("MCZ/Objects.gif")9394SpriteFrame(-24, -8, 48, 16, 141, 165)9596foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)97object[arrayPos0].drawPos.x = object[arrayPos0].xpos98if object[arrayPos0].propertyValue == 099object[arrayPos0].drawPos.x += 0x680000100object[arrayPos0].xvel = -0x10000101object[arrayPos0].timer = 104102else103object[arrayPos0].drawPos.x -= 0x680000104object[arrayPos0].xvel = 0x10000105object[arrayPos0].timer = -104106end if107next108109// Add this object to the debug item list110SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)111SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)112SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)113DebugMode_ObjCount++114end event115116117// ========================118// Editor Events119// ========================120121event RSDKEdit122if editor.returnVariable == true123switch editor.variableID124case EDIT_VAR_PROPVAL // property value125checkResult = object.propertyValue126break127128case 0 // startDir129checkResult = object.propertyValue130checkResult &= 1131break132133end switch134else135switch editor.variableID136case EDIT_VAR_PROPVAL // property value137object.propertyValue = editor.variableValue138break139140case 0 // startDir141object.propertyValue = editor.variableValue142break143144end switch145end if146end event147148149event RSDKDraw150DrawSprite(0)151152if editor.showGizmos == true153editor.drawingOverlay = true154155temp0 = object.xpos156temp0 -= 0x680000157temp1 = object.xpos158temp1 += 0x680000159DrawLine(object.xpos, object.ypos, temp0, object.ypos, 255, 255, 255)160161editor.drawingOverlay = false162end if163end event164165166event RSDKLoad167LoadSpriteSheet("MCZ/Objects.gif")168SpriteFrame(-24, -8, 48, 16, 141, 165)169170AddEditorVariable("startDir")171SetActiveVariable("startDir")172AddEnumVariable("Left", 0)173AddEnumVariable("Right", 1)174end event175176177