Path: blob/master/Sonic 2/Scripts/Enemies/Stegway.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Stegway 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.startPos.x13private alias object.value2 : object.startPos.y14private alias object.value3 : object.showJet15private alias object.value4 : object.jetAnimTimer16private alias object.value5 : object.wheelFrame17private alias object.value6 : object.wheelAnimTimer18private alias object.value7 : object.noFloor1920// States21private alias 0 : STEGWAY_MOVING22private alias 1 : STEGWAY_TURN23private alias 2 : STEGWAY_REVUP24private alias 3 : STEGWAY_REVRELEASE25private alias 4 : STEGWAY_DASH2627// Animations28private alias 0 : STEGWAY_ANI_MOVE29private alias 1 : STEGWAY_ANI_REVRELEASE30private alias 2 : STEGWAY_ANI_REVUP31private alias 3 : STEGWAY_ANI_DASH3233// Player Aliases34private alias object.value40 : player.hitboxLeft35private alias object.value38 : player.hitboxTop36private alias object.value41 : player.hitboxRight37private alias object.value39 : player.hitboxBottom3839// Path ID Aliases40private alias 0 : PATH_A414243// ========================44// Function Declarations45// ========================4647reserve function Stegway_DebugDraw48reserve function Stegway_DebugSpawn495051// ========================52// Function Definitions53// ========================5455private function Stegway_DebugDraw56DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)57end function585960private function Stegway_DebugSpawn61CreateTempObject(TypeName[Stegway], 0, object.xpos, object.ypos)62if object.direction == FACING_RIGHT63object[tempObjectPos].direction = FLIP_NONE64object[tempObjectPos].xvel = -0x400065else66object[tempObjectPos].direction = FLIP_X67object[tempObjectPos].xvel = 0x400068end if69end function707172// ========================73// Events74// ========================7576event ObjectUpdate77switch object.state78case STEGWAY_MOVING79if object.priority != PRIORITY_XBOUNDS_DESTROY80object.priority = PRIORITY_ACTIVE81end if8283object.xpos += object.xvel84foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)85if object.direction == FLIP_NONE86BoxCollisionTest(C_TOUCH, object.entityPos, -96, -32, 0, 14, currentPlayer, 0, 0, 0, 0)87else88BoxCollisionTest(C_TOUCH, object.entityPos, 0, -32, 96, 14, currentPlayer, 0, 0, 0, 0)89end if9091if checkResult == true92object.state = STEGWAY_REVUP93object.animation = STEGWAY_ANI_DASH94end if95next9697if object.direction == FLIP_NONE98ObjectTileGrip(CSIDE_FLOOR, -12, 16, PATH_A)99else100ObjectTileGrip(CSIDE_FLOOR, 12, 16, PATH_A)101end if102103if checkResult == false104object.state = STEGWAY_TURN105object.animation = STEGWAY_ANI_DASH106object.showJet = false107if object.frame == 3108object.frame = 2109end if110end if111break112113case STEGWAY_TURN114if object.timer < 29115object.timer++116else117object.timer = 0118object.state = STEGWAY_MOVING119object.animation = STEGWAY_ANI_MOVE120object.direction ^= FLIP_X121if object.direction == FLIP_NONE122object.xvel = -0x4000123else124object.xvel = 0x4000125end if126end if127break128129case STEGWAY_REVUP130object.timer++131if object.timer == 8132object.timer = 0133object.state = STEGWAY_REVRELEASE134object.animation = STEGWAY_ANI_REVUP135PlaySfx(SfxName[Rev Up], false)136end if137break138139case STEGWAY_REVRELEASE140object.timer++141if object.timer == 32142object.timer = 0143object.state = STEGWAY_DASH144object.animation = STEGWAY_ANI_REVRELEASE145object.showJet = true146object.xvel *= 12147PlaySfx(SfxName[Release], false)148end if149break150151case STEGWAY_DASH152object.xpos += object.xvel153154if object.direction == FLIP_NONE155if object.noFloor == false156temp0 = object.ypos157ObjectTileGrip(CSIDE_FLOOR, -64, 16, PATH_A)158if checkResult == false159object.noFloor = true160end if161162object.ypos = temp0163end if164165ObjectTileGrip(CSIDE_FLOOR, -12, 16, PATH_A)166else167if object.noFloor == false168temp0 = object.ypos169ObjectTileGrip(0, 64, 16, PATH_A)170if checkResult == false171object.noFloor = true172end if173174object.ypos = temp0175end if176177ObjectTileGrip(CSIDE_FLOOR, 12, 16, PATH_A)178end if179180if object.noFloor == true181if ringTimer == 0182CreateTempObject(TypeName[Dust Puff], 0, object.xpos, object.ypos)183if object.direction == FLIP_NONE184object[tempObjectPos].ixpos += 10185else186object[tempObjectPos].ixpos -= 10187end if188object[tempObjectPos].iypos += 16189end if190191if object.xvel >= 0x4000192object.xvel -= 0xA00193if object.xvel < 0x4000194object.xvel = 0x4000195object.state = STEGWAY_MOVING196object.animation = STEGWAY_ANI_MOVE197object.animationTimer = 0198object.frame = 1199object.showJet = false200object.noFloor = false201end if202end if203204if object.xvel <= -0x4000205object.xvel += 0xA00206if object.xvel > -0x4000207object.xvel = -0x4000208object.state = STEGWAY_MOVING209object.animation = STEGWAY_ANI_MOVE210object.animationTimer = 0211object.frame = 1212object.showJet = false213object.noFloor = false214end if215end if216end if217218if checkResult == false219object.state = STEGWAY_TURN220object.animation = STEGWAY_ANI_DASH221object.showJet = false222object.noFloor = false223if object.frame == 3224object.frame = 2225end if226end if227break228229end switch230231if object.outOfBounds == true232temp0 = object.xpos233temp1 = object.ypos234object.xpos = object.startPos.x235object.ypos = object.startPos.y236if object.outOfBounds == true237if object.propertyValue == 0238object.direction = FLIP_NONE239object.xvel = -0x4000240else241object.direction = FLIP_X242object.xvel = 0x4000243end if244245object.animation = STEGWAY_ANI_MOVE246if object.priority != PRIORITY_XBOUNDS_DESTROY247object.priority = PRIORITY_BOUNDS248end if249250object.showJet = false251object.wheelFrame = 0252object.jetAnimTimer = 0253object.noFloor = false254object.state = STEGWAY_MOVING255else256object.xpos = temp0257object.ypos = temp1258end if259end if260261foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)262BoxCollisionTest(C_TOUCH, object.entityPos, -20, -14, 20, 14, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)263if checkResult == true264CallFunction(Player_BadnikBreak)265end if266next267268switch object.animation269case STEGWAY_ANI_MOVE270if object.animationTimer == 0271object.frame++272object.frame %= 3273switch object.frame274case 0275object.animationTimer = 14276break277278case 1279object.animationTimer = 6280break281282case 2283object.animationTimer = 10284break285end switch286else287object.animationTimer--288end if289290object.wheelAnimTimer++291object.wheelAnimTimer &= 15292object.wheelFrame = object.wheelAnimTimer293object.wheelFrame >>= 3294break295296case STEGWAY_ANI_REVRELEASE297object.frame = 3298object.wheelAnimTimer++299object.wheelAnimTimer %= 6300if object.noFloor == true301object.wheelFrame = 0302else303object.wheelFrame = object.wheelAnimTimer304object.wheelFrame /= 3305end if306break307308case STEGWAY_ANI_REVUP309object.frame = 2310object.wheelAnimTimer++311object.wheelAnimTimer &= 3312object.wheelFrame = object.wheelAnimTimer313object.wheelFrame >>= 1314break315316case STEGWAY_ANI_DASH317break318319end switch320321if object.showJet == true322object.jetAnimTimer++323object.jetAnimTimer &= 3324end if325end event326327328event ObjectDraw329DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)330331if object.wheelFrame == 1332DrawSpriteFX(4, FX_FLIP, object.xpos, object.ypos)333end if334335if object.showJet == true336temp0 = object.jetAnimTimer337temp0 >>= 1338temp0 += 5339DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)340end if341end event342343344event ObjectStartup345LoadSpriteSheet("HPZ/Objects.gif")346SpriteFrame(-24, -16, 48, 32, 40, 57) // moving 1 - #0347SpriteFrame(-24, -16, 48, 32, 89, 57) // moving 2 - #1348SpriteFrame(-24, -16, 48, 32, 82, 90) // dashing 1 - #2349SpriteFrame(-24, -16, 48, 32, 33, 90) // dashing 2 - #3350SpriteFrame(0, 0, 24, 16, 198, 29) // wheel - #4351SpriteFrame(24, 4, 7, 6, 206, 7) // jet 1 - #5352SpriteFrame(24, 4, 8, 6, 206, 14) // jet 2 - #6353354foreach (TypeName[Stegway], arrayPos0, ALL_ENTITIES)355object[arrayPos0].startPos.x = object[arrayPos0].xpos356object[arrayPos0].startPos.y = object[arrayPos0].ypos357if object[arrayPos0].propertyValue == 0358object[arrayPos0].direction = FLIP_NONE359object[arrayPos0].xvel = -0x4000360else361object[arrayPos0].direction = FLIP_X362object[arrayPos0].xvel = 0x4000363end if364next365366SetTableValue(TypeName[Stegway], DebugMode_ObjCount, DebugMode_TypesTable)367SetTableValue(Stegway_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)368SetTableValue(Stegway_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)369DebugMode_ObjCount++370end event371372373// ========================374// Editor Events375// ========================376377event RSDKEdit378if editor.returnVariable == true379switch editor.variableID380case EDIT_VAR_PROPVAL // property value381checkResult = object.propertyValue382checkResult &= 1383break384385case 0 // direction386GetBit(checkResult, object.propertyValue, 0)387break388389end switch390else391switch editor.variableID392case EDIT_VAR_PROPVAL // property value393object.propertyValue = editor.variableValue394object.propertyValue &= 1395break396397case 0 // direction398CheckNotEqual(editor.variableValue, 0)399SetBit(object.propertyValue, 0, checkResult)400break401402end switch403end if404end event405406407event RSDKDraw408GetBit(object.direction, object.propertyValue, 0)409DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)410end event411412413event RSDKLoad414LoadSpriteSheet("HPZ/Objects.gif")415SpriteFrame(-24, -16, 48, 32, 40, 57)416417AddEditorVariable("direction")418SetActiveVariable("direction")419AddEnumVariable("Left", 0)420AddEnumVariable("Right", 1)421end event422423424