Path: blob/main/Scripts/R4/Escalator.txt
1319 views
//----------------Sonic CD Escalator Script-------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer6#alias Object.Value1 : Object.OnObject7#alias Object.Value2 : Object.Speed8#alias Object.Value3 : Object.TimerSet910// HUD alias11#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1213// States14#alias 0 : ESCALATOR_IDLE15#alias 1 : ESCALATOR_ASCEND16#alias 2 : ESCALATOR_STOPPED17#alias 3 : ESCALATOR_RESTORE1819// Player Collision20#alias 1 : PLAYER_COL_FLOOR2122// Time Periods23#alias 0 : TIME_PRESENT24#alias 1 : TIME_PAST25#alias 2 : TIME_GOOD_FUTURE26#alias 3 : TIME_BAD_FUTURE2728// Priority29#alias 0 : PRIORITY_BOUNDS30#alias 1 : PRIORITY_ACTIVE31323334sub ObjectMain35switch Object.State36case ESCALATOR_ASCEND37if Object.Timer > 038Object.Timer--39Object.XPos += Object.Speed40Object.YPos -= Object.Speed41else42Object.State++43end if44break4546case ESCALATOR_STOPPED47if Object.OutOfBounds == true48Object.State = ESCALATOR_RESTORE49Object.XPos -= 0xA0000050Object.YPos += 0xA0000051end if52break5354case ESCALATOR_RESTORE55if Object.OutOfBounds == true56Object.State = ESCALATOR_IDLE57Object.Priority = PRIORITY_BOUNDS58end if59break60end switch61end sub626364sub ObjectPlayerInteraction65switch Object.State66case ESCALATOR_IDLE67PlayerObjectCollision(C_BOX, -16, -16, 16, 16)68if CheckResult == PLAYER_COL_FLOOR69Object.State = ESCALATOR_ASCEND70Object.Timer = Object.TimerSet71Object.Priority = PRIORITY_ACTIVE7273Player.TileCollisions = false7475Object.OnObject = true76else77if Object.OnObject == true78Player.TileCollisions = true79end if8081Object.OnObject = false82end if83break8485case ESCALATOR_ASCEND86PlayerObjectCollision(C_BOX, -16, -16, 16, 16)87if CheckResult == PLAYER_COL_FLOOR88Player.XPos += Object.Speed8990Player.TileCollisions = false9192Object.OnObject = true9394PlayerObjectCollision(C_BOX, 20, -32, 32, -16)95Player.Pushing = false96else97if Object.OnObject == true98Player.TileCollisions = true99end if100101Object.OnObject = false102end if103break104105case ESCALATOR_STOPPED106Player.Pushing = false107PlayerObjectCollision(C_BOX, -16, -16, 16, 16)108if CheckResult == PLAYER_COL_FLOOR109Player.TileCollisions = false110111Object.OnObject = true112else113if Object.OnObject == true114Player.TileCollisions = true115end if116Object.OnObject = false117end if118break119120end switch121end sub122123124sub ObjectDraw125if Object.State < ESCALATOR_RESTORE126DrawSprite(0)127end if128end sub129130131sub ObjectStartup132switch HUD.CurrentTimePeriod133case TIME_PRESENT134case TIME_PAST135LoadSpriteSheet("R4/Objects.gif")136SpriteFrame(-16, -16, 32, 32, 130, 1) // #0 - Escalator137break138139case TIME_GOOD_FUTURE140LoadSpriteSheet("R4/Objects3.gif")141SpriteFrame(-16, -16, 32, 32, 1, 150) // #0 - Escalator142break143144case TIME_BAD_FUTURE145LoadSpriteSheet("R4/Objects3.gif")146SpriteFrame(-16, -16, 32, 32, 1, 183) // #0 - Escalator147break148149end switch150151ArrayPos0 = 32152while ArrayPos0 < 1056153if Object[ArrayPos0].Type == TypeName[Escalator]154if HUD.CurrentTimePeriod < 2 // aka present or past155Object[ArrayPos0].Speed = 0x10000156Object[ArrayPos0].TimerSet = 160157else158Object[ArrayPos0].Speed = 0x20000159Object[ArrayPos0].TimerSet = 80160end if161end if162ArrayPos0++163loop164end sub165166167// ========================168// Editor Subs169// ========================170171sub RSDKDraw172DrawSprite(0)173end sub174175176sub RSDKLoad177CallFunction(EditorHelpers_FindTimePeriod)178switch CheckResult179case TIME_PRESENT180case TIME_PAST181LoadSpriteSheet("R4/Objects.gif")182SpriteFrame(-16, -16, 32, 32, 130, 1) // #0 - Escalator183break184185case TIME_GOOD_FUTURE186LoadSpriteSheet("R4/Objects3.gif")187SpriteFrame(-16, -16, 32, 32, 1, 150) // #0 - Escalator188break189190case TIME_BAD_FUTURE191LoadSpriteSheet("R4/Objects3.gif")192SpriteFrame(-16, -16, 32, 32, 1, 183) // #0 - Escalator193break194195end switch196197SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")198end sub199200201