Path: blob/master/Sonic 2/Scripts/Mission/SignPost2.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Sign Post2 Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// TODO: check out its scale attr in stuff like m104, ain't that strange?89// ========================10// Aliases11// ========================1213// Variables14private alias object.value0 : object.centerInit15private alias object.value1 : object.spinCount16private alias object.value2 : object.spinTimer17private alias object.value3 : object.activePlayers18private alias object.value4 : object.allPlayersFinished19private alias object.value5 : object.lastPlayerID20private alias object.value6 : object.centerOffset // x center offset21private alias object.value7 : object.enableExitRight // determines if the exit stage right sequence should occur2223// States24private alias 0 : SIGNPOST2_IDLE25private alias 1 : SIGNPOST2_SPUN26private alias 2 : SIGNPOST2_EXITPLAYER27private alias 3 : SIGNPOST2_IDLE_VS28private alias 4 : SIGNPOST2_SPUN_VS29private alias 5 : SIGNPOST2_UNUSED30private alias 6 : SIGNPOST2_FINISHED3132// Player Aliases33private alias object.type : player.type34private alias object.propertyValue : player.character35private alias object.xpos : player.xpos36private alias object.ypos : player.ypos37private alias object.ixpos : player.ixpos38private alias object.speed : player.speed39private alias object.xvel : player.xvel40private alias object.controlMode : player.controlMode41private alias object.scrollTracking : player.scrollTracking42private alias object.interaction : player.interaction43private alias object.jumpPress : player.jumpPress44private alias object.jumpHold : player.jumpHold45private alias object.up : player.up46private alias object.down : player.down47private alias object.left : player.left48private alias object.right : player.right49private alias object.value7 : player.invincibleTimer50private alias object.value21 : player.acceleration5152private alias 1 : SUPERSTATE_SUPER53private alias 2 : SUPERSTATE_FADEOUT5455// VSGame aliases56private alias object.value0 : vsGame.timer57private alias object.value5 : vsGame.countdownPlayer5859// VSGame States60private alias 0 : VSGAME_DISPLAYTAGS61private alias 2 : VSGAME_FADEOUT62private alias 3 : VSGAME_FINISH_COUNTDOWN63private alias 4 : VSGAME_GOTOVSRESULTS6465// Game Modes66private alias 2 : MODE_TIMEATTACK6768// Tracks69private alias 1 : TRACK_ACTFINISH7071// Achievement Aliases72private alias 0 : ACHIEVEMENT_QUICKRUN73private alias 3 : ACHIEVEMENT_SUPERSTAR74private alias 10 : ACHIEVEMENT_SCRAMBLEDEGG757677// ========================78// Function Declarations79// ========================8081reserve function SignPost2_DebugDraw82reserve function SignPost2_DebugSpawn838485// ========================86// Function Definitions87// ========================8889private function SignPost2_DebugDraw90DrawSprite(0)91DrawSprite(1)92end function939495private function SignPost2_DebugSpawn96CreateTempObject(TypeName[Sign Post2], 0, object.xpos, object.ypos)97object[tempObjectPos].frame = 198object[tempObjectPos].spinCount = 1699if options.vsMode == true100object[tempObjectPos].state = SIGNPOST2_IDLE_VS101end if102end function103104105// ========================106// Events107// ========================108109event ObjectUpdate110switch object.state111case SIGNPOST2_IDLE112temp0 = object.ypos113temp0 += 0x400000114if player[0].ypos < temp0115if object.centerOffset > 0116// These two lines used to use ixpos, but Plus changed them to xpos117temp0 = object.xpos118temp0 -= player[0].xpos119temp0 >>= 16120121CheckGreater(temp0, 0)122temp1 = checkResult123CheckLower(temp0, object.centerOffset)124checkResult &= temp1125if checkResult == true126stage.newXBoundary1 = object.ixpos127stage.newXBoundary1 -= object.centerOffset128stage.newXBoundary2 = object.xpos129stage.newXBoundary2 >>= 16130stage.newXBoundary2 += screen.xcenter131end if132else133stage.newXBoundary1 = object.xpos134stage.newXBoundary1 >>= 16135stage.newXBoundary1 -= screen.xcenter136stage.newXBoundary1 -= screen.xcenter137stage.newXBoundary2 = object.xpos138stage.newXBoundary2 >>= 16139stage.newXBoundary2 += screen.xcenter140end if141142if player[0].xpos > object.xpos143stage.newXBoundary1 = object.xpos144stage.newXBoundary1 >>= 16145stage.newXBoundary1 -= screen.xcenter146147switch player[0].character148case PLAYER_SONIC_A149EditFrame(5, -24, -16, 48, 32, 34, 1)150break151152case PLAYER_TAILS_A153EditFrame(5, -24, -16, 48, 32, 34, 34)154break155156case PLAYER_KNUCKLES_A157EditFrame(5, -24, -16, 48, 32, 34, 67)158break159160case PLAYER_AMY_A161EditFrame(5, -24, -16, 48, 32, 34, 149)162break163end switch164165// No achievements in debug mode!166if stage.debugMode == false167if stage.activeList == BONUS_STAGE168// Boss Attack is on the Bonus Stage list, check for the Boss Attack achievement169// (In Origins all the Missions are on the Bonus stage list too, so this check can reward the achievement for them as well lol)170if stage.minutes < 7171CallNativeFunction2(SetAchievement, ACHIEVEMENT_SCRAMBLEDEGG, 100)172end if173else174if stage.listPos == 0175if stage.minutes == 0176if stage.seconds < 35177CallNativeFunction2(SetAchievement, ACHIEVEMENT_QUICKRUN, 100)178end if179end if180end if181end if182end if183184CallNativeFunction2(NotifyCallback, NOTIFY_TOUCH_SIGNPOST, 0)185186stage.timeEnabled = false187object.state = SIGNPOST2_SPUN188PlaySfx(SfxName[Sign Post], false)189190if Player_superState == SUPERSTATE_SUPER191Player_superState = SUPERSTATE_FADEOUT192if stage.debugMode == false193CallNativeFunction2(SetAchievement, ACHIEVEMENT_SUPERSTAR, 100)194end if195end if196end if197end if198break199200case SIGNPOST2_SPUN201music.volume--202203object.spinTimer++204if object.spinTimer == 2205object.spinTimer = 0206object.frame++207if object.frame == 5208object.frame = 1209Rand(temp0, 48)210temp0 <<= 16211temp0 += object.xpos212temp0 -= 0x180000213Rand(temp1, 32)214temp1 <<= 16215temp1 += object.ypos216temp1 -= 0x140000217CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)218219object.spinCount--220if object.spinCount == 0221if object.enableExitRight != false222SetBit(object.activePlayers, 0, true)223if stage.player2Enabled == true224SetBit(object.activePlayers, 1, true)225end if226else227player[0].interaction = false228player[0].controlMode = CONTROLMODE_NONE229player[0].up = false230player[0].down = false231player[0].left = false232player[0].right = false233player[0].jumpPress = false234player[0].jumpHold = false235end if236object.state = SIGNPOST2_EXITPLAYER237end if238end if239end if240break241242case SIGNPOST2_EXITPLAYER243temp0 = screen.xcenter244temp0 <<= 16245temp0 += object.xpos246CheckGreater(player[0].xpos, temp0)247temp1 = checkResult248CheckEqual(object.enableExitRight, false)249checkResult |= temp1250if checkResult == true251PlayMusic(TRACK_ACTFINISH)252object.state = SIGNPOST2_FINISHED253object[30].type = TypeName[Act Finish]254object[30].drawOrder = 6255object[30].priority = PRIORITY_ACTIVE256end if257break258259case SIGNPOST2_IDLE_VS260stage.newXBoundary2 = object.xpos261stage.newXBoundary2 >>= 16262stage.newXBoundary2 += screen.xcenter263foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)264GetBit(temp1, object.activePlayers, currentPlayer)265if temp1 == false266if player[currentPlayer].xpos > object.xpos267object.priority = PRIORITY_ACTIVE268269SetBit(object.activePlayers, currentPlayer, true)270271if currentPlayer == 0272if Player_superState == SUPERSTATE_SUPER273Player_superState = SUPERSTATE_FADEOUT274end if275276if vs.playerID == 0277temp2 = 0278else279temp2 = 1280end if281else282if vs.playerID == 0283temp2 = 1284else285temp2 = 0286end if287end if288289if temp2 == 0290vs.time1P = stage.milliSeconds291vs.time1P = stage.seconds292vs.time1P *= 100293temp2 = stage.minutes294temp2 *= 6000295vs.time1P += temp2296vs.time1P += stage.milliSeconds297else298vs.time2P = stage.milliSeconds299vs.time2P = stage.seconds300vs.time2P *= 100301temp2 = stage.minutes302temp2 *= 6000303vs.time2P += temp2304vs.time2P += stage.milliSeconds305end if306307object.lastPlayerID = currentPlayer308object.spinCount = 16309object.state = SIGNPOST2_SPUN_VS310PlaySfx(SfxName[Sign Post], false)311312if object.allPlayersFinished == false313PlaySfx(SfxName[Sign Post 2P], false)314object[30].state = VSGAME_FINISH_COUNTDOWN315vsGame[30].countdownPlayer = currentPlayer316vsGame[30].countdownPlayer ^= 1317318switch player[currentPlayer].character319case PLAYER_SONIC_A320EditFrame(5, -24, -16, 48, 32, 34, 1)321break322323case PLAYER_TAILS_A324EditFrame(5, -24, -16, 48, 32, 34, 34)325break326327case PLAYER_KNUCKLES_A328EditFrame(5, -24, -16, 48, 32, 34, 67)329break330331case PLAYER_AMY_A332EditFrame(5, -24, -16, 48, 32, 34, 149)333break334end switch335else336object[30].state = VSGAME_DISPLAYTAGS337end if338339if object.activePlayers == 3340object.allPlayersFinished = true341object[30].state = VSGAME_DISPLAYTAGS342end if343end if344end if345next346break347348case SIGNPOST2_SPUN_VS349if object.allPlayersFinished == true350music.volume--351else352foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)353GetBit(temp1, object.activePlayers, currentPlayer)354if temp1 == false355if player[currentPlayer].xpos > object.xpos356object.spinTimer = 1357object.frame = 4358object.spinCount = 1359end if360end if361next362end if363364object.spinTimer++365if object.spinTimer == 2366object.spinTimer = 0367object.frame++368if object.frame == 5369object.frame = 1370Rand(temp0, 48)371temp0 <<= 16372temp0 += object.xpos373temp0 -= 0x180000374Rand(temp1, 32)375temp1 <<= 16376temp1 += object.ypos377temp1 -= 0x140000378CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)379380object.spinCount--381if object.spinCount == 0382if object.allPlayersFinished == false383object.allPlayersFinished = true384object.state = SIGNPOST2_IDLE_VS385else386object.state = SIGNPOST2_FINISHED387object[30].state = VSGAME_GOTOVSRESULTS388vsGame[30].timer = -768389end if390end if391end if392end if393break394395case SIGNPOST2_FINISHED396break397398default399case SIGNPOST2_UNUSED400break401402end switch403404// Invisible off-screen barrier405temp0 = 40406temp0 += 212 // (screen.xcenter)407temp0 <<= 16408temp0 += object.xpos409currentPlayer = 0410while currentPlayer < playerCount411GetBit(temp1, object.activePlayers, currentPlayer)412if temp1 == true413player[currentPlayer].interaction = false414player[currentPlayer].controlMode = CONTROLMODE_NONE415player[currentPlayer].up = false416player[currentPlayer].down = false417player[currentPlayer].left = false418player[currentPlayer].right = true419player[currentPlayer].jumpPress = false420player[currentPlayer].jumpHold = false421end if422423if player[currentPlayer].xpos > temp0424player[currentPlayer].xpos = temp0425player[currentPlayer].speed = 0426player[currentPlayer].xvel = 0427end if428429if player[currentPlayer].type == TypeName[Debug Mode]430SetBit(object.activePlayers, currentPlayer, false)431end if432currentPlayer++433loop434435if object.state > SIGNPOST2_IDLE436player[0].invincibleTimer = 80437end if438end event439440441event ObjectDraw442DrawSprite(0)443if object.spinCount > 8444DrawSprite(object.frame)445else446temp0 = object.frame447temp0 += 4448DrawSprite(temp0)449end if450end event451452453event ObjectStartup454LoadSpriteSheet("Global/Items2.gif")455456SpriteFrame(-24, 16, 48, 16, 34, 132)457switch stage.playerListPos458// Has Sonic Team never heard of a default case?459case PLAYER_SONIC_A460case PLAYER_TAILS_A461case PLAYER_KNUCKLES_A462case PLAYER_SONIC_TAILS_A463case PLAYER_KNUCKLES_TAILS_A464SpriteFrame(-24, -16, 48, 32, 34, 100) // #1 - Eggman giving a big smile465SpriteFrame(-16, -16, 32, 32, 149, 99) // #2 - Spin frame 1466SpriteFrame(-4, -16, 8, 32, 247, 2) // #3 - Spin frame 2467SpriteFrame(-16, -16, 32, 32, 116, 99) // #4 - Spin frame 3468SpriteFrame(-24, -16, 48, 32, 34, 1) // #5 - Main character frame (Sonic here, but will change to the appropriate character in-game)469SpriteFrame(-16, -16, 32, 32, 149, 99) // #6 - Spin frame 4 (duplicate of frame 1)470SpriteFrame(-4, -16, 8, 32, 247, 2) // #7 - Spin frame 5 (duplicate of frame 2)471SpriteFrame(-16, -16, 32, 32, 116, 99) // #8 - Spin frame 6 (duplicate of frame 3)472break473474case PLAYER_AMY_A475case PLAYER_AMY_TAILS_A476SpriteFrame(-24, -16, 48, 32, 34, 100) // #1 - Eggman giving a big smile477SpriteFrame(-16, -16, 32, 32, 149, 132) // #2 - Spin frame 1 (Amy)478SpriteFrame(-4, -16, 8, 32, 247, 2) // #3 - Spin frame 2479SpriteFrame(-16, -16, 32, 32, 116, 132) // #4 - Spin frame 3 (Amy)480SpriteFrame(-24, -16, 48, 32, 34, 149) // #5 - Amy frame481SpriteFrame(-16, -16, 32, 32, 149, 132) // #6 - Spin frame 4 (duplicate of frame 1)482SpriteFrame(-4, -16, 8, 32, 247, 2) // #7 - Spin frame 5 (duplicate of frame 2)483SpriteFrame(-16, -16, 32, 32, 116, 132) // #8 - Spin frame 6 (duplicate of frame 3)484break485end switch486487foreach (TypeName[Sign Post2], arrayPos0, ALL_ENTITIES)488CheckGreater(object[arrayPos0].propertyValue, 0)489temp0 = checkResult490CheckEqual(options.vsMode, false)491temp0 &= checkResult492if temp0 == true493object[arrayPos0].type = TypeName[Blank Object]494else495// Editors can only set object values 0-3, so set value6 to value0 and then reset value0496// ...they could've just used value0 for the actual offset value though, it's not used for anything else in this object497object[arrayPos0].centerOffset = object[arrayPos0].centerInit498object[arrayPos0].centerOffset <<= 4499object[arrayPos0].centerInit = 0500501// Same thing here, set value7 to value1 and reset value1502object[arrayPos0].enableExitRight = object[arrayPos0].spinCount503object[arrayPos0].spinCount = 0504505object[arrayPos0].frame = 1506object[arrayPos0].spinCount = 16507if object[arrayPos0].propertyValue != 2508object[arrayPos0].priority = PRIORITY_XBOUNDS509end if510end if511512if options.vsMode == true513object[arrayPos0].state = SIGNPOST2_IDLE_VS514end if515next516517SetTableValue(TypeName[Sign Post2], DebugMode_ObjCount, DebugMode_TypesTable)518SetTableValue(SignPost2_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)519SetTableValue(SignPost2_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)520DebugMode_ObjCount++521end event522523524// ========================525// Editor Events526// ========================527528event RSDKEdit529if editor.returnVariable == true530switch editor.variableID531case EDIT_VAR_PROPVAL // property value532checkResult = object.propertyValue533break534535case 0 // type536checkResult = object.propertyValue537break538539end switch540else541switch editor.variableID542case EDIT_VAR_PROPVAL // property value543object.propertyValue = editor.variableValue544break545546case 0 // type547object.propertyValue = editor.variableValue548break549550end switch551end if552end event553554555event RSDKDraw556DrawSprite(0)557DrawSprite(1)558end event559560561event RSDKLoad562LoadSpriteSheet("Global/Items2.gif")563SpriteFrame(-24, 16, 48, 16, 34, 132)564SpriteFrame(-24, -16, 48, 32, 34, 100)565566AddEditorVariable("type")567SetActiveVariable("type")568AddEnumVariable("Normal", 0)569AddEnumVariable("VS Only (No Y Bounds)", 1)570AddEnumVariable("VS Only (Use Y Bounds)", 2)571572SetVariableAlias(ALIAS_VAR_VAL0, "centerOffset")573SetVariableAlias(ALIAS_VAR_VAL1, "enableExitRight")574end event575576577