Path: blob/master/Sonic 1/Scripts/SBZ/VanishPlatform.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Vanish Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer12private alias object.value1 : object.duration13private alias object.value2 : object.intervalOffset14private alias object.value3 : object.interval1516// Player Aliases17private alias object.value17 : debugMode.currentSelection181920// ========================21// Function Declarations22// ========================2324reserve function VanishPlatform_DebugDraw25reserve function VanishPlatform_DebugSpawn262728// ========================29// Static Values30// ========================3132private value VanishPlatform_startDebugID = 0333435// ========================36// Function Definitions37// ========================3839private function VanishPlatform_DebugDraw40DrawSprite(3)41end function424344private function VanishPlatform_DebugSpawn45CreateTempObject(TypeName[Vanish Platform], 0, object.xpos, object.ypos)46object[tempObjectPos].priority = PRIORITY_XBOUNDS47object[tempObjectPos].duration = 12748object[tempObjectPos].timer = 1274950temp1 = debugMode[0].currentSelection51temp1 -= VanishPlatform_startDebugID52temp1 <<= 453temp0 += 12854temp1 *= temp055temp1 >>= 856object[tempObjectPos].intervalOffset = temp157temp0--58object[tempObjectPos].interval = temp059end function606162// ========================63// Events64// ========================6566event ObjectUpdate67if object.state == 068temp0 = SBZSetup_platformTimer69temp0 -= object.intervalOffset70temp0 &= object.interval71if temp0 == 072object.state = 173object.priority = PRIORITY_ACTIVE74end if75end if7677if object.state != 078object.timer--79if object.timer < 080if object.animation == 081object.timer = object.duration82else83object.timer = 12784end if85object.animation ^= 186end if8788if object.animation == 089if object.frame < 390object.animationTimer++91if object.animationTimer == 892object.animationTimer = 093object.frame++94end if95end if96else97if object.frame > 098object.animationTimer++99if object.animationTimer == 8100object.animationTimer = 0101object.frame--102end if103end if104end if105106GetBit(temp0, object.frame, 1)107if temp0 != 0108foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)109BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)110next111end if112end if113114temp0 = camera[0].xpos115temp0 -= object.ixpos116Abs(temp0)117temp0 -= 128118if temp0 > screen.xcenter119object.state = 0120object.timer = 127121object.priority = PRIORITY_XBOUNDS122object.animation = 0123object.frame = 0124object.animationTimer = 0125end if126end event127128129event ObjectDraw130DrawSprite(object.frame)131end event132133134event ObjectStartup135LoadSpriteSheet("SBZ/Objects.gif")136137// Platform frames138SpriteFrame(0, 0, 1, 1, 449, 198)139SpriteFrame(-2, -8, 4, 32, 507, 231)140SpriteFrame(-8, -8, 16, 32, 490, 231)141SpriteFrame(-16, -8, 32, 32, 457, 231)142143// Do setup for every vanish platform object144foreach (TypeName[Vanish Platform], arrayPos0, ALL_ENTITIES)145object[arrayPos0].priority = PRIORITY_XBOUNDS146temp0 = object[arrayPos0].propertyValue147temp0 &= 0x0F148temp0++149temp0 <<= 7150object[arrayPos0].duration = temp0151object[arrayPos0].duration--152object[arrayPos0].timer = 127153154temp1 = object[arrayPos0].propertyValue155temp1 &= 0xF0156temp0 += 0x80157temp1 *= temp0158temp1 >>= 8159object[arrayPos0].intervalOffset = temp1160temp0--161object[arrayPos0].interval = temp0162next163164// Add this object to the debug object list, several times for the different intervals165temp0 = 0166VanishPlatform_startDebugID = DebugMode_ObjCount167while temp0 < 16168SetTableValue(TypeName[Vanish Platform], DebugMode_ObjCount, DebugMode_TypesTable)169SetTableValue(VanishPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)170SetTableValue(VanishPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)171DebugMode_ObjCount++172temp0++173loop174end event175176177// ========================178// Editor Events179// ========================180181event RSDKEdit182if editor.returnVariable == true183switch editor.variableID184case EDIT_VAR_PROPVAL // property value185checkResult = object.propertyValue186break187188case 0 // interval189checkResult = object.propertyValue190checkResult &= 0xF191break192193case 1 // intervalOffset194checkResult = object.propertyValue195checkResult >>= 4196checkResult &= 0xF197break198199end switch200else201switch editor.variableID202case EDIT_VAR_PROPVAL // property value203object.propertyValue = editor.variableValue204break205206case 0 // interval207temp0 = editor.variableValue208temp0 &= 0xF209object.propertyValue &= 0xF0210object.propertyValue |= temp0211break212213case 1 // intervalOffset214temp0 = editor.variableValue215temp0 &= 0xF216temp0 <<= 4217object.propertyValue &= 0xF218object.propertyValue |= temp0219break220221end switch222end if223end event224225226event RSDKDraw227DrawSprite(0)228end event229230231event RSDKLoad232LoadSpriteSheet("SBZ/Objects.gif")233234// Platform frames235SpriteFrame(-16, -8, 32, 32, 457, 231)236237AddEditorVariable("interval")238SetActiveVariable("interval")239AddEnumVariable("Every 128 Frames", 0)240AddEnumVariable("Every 256 Frames", 1)241AddEnumVariable("Every 384 Frames", 2)242AddEnumVariable("Every 512 Frames", 3)243AddEnumVariable("Every 640 Frames", 4)244AddEnumVariable("Every 768 Frames", 5)245AddEnumVariable("Every 896 Frames", 6)246AddEnumVariable("Every 1024 Frames", 7)247AddEnumVariable("Every 1152 Frames", 8)248AddEnumVariable("Every 1280 Frames", 9)249AddEnumVariable("Every 1408 Frames", 10)250AddEnumVariable("Every 1536 Frames", 11)251AddEnumVariable("Every 1664 Frames", 12)252AddEnumVariable("Every 1792 Frames", 13)253AddEnumVariable("Every 1920 Frames", 14)254AddEnumVariable("Every 2048 Frames", 15)255256AddEditorVariable("intervalOffset")257SetActiveVariable("intervalOffset")258AddEnumVariable("0% through the interval", 0)259AddEnumVariable("6.25% through the interval", 1)260AddEnumVariable("12.5% through the interval", 2)261AddEnumVariable("18.75% through the interval", 3)262AddEnumVariable("25% through the interval", 4)263AddEnumVariable("31.25% through the interval", 5)264AddEnumVariable("37.5% through the interval", 6)265AddEnumVariable("43.75% through the interval", 7)266AddEnumVariable("50% through the interval", 8)267AddEnumVariable("56.25% through the interval", 9)268AddEnumVariable("62.5% through the interval", 10)269AddEnumVariable("68.75% through the interval", 11)270AddEnumVariable("75% through the interval", 12)271AddEnumVariable("81.25% through the interval", 13)272AddEnumVariable("87.5% through the interval", 14)273AddEnumVariable("93.75% through the interval", 15)274end event275276277