Path: blob/master/Sonic 1/Scripts/Global/AnimalPrison.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Animal Prison Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer1213private alias 0 : ANIMALPRISON_AWAITOPEN14private alias 1 : ANIMALPRISON_OPENED15private alias 2 : ANIMALPRISON_EXPLODE16private alias 3 : ANIMALPRISON_HANDLEACTCLEAR17private alias 4 : ANIMALPRISON_FINISHED1819// Animal aliases20private alias object.value1 : animal.randomizeDir2122// Player aliases23private alias object.animation : player.animation24private alias object.xpos : player.xpos25private alias object.ypos : player.ypos26private alias object.xvel : player.xvel27private alias object.yvel : player.yvel28private alias object.speed : player.speed29private alias object.gravity : player.gravity30private alias object.jumpPress : player.jumpPress31private alias object.jumpHold : player.jumpHold32private alias object.up : player.up33private alias object.down : player.down34private alias object.left : player.left35private alias object.right : player.right36private alias object.controlMode : player.controlMode37private alias object.value30 : player.jumpOffset3839// Tracks40private alias 1 : TRACK_ACTFINISH4142// Game Modes43private alias 0 : MODE_NOSAVE44private alias 1 : MODE_SAVEGAME45private alias 2 : MODE_TIMEATTACK4647// Super States48private alias 1 : SUPERSTATE_SUPER49private alias 2 : SUPERSTATE_UNTRANSFORM5051// Reserved Object Slot Aliases52private alias 30 : SLOT_ACTFINISH535455// ========================56// Function Declarations57// ========================5859reserve function AnimalPrison_DebugDraw60reserve function AnimalPrison_DebugSpawn616263// ========================64// Function Definitions65// ========================6667private function AnimalPrison_DebugDraw68DrawSprite(2)69DrawSprite(0)70end function717273private function AnimalPrison_DebugSpawn74CreateTempObject(TypeName[Animal Prison], 0, object.xpos, object.ypos)75end function767778// ========================79// Events80// ========================8182event ObjectUpdate83switch object.state84case ANIMALPRISON_AWAITOPEN85temp0 = object.ixpos86temp0 -= screen.xcenter87stage.newXBoundary1 = temp088temp0 = object.ixpos89temp0 += screen.xcenter90stage.newXBoundary2 = temp091object.frame = object.animationTimer92object.frame /= 393object.frame += 294object.animationTimer++95object.animationTimer %= 696break9798case ANIMALPRISON_OPENED99if player[0].controlMode == CONTROLMODE_NONE100// Make the player start running to the right101player[0].left = false102player[0].right = true103player[0].up = false104player[0].down = false105player[0].jumpHold = false106end if107108object.timer++109temp0 = object.timer110temp0 &= 7111if temp0 == 4112Rand(temp0, 48)113temp0 -= 24114temp0 <<= 16115temp0 += object.xpos116Rand(temp1, 48)117temp1 -= 24118temp1 <<= 16119temp1 += object.ypos120CreateTempObject(TypeName[Explosion], 0, temp0, temp1)121object[tempObjectPos].drawOrder = 4122PlaySfx(SfxName[Explosion], false)123end if124125if object.timer == 60126temp1 = object.ypos127temp1 += 0x40000128temp2 = 0129temp3 = 30130while temp2 < 32131Rand(temp0, 48)132temp0 >>= 2133temp0 <<= 18134temp0 -= 0x180000135temp0 += object.xpos136temp4 = temp2137temp4 &= 1138if temp4 == 0139CreateTempObject(animalType1, temp3, temp0, temp1)140else141CreateTempObject(animalType2, temp3, temp0, temp1)142end if143animal[tempObjectPos].randomizeDir = true144temp0 += 0x40000145temp2++146temp3 += 5147loop148object.drawOrder = 4149object.timer = 4150object.state++151end if152object.frame = object.animationTimer153object.frame /= 3154object.frame += 4155object.animationTimer++156object.animationTimer %= 6157break158159case ANIMALPRISON_EXPLODE160object.timer++161temp0 = object.timer162temp0 &= 7163if temp0 == 4164Rand(temp0, 48)165temp0 -= 24166temp0 <<= 16167temp0 += object.xpos168Rand(temp1, 48)169temp1 -= 24170temp1 <<= 16171temp1 += object.ypos172CreateTempObject(TypeName[Explosion], 0, temp0, temp1)173object[tempObjectPos].drawOrder = 4174PlaySfx(SfxName[Explosion], false)175end if176177if object.timer == 34178object.timer = 0179object.state++180end if181182object.frame = object.animationTimer183object.frame /= 3184object.frame += 4185object.animationTimer++186object.animationTimer %= 6187break188189case ANIMALPRISON_HANDLEACTCLEAR190if object.timer < 300191object.timer++192else193PlayMusic(TRACK_ACTFINISH)194object[SLOT_ACTFINISH].type = TypeName[Act Finish]195object[SLOT_ACTFINISH].drawOrder = 6196object[SLOT_ACTFINISH].priority = PRIORITY_ACTIVE197object.timer = 0198object.state++199end if200break201202case ANIMALPRISON_FINISHED203break204205end switch206207foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)208switch object.state209case ANIMALPRISON_AWAITOPEN210BoxCollisionTest(C_SOLID, object.entityPos, -32, -24, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)211212BoxCollisionTest(C_SOLID, object.entityPos, -11, -48, 11, -24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)213if checkResult == COL_TOP214object.state = ANIMALPRISON_OPENED215stage.timeEnabled = false216217if player[currentPlayer].animation == ANI_JUMPING218player[currentPlayer].animation = ANI_WALKING219end if220221if Player_superState == SUPERSTATE_SUPER222Player_superState = SUPERSTATE_UNTRANSFORM223end if224225player[0].controlMode = CONTROLMODE_NONE226227#platform: USE_ORIGINS228// A fallback in case the player somehow gets to this capsule without beating the boss, for the Boss Rush229// -> Every individual boss calls this function already, but it doesn't hurt to play it safe230CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, true)231#endplatform232end if233break234235case ANIMALPRISON_OPENED236BoxCollisionTest(C_SOLID, object.entityPos, -32, -24, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)237BoxCollisionTest(C_SOLID, object.entityPos, -11, -40, 11, -24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)238break239240end switch241242#platform: USE_DECOMP243// Fix for when the screen is wide enough to extend beyond the stage width,244// causing the player to die during the results screen245temp0 = tileLayer[0].xsize246temp0 <<= 7247temp0 <<= 16248249if player[currentPlayer].xpos > temp0250temp1 = object.ypos251temp1 += 0xD0000252if player[currentPlayer].animation == ANI_JUMPING253temp2 = player[currentPlayer].jumpOffset254temp2 <<= 16255temp1 -= temp2256end if257if player[currentPlayer].ypos > temp1258player[currentPlayer].ypos = temp1259player[currentPlayer].yvel = 0260end if261end if262#endplatform263264temp0 = screen.xcenter265temp0 += 40266temp0 <<= 16267temp1 = object.xpos268temp1 += temp0269if player[currentPlayer].xpos > temp1270player[currentPlayer].xpos = temp1271player[currentPlayer].speed = 0272player[currentPlayer].xvel = 0273if player[currentPlayer].gravity == 0274player[currentPlayer].yvel = 0275end if276end if277278next279end event280281282event ObjectDraw283switch object.state284case ANIMALPRISON_AWAITOPEN285case ANIMALPRISON_OPENED286DrawSprite(object.frame)287DrawSprite(0)288break289290case ANIMALPRISON_EXPLODE291case ANIMALPRISON_HANDLEACTCLEAR292case ANIMALPRISON_FINISHED293DrawSprite(1)294break295296end switch297end event298299300event ObjectStartup301LoadSpriteSheet("Global/Items.gif")302303// Prison frames304SpriteFrame(-32, -32, 64, 62, 109, 166)305SpriteFrame(-32, -2, 64, 32, 35, 202)306SpriteFrame(-11, -48, 22, 16, 84, 166)307SpriteFrame(-11, -48, 22, 16, 35, 236)308SpriteFrame(-11, -40, 22, 16, 84, 166)309SpriteFrame(-11, -40, 22, 16, 35, 236)310311// Add the Animal Prison to the debug object list312SetTableValue(TypeName[Animal Prison], DebugMode_ObjCount, DebugMode_TypesTable)313SetTableValue(AnimalPrison_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)314SetTableValue(AnimalPrison_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)315DebugMode_ObjCount++316end event317318319// ========================320// Editor Events321// ========================322323event RSDKDraw324DrawSprite(1)325DrawSprite(0)326end event327328329event RSDKLoad330LoadSpriteSheet("Global/Items.gif")331SpriteFrame(-32, -32, 64, 62, 109, 166)332SpriteFrame(-11, -48, 22, 16, 84, 166)333334SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")335end event336337338