Path: blob/master/Sonic 2/Scripts/Global/LoseRing.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Lose Ring 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.targetPlayer13private alias object.value16 : player.isSidekick1415private alias 0 : LOSERING_TYPE_HIGH16private alias 1 : LOSERING_TYPE_LOW1718// Player Aliases19private alias object.state : player.state20private alias object.value0 : player.rings2122// Game Modes23private alias 2 : MODE_TIMEATTACK2425// Music Events26private alias 25 : SLOT_MUSICEVENT_CHANGE2728private alias 2 : MUSICEVENT_TRANSITION2930// Path ID Aliases31private alias 0 : PATH_A323334// ========================35// Events36// ========================3738event ObjectUpdate39object.yvel += 0x180040object.xpos += object.xvel41object.ypos += object.yvel4243if object.yvel >= 044ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)45if checkResult == true46temp0 = object.yvel47temp0 >>= 248object.yvel -= temp049FlipSign(object.yvel)50if object.yvel > -0x1000051object.yvel = -0x1000052end if53end if54end if5556object.timer++57if object.timer == 25658object.type = TypeName[Blank Object]59object.xvel = 060object.yvel = 061object.timer = 062else63object.animationTimer += object.animationSpeed64if object.animationTimer >= 0x10065object.animationTimer -= 0x10066object.frame++67if object.frame == 868object.frame = 069if object.animationSpeed > 1670object.animationSpeed -= 1671end if72end if73end if7475if object.timer >= 24076object.alpha -= 1677end if78end if7980if object.timer >= 6481foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)82CheckEqual(player[currentPlayer].state, Player_State_Hurt)83temp0 = checkResult84CheckEqual(player[currentPlayer].state, Player_State_GotHit)85temp0 |= checkResult86if temp0 == false87BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)88if checkResult == true89object.type = TypeName[Ring Sparkle]90if object.propertyValue == LOSERING_TYPE_HIGH91object.drawOrder = 492else93object.drawOrder = 294end if95object.timer = 096object.targetPlayer = 097object.timer = 098object.frame = 099// Add it to the player's ring count100if player[currentPlayer].isSidekick == true101// P2 Tails in normal gameplay (not VS)102// So add it to P1's ring count103player[0].rings++104if player[0].rings > 999105player[0].rings = 999106end if107else108// Either P2 in VS or P1 in any mode109// In any case, give the ring to the player that collected it110player[currentPlayer].rings++111if player[currentPlayer].rings > 999112player[currentPlayer].rings = 999113end if114end if115if player[0].rings >= ringExtraLife116if options.gameMode != MODE_TIMEATTACK117#platform: USE_ORIGINS118if game.coinMode == false119player.lives++120else121CallNativeFunction2(NotifyCallback, NOTIFY_ADD_COIN, 1)122end if123#endplatform124#platform: USE_STANDALONE125player.lives++126#endplatform127PlaySfx(SfxName[Life], false)128PauseMusic()129ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)130object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE131ringExtraLife += 100132if ringExtraLife > 300133ringExtraLife = 1000134end if135end if136end if137138if ringPan == false139PlaySfx(SfxName[Ring L], false)140SetSfxAttributes(SfxName[Ring L], -1, -100)141ringPan = true142else143PlaySfx(SfxName[Ring R], false)144SetSfxAttributes(SfxName[Ring R], -1, 100)145ringPan = false146end if147end if148end if149next150end if151end event152153154event ObjectDraw155DrawSpriteFX(object.frame, FX_INK, object.xpos, object.ypos)156end event157158159event ObjectStartup160LoadSpriteSheet("Global/Items.gif")161SpriteFrame(-8, -8, 16, 16, 1, 1)162SpriteFrame(-8, -8, 16, 16, 1, 18)163SpriteFrame(-8, -8, 16, 16, 1, 35)164SpriteFrame(-8, -8, 16, 16, 1, 52)165SpriteFrame(-8, -8, 16, 16, 1, 69)166SpriteFrame(-8, -8, 16, 16, 1, 86)167SpriteFrame(-8, -8, 16, 16, 1, 103)168SpriteFrame(-8, -8, 16, 16, 1, 120)169end event170171172// ========================173// Editor Events174// ========================175176event RSDKDraw177DrawSprite(0)178end event179180181event RSDKLoad182LoadSpriteSheet("Global/Items.gif")183SpriteFrame(-8, -8, 16, 16, 1, 1)184185// used, but this shouldn't be placed down in the scene so it doesn't matter186SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")187end event188189190