Path: blob/master/Sonic 1/Scripts/SBZ/Piston.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Piston Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.moveDistance12private alias object.value1 : object.movePos13private alias object.value2 : object.timer1415// Player Aliases16private alias object.ypos : player.ypos17private alias object.gravity : player.gravity1819private alias object.value17 : debugMode.currentSelection202122// ========================23// Function Declarations24// ========================2526reserve function Piston_DebugDraw27reserve function Piston_DebugSpawn282930// ========================31// Static Values32// ========================3334private value Piston_startDebugID = 0353637// ========================38// Tables39// ========================4041private table Piston_moveDistances420x380000, 0x400000, 0x60000043end table444546// ========================47// Function Definitions48// ========================4950private function Piston_DebugDraw51temp0 = debugMode[0].currentSelection52temp0 -= Piston_startDebugID53DrawSprite(0)54end function555657private function Piston_DebugSpawn58temp0 = debugMode[0].currentSelection59temp0 -= Piston_startDebugID60CreateTempObject(TypeName[Piston], temp0, object.xpos, object.ypos)61GetTableValue(object[tempObjectPos].moveDistance, object[tempObjectPos].propertyValue, Piston_moveDistances)62end function636465// ========================66// Events67// ========================6869event ObjectUpdate70if object.timer != 071object.timer--72object.yvel = 073else74if object.direction == FLIP_NONE75object.yvel = 0x8000076object.movePos += object.yvel7778if object.movePos >= object.moveDistance79object.direction ^= FLIP_X80if object.propertyValue != 081object.timer = 6082end if83end if84else85if object.propertyValue != 086object.yvel = -0x8000087else88object.yvel = -0x1000089end if9091object.movePos += object.yvel92if object.movePos <= 093object.direction ^= FLIP_X94object.timer = 6095end if96end if97end if9899foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)100BoxCollisionTest(C_SOLID2, object.entityPos, -28, -32, 28, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)101switch checkResult102case COL_TOP103player[currentPlayer].ypos += object.yvel104break105106case COL_BOTTOM107if player[currentPlayer].gravity == GRAVITY_GROUND108if object.yvel > 0109CallFunction(Player_Kill)110end if111end if112break113114end switch115next116117object.ypos += object.yvel118end event119120121event ObjectDraw122DrawSprite(0)123end event124125126event ObjectStartup127LoadSpriteSheet("SBZ/Objects.gif")128SpriteFrame(-28, -32, 56, 64, 132, 1)129130foreach (TypeName[Piston], arrayPos0, ALL_ENTITIES)131GetTableValue(object[arrayPos0].moveDistance, object[arrayPos0].propertyValue, Piston_moveDistances)132next133134temp0 = 0135Piston_startDebugID = DebugMode_ObjCount136while temp0 < 3137SetTableValue(TypeName[Piston], DebugMode_ObjCount, DebugMode_TypesTable)138SetTableValue(Piston_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)139SetTableValue(Piston_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)140DebugMode_ObjCount++141temp0++142loop143end event144145146// ========================147// Editor Events148// ========================149150event RSDKEdit151if editor.returnVariable == true152switch editor.variableID153case EDIT_VAR_PROPVAL // property value154checkResult = object.propertyValue155checkResult %= 3156break157158case 0 // moveDist159checkResult = object.propertyValue160checkResult %= 3161break162163end switch164else165switch editor.variableID166case EDIT_VAR_PROPVAL // property value167object.propertyValue = editor.variableValue168object.propertyValue %= 3169break170171case 0 // moveDist172object.propertyValue = editor.variableValue173object.propertyValue %= 3174break175176end switch177end if178end event179180181event RSDKDraw182DrawSprite(0)183184if editor.showGizmos == true185editor.drawingOverlay = true186187temp0 = object.propertyValue188temp0 %= 3189GetTableValue(object.moveDistance, temp0, Piston_moveDistances)190191temp1 = object.ypos192temp1 += object.moveDistance193194object.inkEffect = INK_BLEND195DrawSpriteFX(0, FX_INK, object.xpos, temp1)196197editor.drawingOverlay = false198end if199end event200201202event RSDKLoad203LoadSpriteSheet("SBZ/Objects.gif")204SpriteFrame(-28, -32, 56, 64, 132, 1)205206AddEditorVariable("moveDist")207SetActiveVariable("moveDist")208AddEnumVariable("56 Pixels", 0)209AddEnumVariable("64 Pixels", 1)210AddEnumVariable("96 Pixels", 2)211end event212213214