Path: blob/master/Sonic 2/Scripts/CPZ/TubeSpring.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Tube Spring 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.springPower1314// Player Aliases15private alias object.state : player.state16private alias object.xvel : player.xvel17private alias object.yvel : player.yvel18private alias object.speed : player.speed19private alias object.gravity : player.gravity20private alias object.animation : player.animation21private alias object.collisionPlane : player.collisionPlane22private alias object.tileCollisions : player.tileCollisions23private alias object.value1 : player.timer24private alias object.value10 : player.animationReserve25private alias object.value17 : debugMode.currentSelection26private alias object.value25 : player.gravityStrength272829// ========================30// Function Declarations31// ========================3233reserve function TubeSpring_DebugDraw34reserve function TubeSpring_DebugSpawn353637// ========================38// Static Values39// ========================4041private value TubeSpring_startDebugID = 0424344// ========================45// Function Definitions46// ========================4748private function TubeSpring_DebugDraw49DrawSprite(0)50end function515253private function TubeSpring_DebugSpawn54CreateTempObject(TypeName[Tube Spring], 0, object.xpos, object.ypos)5556temp0 = debugMode[0].currentSelection57temp0 -= TubeSpring_startDebugID58if temp0 == 059object[tempObjectPos].springPower = -0x10000060else61object[tempObjectPos].springPower = -0xA800062end if63object[tempObjectPos].drawOrder = 564end function656667// ========================68// Events69// ========================7071event ObjectUpdate72foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)73BoxCollisionTest(C_TOUCH, object.entityPos, -16, 0, 16, 48, currentPlayer, 1, 1, 1, 1)74if checkResult == true75if object.animation == 076object.timer = 077end if78object.animation = 179end if8081if object.animation == 082BoxCollisionTest(C_SOLID, object.entityPos, -14, -8, 14, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)83if checkResult == COL_TOP84player[currentPlayer].animationReserve = ANI_WALKING85if player[currentPlayer].animation == ANI_RUNNING86player[currentPlayer].animationReserve = ANI_RUNNING87end if8889if player[currentPlayer].animation == ANI_PEELOUT90player[currentPlayer].animationReserve = ANI_PEELOUT91end if9293if object.animation == 094object.timer = 195end if9697#platform: USE_STANDALONE98player[currentPlayer].state = Player_State_Air99#endplatform100#platform: USE_ORIGINS101player[currentPlayer].state = Player_State_Air_NoDropDash102#endplatform103player[currentPlayer].tileCollisions = true104player[currentPlayer].gravity = GRAVITY_AIR105player[currentPlayer].speed = player[currentPlayer].xvel106player[currentPlayer].yvel = object.springPower107player[currentPlayer].yvel -= player[currentPlayer].gravityStrength108109GetBit(temp0, object[arrayPos0].propertyValue, 7)110if temp0 == true111player[currentPlayer].xvel = 0112end if113114GetBit(temp0, object[arrayPos0].propertyValue, 0)115if temp0 == true116player[currentPlayer].animation = ANI_TWIRL117else118player[currentPlayer].animation = ANI_BOUNCING119end if120121player[currentPlayer].timer = 0122123GetBit(temp0, object[arrayPos0].propertyValue, 2)124if temp0 == true125player[currentPlayer].collisionPlane = 0126end if127128GetBit(temp0, object[arrayPos0].propertyValue, 3)129if temp0 == true130player[currentPlayer].collisionPlane = 1131end if132133PlaySfx(SfxName[Spring], false)134end if135end if136next137138switch object.animation139case 0140if object.timer != 0141switch object.timer142case 0143case 2144case 3145object.frame = 0146break147148case 1149object.frame = 1150break151152case 4153case 5154case 6155case 7156case 8157case 9158object.frame = 2159break160end switch161162object.timer++163if object.timer >= 10164object.timer = 0165end if166else167object.frame = 0168end if169break170171case 1172if object.timer < 6173object.frame = 3174else175object.frame = 4176if object.timer == 23177object.timer = 0178object.animation = 2179end if180end if181object.timer++182break183184case 2185object.frame = 3186object.timer++187if object.timer == 6188object.timer = 0189object.animation = 0190end if191break192193end switch194end event195196197event ObjectDraw198DrawSprite(object.frame)199end event200201202event ObjectStartup203CheckCurrentStageFolder("Zone02")204if checkResult == true205LoadSpriteSheet("CPZ/Objects.gif")206SpriteFrame(-16, -16, 32, 16, 191, 1)207SpriteFrame(-16, -10, 32, 10, 191, 81)208SpriteFrame(-16, -32, 32, 32, 191, 92)209SpriteFrame(-16, -29, 32, 29, 191, 18)210SpriteFrame(-16, -32, 32, 32, 191, 48)211SpriteFrame(-16, -29, 32, 29, 191, 18)212else213LoadSpriteSheet("MBZ/Objects.gif")214SpriteFrame(-16, -16, 32, 16, 99, 377)215SpriteFrame(-16, -10, 32, 10, 99, 457)216SpriteFrame(-16, -32, 32, 32, 99, 468)217SpriteFrame(-16, -29, 32, 29, 99, 394)218SpriteFrame(-16, -32, 32, 32, 99, 424)219SpriteFrame(-16, -29, 32, 29, 99, 394)220end if221222foreach (TypeName[Tube Spring], arrayPos0, ALL_ENTITIES)223GetBit(temp0, object[arrayPos0].propertyValue, 1)224if temp0 == 0225object[arrayPos0].springPower = -0x100000226else227object[arrayPos0].springPower = -0xA8000228end if229object[arrayPos0].drawOrder = 5230next231232temp0 = 0233TubeSpring_startDebugID = DebugMode_ObjCount234while temp0 < 2235SetTableValue(TypeName[Tube Spring], DebugMode_ObjCount, DebugMode_TypesTable)236SetTableValue(TubeSpring_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)237SetTableValue(TubeSpring_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)238DebugMode_ObjCount++239temp0++240loop241end event242243244// ========================245// Editor Events246// ========================247248event RSDKEdit249if editor.returnVariable == true250switch editor.variableID251case EDIT_VAR_PROPVAL // property value252checkResult = object.propertyValue253break254255case 0 // useTwirlAnim256GetBit(checkResult, object.propertyValue, 0)257break258259case 1 // springPower260GetBit(checkResult, object.propertyValue, 1)261break262263case 2 // newCPlane264checkResult = object.propertyValue265checkResult >>= 2266checkResult %= 3267break268269case 3 // killXVelocity270GetBit(checkResult, object.propertyValue, 7)271break272273end switch274else275switch editor.variableID276case EDIT_VAR_PROPVAL // property value277object.propertyValue = editor.variableValue278break279280case 0 // useTwirlAnim281CheckNotEqual(editor.variableValue, false)282SetBit(object.propertyValue, 0, checkResult)283break284285case 1 // springPower286CheckNotEqual(editor.variableValue, false)287SetBit(object.propertyValue, 1, checkResult)288break289290case 2 // newCPlane291SetBit(object.propertyValue, 2, false)292SetBit(object.propertyValue, 3, false)293294editor.variableValue %= 3295editor.variableValue <<= 2296297object.propertyValue |= editor.variableValue298break299300case 3 // killXVelocity301CheckNotEqual(editor.variableValue, false)302SetBit(object.propertyValue, 7, checkResult)303break304305end switch306end if307end event308309310event RSDKDraw311DrawSprite(0)312end event313314315event RSDKLoad316CheckCurrentStageFolder("Zone02")317if checkResult == true318LoadSpriteSheet("CPZ/Objects.gif")319SpriteFrame(-16, -16, 32, 16, 191, 1)320else321LoadSpriteSheet("MBZ/Objects.gif")322SpriteFrame(-16, -16, 32, 16, 99, 377)323end if324325AddEditorVariable("useTwirlAnim")326SetActiveVariable("useTwirlAnim")327AddEnumVariable("false", false)328AddEnumVariable("true", true)329330AddEditorVariable("springPower")331SetActiveVariable("springPower")332AddEnumVariable("Weak", false)333AddEnumVariable("Strong", true)334335AddEditorVariable("newCPlane")336SetActiveVariable("newCPlane")337AddEnumVariable("Don't Set New Collision Plane", 0)338AddEnumVariable("Collision Plane A", 1)339AddEnumVariable("Collision Plane B", 2)340341AddEditorVariable("killXVelocity")342SetActiveVariable("killXVelocity")343AddEnumVariable("false", false)344AddEnumVariable("true", true)345end event346347348