Path: blob/main/Scripts/R7/SolidBlock.txt
1319 views
//----------------Sonic CD Solid Block Script-----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases56// Time Period Aliases7#alias Object[24].PropertyValue : HUD.CurrentTimePeriod89#alias 0 : TIME_PRESENT10#alias 1 : TIME_PAST11#alias 2 : TIME_GOOD_FUTURE12#alias 3 : TIME_BAD_FUTURE1314// Gravity15#alias 0 : GRAVITY_GROUND1617// Ink Effect18#alias 1 : INK_BLEND1920// Player Collision21#alias 4 : C_BOX322#alias 2 : PLAYER_COL_LWALL23#alias 3 : PLAYER_COL_RWALL24#alias 4 : PLAYER_COL_ROOF2526// Property Values27#alias 0 : BLOCK_SINGLE28#alias 1 : BLOCK_TWO_H29#alias 2 : BLOCK_THREE_H30#alias 3 : BLOCK_FOUR_H31#alias 4 : BLOCK_TWO_V32#alias 5 : BLOCK_THREE_V33#alias 6 : BLOCK_FOUR_V34#alias 7 : BLOCK_INVISIBLE353637sub ObjectPlayerInteraction38TempValue0 = Player.YPos39#platform: Use_Origins40if Player.State != Player_State_LedgePullUp41if Player.Animation == ANI_CLIMBING42switch Object.PropertyValue43case BLOCK_SINGLE44case BLOCK_INVISIBLE45PlayerObjectCollision(C_BOX3, -16, -16, 16, 16)46break4748case BLOCK_TWO_H49PlayerObjectCollision(C_BOX3, -32, -16, 32, 16)50break5152case BLOCK_THREE_H53PlayerObjectCollision(C_BOX3, -48, -16, 48, 16)54break5556case BLOCK_FOUR_H57PlayerObjectCollision(C_BOX3, -64, -16, 64, 16)58break5960case BLOCK_TWO_V61PlayerObjectCollision(C_BOX3, -16, -32, 16, 32)62break6364case BLOCK_THREE_V65PlayerObjectCollision(C_BOX3, -16, -48, 16, 48)66break6768case BLOCK_FOUR_V69PlayerObjectCollision(C_BOX3, -16, -64, 16, 64)70break71end switch72else73if Player.Animation == ANI_GLIDING74switch Object.PropertyValue75case BLOCK_SINGLE76case BLOCK_INVISIBLE77PlayerObjectCollision(C_BOX3, -16, -16, 16, 16)78break7980case BLOCK_TWO_H81PlayerObjectCollision(C_BOX3, -32, -16, 32, 16)82break8384case BLOCK_THREE_H85PlayerObjectCollision(C_BOX3, -48, -16, 48, 16)86break8788case BLOCK_FOUR_H89PlayerObjectCollision(C_BOX3, -64, -16, 64, 16)90break9192case BLOCK_TWO_V93PlayerObjectCollision(C_BOX3, -16, -32, 16, 32)94break9596case BLOCK_THREE_V97PlayerObjectCollision(C_BOX3, -16, -48, 16, 48)98break99100case BLOCK_FOUR_V101PlayerObjectCollision(C_BOX3, -16, -64, 16, 64)102break103end switch104105if Player.Animation == ANI_GLIDING106switch CheckResult107case PLAYER_COL_LWALL108case PLAYER_COL_RWALL109CallFunction(Player_ClimbBlock)110break111end switch112end if113else114#endplatform115switch Object.PropertyValue116case BLOCK_SINGLE117case BLOCK_INVISIBLE118PlayerObjectCollision(C_BOX, -16, -16, 16, 16)119break120121case BLOCK_TWO_H122PlayerObjectCollision(C_BOX, -32, -16, 32, 16)123break124125case BLOCK_THREE_H126PlayerObjectCollision(C_BOX, -48, -16, 48, 16)127break128129case BLOCK_FOUR_H130PlayerObjectCollision(C_BOX, -64, -16, 64, 16)131break132133case BLOCK_TWO_V134PlayerObjectCollision(C_BOX, -16, -32, 16, 32)135break136137case BLOCK_THREE_V138PlayerObjectCollision(C_BOX, -16, -48, 16, 48)139break140141case BLOCK_FOUR_V142PlayerObjectCollision(C_BOX, -16, -64, 16, 64)143break144end switch145#platform: Use_Origins146end if147end if148end if149#endplatform150151if CheckResult == PLAYER_COL_LWALL152Player.RCollisionFlag = true // Used in the Metal Sonic race sequence, but set by the Block regardless of current level153end if154155if Player.Gravity == GRAVITY_GROUND156if CheckResult == PLAYER_COL_ROOF157Player.YPos = TempValue0 // Move the player back ontop of the block158end if159end if160end sub161162163sub ObjectDraw164switch Object.PropertyValue165case BLOCK_SINGLE166DrawSprite(0)167break168169case BLOCK_TWO_H170TempValue0 = Object.XPos171TempValue0 -= 0x100000172DrawSpriteXY(0, TempValue0, Object.YPos)173TempValue0 += 0x200000174DrawSpriteXY(0, TempValue0, Object.YPos)175break176177case BLOCK_THREE_H178TempValue0 = Object.XPos179TempValue0 -= 0x200000180DrawSpriteXY(0, TempValue0, Object.YPos)181TempValue0 += 0x200000182DrawSpriteXY(0, TempValue0, Object.YPos)183TempValue0 += 0x200000184DrawSpriteXY(0, TempValue0, Object.YPos)185break186187case BLOCK_FOUR_H188TempValue0 = Object.XPos189TempValue0 -= 0x300000190DrawSpriteXY(0, TempValue0, Object.YPos)191TempValue0 += 0x200000192DrawSpriteXY(0, TempValue0, Object.YPos)193TempValue0 += 0x200000194DrawSpriteXY(0, TempValue0, Object.YPos)195TempValue0 += 0x200000196DrawSpriteXY(0, TempValue0, Object.YPos)197break198199case BLOCK_TWO_V200TempValue0 = Object.YPos201TempValue0 -= 0x100000202DrawSpriteXY(0, Object.XPos, TempValue0)203TempValue0 += 0x200000204DrawSpriteXY(0, Object.XPos, TempValue0)205break206207case BLOCK_THREE_V208TempValue0 = Object.YPos209TempValue0 -= 0x200000210DrawSpriteXY(0, Object.XPos, TempValue0)211TempValue0 += 0x200000212DrawSpriteXY(0, Object.XPos, TempValue0)213TempValue0 += 0x200000214DrawSpriteXY(0, Object.XPos, TempValue0)215break216217case BLOCK_FOUR_V218TempValue0 = Object.YPos219TempValue0 -= 0x300000220DrawSpriteXY(0, Object.XPos, TempValue0)221TempValue0 += 0x200000222DrawSpriteXY(0, Object.XPos, TempValue0)223TempValue0 += 0x200000224DrawSpriteXY(0, Object.XPos, TempValue0)225TempValue0 += 0x200000226DrawSpriteXY(0, Object.XPos, TempValue0)227break228229// case 7, the invisible block, doesn't draw anything of course230end switch231end sub232233234sub ObjectStartup235LoadSpriteSheet("R7/Objects.gif")236237// Load the appropriate version of the sprite based on the current time period238switch HUD.CurrentTimePeriod239case TIME_PRESENT240case TIME_PAST241case TIME_BAD_FUTURE242// Normal version of the sprite243SpriteFrame(-16, -16, 32, 32, 1, 1)244break245246case TIME_GOOD_FUTURE247// Good future version of the sprite248SpriteFrame(-16, -16, 32, 32, 117, 219)249break250end switch251end sub252253254// ========================255// Editor Subs256// ========================257258sub RSDKEdit259if Editor.ReturnVariable == true260switch Editor.VariableID261case EDIT_VAR_PROPVAL // Property Value262CheckResult = Object.PropertyValue263break264case 0 // Type265CheckResult = Object.PropertyValue266CheckResult &= 7267break268end switch269else270switch Editor.VariableID271case EDIT_VAR_PROPVAL // Property Value272Object.PropertyValue = Editor.VariableValue273break274case 0 // Type275Object.PropertyValue = Editor.VariableValue276Object.PropertyValue &= 7277break278end switch279end if280end sub281282283sub RSDKDraw284switch Object.PropertyValue285case BLOCK_SINGLE286DrawSprite(0)287break288289case BLOCK_TWO_H290TempValue0 = Object.XPos291TempValue0 -= 0x100000292DrawSpriteXY(0, TempValue0, Object.YPos)293TempValue0 += 0x200000294DrawSpriteXY(0, TempValue0, Object.YPos)295break296297case BLOCK_THREE_H298TempValue0 = Object.XPos299TempValue0 -= 0x200000300DrawSpriteXY(0, TempValue0, Object.YPos)301TempValue0 += 0x200000302DrawSpriteXY(0, TempValue0, Object.YPos)303TempValue0 += 0x200000304DrawSpriteXY(0, TempValue0, Object.YPos)305break306307case BLOCK_FOUR_H308TempValue0 = Object.XPos309TempValue0 -= 0x300000310DrawSpriteXY(0, TempValue0, Object.YPos)311TempValue0 += 0x200000312DrawSpriteXY(0, TempValue0, Object.YPos)313TempValue0 += 0x200000314DrawSpriteXY(0, TempValue0, Object.YPos)315TempValue0 += 0x200000316DrawSpriteXY(0, TempValue0, Object.YPos)317break318319case BLOCK_TWO_V320TempValue0 = Object.YPos321TempValue0 -= 0x100000322DrawSpriteXY(0, Object.XPos, TempValue0)323TempValue0 += 0x200000324DrawSpriteXY(0, Object.XPos, TempValue0)325break326327case BLOCK_THREE_V328TempValue0 = Object.YPos329TempValue0 -= 0x200000330DrawSpriteXY(0, Object.XPos, TempValue0)331TempValue0 += 0x200000332DrawSpriteXY(0, Object.XPos, TempValue0)333TempValue0 += 0x200000334DrawSpriteXY(0, Object.XPos, TempValue0)335break336337case BLOCK_FOUR_V338TempValue0 = Object.YPos339TempValue0 -= 0x300000340DrawSpriteXY(0, Object.XPos, TempValue0)341TempValue0 += 0x200000342DrawSpriteXY(0, Object.XPos, TempValue0)343TempValue0 += 0x200000344DrawSpriteXY(0, Object.XPos, TempValue0)345TempValue0 += 0x200000346DrawSpriteXY(0, Object.XPos, TempValue0)347break348349case BLOCK_INVISIBLE350// This subtype acts as an invis block so normally it's invisible - but it has to show in the editor somehow!351352Object.InkEffect = INK_BLEND353DrawSpriteFX(0, FX_INK, Object.XPos, Object.YPos)354355// The sprite is faint so draw the hitbox of the box356357TempValue0 = Object.XPos358TempValue0 -= 0x100000359TempValue1 = Object.YPos360TempValue1 -= 0x100000361DrawRectOutline(TempValue0, TempValue1, 32, 32, 255, 255, 255, 255)362break363end switch364end sub365366367sub RSDKLoad368LoadSpriteSheet("R7/Objects.gif")369SpriteFrame(-16, -16, 32, 32, 1, 1)370371AddEditorVariable("Type")372SetActiveVariable("Type")373AddEnumVariable("Single Block", BLOCK_SINGLE)374AddEnumVariable("Two Blocks (Horizontal)", BLOCK_TWO_H)375AddEnumVariable("Three Blocks (Horizontal)", BLOCK_THREE_H)376AddEnumVariable("Four Blocks (Horizontal)", BLOCK_FOUR_H)377AddEnumVariable("Two Blocks (Vertical)", BLOCK_TWO_V)378AddEnumVariable("Three Blocks (Vertical)", BLOCK_THREE_V)379AddEnumVariable("Four Blocks (Vertical)", BLOCK_FOUR_V)380AddEnumVariable("Invisible Block", BLOCK_INVISIBLE)381end sub382383384