Path: blob/master/Sonic 2/Scripts/CPZ/TippingFloor.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Tipping Floor 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.intervalOffset1415// Player Aliases16private alias object.value17 : debugMode.currentSelection1718private alias 0 : TIPPINGFLOOR_IDLE19private alias 1 : TIPPINGFLOOR_TIPPING20private alias 2 : TIPPINGFLOOR_STATIC212223// ========================24// Function Declarations25// ========================2627reserve function TippingFloor_DebugDraw28reserve function TippingFloor_DebugSpawn293031// ========================32// Static Values33// ========================3435private value TippingFloor_startDebugID = 0363738// ========================39// Function Definitions40// ========================4142private function TippingFloor_DebugDraw43DrawSprite(0)44end function454647private function TippingFloor_DebugSpawn48CreateTempObject(TypeName[Tipping Floor], 0, object.xpos, object.ypos)49object[tempObjectPos].duration = 12750object[tempObjectPos].timer = 12751object[tempObjectPos].intervalOffset = debugMode[0].currentSelection52object[tempObjectPos].intervalOffset -= TippingFloor_startDebugID53object[tempObjectPos].intervalOffset <<= 454object[tempObjectPos].intervalOffset += 1655object[tempObjectPos].intervalOffset--56end function575859// ========================60// Events61// ========================6263event ObjectUpdate64if object.state == TIPPINGFLOOR_IDLE65temp0 = oscillation66temp0 += object.intervalOffset67temp0 &= 0xFF68if temp0 == 069object.state = TIPPINGFLOOR_TIPPING70object.priority = PRIORITY_ACTIVE71end if72end if7374if object.state == TIPPINGFLOOR_TIPPING75object.timer--76if object.timer < 077if object.animation == 078object.timer = object.duration79else80object.timer = 12781end if8283object.animation ^= 184end if8586if object.animation == 087if object.frame < 488object.animationTimer++89if object.animationTimer == 890object.animationTimer = 091object.frame++92end if93end if94else95if object.frame > 096object.animationTimer++97if object.animationTimer == 898object.animationTimer = 099object.frame--100end if101end if102end if103end if104105if object.frame == 0106foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)107BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -16, 16, -8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)108next109end if110111if options.vsMode == false112temp0 = camera[0].xpos113temp0 -= object.ixpos114Abs(temp0)115temp0 -= 128116if temp0 > screen.xcenter117object.state = TIPPINGFLOOR_IDLE118object.timer = object.duration119object.priority = PRIORITY_XBOUNDS120object.animation = 0121object.frame = 0122object.animationTimer = 0123end if124end if125end event126127128event ObjectDraw129DrawSprite(object.frame)130end event131132133event ObjectStartup134CheckCurrentStageFolder("Zone02")135if checkResult == true136LoadSpriteSheet("CPZ/Objects.gif")137SpriteFrame(-16, -16, 32, 32, 1, 222)138SpriteFrame(-16, -21, 32, 37, 34, 218)139SpriteFrame(-16, -12, 32, 32, 67, 223)140SpriteFrame(-16, -8, 32, 37, 99, 218)141SpriteFrame(-16, -8, 32, 32, 132, 223)142else143LoadSpriteSheet("MBZ/Objects.gif")144SpriteFrame(-16, -16, 32, 32, 34, 692)145SpriteFrame(-16, -21, 32, 37, 34, 725)146SpriteFrame(-16, -12, 32, 32, 34, 763)147SpriteFrame(-16, -8, 32, 37, 34, 796)148SpriteFrame(-16, -8, 32, 32, 34, 834)149end if150151foreach (TypeName[Tipping Floor], arrayPos0, ALL_ENTITIES)152object[arrayPos0].priority = PRIORITY_XBOUNDS153CheckGreater(object[arrayPos0].propertyValue, 0x7F)154temp0 = checkResult155CheckEqual(options.vsMode, true)156temp0 &= checkResult157if temp0 == true158object[arrayPos0].state = TIPPINGFLOOR_STATIC159else160object[arrayPos0].intervalOffset = object[arrayPos0].propertyValue161object[arrayPos0].intervalOffset &= 0x0F162object[arrayPos0].intervalOffset++163object[arrayPos0].intervalOffset <<= 4164object[arrayPos0].duration = object[arrayPos0].propertyValue165object[arrayPos0].duration &= 0x70166object[arrayPos0].duration += 16167object[arrayPos0].duration--168object[arrayPos0].timer = object[arrayPos0].duration169end if170next171172temp0 = 0173TippingFloor_startDebugID = DebugMode_ObjCount174while temp0 < 16175SetTableValue(TypeName[Tipping Floor], DebugMode_ObjCount, DebugMode_TypesTable)176SetTableValue(TippingFloor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)177SetTableValue(TippingFloor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)178DebugMode_ObjCount++179temp0++180loop181end event182183184// ========================185// Editor Events186// ========================187188event RSDKEdit189if editor.returnVariable == true190switch editor.variableID191case EDIT_VAR_PROPVAL // property value192checkResult = object.propertyValue193break194195case 0 // duration196checkResult = object.propertyValue197checkResult >>= 4198checkResult &= 3199break200201case 1 // intervalOffset202checkResult = object.propertyValue203checkResult &= 0x0F204break205206case 2 // vsDisable207GetBit(checkResult, object.propertyValue, 7)208break209210end switch211else212switch editor.variableID213case EDIT_VAR_PROPVAL // property value214object.propertyValue = editor.variableValue215break216217case 0 // duration218temp0 = 0x70219Not(temp0)220object.propertyValue &= temp0221editor.variableValue &= 3222editor.variableValue <<= 4223object.propertyValue |= editor.variableValue224break225226case 1 // intervalOffset227object.propertyValue &= 0xF0228editor.variableValue &= 0x0F229object.propertyValue |= editor.variableValue230break231232case 2 // vsDisable233CheckNotEqual(editor.variableValue, false)234SetBit(object.propertyValue, 7, checkResult)235break236237end switch238end if239end event240241242event RSDKDraw243DrawSprite(0)244end event245246247event RSDKLoad248CheckCurrentStageFolder("Zone02")249if checkResult == true250LoadSpriteSheet("CPZ/Objects.gif")251SpriteFrame(-16, -16, 32, 32, 1, 222)252SpriteFrame(-16, -21, 32, 37, 34, 218)253SpriteFrame(-16, -12, 32, 32, 67, 223)254SpriteFrame(-16, -8, 32, 37, 99, 218)255SpriteFrame(-16, -8, 32, 32, 132, 223)256else257LoadSpriteSheet("MBZ/Objects.gif")258SpriteFrame(-16, -16, 32, 32, 34, 692)259SpriteFrame(-16, -21, 32, 37, 34, 725)260SpriteFrame(-16, -12, 32, 32, 34, 763)261SpriteFrame(-16, -8, 32, 37, 34, 796)262SpriteFrame(-16, -8, 32, 32, 34, 834)263end if264265AddEditorVariable("duration")266SetActiveVariable("duration")267AddEnumVariable("15 Frames", 0)268AddEnumVariable("31 Frames", 1)269AddEnumVariable("47 Frames", 2)270AddEnumVariable("63 Frames", 3)271272AddEditorVariable("intervalOffset")273SetActiveVariable("intervalOffset")274AddEnumVariable("0% through the interval", 0)275AddEnumVariable("6.25% through the interval", 1)276AddEnumVariable("12.5% through the interval", 2)277AddEnumVariable("18.75% through the interval", 3)278AddEnumVariable("25% through the interval", 4)279AddEnumVariable("31.25% through the interval", 5)280AddEnumVariable("37.5% through the interval", 6)281AddEnumVariable("43.75% through the interval", 7)282AddEnumVariable("50% through the interval", 8)283AddEnumVariable("56.25% through the interval", 9)284AddEnumVariable("62.5% through the interval", 10)285AddEnumVariable("68.75% through the interval", 11)286AddEnumVariable("75% through the interval", 12)287AddEnumVariable("81.25% through the interval", 13)288AddEnumVariable("87.5% through the interval", 14)289AddEnumVariable("93.75% through the interval", 15)290291AddEditorVariable("vsDisable")292SetActiveVariable("vsDisable")293AddEnumVariable("false", false)294AddEnumVariable("true", true)295end event296297298