Path: blob/master/Sonic 2/Scripts/Mission/EggmanSignPost.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: EggmanSignPost Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// This Object is used in Mission "Eggman: Blue Beam" - M049 - Mission_Zone028// The script's name is kinda half misleading, this isn't just a signpost but it's also kind of a manager for the entire fight9// It's prolly just named this way because it's based off of S1's or CD's EggmanSignPosts which *were* actual signposts1011// ========================12// Aliases13// ========================1415// Variables16// First four are set from editor17private alias object.value0 : object.animTimerIncrease18private alias object.value1 : object.frameIncrease19private alias object.value2 : object.initialTrackSpeed20private alias object.value3 : object.initialExtraSpeed21private alias object.value4 : object.eggmanID22private alias object.value5 : object.newXBounds23private alias object.value6 : object.signPostID2425// States26private alias 0 : EGGMANSIGNPOST_AWAITEGGMAN27private alias 1 : EGGMANSIGNPOST_AWAITBOSSFIGHT28private alias 2 : EGGMANSIGNPOST_SPEEDUPBOSS29private alias 3 : EGGMANSIGNPOST_DEFEATFALL30private alias 4 : EGGMANSIGNPOST_ESCAPE31private alias 5 : EGGMANSIGNPOST_SPAWNFALLSIGNPOST32private alias 6 : EGGMANSIGNPOST_FINDFALLSIGNPOST33private alias 7 : EGGMANSIGNPOST_MISSIONCOMPLETE34private alias 8 : EGGMANSIGNPOST_FINISHED3536// Eggman States37private alias 0 : CPZEGGMAN_AWAITPLAYER38private alias 1 : CPZEGGMAN_BOSSFIGHT39private alias 3 : CPZEGGMAN_DEFEATFALL40private alias 6 : CPZEGGMAN_ESCAPE4142// Tipping Floor States43private alias 1 : TIPPINGFLOOR_TIPPING4445// Fall Sign Post States46private alias 1 : FALLSIGNPOST_FALLTOGROUND47private alias 2 : FALLSIGNPOST_SPINNINGONGROUND48private alias 4 : FALLSIGNPOST_LANDONGROUND4950// Player Aliases51private alias object.state : player.state52private alias object.speed : player.speed53private alias object.ixpos : player.ixpos54private alias object.xvel : player.xvel55private alias object.yvel : player.yvel56private alias object.animation : player.animation57private alias object.controlMode : player.controlMode58private alias object.interaction : player.interaction59private alias object.outOfBounds : player.outOfBounds60private alias object.jumpPress : player.jumpPress61private alias object.jumpHold : player.jumpHold62private alias object.up : player.up63private alias object.down : player.down64private alias object.left : player.left65private alias object.right : player.right6667// Chemical Dropper Aliases68private alias object.value14 : object.dropletAnimTimer69private alias object.value15 : object.chemicalFrame70private alias object.value19 : object.dropTrackSpeed71private alias object.value20 : object.extraSpeed7273// Tipping Floor Aliases74private alias object.value0 : object.timer75private alias object.value3 : object.bossEnd7677// Fall Sign Post Aliases78private alias object.value1 : object.spinCount798081// ========================82// Events83// ========================8485event ObjectUpdate86switch object.state87case EGGMANSIGNPOST_AWAITEGGMAN88if object.eggmanID == 089foreach (TypeName[Eggman], arrayPos0, ACTIVE_ENTITIES)90object.eggmanID = arrayPos091next9293if object.eggmanID != 094object.state++9596// All of these values are to be set from editor, enforce some limits on them97// Their actual values in the scene are listed next to every entry9899// Normally 10100if object.animTimerIncrease < 0101object.animTimerIncrease = 0102else103if object.animTimerIncrease > 18104object.animTimerIncrease = 18105end if106end if107108// Normally 7109if object.frameIncrease < 0110object.frameIncrease = 0111else112if object.frameIncrease > 12113object.frameIncrease = 12114end if115end if116117// Normally 2118if object.initialTrackSpeed < 0119object.initialTrackSpeed = 0120end if121122// Normally 2123if object.initialExtraSpeed < 0124object.initialExtraSpeed = 0125end if126end if127end if128break129130case EGGMANSIGNPOST_AWAITBOSSFIGHT131arrayPos0 = object.eggmanID132if object[arrayPos0].state == CPZEGGMAN_BOSSFIGHT133arrayPos0++134object[arrayPos0].dropTrackSpeed = object.initialTrackSpeed135object[arrayPos0].dropTrackSpeed <<= 16136object[arrayPos0].dropTrackSpeed += 0x10000137138object[arrayPos0].extraSpeed = object.initialExtraSpeed139object[arrayPos0].extraSpeed <<= 16140object[arrayPos0].extraSpeed += 0x30000141object.state++142end if143break144145case EGGMANSIGNPOST_SPEEDUPBOSS146arrayPos0 = object.eggmanID147if object[arrayPos0].state == CPZEGGMAN_BOSSFIGHT148arrayPos1 = object.eggmanID149arrayPos1++150if object[arrayPos1].dropletAnimTimer == 0151object[arrayPos1].dropletAnimTimer = object.animTimerIncrease152temp0 = object[arrayPos1].chemicalFrame153temp0 += object.frameIncrease154if temp0 >= 30155object[arrayPos1].chemicalFrame = 30156end if157end if158else159object.type = TypeName[Blank Object]160end if161break162163case EGGMANSIGNPOST_DEFEATFALL164arrayPos0 = object.eggmanID165if object[arrayPos0].state == CPZEGGMAN_DEFEATFALL166stage.newXBoundary2 = object.newXBounds167object.state++168end if169break170171case EGGMANSIGNPOST_ESCAPE172arrayPos0 = object.eggmanID173if object[arrayPos0].state == CPZEGGMAN_ESCAPE174stage.newXBoundary2 = object.newXBounds175object.state++176end if177break178179case EGGMANSIGNPOST_SPAWNFALLSIGNPOST180arrayPos0 = object.eggmanID181if object[arrayPos0].type == TypeName[Blank Object]182game.missionCondition = MISSION_CONDITION_CLEAR183CreateTempObject(TypeName[FallSignPost], 0, 0, 0)184object[tempObjectPos].frame = 1185object[tempObjectPos].spinCount = 16186object[tempObjectPos].priority = PRIORITY_ACTIVE187object.state++188object.priority = PRIORITY_ACTIVE189end if190break191192case EGGMANSIGNPOST_FINDFALLSIGNPOST193foreach (TypeName[FallSignPost], arrayPos0, ACTIVE_ENTITIES)194object.signPostID = arrayPos0195next196object.state++197break198199case EGGMANSIGNPOST_MISSIONCOMPLETE200arrayPos2 = 0201foreach (TypeName[Tipping Floor], arrayPos0, ACTIVE_ENTITIES)202if object[arrayPos0].bossEnd != false203object[arrayPos0].state = TIPPINGFLOOR_TIPPING204object[arrayPos0].timer = 1205object[arrayPos0].animation = 1206object[arrayPos0].frame = 0207else208if object[arrayPos0].frame == 0209object[arrayPos0].state = TIPPINGFLOOR_TIPPING210object[arrayPos0].timer = 1211object[arrayPos0].animation = 1212object[arrayPos0].bossEnd = true213end if214end if215216// Provide Platform collision between the Tipping Floor and the player, regardless of the Floor's actual frame so that the player doesn't fall and die post-boss217BoxCollisionTest(C_PLATFORM, object[arrayPos0].entityPos, -16, -16, 16, -8, 0, C_BOX, C_BOX, C_BOX, C_BOX)218arrayPos2 = arrayPos0219next220221if object.signPostID != 0222arrayPos1 = object.signPostID223if object[arrayPos1].type == TypeName[FallSignPost]224if object[arrayPos1].state < FALLSIGNPOST_SPINNINGONGROUND225temp0 = 48226temp0 <<= 16227temp0 += object[arrayPos1].ypos228if object[arrayPos2].ypos <= temp0229if object[arrayPos1].state == FALLSIGNPOST_FALLTOGROUND230object[arrayPos1].state = FALLSIGNPOST_LANDONGROUND231end if232end if233end if234else235arrayPos0 = object.signPostID236CheckEqual(player[0].state, Player_State_Ground)237temp0 = checkResult238CheckEqual(player[0].state, Player_State_Static)239temp0 |= checkResult240CheckEqual(player[0].outOfBounds, true)241temp0 |= checkResult242temp1 = screen.xoffset243temp1 += screen.xsize244temp1 += 32245CheckGreater(player[0].ixpos, temp1)246temp0 |= checkResult247CheckGreater(object[arrayPos0].state, FALLSIGNPOST_FALLTOGROUND)248temp0 &= checkResult249250if temp0 == true251SetBit(object[arrayPos0].value3, 0, false) // FallSignPosts don't use their value3 btw252player[0].state = Player_State_Static253player[0].controlMode = CONTROLMODE_NONE254player[0].interaction = false255player[0].up = false256player[0].down = false257player[0].left = false258player[0].right = false259player[0].jumpHold = false260player[0].jumpPress = false261player[0].xvel = 0262player[0].yvel = 0263player[0].speed = 0264player[0].animation = ANI_WAITING265screen.cameraEnabled = false266end if267end if268end if269break270271case EGGMANSIGNPOST_FINISHED272// This state isn't ever even used, it seems?273// EGGMANSIGNPOST_MISSIONCOMPLETE is what the object should be on at the end of everything, and there's nothing to make it to go this state at all274break275276end switch277end event278279280// ========================281// Editor Events282// ========================283284event RSDKDraw285DrawSprite(0)286end event287288289event RSDKLoad290LoadSpriteSheet("Global/Display.gif")291SpriteFrame(-16, -16, 32, 32, 1, 143)292293// TODO: val0, val1, val2, val3, they're all set from editor so they prolly do something294// (m049)295// it looks like they're used for controlling robotnik's speed and stuff? that's honestly a really cool way to do it, props to them296SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")297end event298299300