Path: blob/main/Scripts/R7/Amy2.txt
1319 views
//-------------------Sonic CD Amy 2 Script--------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer6#alias Object.Value1 : Object.XVelocity7#alias Object.Value2 : Object.YVelocity8#alias Object.Value3 : Object.Bounds.Left9#alias Object.Value4 : Object.Bounds.Right10#alias Object.Value5 : Object.InAir11#alias Object.Value6 : Object.HeartsTimer12#alias Object.Value7 : Object.FallBackTimer1314// States15#alias 0 : AMY2_CHASEPLAYER16#alias 1 : AMY2_TRACKPLAYER17#alias 2 : AMY2_HUGGING18#alias 3 : AMY2_RECOIL19#alias 4 : AMY2_WAITNG_R20#alias 5 : AMY2_WAITNG_L21#alias 7 : AMY2_UNUSED2223// Collision Sides24#alias 0 : CSIDE_FLOOR2526// Gravity27#alias 0 : GRAVITY_GROUND28#alias 1 : GRAVITY_AIR2930// Control Mode31#alias -1 : CONTROLMODE_NONE3233// Fade Music States34#alias 3 : FADEMUSIC_SSZAMY3536// Ink Effect37#alias 2 : INK_ALPHA3839// Stage SFX40#alias 8 : SFX_S_GIGGLE414243sub ObjectMain44// Always face Sonic45if Player.XPos < Object.XPos46Object.Direction = FACING_LEFT47else48Object.Direction = FACING_RIGHT49end if5051if Object.FallBackTimer < 60052Object.FallBackTimer++53else54if Object.FallBackTimer == 60055// Can't run away forever!5657// It's been 10 seconds of chasing Sonic already so end the level regardless if he wants it or not58Object.FallBackTimer = 6015960// Lock Sonic's controls61Player.Left = false62Player.Right = false63Player.Up = false64Player.Down = false65Player.ControlMode = CONTROLMODE_NONE6667CreateTempObject(TypeName[Fade Music], FADEMUSIC_SSZAMY, Object.XPos, Object.YPos)68end if69end if7071switch Object.State72case AMY2_CHASEPLAYER73Object.Timer++74switch Object.Frame75case 476case 677if Object.Timer == 478Object.Timer = 079Object.Frame++80end if81break8283case 584case 785if Object.Timer == 386Object.Timer = 087Object.Frame++88end if89break9091end switch9293if Object.Frame > 794Object.Frame = 495end if9697if Object.Direction == FACING_RIGHT98// We're chasing Sonic, going right of course99100if Object.XVelocity < 0x20000101Object.XVelocity += 0x2000102end if103104PlayerObjectCollision(C_TOUCH, -32, -360, 4, 360)105if CheckResult == true106if Player.Gravity == GRAVITY_GROUND107if Player.Direction == Object.Direction108PlayerObjectCollision(C_TOUCH, -32, -20, 4, 20)109if CheckResult == true110if Player.Animation == ANI_SPINDASH111// Sonic's doing a spindash, throw Amy back (!)112113Object.State = AMY2_RECOIL114Object.Frame = 9115Object.YVelocity = -0x40000116Object.InAir = true117Object.XVelocity = -0x10000118else119if Object.FallBackTimer < 600120Object.FallBackTimer = 601121Player.Left = false122Player.Right = false123Player.Up = false124Player.Down = false125Player.ControlMode = CONTROLMODE_NONE126127CreateTempObject(TypeName[Fade Music], FADEMUSIC_SSZAMY, Object.XPos, Object.YPos)128end if129130#platform: Use_Haptics131// Soft little nudge132HapticEffect(52, 0, 0, 0)133#endplatform134135Object.State = AMY2_HUGGING136Object.Frame = 8137Object.Timer = 0138Player.State = Player_State_Hugged139PlayStageSfx(SFX_S_GIGGLE, false)140141// Grant the "One Hug Is Enough" achievement142// -> It's possible that the player may have skipped Amy in PPZ, where the achievement is normally unlocked,143// so there's another opportunity here144SetAchievement(1, 100)145end if146else147Object.State = AMY2_TRACKPLAYER148Object.Frame = 0149Object.Timer = 0150Object.XVelocity = 0151end if152else153// Presumably some code should be here, given that the condition exists and all, and yet there isn't...154end if155end if156end if157158if Object.XPos < Object.Bounds.Right159Object.XPos += Object.XVelocity160else161// Sonic has somehow escaped out of bounds to the left, stand still and patiently await his return162Object.XVelocity = 0163Object.XPos = Object.Bounds.Right164Object.State = AMY2_WAITNG_R165Object.Frame = 0166Object.Timer = 0167end if168169else170171if Object.XVelocity > -0x20000172Object.XVelocity -= 0x2000173end if174175PlayerObjectCollision(C_TOUCH, -4, -360, 32, 360)176if CheckResult == true177if Player.Gravity == GRAVITY_GROUND178if Player.Direction == Object.Direction179PlayerObjectCollision(C_TOUCH, -32, -20, 4, 20)180if CheckResult == true181if Player.Animation == ANI_SPINDASH182// Sonic's doing a spindash, hit Amy back (!)183184Object.State = AMY2_RECOIL185Object.Frame = 9186Object.YVelocity = -0x40000187Object.InAir = true188Object.XVelocity = 0x10000189else190if Object.FallBackTimer < 600191Object.FallBackTimer = 601192193Player.Left = false194Player.Right = false195Player.Up = false196Player.Down = false197Player.ControlMode = CONTROLMODE_NONE198199CreateTempObject(TypeName[Fade Music], FADEMUSIC_SSZAMY, Object.XPos, Object.YPos)200end if201202Object.State = AMY2_HUGGING203Object.Frame = 8204Object.Timer = 0205Player.State = Player_State_Hugged206PlayStageSfx(SFX_S_GIGGLE, false)207208// Unlock the "One Hug Is Enough" achievement209// There's a small chance you missed it in PPZ, so now you have a second chance at it here!210SetAchievement(1, 100)211212#platform: Use_Haptics213HapticEffect(52, 0, 0, 0)214#endplatform215216end if217else218Object.State = AMY2_TRACKPLAYER219Object.Frame = 0220Object.Timer = 0221Object.XVelocity = 0222end if223else224// This condition exists and yet there's no code inside of it...225end if226end if227end if228229if Object.XPos > Object.Bounds.Left230Object.XPos += Object.XVelocity231else232// Sonic somehow escaped out of bounds to the right, look at him and wait233Object.XVelocity = 0234Object.XPos = Object.Bounds.Left235Object.State = AMY2_WAITNG_L236Object.Frame = 0237Object.Timer = 0238end if239240end if241break242243case AMY2_TRACKPLAYER244Object.Timer++245if Object.Timer == 12246Object.Timer = 0247Object.Frame++248end if249250if Object.Frame > 3251Object.Frame = 0252end if253254PlayerObjectCollision(C_TOUCH, -4, -360, 4, 360)255if CheckResult == false256if Player.Gravity == GRAVITY_GROUND257Object.State = AMY2_CHASEPLAYER258Object.Frame = 4259Object.Timer = 0260end if261else262if Player.Gravity == GRAVITY_AIR263Object.State = AMY2_CHASEPLAYER264Object.Frame = 4265Object.Timer = 0266end if267end if268break269270case AMY2_HUGGING271Player.Speed = 0272Player.XVelocity = 0273Player.Direction = Object.Direction274break275276case AMY2_RECOIL277if Object.YVelocity > 0278Object.Frame = 10279end if280281if Object.XVelocity > 0282Object.XVelocity -= 0x800283end if284285if Object.XVelocity < 0286Object.XVelocity += 0x800287end if288289Object.XPos += Object.XVelocity290if Object.InAir == false291if Object.Timer == 16292Object.State = AMY2_CHASEPLAYER293Object.Frame = 4294Object.Timer = 0295else296Object.Timer++297end if298end if299break300301case AMY2_WAITNG_R302// Staring at Sonic to the right303Object.Timer++304if Object.Timer == 12305Object.Timer = 0306Object.Frame++307end if308309if Object.Frame > 3310Object.Frame = 0311end if312313if Object.Direction == FACING_LEFT314Object.State = AMY2_CHASEPLAYER315Object.Frame = 4316Object.Timer = 0317end if318break319320case AMY2_WAITNG_L321// Staring at Sonic to the Left322Object.Timer++323if Object.Timer == 12324Object.Timer = 0325Object.Frame++326end if327328if Object.Frame > 3329Object.Frame = 0330end if331332if Object.Direction == FACING_RIGHT333Object.State = AMY2_CHASEPLAYER334Object.Frame = 4335Object.Timer = 0336end if337break338339end switch340341Object.HeartsTimer++342343// Wait what? State 7? Where'd that come from? This object's states end at 5!344// But I digress, spawn hearts at a faster rate while in state 7345// (Perhaps it was the hugging state? It is for PPZ's Amy, which is what this object seems to be based on)346if Object.State == AMY2_UNUSED347if Object.HeartsTimer > 15348CreateTempObject(TypeName[Love Heart], 0, Object.XPos, Object.YPos)349Object[TempObjectPos].iYPos -= 6350351Object[TempObjectPos].InkEffect = INK_ALPHA352Object[TempObjectPos].Alpha = 255353354Object.HeartsTimer = 0355end if356else357if Object.HeartsTimer > 41358CreateTempObject(TypeName[Love Heart], 0, Object.XPos, Object.YPos)359Object[TempObjectPos].iYPos -= 6360361Object[TempObjectPos].InkEffect = INK_ALPHA362Object[TempObjectPos].Alpha = 255363364Object.HeartsTimer = 0365end if366end if367368if Object.InAir == false369// Track the ground370ObjectTileGrip(CSIDE_FLOOR, 0, 19, 0)371else372// Got launched into the air by Sonic...373374// Apply air movements & gravity375Object.YVelocity += 0x4000376Object.YPos += Object.YVelocity377378// See if Amy's landed yet379ObjectTileCollision(CSIDE_FLOOR, 0, 19, 0)380if CheckResult == true381Object.YVelocity = 0382Object.InAir = false383end if384end if385386end sub387388389sub ObjectDraw390DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)391end sub392393394sub ObjectStartup395396LoadSpriteSheet("R7/Objects2.gif")397398// Amy Frames399400// Idle Animation401SpriteFrame(-11, -20, 22, 40, 34, 208)402SpriteFrame(-11, -20, 22, 40, 57, 208)403SpriteFrame(-11, -20, 22, 40, 34, 208)404SpriteFrame(-11, -20, 22, 40, 126, 167)405406// Walking Animation407SpriteFrame(-15, -20, 30, 40, 68, 167)408SpriteFrame(-10, -20, 21, 40, 149, 109)409SpriteFrame(-13, -20, 26, 40, 99, 167)410SpriteFrame(-10, -20, 21, 40, 149, 109)411412// Hugging Frame, hearted eyes413SpriteFrame(-12, -20, 24, 40, 181, 208)414415// Flown into Air Frame416SpriteFrame(-13, -20, 26, 40, 80, 208)417418// Falling Frame419SpriteFrame(-12, -20, 24, 40, 107, 208)420421end sub422423424// ========================425// Editor Subs426// ========================427428sub RSDKDraw429DrawSprite(0)430end sub431432433sub RSDKLoad434// Amy 2 should never appear in a stage layout, only Amy 1 should, but may as well add a render for completeness's sake435436LoadSpriteSheet("R7/Objects2.gif")437SpriteFrame(-11, -20, 22, 40, 34, 208)438439SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")440end sub441442443