Path: blob/master/Sonic 1/Scripts/Global/SpecialRing.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Special Ring Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias 0 : SPECIALRING_FLOATING12private alias 1 : SPECIALRING_DISAPPEARING1314// Player Aliases15private alias object.type : player.type16private alias object.direction : player.direction17private alias object.controlMode : player.controlMode18private alias object.jumpPress : player.jumpPress19private alias object.jumpHold : player.jumpHold20private alias object.up : player.up21private alias object.down : player.down22private alias object.left : player.left23private alias object.right : player.right24private alias object.value0 : player.rings25private alias object.value16 : player.isSidekick2627// Game Modes28private alias 2 : MODE_TIMEATTACK2930// Super States31private alias 1 : SUPERSTATE_SUPER323334// ========================35// Events36// ========================3738event ObjectUpdate39if object.state == SPECIALRING_FLOATING40// Are 50 or more rings collected?41if player[0].rings > 4942// Did P1 collide with the special ring?43BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, 0, C_BOX, C_BOX, C_BOX, C_BOX)44if checkResult == true45// Make P1 and their shield "disappear"46player[0].type = TypeName[Blank Object]47object[playerCount].type = TypeName[Blank Object]48player[0].controlMode = CONTROLMODE_NONE49player[0].direction = FACING_RIGHT5051// Huh? What object is this supposed to be?52// Slot 4's never used in normal gameplay at all, so this shouldn't do anything53// If there are 4 players active then slot 4 would have P1's shield, but I doubt that's what this is meant to be for though...54ResetObjectEntity(4, TypeName[Blank Object], 0, 0, 0)5556object.drawOrder = 457object.state = SPECIALRING_DISAPPEARING58object.frame = 325960StopSfx(SfxName[Flying])61StopSfx(SfxName[Tired])62PlaySfx(SfxName[Special Ring], false)6364player[0].left = false65player[0].right = false6667if stage.player2Enabled == true68if player[1].isSidekick == true69player[1].controlMode = CONTROLMODE_NONE70player[1].up = false71player[1].down = false72player[1].left = false73player[1].right = false74player[1].jumpPress = false75player[1].jumpHold = false76end if77end if78end if79end if80end if8182// If the player is Super, don't show up83// -> This should only happen in Debug Mode, since special rings are unloaded84// if the player has max emeralds during startup85if Player_superState == SUPERSTATE_SUPER86ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)87end if88end event899091event ObjectDraw92switch object.state93case SPECIALRING_FLOATING94// Only show up if there are 50 or more rings collected95if player[0].rings >= 5096temp0 = object.frame97temp0 >>= 298if temp0 > 399object.direction = FLIP_X100else101object.direction = FLIP_NONE102end if103104DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)105106object.frame++107if object.frame > 31108object.frame = 0109end if110end if111break112113case SPECIALRING_DISAPPEARING114// Determine whether to flip the sprite or not based on current frame115temp0 = object.frame116temp0 >>= 2117if temp0 > 11118object.direction = FLIP_X119else120object.direction = FLIP_NONE121end if122123// Draw the sprite124DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)125126if temp0 == 11127object.direction = FLIP_X128DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)129else130if temp0 == 15131object.direction = FLIP_X132DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)133end if134end if135136object.frame++137if object.frame > 63 // Time to disappear?138// Clear this object139ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)140end if141break142143end switch144end event145146147event ObjectStartup148LoadSpriteSheet("Global/Items2.gif")149150// Sprite frames151152// Special Ring Spinning - #0-7153SpriteFrame(-32, -32, 64, 64, 83, 1)154SpriteFrame(-28, -32, 56, 64, 199, 131)155SpriteFrame(-24, -32, 48, 64, 148, 1)156SpriteFrame(-16, -32, 32, 64, 223, 66)157SpriteFrame(-12, -32, 24, 64, 197, 1)158SpriteFrame(-16, -32, 32, 64, 223, 66)159SpriteFrame(-24, -32, 48, 64, 148, 1)160SpriteFrame(-28, -32, 56, 64, 199, 131)161162// Special Ring Warping - #8-15163SpriteFrame(0, -32, 32, 64, 222, 1)164SpriteFrame(-16, -32, 48, 64, 101, 66)165SpriteFrame(-24, -32, 56, 64, 150, 66)166SpriteFrame(0, -32, 32, 64, 156, 131)167SpriteFrame(-24, -32, 56, 64, 150, 66)168SpriteFrame(-16, -32, 48, 64, 101, 66)169SpriteFrame(0, -32, 32, 64, 222, 1)170SpriteFrame(-32, -32, 32, 64, 124, 131)171172// Find max emerald count173if options.superStates == false174temp0 = 0x3F // 6 emeralds175else176temp0 = 0x7F // 7 emeralds177end if178179// Are all emeralds already gathered?180if specialStage.emeralds >= temp0181// Big rings aren't needed anymore, delete them182foreach (TypeName[Special Ring], arrayPos0, ALL_ENTITIES)183ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)184next185end if186187if options.gameMode == MODE_TIMEATTACK188// Delete every big ring, they shouldn't be in time attack189foreach (TypeName[Special Ring], arrayPos0, ALL_ENTITIES)190ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)191next192end if193end event194195196// ========================197// Editor Events198// ========================199200event RSDKDraw201DrawSprite(0)202end event203204205event RSDKLoad206LoadSpriteSheet("Global/Items2.gif")207SpriteFrame(-32, -32, 64, 64, 83, 1)208209SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")210end event211212213