Path: blob/master/Sonic 2/Scripts/HTZ/Earthquake.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Earthquake Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.earthquakeType1213private alias object.value1 : object.maxPos14private alias object.value2 : object.minPos1516// First set of sensor values for knowing whether to hold earthquake values or to reset17private alias object.value3 : object.sensorHold.left18private alias object.value4 : object.sensorHold.top19private alias object.value5 : object.sensorHold.right20private alias object.value6 : object.sensorHold.bottom2122// Main set of sensor values, used for sensing if the player's in the actual earthquake area23private alias object.value7 : object.sensorMain.left24private alias object.value8 : object.sensorMain.top25private alias object.value9 : object.sensorMain.right26private alias object.value10 : object.sensorMain.bottom2728// Acutal collision sizes for the object to use with player interaction during earthquake29private alias object.value11 : object.colbox.left30private alias object.value12 : object.colbox.top31private alias object.value13 : object.colbox.right32private alias object.value14 : object.colbox.bottom3334private alias object.value15 : object.prevPos35private alias object.value16 : object.scrollStartPos3637// Reserved object slots38private alias 0 : SLOT_PLAYER13940private alias 0 : EARTHQUAKE_NONE41private alias 1 : EARTHQUAKE_HOLD42private alias 2 : EARTHQUAKE_ACTIVE4344// Player Aliases45private alias object.xpos : player.xpos46private alias object.ypos : player.ypos47private alias object.xvel : player.xvel48private alias object.gravity : player.gravity4950private alias object.value42 : player.prevGravity515253// ========================54// Tables55// ========================5657private table Earthquake_collisionBoxSizes58-192, -256, 192, 25659-192, -320, 192, 32060-192, -448, 192, 44861-384, -256, 384, 12862-448, -448, 448, 44863-448, -448, 448, 44864end table6566private table Earthquake_sensorsMain67-192, -640, 1042, 256680, 0, 0, 0 // Two empty ones here because these are in a set of three earquake objects in the HTZ1 scene, so there's only really need to have one hitbox sensor690, 0, 0, 070-384, -896, 600, 12871-448, -1344, 672, 44872-448, -1120, 672, 44873end table7475private table Earthquake_sensorsHold76-448, -640, 1298, 256770, 0, 0, 0780, 0, 0, 079-640, -896, 856, 12880-704, -1344, 928, 44881-704, -1120, 928, 44882end table8384private table Earthquake_types851, 1, 1 // These first three are all the same because they're used in the same earthquake event862, 3, 487end table8889private table Earthquake_maxMinPos90-0xE00000, -0x1400000910x000000, -0x2B40000920x000000, -0x3000000930x000000, -0x350000094end table9596private table Earthquake_scrollStartPos970, 0, 0x6800000, 0x1180000098end table99100101// ========================102// Events103// ========================104105event ObjectUpdate106BoxCollisionTest(C_TOUCH, object.entityPos, object.sensorMain.left, object.sensorMain.top, object.sensorMain.right, object.sensorMain.bottom, SLOT_PLAYER1, 0, 0, 0, 0)107if checkResult == true108if HTZSetup_earthquakeState == EARTHQUAKE_NONE109HTZSetup_earthquakeState = EARTHQUAKE_ACTIVE110HTZSetup_activeEarthquakeType = object.earthquakeType111HTZSetup_earthquakePosMax = object.maxPos112HTZSetup_earthquakePosMin = object.minPos113hParallax[20].scrollPos = object.scrollStartPos114end if115end if116117BoxCollisionTest(C_TOUCH, object.entityPos, object.sensorHold.left, object.sensorHold.top, object.sensorHold.right, object.sensorHold.bottom, SLOT_PLAYER1, 0, 0, 0, 0)118if checkResult == true119if HTZSetup_earthquakeState == EARTHQUAKE_NONE120// Player isn't exactly in active earthquake area, but they're not fully out either,121// so make the earthquake holds its values in case it's still in view or the player decides to go back122HTZSetup_earthquakeState = EARTHQUAKE_HOLD123HTZSetup_activeEarthquakeType = object.earthquakeType124HTZSetup_earthquakePosMax = object.maxPos125HTZSetup_earthquakePosMin = object.minPos126hParallax[20].scrollPos = object.scrollStartPos127end if128end if129130foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)131temp0 = object.colbox.top132temp0 -= object.prevPos133temp1 = object.colbox.bottom134temp1 -= object.prevPos135136if object.propertyValue == 3137// If it's the slope version, then account for its special collision properties138temp2 = player[currentPlayer].xpos139temp2 -= object.xpos140temp2 += 0x1800000141if temp2 > 0142temp2 >>= 18143temp0 += temp2144end if145146temp0++147if player[currentPlayer].prevGravity == GRAVITY_GROUND148if player[currentPlayer].gravity == GRAVITY_AIR149if player[currentPlayer].xvel > 0150temp2 = player[currentPlayer].xvel151temp2 >>= 2152player[currentPlayer].ypos += temp2153player[currentPlayer].ypos += 0x20000154end if155end if156end if157end if158159BoxCollisionTest(C_SOLID, object.entityPos, object.colbox.left, temp0, object.colbox.right, temp1, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)160switch checkResult161case COL_TOP162temp0 = HTZSetup_earthquakePos163temp0 -= object.prevPos164temp0 <<= 16165player[currentPlayer].ypos -= temp0166// [Fallthrough]167case COL_LEFT168case COL_RIGHT169if object.propertyValue == 2170CallFunction(Player_FireHit)171end if172173if object.propertyValue == 4174CallFunction(Player_FireHit)175end if176177if object.propertyValue == 5178CallFunction(Player_FireHit)179end if180break181182case COL_BOTTOM183if player[currentPlayer].gravity == GRAVITY_GROUND184CallFunction(Player_Kill)185end if186break187188end switch189next190191foreach (TypeName[Lose Ring], arrayPos0, ACTIVE_ENTITIES)192if object[arrayPos0].yvel >= 0193temp0 = object.colbox.top194temp0 -= object.prevPos195temp1 = object.colbox.bottom196temp1 -= object.prevPos197if object.propertyValue == 3198temp2 = object[arrayPos0].xpos199temp2 -= object.xpos200temp2 += 0x1800000201if temp2 > 0202temp2 >>= 18203temp0 += temp2204end if205temp0++206end if207temp2 = object[arrayPos0].yvel208209BoxCollisionTest(C_PLATFORM, object.entityPos, object.colbox.left, temp0, object.colbox.right, temp1, arrayPos0, -8, -8, 8, 8)210if checkResult == true211object[arrayPos0].yvel = temp2212temp2 >>= 2213object[arrayPos0].yvel -= temp2214FlipSign(object[arrayPos0].yvel)215if object[arrayPos0].yvel > -0x10000216object[arrayPos0].yvel = -0x10000217end if218object[arrayPos0].gravity = GRAVITY_AIR219end if220end if221next222223object.prevPos = HTZSetup_earthquakePos224end event225226227event ObjectStartup228foreach (TypeName[Earthquake], arrayPos0, ALL_ENTITIES)229object[arrayPos0].priority = PRIORITY_ACTIVE230231// First get the object's target earthquake type based off its property value232GetTableValue(object[arrayPos0].earthquakeType, object[arrayPos0].propertyValue, Earthquake_types)233234// Then use the earthquake's dedicated type for the next few value searches rather than simply its property value235temp0 = object[arrayPos0].earthquakeType236temp0--237238GetTableValue(object[arrayPos0].scrollStartPos, temp0, Earthquake_scrollStartPos)239240temp0 <<= 1241GetTableValue(object[arrayPos0].maxPos, temp0, Earthquake_maxMinPos)242243temp0++244GetTableValue(object[arrayPos0].minPos, temp0, Earthquake_maxMinPos)245246// Get the sizes of the earthquake boxes247temp0 = object[arrayPos0].propertyValue248temp0 <<= 2249GetTableValue(object[arrayPos0].colbox.left, temp0, Earthquake_collisionBoxSizes)250GetTableValue(object[arrayPos0].sensorHold.left, temp0, Earthquake_sensorsHold)251GetTableValue(object[arrayPos0].sensorMain.left, temp0, Earthquake_sensorsMain)252253temp0++254GetTableValue(object[arrayPos0].colbox.top, temp0, Earthquake_collisionBoxSizes)255GetTableValue(object[arrayPos0].sensorHold.top, temp0, Earthquake_sensorsHold)256GetTableValue(object[arrayPos0].sensorMain.top, temp0, Earthquake_sensorsMain)257258temp0++259GetTableValue(object[arrayPos0].colbox.right, temp0, Earthquake_collisionBoxSizes)260GetTableValue(object[arrayPos0].sensorHold.right, temp0, Earthquake_sensorsHold)261GetTableValue(object[arrayPos0].sensorMain.right, temp0, Earthquake_sensorsMain)262263temp0++264GetTableValue(object[arrayPos0].colbox.bottom, temp0, Earthquake_collisionBoxSizes)265GetTableValue(object[arrayPos0].sensorHold.bottom, temp0, Earthquake_sensorsHold)266GetTableValue(object[arrayPos0].sensorMain.bottom, temp0, Earthquake_sensorsMain)267268if options.vsMode == true269// No earthquakes in 2P270ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)271end if272next273end event274275276// ========================277// Editor Events278// ========================279280event RSDKEdit281if editor.returnVariable == true282switch editor.variableID283case EDIT_VAR_PROPVAL // property value284checkResult = object.propertyValue285break286287case 0 // type288checkResult = object.propertyValue289break290291end switch292else293switch editor.variableID294case EDIT_VAR_PROPVAL // property value295object.propertyValue = editor.variableValue296break297298case 0 // type299object.propertyValue = editor.variableValue300break301302end switch303end if304end event305306307event RSDKDraw308DrawSprite(0)309end event310311312event RSDKLoad313LoadSpriteSheet("Global/Display.gif")314SpriteFrame(-16, -16, 32, 32, 1, 143)315316AddEditorVariable("type")317SetActiveVariable("type")318AddEnumVariable("Ground (Flat)", 0)319AddEnumVariable("Ground (Wall)", 1)320AddEnumVariable("Lava (Wide, Ver 1)", 2)321AddEnumVariable("Ground (Sloped)", 3)322AddEnumVariable("Lava (Wide, Ver 2)", 4)323AddEnumVariable("Lava (Wide, Ver 3)", 5)324end event325326327