Path: blob/main/Scripts/R4/HorizontalDoor.txt
1319 views
//---------------Sonic CD Horizontal Door 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.CloseBehaviour78// HUD alias9#alias Object[24].PropertyValue : HUD.CurrentTimePeriod1011// Push Button alias12#alias Object.PropertyValue : PushButton.Pressed1314// Property Values15// At startup is used to set it's direction, so 0 is facing right, 1 facing left16#alias 0 : CLOSED_DOOR17#alias 1 : OPEN_DOOR1819// Push Button Property Values20#alias 1 : PUSHBUTTON_PRESSED2122// Time Periods23#alias 2 : TIME_GOOD_FUTURE2425// Player Collision26#alias 0 : PLAYER_COL_NONE2728// Collision Modes29#alias 0 : CMODE_FLOOR3031// Priority32#alias 3 : PRIORITY_XBOUNDS3334// Function declarations35#function HorizontalDoor_CheckClose3637function HorizontalDoor_CheckClose38#platform: Use_Origins39CheckResult = false40if Object.CloseBehaviour == 041TempValue0 = Object.YPos42TempValue0 -= 0x30000043if Player.YPos < TempValue044CheckResult = true45end if46else47TempValue0 = Object.XPos48if Object.Direction == FACING_RIGHT49Object.XPos += 0x8000050else51Object.XPos -= 0x8000052end if53PlayerObjectCollision(C_TOUCH, -400, -100, 400, -20)54Object.XPos = TempValue055end if56#endplatform57end function5859sub ObjectMain60switch Object.PropertyValue61case CLOSED_DOOR62if Object.Timer > 063Object.Timer -= 0x8000064if Object.Direction == FACING_RIGHT65Object.XPos += 0x8000066else67Object.XPos -= 0x8000068end if69end if7071if PushButton[-1].Pressed == true72Object.PropertyValue = OPEN_DOOR73end if74break7576case OPEN_DOOR77if Object.Timer < 0x80000078Object.Timer += 0x8000079if Object.Direction == FACING_RIGHT80Object.XPos -= 0x8000081else82Object.XPos += 0x8000083end if84end if8586#platform: Use_Standalone87TempValue0 = Object.YPos88TempValue0 -= 0x30000089if Player.YPos < TempValue090Object.PropertyValue = CLOSED_DOOR91end if92#endplatform93#platform: Use_Origins94CallFunction(HorizontalDoor_CheckClose)95if CheckResult != false96Object.PropertyValue = CLOSED_DOOR97end if98#endplatform99break100end switch101end sub102103104sub ObjectPlayerInteraction105PlayerObjectCollision(C_BOX, -64, -8, 64, 8)106if CheckResult > PLAYER_COL_NONE107Player.CollisionMode = CMODE_FLOOR108end if109end sub110111112sub ObjectDraw113DrawSprite(0)114end sub115116117sub ObjectStartup118if HUD.CurrentTimePeriod < 2 // Past or Present119LoadSpriteSheet("R4/Objects.gif")120SpriteFrame(-64, -8, 128, 16, 18, 69) // Horizontal Door121else122LoadSpriteSheet("R4/Objects3.gif")123SpriteFrame(-64, -8, 128, 16, 62, 211) // Horizontal Door124end if125126ArrayPos0 = 32127while ArrayPos0 < 1056128if Object[ArrayPos0].Type == TypeName[Horizontal Door]129Object[ArrayPos0].Priority = PRIORITY_XBOUNDS130#platform: Use_Standalone131Object[ArrayPos0].Direction = Object[ArrayPos0].PropertyValue132#endplatform133#platform: Use_Origins134TempValue0 = Object[ArrayPos0].PropertyValue135TempValue0 &= 1136Object[ArrayPos0].Direction = TempValue0137TempValue0 = Object[ArrayPos0].PropertyValue138TempValue0 >>= 1139TempValue0 &= 1140Object[ArrayPos0].CloseBehaviour = TempValue0141#endplatform142Object[ArrayPos0].PropertyValue = CLOSED_DOOR143end if144ArrayPos0++145loop146end sub147148149// ========================150// Editor Subs151// ========================152153sub RSDKDraw154Object.Direction = Object.PropertyValue155Object.Direction &= 1156DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)157end sub158159160sub RSDKLoad161CallFunction(EditorHelpers_FindTimePeriod)162if CheckResult < 2 // Past or Present163LoadSpriteSheet("R4/Objects.gif")164SpriteFrame(-64, -8, 128, 16, 18, 69) // Horizontal Door165else166LoadSpriteSheet("R4/Objects3.gif")167SpriteFrame(-64, -8, 128, 16, 62, 211) // Horizontal Door168end if169170SetVariableAlias(ALIAS_VAR_PROPVAL, "Direction")171end sub172173174