Path: blob/main/Scripts/R5/HPlatformMedium2.txt
1319 views
//--------------Sonic CD HPlatformMedium2 Script--------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Pressed67#alias Object.Value1 : Object.PlatformY8#alias Object.Value2 : Object.ChangeY910#alias Object.Value3 : Object.PlatformX11#alias Object.Value4 : Object.ChangeX1213#alias Object.Value5 : Object.Angle14#alias Object.Value6 : Object.Oscillation1516#alias Object.Value7 : Object.Cooldown1718// HUD Alias19#alias Object[24].PropertyValue : HUD.CurrentTimePeriod2021// Time Period Aliases22#alias 0 : TIME_PRESENT23#alias 1 : TIME_PAST24#alias 2 : TIME_GOOD_FUTURE25#alias 3 : TIME_BAD_FUTURE2627// Property Values28#alias 0 : START_MOVING_RIGHT29#alias 1 : START_MOVING_RIGHT_W/SPRING30#alias 2 : START_MOVING_RIGHT_W/CONV31#alias 3 : START_MOVING_LEFT32#alias 4 : START_MOVING_LEFT_W/SPRING33#alias 5 : START_MOVING_LEFT_W/CONV343536sub ObjectMain3738// Update the Platform's Oscillation value39// Do note, that because this Oscillation is per-object and40// not global, that means Platforms won't be synced41Object.Oscillation++42if Object.Oscillation == 31243Object.Oscillation = 044end if4546// From this Oscillation value, get the Platform's Angle to be at47// This resulting value will range from 0 to 51048Object.Angle = Object.Oscillation49Object.Angle <<= 650Object.Angle /= 395152// And then from this Angle, get the base X Change Value53Sin(Object.ChangeX, Object.Angle)5455switch Object.PropertyValue56case START_MOVING_RIGHT57case START_MOVING_RIGHT_W/CONV58Object.ChangeX *= 0x180059Object.ChangeX += 0x30000060Object.ChangeX += Object.XPos61Object.ChangeX &= 0xFFFF0000 // Truncate the value62Object.ChangeX -= Object.PlatformX63break64case START_MOVING_LEFT65case START_MOVING_LEFT_W/CONV66Object.ChangeX *= -0x180067Object.ChangeX -= 0x30000068Object.ChangeX += Object.XPos69Object.ChangeX &= 0xFFFF0000 // Truncate the value70Object.ChangeX -= Object.PlatformX71break72case START_MOVING_RIGHT_W/SPRING73Object.ChangeX *= 0x180074Object.ChangeX += 0x30000075Object.ChangeX += Object.XPos76Object.ChangeX &= 0xFFFF0000 // Truncate the value77Object[+1].XPos = Object.ChangeX78Object[+1].XPos -= 0x10000079Object[+1].YPos = Object.YPos80Object[+1].YPos -= 0x18000081Object[+2].XPos = Object.ChangeX82Object[+2].XPos += 0x10000083Object[+2].YPos = Object.YPos84Object[+2].YPos -= 0x18000085Object.ChangeX -= Object.PlatformX86break87case START_MOVING_LEFT_W/SPRING88Object.ChangeX *= -0x180089Object.ChangeX -= 0x30000090Object.ChangeX += Object.XPos91Object.ChangeX &= 0xFFFF0000 // Truncate the value92Object[+1].XPos = Object.ChangeX93Object[+1].XPos -= 0x10000094Object[+1].YPos = Object.YPos95Object[+1].YPos -= 0x18000096Object[+2].XPos = Object.ChangeX97Object[+2].XPos += 0x10000098Object[+2].YPos = Object.YPos99Object[+2].YPos -= 0x180000100Object.ChangeX -= Object.PlatformX101break102103end switch104105if Object.Pressed == true106if Object.PlatformY < 16107Object.PlatformY++108TempValue0 = Object.PlatformY109TempValue0 &= 3110if TempValue0 == 3111Object.ChangeY = 0x10000112else113Object.ChangeY = 0114end if115else116Object.ChangeY = 0117end if118else119if Object.PlatformY > 0120Object.PlatformY--121TempValue0 = Object.PlatformY122TempValue0 &= 3123if TempValue0 == 3124Object.ChangeY = -0x10000125else126Object.ChangeY = 0127end if128else129Object.ChangeY = 0130end if131end if132133Object.Pressed = false134135end sub136137138sub ObjectPlayerInteraction139140// First, back up the Object's base position141TempValue0 = Object.XPos142143// Then, move the Object to where its Platform is144Object.XPos = Object.PlatformX145146// From here, jump as needed to the special handling type to be used147switch Object.PropertyValue148case START_MOVING_RIGHT149case START_MOVING_LEFT150// Standard Platform151152PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)153154if CheckResult == true155156// Let the Platform Object know that the Player's on it so that it can dip157Object.Pressed = true158159// And move the Player along with the Platform160Player.XPos += Object.ChangeX161Player.YPos += Object.ChangeY162163end if164break165166case START_MOVING_RIGHT_W/CONV167case START_MOVING_LEFT_W/CONV168// Conveyor Platform169if Object.Cooldown == 0170PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)171172if CheckResult == true173174// Now that the Player's on the Platform, let the Platform know175Object.Pressed = true176177// And from here, carry the Player along with the Platform178Player.XPos += Object.ChangeX179Player.YPos += Object.ChangeY180181// But also move them in them with the Conveyor Belt too182if ConveyorBelt_Flag == 0183Player.XPos += ConveyorBelt_Speed184else185Player.XPos -= ConveyorBelt_Speed186end if187188// However, since this Platform is a conveyor belt Platform, there's a brief cooldown activated if the Player189// is seen to be on the Platform's edge190// This is here so that they don't get into a loop of pushed off -> regrabbed -> pushed off -> regrabbed -> [...]191// since that makes things look quite... odd192193if Player.Animation == ANI_FLAILINGLEFT194Object.Cooldown = 30195end if196197if Player.Animation == ANI_FLAILINGRIGHT198Object.Cooldown = 30199end if200end if201else202// Hold for a moment...203Object.Cooldown--204end if205break206207end switch208209// And now restore the Platform to its base Position210Object.XPos = TempValue0211212end sub213214215sub ObjectDraw216217// Move the Platform as needed for its dipping218Object.YPos += Object.ChangeY219220switch Object.PropertyValue221case START_MOVING_RIGHT222case START_MOVING_RIGHT_W/SPRING223// Right-going Platform224Sin(Object.PlatformX, Object.Angle)225Object.PlatformX *= 0x1800226Object.PlatformX += 0x300000227Object.PlatformX += Object.XPos228Object.PlatformX &= 0xFFFF0000 // Truncate the value229DrawSpriteXY(0, Object.PlatformX, Object.YPos)230break231232case START_MOVING_RIGHT_W/CONV233// Right-going Conveyor Platform234Sin(Object.PlatformX, Object.Angle)235Object.PlatformX *= 0x1800236Object.PlatformX += 0x300000237Object.PlatformX += Object.XPos238Object.PlatformX &= 0xFFFF0000 // Truncate the value239DrawSpriteXY(0, Object.PlatformX, Object.YPos)240DrawSpriteXY(1, Object.PlatformX, Object.YPos)241break242243case START_MOVING_LEFT244case START_MOVING_LEFT_W/SPRING245// Left-moving Platform246Sin(Object.PlatformX, Object.Angle)247Object.PlatformX *= -0x1800248Object.PlatformX -= 0x300000249Object.PlatformX += Object.XPos250Object.PlatformX &= 0xFFFF0000 // Truncate the value251DrawSpriteXY(0, Object.PlatformX, Object.YPos)252break253254case START_MOVING_LEFT_W/CONV255// Left-moving Conveyor Platform256Sin(Object.PlatformX, Object.Angle)257Object.PlatformX *= -0x1800258Object.PlatformX -= 0x300000259Object.PlatformX += Object.XPos260Object.PlatformX &= 0xFFFF0000 // Truncate the value261DrawSpriteXY(0, Object.PlatformX, Object.YPos)262DrawSpriteXY(1, Object.PlatformX, Object.YPos)263break264265end switch266267end sub268269270sub ObjectStartup271272LoadSpriteSheet("R5/Objects.gif")273274// Load different Sprites for the different Time Periods275switch HUD.CurrentTimePeriod276case TIME_PRESENT277LoadSpriteSheet("R5/Objects.gif")278SpriteFrame(-32, -16, 64, 32, 34, 51)279SpriteFrame(-32, -16, 64, 16, 1, 208)280break281282case TIME_PAST283LoadSpriteSheet("R5/Objects3.gif")284SpriteFrame(-32, -16, 64, 32, 34, 170)285SpriteFrame(-32, -16, 64, 16, 159, 148)286break287288case TIME_GOOD_FUTURE289LoadSpriteSheet("R5/Objects3.gif")290SpriteFrame(-32, -16, 64, 32, 34, 170)291SpriteFrame(-32, -16, 64, 16, 159, 182)292break293294case TIME_BAD_FUTURE295LoadSpriteSheet("R5/Objects3.gif")296SpriteFrame(-32, -16, 64, 32, 34, 170)297SpriteFrame(-32, -16, 64, 16, 159, 216)298break299300end switch301302end sub303304305// ========================306// Editor Subs307// ========================308309sub RSDKDraw310TempValue2 = 0311312switch Object.PropertyValue313case 2314TempValue2 = 1315case 0316case 1317TempValue0 = 0x1800318TempValue1 = 0x300000319break320321case 5322TempValue2 = 1323case 3324case 4325TempValue0 = -0x1800326TempValue1 = -0x300000327break328329end switch330331DrawSprite(0)332DrawSprite(TempValue2)333334if Editor.ShowGizmos == true335336TempValue3 = Object.XPos337TempValue3 &= 0xFFFF0000 // Truncate the value338339Sin(TempValue4, 128)340TempValue4 *= TempValue0341TempValue4 += TempValue1342TempValue4 += Object.XPos343TempValue4 &= 0xFFFF0000 // Truncate the value344345Editor.DrawingOverlay = true346347// Draw the Platform's path348349DrawLine(TempValue3, Object.YPos, TempValue4, Object.YPos, 255, 255, 255)350351Editor.DrawingOverlay = false352end if353end sub354355356sub RSDKLoad357LoadSpriteSheet("R5/Objects.gif")358// TODO: using present graphics here, yada yada daba daba doo359SpriteFrame(-32, -16, 64, 32, 34, 51)360SpriteFrame(-32, -16, 64, 16, 1, 208)361362SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")363end sub364365366