Path: blob/master/Sonic 1/Scripts/SYZ/HBlock.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: H Block Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.amplitude.x12private alias object.value1 : object.drawPos.x13private alias object.value2 : object.collisionOffset.x1415// Player Aliases16private alias object.value17 : debugMode.currentSelection1718// Player Aliases19private alias object.xpos : player.xpos20private alias object.gravity : player.gravity2122// ========================23// Function Declarations24// ========================2526reserve function HBlock_DebugDraw27reserve function HBlock_DebugSpawn282930// ========================31// Static Values32// ========================3334private value HBlock_startDebugID = 0353637// ========================38// Function Definitions39// ========================4041private function HBlock_DebugDraw42DrawSprite(0)43end function444546private function HBlock_DebugSpawn47CreateTempObject(TypeName[H Block], object.direction, object.xpos, object.ypos)4849temp0 = debugMode[0].currentSelection50temp0 -= HBlock_startDebugID51if temp0 == 052if object.direction == FLIP_NONE53object[tempObjectPos].amplitude.x = 0x200054else55object[tempObjectPos].amplitude.x = -0x200056end if57else58if object.direction == FLIP_NONE59object[tempObjectPos].amplitude.x = 0x100060else61object[tempObjectPos].amplitude.x = -0x100062end if63end if64end function656667// ========================68// Events69// ========================7071event ObjectUpdate72object.angle = SYZSetup_oscillation73object.angle *= 0x20074object.angle /= 3567576Sin(object.collisionOffset.x, object.angle)77object.collisionOffset.x *= object.amplitude.x78object.collisionOffset.x += object.xpos79object.collisionOffset.x &= 0xFFFF000080object.collisionOffset.x -= object.drawPos.x8182foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)83temp0 = object.xpos84object.xpos = object.drawPos.x85temp1 = player[currentPlayer].gravity86BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)87if checkResult == COL_TOP88if temp1 == GRAVITY_AIR89player[currentPlayer].xpos += object.collisionOffset.x90end if91end if92object.xpos = temp093next94end event959697event ObjectDraw98Sin(object.drawPos.x, object.angle)99object.drawPos.x *= object.amplitude.x100object.drawPos.x += object.xpos101object.drawPos.x &= 0xFFFF0000102103DrawSpriteXY(0, object.drawPos.x, object.ypos)104end event105106107event ObjectStartup108LoadSpriteSheet("SYZ/Objects.gif")109SpriteFrame(-16, -16, 32, 32, 119, 34)110111foreach (TypeName[H Block], arrayPos0, ALL_ENTITIES)112switch object[arrayPos0].propertyValue113case 0114object[arrayPos0].amplitude.x = 0x2000115break116117case 1118object[arrayPos0].amplitude.x = 0x1000119break120121case 2122object[arrayPos0].amplitude.x = -0x1000123break124125case 3126object[arrayPos0].amplitude.x = -0x2000127break128129end switch130next131132temp0 = 0133HBlock_startDebugID = DebugMode_ObjCount134while temp0 < 2135SetTableValue(TypeName[H Block], DebugMode_ObjCount, DebugMode_TypesTable)136SetTableValue(HBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)137SetTableValue(HBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)138DebugMode_ObjCount++139temp0++140loop141end event142143144// ========================145// Editor Events146// ========================147148event RSDKEdit149if editor.returnVariable == true150switch editor.variableID151case EDIT_VAR_PROPVAL // property value152checkResult = object.propertyValue153checkResult &= 3154break155156case 0 // moveSpeed157checkResult = object.propertyValue158checkResult &= 3159break160161end switch162else163switch editor.variableID164case EDIT_VAR_PROPVAL // property value165object.propertyValue = editor.variableValue166object.propertyValue &= 3167break168169case 0 // moveSpeed170object.propertyValue = editor.variableValue171object.propertyValue &= 3172break173174end switch175end if176end event177178179event RSDKDraw180DrawSprite(0)181182if editor.showGizmos == true183editor.drawingOverlay = true184185// Draw the block's starting position186187switch object.propertyValue188case 0189object.amplitude.x = 0x2000190break191192case 1193object.amplitude.x = 0x1000194break195196case 2197object.amplitude.x = -0x1000198break199200case 3201object.amplitude.x = -0x2000202break203204end switch205206object.inkEffect = INK_BLEND207Sin(object.drawPos.x, 0x80)208object.drawPos.x *= object.amplitude.x209object.drawPos.x += object.xpos210object.drawPos.x &= 0xFFFF0000211212DrawSpriteFX(0, FX_INK, object.drawPos.x, object.ypos)213214switch object.propertyValue215case 0216case 3217// Draw an arrow for the block's full path218FlipSign(object.amplitude.x)219Sin(temp0, 0x80)220temp0 *= object.amplitude.x221temp0 += object.xpos222temp0 &= 0xFFFF0000223DrawArrow(object.drawPos.x, object.ypos, temp0, object.ypos, 255, 255, 255)224break225226end switch227228editor.drawingOverlay = false229end if230end event231232233event RSDKLoad234LoadSpriteSheet("SYZ/Objects.gif")235SpriteFrame(-16, -16, 32, 32, 119, 34)236237AddEditorVariable("moveSpeed")238SetActiveVariable("moveSpeed")239AddEnumVariable("Fast", 0)240AddEnumVariable("Slow", 1)241AddEnumVariable("Fast (Reverse)", 2)242AddEnumVariable("Slow (Reverse)", 3)243end event244245246