Path: blob/master/Sonic 2/Scripts/MPZ/SmallPiston.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Small Piston 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.startPos.y13private alias object.value2 : object.stoodPlayers14private alias object.value31 : object.wrapOffset.y1516// States17private alias 0 : SMALLPISTON_IDLE_UP18private alias 1 : SMALLPISTON_MOVEDOWN19private alias 2 : SMALLPISTON_IDLE_DOWN20private alias 3 : SMALLPISTON_MOVEUP2122// Player Aliases23private alias object.ypos : player.ypos24private alias object.gravity : player.gravity252627// ========================28// Function Declarations29// ========================3031reserve function SmallPiston_Setup32reserve function SmallPiston_DebugDraw33reserve function SmallPiston_DebugSpawn343536// ========================37// Function Definitions38// ========================3940private function SmallPiston_Setup41object[arrayPos0].ypos = object[arrayPos0].startPos.y42object[arrayPos0].ypos += object[arrayPos0].wrapOffset.y43object[arrayPos0].timer = 9044object[arrayPos0].stoodPlayers = 045object[arrayPos0].state = SMALLPISTON_IDLE_UP46object[arrayPos0].priority = PRIORITY_BOUNDS47end function484950private function SmallPiston_DebugDraw51DrawSprite(0)52end function535455private function SmallPiston_DebugSpawn56CreateTempObject(TypeName[Small Piston], 0, object.xpos, object.ypos)57arrayPos0 = object[tempObjectPos].entityPos58object[arrayPos0].startPos.y = object.ypos59CallFunction(SmallPiston_Setup)60end function616263// ========================64// Events65// ========================6667event ObjectUpdate68temp0 = object.ypos69switch object.state70case SMALLPISTON_IDLE_UP71object.timer--72if object.timer == 073object.priority = PRIORITY_ACTIVE74object.timer = 875object.state = SMALLPISTON_MOVEDOWN76end if77break7879case SMALLPISTON_MOVEDOWN80object.ypos += 0x800008182object.timer--83if object.timer == 084object.timer = 9085object.state = SMALLPISTON_IDLE_DOWN86end if87break8889case SMALLPISTON_IDLE_DOWN90object.timer--91if object.timer == 092object.timer = 893object.state = SMALLPISTON_MOVEUP94end if95break9697case SMALLPISTON_MOVEUP98object.ypos -= 0x8000099100object.timer--101if object.timer == 0102object.timer = 90103object.state = SMALLPISTON_IDLE_UP104end if105break106107end switch108109temp1 = object.ypos110temp1 -= temp0111112temp2 = 0113foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)114GetBit(temp0, object.stoodPlayers, temp2)115if temp0 == true116player[currentPlayer].ypos += temp1117end if118119SetBit(object.stoodPlayers, temp2, false)120BoxCollisionTest(C_SOLID, object.entityPos, -16, -32, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)121switch checkResult122case COL_TOP123SetBit(object.stoodPlayers, temp2, true)124break125126case COL_BOTTOM127if player[currentPlayer].gravity == GRAVITY_GROUND128CallFunction(Player_Kill)129end if130break131132end switch133temp2++134next135136if object.outOfBounds == true137arrayPos0 = object.entityPos138CallFunction(SmallPiston_Setup)139end if140end event141142143event ObjectDraw144DrawSprite(0)145end event146147148event ObjectStartup149LoadSpriteSheet("MPZ/Objects.gif")150SpriteFrame(-16, -32, 32, 64, 1, 70)151152foreach (TypeName[Small Piston], arrayPos0, ALL_ENTITIES)153object[arrayPos0].startPos.y = object[arrayPos0].ypos154CallFunction(SmallPiston_Setup)155next156157SetTableValue(TypeName[Small Piston], DebugMode_ObjCount, DebugMode_TypesTable)158SetTableValue(SmallPiston_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)159SetTableValue(SmallPiston_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)160DebugMode_ObjCount++161end event162163164// ========================165// Editor Events166// ========================167168event RSDKDraw169DrawSprite(0)170end event171172173event RSDKLoad174LoadSpriteSheet("MPZ/Objects.gif")175SpriteFrame(-16, -32, 32, 64, 1, 70)176177SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")178end event179180181