Path: blob/master/Sonic 1/Scripts/SBZ/FZPiston.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: FZ Piston Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.propertyValue : object.hasEggman1213private alias object.value0 : object.fzEggmanSlot14private alias object.value3 : object.timer15private alias object.value4 : object.explosionTimer1617// Piston States18private alias 0 : FZPISTON_IDLE19private alias 1 : FZPISTON_SETUP_CRUSHING20private alias 2 : FZPISTON_CRUSHING21private alias 3 : FZPISTON_SETUP_RETRACT22private alias 4 : FZPISTON_RETRACTING23private alias 5 : FZPISTON_SETUP_DESTROYED24private alias 6 : FZPISTON_DESTROYED2526// Eggman aliases27private alias object.value0 : fzEggman.timer28private alias object.value2 : fzEggman.health // Health counts up instead of down this time...2930// Player Aliases31private alias object.ypos : player.ypos32private alias object.gravity : player.gravity333435// ========================36// Events37// ========================3839event ObjectUpdate40switch object.state41case FZPISTON_IDLE42// Waiting...43break4445case FZPISTON_SETUP_CRUSHING46object.timer = 3147object.yvel = -0x800048if object.direction != FLIP_NONE49FlipSign(object.yvel)50end if51object.state++52break5354case FZPISTON_CRUSHING55object.timer--56if object.timer <= 057object.state++58end if59break6061case FZPISTON_SETUP_RETRACT62object.timer = 4863object.yvel = -0x3000064if object.direction != FLIP_NONE65FlipSign(object.yvel)66end if67object.state++68break6970case FZPISTON_RETRACTING71object.timer--72if object.timer <= 073object.timer = 8074object.yvel = 0x2000075if object.direction != FLIP_NONE76FlipSign(object.yvel)77end if78object.state++79end if80break8182case FZPISTON_SETUP_DESTROYED83case FZPISTON_DESTROYED84object.timer--85if object.timer <= 086object.yvel = 087object.hasEggman = false88object.state = FZPISTON_IDLE89end if90break9192end switch9394temp0 = object.ypos95temp0 += object.yvel96temp0 &= 0xFFFF000097temp1 = object.ypos98temp1 &= 0xFFFF000099temp0 -= temp1100101foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)102if object.direction == 0103BoxCollisionTest(C_SOLID2, object.entityPos, -32, -96, 32, 160, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)104else105BoxCollisionTest(C_SOLID2, object.entityPos, -32, -160, 32, 96, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)106end if107108switch checkResult109case COL_TOP110player[currentPlayer].ypos += temp0111break112113case COL_BOTTOM114if player[currentPlayer].gravity == 0115if object.yvel > 0116CallFunction(Player_Kill)117end if118end if119break120121end switch122next123124object.ypos += object.yvel125arrayPos0 = object.fzEggmanSlot126if object.hasEggman == true127object[arrayPos0].xpos = object.xpos128object[arrayPos0].ypos = object.ypos129if object.direction == 0130object[arrayPos0].ypos -= 0xA0000131else132object[arrayPos0].ypos += 0xE0000133end if134end if135136if object.state > FZPISTON_RETRACTING137if fzEggman[arrayPos0].health == 8138if object.state == FZPISTON_SETUP_DESTROYED139object.state++140object.timer <<= 1141object.timer--142object.yvel >>= 1143fzEggman[arrayPos0].timer = 160144arrayPos0 += 6145if object[arrayPos0].state == 0146object[arrayPos0].state++147end if148end if149150object.explosionTimer++151temp0 = object.explosionTimer152temp0 &= 7153if temp0 == 4154Rand(temp0, 96)155temp0 -= 48156temp0 <<= 16157temp0 += object.xpos158Rand(temp1, 48)159temp1 -= 24160temp1 <<= 16161temp1 += object.ypos162CreateTempObject(TypeName[Explosion], 0, temp0, temp1)163object[tempObjectPos].drawOrder = 5164PlaySfx(SfxName[Explosion], false)165end if166end if167end if168end event169170171event ObjectDraw172DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)173end event174175176event ObjectStartup177LoadSpriteSheet("SBZ/Objects.gif")178179// Piston frame180SpriteFrame(-32, -96, 64, 216, 124, 66)181182foreach (TypeName[FZ Piston], arrayPos0, ALL_ENTITIES)183object[arrayPos0].drawOrder = 4184next185end event186187188// ========================189// Editor Events190// ========================191192event RSDKDraw193DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)194end event195196197event RSDKLoad198LoadSpriteSheet("SBZ/Objects.gif")199SpriteFrame(-32, -96, 64, 216, 124, 66)200201// Used by the boss, but not by the scene file itself202SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")203end event204205206