Path: blob/master/Sonic 2/Scripts/Global/SignPost.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Sign Post Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011// Variables12private alias object.value0 : object.fallbackTimer // Added in Origins 2.0.113private alias object.value1 : object.spinCount14private alias object.value2 : object.spinTimer15private alias object.value3 : object.activePlayers16private alias object.value4 : object.allPlayersFinished17private alias object.value5 : object.lastPlayerID1819// States20private alias 0 : SIGNPOST_IDLE21private alias 1 : SIGNPOST_SPUN22private alias 2 : SIGNPOST_EXITPLAYER23private alias 3 : SIGNPOST_IDLE_VS24private alias 4 : SIGNPOST_SPUN_VS25private alias 5 : SIGNPOST_UNUSED // used for SBZ2>3 transition in S1, not used in this game26private alias 6 : SIGNPOST_FINISHED2728// Player Aliases29private alias object.type : player.type30private alias object.propertyValue : player.character31private alias object.xpos : player.xpos32private alias object.ypos : player.ypos33private alias object.ixpos : player.ixpos34private alias object.speed : player.speed35private alias object.xvel : player.xvel36private alias object.yvel : player.yvel37private alias object.gravity : player.gravity38private alias object.animation : player.animation39private alias object.controlMode : player.controlMode40private alias object.scrollTracking : player.scrollTracking41private alias object.interaction : player.interaction42private alias object.jumpPress : player.jumpPress43private alias object.jumpHold : player.jumpHold44private alias object.up : player.up45private alias object.down : player.down46private alias object.left : player.left47private alias object.right : player.right48private alias object.value7 : player.invincibleTimer49private alias object.value21 : player.acceleration50private alias object.value30 : player.jumpOffset5152private 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_SCRAMBLEDEGG7576// Reserved Object Slot Aliases77private alias 30 : SLOT_ACTFINISH787980// ========================81// Function Declarations82// ========================8384reserve function SignPost_DebugDraw85reserve function SignPost_DebugSpawn868788// ========================89// Static Values90// ========================9192public value SignPost_initFallback = 093public value SignPost_fallbackCheck = 0949596// ========================97// Function Definitions98// ========================99100private function SignPost_DebugDraw101DrawSprite(0)102DrawSprite(1)103end function104105106private function SignPost_DebugSpawn107CreateTempObject(TypeName[Sign Post], 0, object.xpos, object.ypos)108object[tempObjectPos].frame = 1109object[tempObjectPos].spinCount = 16110if options.vsMode == true111object[tempObjectPos].state = SIGNPOST_IDLE_VS112end if113end function114115116// ========================117// Events118// ========================119120event ObjectUpdate121switch object.state122case SIGNPOST_IDLE123#platform: USE_ORIGINS124object.fallbackTimer++125#endplatform126127temp0 = object.ypos128temp0 += 0x400000129if player[0].ypos < temp0130stage.newXBoundary1 = object.xpos131stage.newXBoundary1 >>= 16132stage.newXBoundary1 -= screen.xcenter133stage.newXBoundary1 -= screen.xcenter134135stage.newXBoundary2 = object.xpos136stage.newXBoundary2 >>= 16137stage.newXBoundary2 += screen.xcenter138139if player[0].xpos > object.xpos140stage.newXBoundary1 = object.xpos141stage.newXBoundary1 >>= 16142stage.newXBoundary1 -= screen.xcenter143144switch player[0].character145case PLAYER_SONIC_A146EditFrame(5, -24, -16, 48, 32, 34, 1)147break148149case PLAYER_TAILS_A150EditFrame(5, -24, -16, 48, 32, 34, 34)151break152153case PLAYER_KNUCKLES_A154EditFrame(5, -24, -16, 48, 32, 34, 67)155break156157#platform: USE_ORIGINS158case PLAYER_AMY_A159EditFrame(5, -24, -16, 48, 32, 34, 149)160break161#endplatform162end switch163164// No achievements in debug mode!165if stage.debugMode == false166if stage.activeList == BONUS_STAGE167// Boss Attack is on the Bonus Stage list, check for the Boss Attack achievement168// (This code doesn't account for Origins having everything on the Bonus list since Missions didn't even exist back then)169if stage.minutes < 7170// Grant the "Scrambled Egg" Achievement171CallNativeFunction2(SetAchievement, ACHIEVEMENT_SCRAMBLEDEGG, 100)172end if173else174if stage.listPos == 0175if stage.minutes == 0176if stage.seconds < 35177// Grant the "Quick Run" Achievement, for beating EHZ in under 35 seconds178CallNativeFunction2(SetAchievement, ACHIEVEMENT_QUICKRUN, 100)179end if180end if181end if182end if183end if184185#platform: USE_ORIGINS186CallNativeFunction2(NotifyCallback, NOTIFY_TOUCH_SIGNPOST, 0)187#endplatform188stage.timeEnabled = false189object.state = SIGNPOST_SPUN190#platform: USE_ORIGINS191SignPost_initFallback = object.fallbackTimer192#endplatform193PlaySfx(SfxName[Sign Post], false)194195if Player_superState == SUPERSTATE_SUPER196Player_superState = SUPERSTATE_FADEOUT197if stage.debugMode == false198// Grant the "Superstar" Achievement, for beating an act while transformed199CallNativeFunction2(SetAchievement, ACHIEVEMENT_SUPERSTAR, 100)200end if201end if202end if203end if204break205206case SIGNPOST_SPUN207music.volume--208209object.spinTimer++210if object.spinTimer == 2211object.spinTimer = 0212object.frame++213if object.frame == 5214object.frame = 1215216Rand(temp0, 48)217temp0 <<= 16218temp0 += object.xpos219temp0 -= 0x180000220221Rand(temp1, 32)222temp1 <<= 16223temp1 += object.ypos224temp1 -= 0x140000225226CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)227228object.spinCount--229if object.spinCount == 0230SetBit(object.activePlayers, 0, true)231if stage.player2Enabled == true232SetBit(object.activePlayers, 1, true)233end if234object.state = SIGNPOST_EXITPLAYER235end if236end if237end if238break239240case SIGNPOST_EXITPLAYER241temp0 = screen.xcenter242temp0 <<= 16243temp0 += object.xpos244245#platform: USE_ORIGINS246object.fallbackTimer++247SignPost_fallbackCheck = object.fallbackTimer248SignPost_fallbackCheck -= SignPost_initFallback249if SignPost_fallbackCheck > 200250PlayMusic(TRACK_ACTFINISH)251object[SLOT_ACTFINISH].type = TypeName[Act Finish]252object[SLOT_ACTFINISH].drawOrder = 6253object[SLOT_ACTFINISH].priority = PRIORITY_ACTIVE254end if255#endplatform256257if player[0].xpos > temp0258PlayMusic(TRACK_ACTFINISH)259object.state = SIGNPOST_FINISHED260object[30].type = TypeName[Act Finish]261object[30].drawOrder = 6262object[30].priority = PRIORITY_ACTIVE263#platform: USE_ORIGINS264else265if player[0].animation == ANI_PUSHING266PlayMusic(TRACK_ACTFINISH)267object.state = SIGNPOST_FINISHED268object[30].type = TypeName[Act Finish]269object[30].drawOrder = 6270object[30].priority = PRIORITY_ACTIVE271end if272#endplatform273end if274break275276case SIGNPOST_IDLE_VS277stage.newXBoundary2 = object.xpos278stage.newXBoundary2 >>= 16279stage.newXBoundary2 += screen.xcenter280foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)281GetBit(temp1, object.activePlayers, currentPlayer)282if temp1 == false283if player[currentPlayer].xpos > object.xpos284object.priority = PRIORITY_ACTIVE285286SetBit(object.activePlayers, currentPlayer, true)287288if currentPlayer == 0289if Player_superState == SUPERSTATE_SUPER290Player_superState = SUPERSTATE_FADEOUT291end if292293if vs.playerID == 0294temp2 = 0295else296temp2 = 1297end if298else299if vs.playerID == 0300temp2 = 1301else302temp2 = 0303end if304end if305306if temp2 == 0307vs.time1P = stage.milliSeconds308vs.time1P = stage.seconds309vs.time1P *= 100310temp2 = stage.minutes311temp2 *= 6000312vs.time1P += temp2313vs.time1P += stage.milliSeconds314else315vs.time2P = stage.milliSeconds316vs.time2P = stage.seconds317vs.time2P *= 100318temp2 = stage.minutes319temp2 *= 6000320vs.time2P += temp2321vs.time2P += stage.milliSeconds322end if323324object.lastPlayerID = currentPlayer325object.spinCount = 16326object.state = SIGNPOST_SPUN_VS327PlaySfx(SfxName[Sign Post], false)328329if object.allPlayersFinished == false330PlaySfx(SfxName[Sign Post 2P], false)331object[30].state = VSGAME_FINISH_COUNTDOWN332vsGame[30].countdownPlayer = currentPlayer333vsGame[30].countdownPlayer ^= 1334switch player[currentPlayer].character335case PLAYER_SONIC_A336EditFrame(5, -24, -16, 48, 32, 34, 1)337break338339case PLAYER_TAILS_A340EditFrame(5, -24, -16, 48, 32, 34, 34)341break342343case PLAYER_KNUCKLES_A344EditFrame(5, -24, -16, 48, 32, 34, 67)345break346347#platform: USE_ORIGINS348case PLAYER_AMY_A349EditFrame(5, -24, -16, 48, 32, 34, 149)350break351#endplatform352end switch353else354object[30].state = VSGAME_DISPLAYTAGS355#platform: USE_ORIGINS356stage.timeEnabled = false357#endplatform358end if359360if object.activePlayers == 3 // both bits set? (3 is 0b11)361object.allPlayersFinished = true362object[30].state = VSGAME_DISPLAYTAGS363end if364end if365end if366next367break368369case SIGNPOST_SPUN_VS370if object.allPlayersFinished == true371music.volume--372else373foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)374GetBit(temp1, object.activePlayers, currentPlayer)375if temp1 == false376if player[currentPlayer].xpos > object.xpos377object.spinTimer = 1378object.frame = 4379object.spinCount = 1380end if381end if382next383end if384385object.spinTimer++386if object.spinTimer == 2387object.spinTimer = 0388object.frame++389if object.frame == 5390object.frame = 1391Rand(temp0, 48)392temp0 <<= 16393temp0 += object.xpos394temp0 -= 0x180000395Rand(temp1, 32)396temp1 <<= 16397temp1 += object.ypos398temp1 -= 0x140000399CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)400401object.spinCount--402if object.spinCount == 0403if object.allPlayersFinished == false404object.allPlayersFinished = true405object.state = SIGNPOST_IDLE_VS406407#platform: USE_STANDALONE408if object.lastPlayerID == 0409// Start spectating P2410camera[0].target = 1411player[1].scrollTracking = true412object[9].type = TypeName[Blank Object]413CreateTempObject(TypeName[VS Game], 0, object.xpos, object.ypos)414vsGame[tempObjectPos].timer = 384415object[tempObjectPos].state = VSGAME_FADEOUT416camera[0].xpos = player[1].xpos417camera[0].xpos >>= 16418camera[0].ypos = player[1].ypos419camera[0].ypos >>= 16420end if421#endplatform422else423object.state = SIGNPOST_FINISHED424object[30].state = VSGAME_GOTOVSRESULTS425vsGame[30].timer = -768426end if427end if428end if429end if430break431432case SIGNPOST_FINISHED433break434end switch435436// Invisible off-screen barrier437438// Bug Details:439// 212 in the line "temp0 += 212" is supposed to be the center of the screen when the screen width is set to 424 (the default screen width in RSDK)440// For some reason, it's set as a constant rather than using "screen.xcenter", meaning the barrier will always be 252 pixels away from the sign post regardless of screen width441// If your screen width is set to over 520, the barrier won't reach the edge of the screen, softlocking the game during exit stage right...442// We decided to provide a decomp-exclusive fix, so you shouldn't have to worry about this there443444temp0 = 40445temp0 += 212446#platform: USE_DECOMP447temp0 = 40448temp0 += screen.xcenter449#endplatform450temp0 <<= 16451temp0 += object.xpos452currentPlayer = 0453while currentPlayer < playerCount454GetBit(temp1, object.activePlayers, currentPlayer)455if temp1 == true456player[currentPlayer].interaction = false457player[currentPlayer].controlMode = CONTROLMODE_NONE458player[currentPlayer].up = false459player[currentPlayer].down = false460player[currentPlayer].left = false461player[currentPlayer].right = true462player[currentPlayer].jumpPress = false463player[currentPlayer].jumpHold = false464end if465466#platform: USE_DECOMP467// Another ultrawide screen fix, this time for when the screen is wide enough to extend beyond468// the stage width, causing the player to constantly fall and wrap around the stage vertically469temp1 = tileLayer[0].xsize470temp1 <<= 7471temp1 <<= 16472if player[currentPlayer].xpos > temp1473temp1 = object.ypos474temp1 += 0x200000 // This is quite a bit under the floor - this is because some acts have wavy ground at the end475if player[currentPlayer].animation == ANI_JUMPING476temp2 = player[currentPlayer].jumpOffset477temp2 <<= 16478temp1 -= temp2479end if480if player[currentPlayer].ypos > temp1481player[currentPlayer].ypos = temp1482player[currentPlayer].yvel = 0483end if484end if485#endplatform486487if player[currentPlayer].xpos > temp0488player[currentPlayer].xpos = temp0489player[currentPlayer].speed = 0490player[currentPlayer].xvel = 0491end if492493if player[currentPlayer].type == TypeName[Debug Mode]494SetBit(object.activePlayers, currentPlayer, false)495end if496497currentPlayer++498loop499500#platform: USE_ORIGINS501if game.playMode == BOOT_PLAYMODE_MISSION502if object.state > SIGNPOST_IDLE503player[0].invincibleTimer = 80504end if505end if506#endplatform507end event508509510event ObjectDraw511DrawSprite(0)512513if object.spinCount > 8514DrawSprite(object.frame)515else516temp0 = object.frame517temp0 += 4518DrawSprite(temp0)519end if520end event521522523event ObjectStartup524LoadSpriteSheet("Global/Items2.gif")525526SpriteFrame(-24, 16, 48, 16, 34, 132) // #0 - Post527528#platform: USE_ORIGINS529switch stage.playerListPos530// Has Sonic Team never heard of a default case?531case PLAYER_SONIC_A532case PLAYER_TAILS_A533case PLAYER_KNUCKLES_A534case PLAYER_SONIC_TAILS_A535case PLAYER_KNUCKLES_TAILS_A536#endplatform537SpriteFrame(-24, -16, 48, 32, 34, 100) // #1 - Eggman giving a big smile538SpriteFrame(-16, -16, 32, 32, 149, 99) // #2 - Spin frame 1539SpriteFrame(-4, -16, 8, 32, 247, 2) // #3 - Spin frame 2540SpriteFrame(-16, -16, 32, 32, 116, 99) // #4 - Spin frame 3541SpriteFrame(-24, -16, 48, 32, 34, 1) // #5 - Main character frame (Sonic here, but will change to the appropriate character in-game)542SpriteFrame(-16, -16, 32, 32, 149, 99) // #6 - Spin frame 4 (duplicate of frame 1)543SpriteFrame(-4, -16, 8, 32, 247, 2) // #7 - Spin frame 5 (duplicate of frame 2)544SpriteFrame(-16, -16, 32, 32, 116, 99) // #8 - Spin frame 6 (duplicate of frame 3)545#platform: USE_ORIGINS546break547548case PLAYER_AMY_A549case PLAYER_AMY_TAILS_A550SpriteFrame(-24, -16, 48, 32, 34, 100) // #1 - Eggman giving a big smile551SpriteFrame(-16, -16, 32, 32, 149, 132) // #2 - Spin frame 1 (Amy)552SpriteFrame(-4, -16, 8, 32, 247, 2) // #3 - Spin frame 2553SpriteFrame(-16, -16, 32, 32, 116, 132) // #4 - Spin frame 3 (Amy)554SpriteFrame(-24, -16, 48, 32, 34, 149) // #5 - Amy frame555SpriteFrame(-16, -16, 32, 32, 149, 132) // #6 - Spin frame 4 (duplicate of frame 1)556SpriteFrame(-4, -16, 8, 32, 247, 2) // #7 - Spin frame 5 (duplicate of frame 2)557SpriteFrame(-16, -16, 32, 32, 116, 132) // #8 - Spin frame 6 (duplicate of frame 3)558break559end switch560#endplatform561562foreach (TypeName[Sign Post], arrayPos0, ALL_ENTITIES)563CheckGreater(object[arrayPos0].propertyValue, 0)564temp0 = checkResult565CheckEqual(options.vsMode, false)566temp0 &= checkResult567if temp0 == true568object[arrayPos0].type = TypeName[Blank Object]569else570object[arrayPos0].frame = 1571object[arrayPos0].spinCount = 16572if object[arrayPos0].propertyValue != 2573object[arrayPos0].priority = PRIORITY_XBOUNDS574end if575end if576577if options.vsMode == true578object[arrayPos0].state = SIGNPOST_IDLE_VS579end if580next581582SetTableValue(TypeName[Sign Post], DebugMode_ObjCount, DebugMode_TypesTable)583SetTableValue(SignPost_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)584SetTableValue(SignPost_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)585DebugMode_ObjCount++586end event587588589// ========================590// Editor Events591// ========================592593event RSDKEdit594if editor.returnVariable == true595switch editor.variableID596case EDIT_VAR_PROPVAL // property value597checkResult = object.propertyValue598break599600case 0 // type601checkResult = object.propertyValue602break603604end switch605else606switch editor.variableID607case EDIT_VAR_PROPVAL // property value608object.propertyValue = editor.variableValue609break610611case 0 // type612object.propertyValue = editor.variableValue613break614615end switch616end if617end event618619620event RSDKDraw621DrawSprite(0)622DrawSprite(1)623end event624625626event RSDKLoad627LoadSpriteSheet("Global/Items2.gif")628SpriteFrame(-24, 16, 48, 16, 34, 132)629SpriteFrame(-24, -16, 48, 32, 34, 100)630631AddEditorVariable("type")632SetActiveVariable("type")633AddEnumVariable("Normal", 0)634AddEnumVariable("VS Only (No Y Bounds)", 1)635AddEnumVariable("VS Only (Use Y Bounds)", 2)636end event637638639