Path: blob/master/Sonic 2/Scripts/Special/TextMessage.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Text Message Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer12private alias object.value1 : object.textMessage13private alias object.value2 : object.charPos.x14private alias object.value3 : object.messageLength15private alias object.value4 : object.number16private alias object.value5 : object.angleOffset17private alias object.value6 : object.scaleSpeed18private alias object.value7 : object.rotateSpeed19private alias object.value8 : object.spinDirection2021// Property Values22private alias 0 : TEXTMESSAGE_COOL23private alias 1 : TEXTMESSAGE_NOTENOUGH24private alias 2 : TEXTMESSAGE_GETRINGS25private alias 3 : TEXTMESSAGE_RINGREMINDER26private alias 4 : TEXTMESSAGE_PLAYERPLAYER27private alias 5 : TEXTMESSAGE_MOSTRINGSWIN28private alias 6 : TEXTMESSAGE_P1WINS29private alias 7 : TEXTMESSAGE_P2WINS30private alias 8 : TEXTMESSAGE_TIE31private alias 9 : TEXTMESSAGE_ANICHARACTER3233// Messages34private alias 0 : MESSAGE_COOL35private alias 1 : MESSAGE_NOTENOUGH36private alias 2 : MESSAGE_RINGS37private alias 3 : MESSAGE_GETRINGS138private alias 4 : MESSAGE_GETRINGS239private alias 5 : MESSAGE_GETRINGS340private alias 6 : MESSAGE_RINGTOGO41private alias 7 : MESSAGE_RINGSTOGO142private alias 8 : MESSAGE_RINGSTOGO243private alias 9 : MESSAGE_RINGSTOGO344private alias 10 : MESSAGE_PLAYERPLAYER45private alias 11 : MESSAGE_MOSTRINGSWINS46private alias 12 : MESSAGE_P1WINS47private alias 13 : MESSAGE_P2WINS48private alias 14 : MESSAGE_TIE4950// Player Aliases51private alias object.value0 : player.rings5253// Text Menu Info Type Aliases54private alias 0 : TEXTINFO_TEXTDATA55private alias 1 : TEXTINFO_TEXTSIZE565758// ========================59// Function Declarations60// ========================6162reserve function TextMessage_DrawMessage63reserve function TextMessage_SetupTextChars646566// ========================67// Function Definitions68// ========================6970private function TextMessage_DrawMessage71// This function is called to *draw* a line of text7273GetTextInfo(object.messageLength, MENU_1, TEXTINFO_TEXTSIZE, object.textMessage, 0)7475object.charPos.x = object.messageLength76object.charPos.x <<= 277FlipSign(object.charPos.x)78object.charPos.x += screen.xcenter79object.charPos.x += 48081temp0 = 082while object.messageLength > 083GetTextInfo(temp1, MENU_1, TEXTINFO_TEXTDATA, object.textMessage, temp0)84switch temp185case 33 // !86DrawSpriteScreenXY(37, object.charPos.x, object.ypos)87object.charPos.x += 888break8990case 35 // #91temp2 = object.number92temp2 /= 10093DrawSpriteScreenXY(temp2, object.charPos.x, object.ypos)94object.charPos.x += 895break9697case 36 // $98temp2 = object.number99temp2 %= 100100temp2 /= 10101DrawSpriteScreenXY(temp2, object.charPos.x, object.ypos)102object.charPos.x += 8103break104105case 37 // %106temp2 = object.number107temp2 %= 10108DrawSpriteScreenXY(temp2, object.charPos.x, object.ypos)109object.charPos.x += 8110break111112case 38 // &113DrawSpriteScreenXY(38, object.charPos.x, object.ypos)114object.charPos.x += 8115break116117case 46 // .118DrawSpriteScreenXY(36, object.charPos.x, object.ypos)119object.charPos.x += 8120break121122default123object.frame = 0124125// Translate uppercase letters to Sprite Frames126if temp1 > 64127if temp1 < 91128object.frame = temp1129object.frame -= 55130end if131end if132133// Translate lowercase letters to Sprite Frames134if temp1 > 96135if temp1 < 123136object.frame = temp1137object.frame -= 87138end if139end if140141if object.frame > 0142DrawSpriteScreenXY(object.frame, object.charPos.x, object.ypos)143end if144145object.charPos.x += 8146break147148end switch149150temp0++151object.messageLength--152loop153end function154155156private function TextMessage_SetupTextChars157// This function is called to create letter objects for every individual letter in a line, for when the message should separate and fall apart158// This is not to be confused with actually drawing the text normally, that's up above159160GetTextInfo(object.messageLength, MENU_1, TEXTINFO_TEXTSIZE, object.textMessage, 0)161162object.charPos.x = object.messageLength163object.charPos.x <<= 2164FlipSign(object.charPos.x)165object.charPos.x += 4166object.charPos.x <<= 16167168temp0 = 0169temp3 = object.ypos170temp3 <<= 16171object.angleOffset = 224172object.angleOffset /= object.messageLength173while object.messageLength > 0174GetTextInfo(temp1, MENU_1, TEXTINFO_TEXTDATA, object.textMessage, temp0)175object.frame = 255176177switch temp1178case 33 // !179object.frame = 37180break181182case 35 // #183temp2 = object.number184temp2 /= 100185object.frame = temp2186break187188case 36 // $189temp2 = object.number190temp2 %= 100191temp2 /= 10192object.frame = temp2193break194195case 37 // %196temp2 = object.number197temp2 %= 10198object.frame = temp2199break200201case 38 // &202object.frame = 38203break204205case 46 // .206object.frame = 36207break208209default210if temp1 > 64211if temp1 < 91212object.frame = temp1213object.frame -= 55214end if215end if216217if temp1 > 96218if temp1 < 123219object.frame = temp1220object.frame -= 87221end if222end if223break224225end switch226227if object.frame < 255228CreateTempObject(TypeName[Text Message], TEXTMESSAGE_ANICHARACTER, object.charPos.x, temp3)229#platform: USE_STANDALONE230object[tempObjectPos].drawOrder = 5231#endplatform232#platform: USE_ORIGINS233object[tempObjectPos].drawOrder = 6234#endplatform235object[tempObjectPos].frame = object.frame236237if object.spinDirection == 0238object[tempObjectPos].angle = object.angle239else240object[tempObjectPos].angle = object.angle241FlipSign(object[tempObjectPos].angle)242object[tempObjectPos].angle += 0x100243object[tempObjectPos].angle &= 0x1FF244end if245246object[tempObjectPos].speed = -0x10000247object[tempObjectPos].scaleSpeed = 16248Rand(object[tempObjectPos].rotateSpeed, 32)249object[tempObjectPos].rotateSpeed -= 16250end if251252object.angle -= object.angleOffset253object.angle &= 0x1FF254object.charPos.x += 0x80000255temp0++256object.messageLength--257loop258end function259260261// ========================262// Events263// ========================264265event ObjectUpdate266switch object.propertyValue267case TEXTMESSAGE_COOL268case TEXTMESSAGE_PLAYERPLAYER269if object.timer < 120270object.timer++271else272object.angle = 96273CallFunction(TextMessage_SetupTextChars)274ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)275end if276break277278case TEXTMESSAGE_NOTENOUGH279if object.timer < 120280object.timer++281else282object.spinDirection = 0283object.textMessage = MESSAGE_NOTENOUGH284object.ypos = 116285object.angle = 96286CallFunction(TextMessage_SetupTextChars)287288object.spinDirection = 1289object.ypos += 22290object.textMessage = MESSAGE_RINGS291object.angle = 96292CallFunction(TextMessage_SetupTextChars)293294ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)295end if296break297298case TEXTMESSAGE_GETRINGS299case TEXTMESSAGE_MOSTRINGSWIN300if object.timer < 90301object.timer++302else303object.angle = 96304CallFunction(TextMessage_SetupTextChars)305ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)306end if307break308309case TEXTMESSAGE_RINGREMINDER310if stage.player2Enabled == true311temp0 = player[2].rings312temp0 += player[3].rings313else314temp0 = player[2].rings315end if316317GetTableValue(temp1, SpecialSetup_checkpointID, SpecialSetup_ringCountTable)318if temp0 < temp1319object.animationTimer = 0320else321if object.animationTimer < 30322object.animationTimer++323end if324end if325326CheckLower(temp0, temp1)327temp2 = checkResult328CheckLower(object.animationTimer, 30)329temp2 |= checkResult330if temp2 == true331GetBit(object.visible, object.timer, 2)332object.timer++333object.timer &= 7334object.number = temp1335object.number -= temp0336if object.number < 0337object.number = 0338end if339else340object.visible = false341end if342break343344case TEXTMESSAGE_P1WINS345case TEXTMESSAGE_P2WINS346case TEXTMESSAGE_TIE347if object.timer < 90348object.timer++349else350object.angle = 96351CallFunction(TextMessage_SetupTextChars)352ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)353if SpecialSetup_checkpointID < 3354player[2].rings = 0355player[3].rings = 0356end if357end if358break359360case TEXTMESSAGE_ANICHARACTER361object.xpos += object.xvel362object.ypos += object.yvel363object.scale += object.scaleSpeed364object.rotation += object.rotateSpeed365object.rotation &= 0x1FF366object.speed -= 0x8000367object.scaleSpeed++368369Cos(object.yvel, object.angle)370object.yvel *= object.speed371object.yvel >>= 9372373Sin(object.xvel, object.angle)374object.xvel *= object.speed375object.xvel >>= 9376377if object.timer < 120378object.timer++379else380object.type = TypeName[Blank Object]381end if382break383384end switch385end event386387388event ObjectDraw389switch object.propertyValue390case TEXTMESSAGE_COOL391object.ypos = 116392object.textMessage = MESSAGE_COOL393CallFunction(TextMessage_DrawMessage)394break395396case TEXTMESSAGE_NOTENOUGH397object.textMessage = MESSAGE_NOTENOUGH398object.ypos = 116399CallFunction(TextMessage_DrawMessage)400401object.ypos += 22402object.textMessage = MESSAGE_RINGS403CallFunction(TextMessage_DrawMessage)404break405406case TEXTMESSAGE_GETRINGS407object.ypos = 116408if object.number > 99409object.textMessage = MESSAGE_GETRINGS3410CallFunction(TextMessage_DrawMessage)411else412if object.number > 9413object.textMessage = MESSAGE_GETRINGS2414CallFunction(TextMessage_DrawMessage)415else416object.textMessage = MESSAGE_GETRINGS1417CallFunction(TextMessage_DrawMessage)418end if419end if420break421422case TEXTMESSAGE_RINGREMINDER423if object.visible == true424object.ypos = 64425if object.number > 99426object.textMessage = MESSAGE_RINGSTOGO3427CallFunction(TextMessage_DrawMessage)428else429if object.number > 9430object.textMessage = MESSAGE_RINGSTOGO2431CallFunction(TextMessage_DrawMessage)432else433if object.number == 1434object.textMessage = MESSAGE_RINGTOGO435CallFunction(TextMessage_DrawMessage)436else437object.textMessage = MESSAGE_RINGSTOGO1438CallFunction(TextMessage_DrawMessage)439end if440end if441end if442end if443break444445case TEXTMESSAGE_PLAYERPLAYER446object.ypos = 116447object.textMessage = MESSAGE_PLAYERPLAYER448CallFunction(TextMessage_DrawMessage)449break450451case TEXTMESSAGE_MOSTRINGSWIN452object.ypos = 116453object.textMessage = MESSAGE_MOSTRINGSWINS454CallFunction(TextMessage_DrawMessage)455break456457case TEXTMESSAGE_P1WINS458object.ypos = 116459object.textMessage = MESSAGE_P1WINS460CallFunction(TextMessage_DrawMessage)461break462463case TEXTMESSAGE_P2WINS464object.ypos = 116465object.textMessage = MESSAGE_P2WINS466CallFunction(TextMessage_DrawMessage)467break468469case TEXTMESSAGE_TIE470object.ypos = 68471object.textMessage = MESSAGE_TIE472CallFunction(TextMessage_DrawMessage)473break474475case TEXTMESSAGE_ANICHARACTER476temp0 = object.xpos477temp0 >>= 16478temp0 += screen.xcenter479480temp1 = object.ypos481temp1 >>= 16482483DrawSpriteScreenFX(object.frame, FX_ROTOZOOM, temp0, temp1)484break485486end switch487end event488489490event ObjectStartup491LoadSpriteSheet("Special/Objects.gif")492493// Here, we set up just about an entire font in Sprite Frames494SpriteFrame(-4, -8, 8, 15, 291, 42) // 0495SpriteFrame(-4, -8, 8, 15, 300, 42) // 1496SpriteFrame(-4, -8, 8, 15, 309, 42) // 2497SpriteFrame(-4, -8, 8, 15, 318, 42) // 3498SpriteFrame(-4, -8, 8, 15, 327, 42) // 4499SpriteFrame(-4, -8, 8, 15, 336, 42) // 5500SpriteFrame(-4, -8, 8, 15, 345, 42) // 6501SpriteFrame(-4, -8, 8, 15, 354, 42) // 7502SpriteFrame(-4, -8, 8, 15, 363, 42) // 8503SpriteFrame(-4, -8, 8, 15, 372, 42) // 9504SpriteFrame(-4, -8, 8, 15, 291, 26) // A505SpriteFrame(-4, -8, 8, 15, 300, 26) // B506SpriteFrame(-4, -8, 8, 15, 309, 26) // C507SpriteFrame(-4, -8, 8, 15, 318, 26) // D508SpriteFrame(-4, -8, 8, 15, 327, 26) // E509SpriteFrame(-4, -8, 8, 15, 336, 26) // F510SpriteFrame(-4, -8, 8, 15, 345, 26) // G511SpriteFrame(-4, -8, 8, 15, 354, 26) // H512SpriteFrame(-4, -8, 8, 15, 363, 26) // I513SpriteFrame(-4, -8, 8, 15, 372, 26) // J514SpriteFrame(-4, -8, 8, 15, 381, 26) // K515SpriteFrame(-4, -8, 8, 15, 390, 26) // L516SpriteFrame(-4, -8, 8, 15, 399, 26) // M517SpriteFrame(-4, -8, 8, 15, 408, 26) // N518SpriteFrame(-4, -8, 8, 15, 417, 26) // O519SpriteFrame(-4, -8, 8, 15, 426, 26) // P520SpriteFrame(-4, -8, 8, 15, 435, 26) // Q521SpriteFrame(-4, -8, 8, 15, 444, 26) // R522SpriteFrame(-4, -8, 8, 15, 453, 26) // S523SpriteFrame(-4, -8, 8, 15, 462, 26) // T524SpriteFrame(-4, -8, 8, 15, 471, 26) // U525SpriteFrame(-4, -8, 8, 15, 480, 26) // Supposed to be V, actually placeholder dash instead526SpriteFrame(-4, -8, 8, 15, 381, 42) // W527SpriteFrame(-4, -8, 8, 15, 390, 42) // Supposed to be X, actually placeholder dash instead528SpriteFrame(-4, -8, 8, 15, 399, 42) // Y529SpriteFrame(-4, -8, 8, 15, 408, 42) // Supposed to be Z, actually placeholder dash instead530SpriteFrame(-4, -8, 8, 15, 489, 26) // . (Period)531SpriteFrame(-4, -8, 8, 15, 498, 26) // ! (Exclamation mark)532SpriteFrame(-12, -8, 24, 15, 417, 42) // VS yellow tag533534SetupMenu(MENU_1, 0, 3, 1)535536// Here, all the texts to be displayed are set up537// The characters of #, $, and % are special, they display object.number's hundreds, tens, and ones place, respectively538AddMenuEntry(MENU_1, "COOL!", false)539AddMenuEntry(MENU_1, "NOT ENOUGH", false)540AddMenuEntry(MENU_1, "RINGS ... ", false)541AddMenuEntry(MENU_1, "GET % RINGS!", false)542AddMenuEntry(MENU_1, "GET $% RINGS!", false)543AddMenuEntry(MENU_1, "GET #$% RINGS!", false)544AddMenuEntry(MENU_1, "% RING TO GO!", false)545AddMenuEntry(MENU_1, "% RINGS TO GO!", false)546AddMenuEntry(MENU_1, "$% RINGS TO GO!", false)547AddMenuEntry(MENU_1, "#$% RINGS TO GO!", false)548AddMenuEntry(MENU_1, "PLAYER & PLAYER", false)549AddMenuEntry(MENU_1, "MOST RINGS WINS!", false)550AddMenuEntry(MENU_1, "PLAYER ONE WINS!", false)551AddMenuEntry(MENU_1, "PLAYER TWO WINS!", false)552AddMenuEntry(MENU_1, "TIE!", false)553end event554555556// ========================557// Editor Events558// ========================559560event RSDKDraw561DrawSprite(0)562end event563564565event RSDKLoad566LoadSpriteSheet("Global/Display.gif")567SpriteFrame(-16, -16, 32, 32, 1, 143)568569SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")570end event571572573