Path: blob/master/Sonic 1/Scripts/Enemies/Roller.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Roller 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.onGround13private alias object.value2 : object.hasTarget14private alias object.value3 : object.startPos.x15private alias object.value4 : object.startPos.y1617private alias 0 : ROLLER_FINDTARGET18private alias 1 : ROLLER_ROLLING19private alias 2 : ROLLER_FALLING20private alias 3 : ROLLER_STANDING2122private alias 0 : ROLLER_ANI_HIDDEN23private alias 1 : ROLLER_ANI_ROLLING24private alias 2 : ROLLER_ANI_ENDROLL25private alias 3 : ROLLER_ANI_STANDING26private alias 4 : ROLLER_ANI_BEGINROLL2728// Player Aliases29private alias object.xpos : player.xpos30private alias object.ypos : player.ypos31private alias object.value40 : player.hitboxLeft32private alias object.value38 : player.hitboxTop33private alias object.value41 : player.hitboxRight34private alias object.value39 : player.hitboxBottom3536// Tile Info ID Aliases37private alias 6 : TILEINFO_ANGLEA3839// Path ID Aliases40private alias 0 : PATH_A414243// ========================44// Events45// ========================4647event ObjectUpdate48switch object.state49case ROLLER_FINDTARGET50object.priority = PRIORITY_ACTIVE5152temp0 = true53temp1 = false54foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)55BoxCollisionTest(C_TOUCH, object.entityPos, -212, -120, 212, 120, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)56if checkResult == true57temp0 = false58end if5960temp2 = player[currentPlayer].xpos61temp2 -= object.xpos62if temp2 >= 0x100000063if temp2 < 0x240000064temp2 = player[currentPlayer].ypos65temp2 -= object.ypos66if temp2 >= -0xF0000067if temp2 < 0xF0000068temp1 = true69end if70end if71end if72end if73next7475temp0 &= temp176if temp0 != false77object.animation = ROLLER_ANI_ROLLING78object.xvel = 0x7000079object.state = ROLLER_ROLLING80end if81break8283case ROLLER_ROLLING84object.xpos += object.xvel85temp0 = false86ObjectTileGrip(CSIDE_FLOOR, 0, 15, PATH_A)87ObjectTileGrip(CSIDE_FLOOR, 0, 14, PATH_A)8889if object.onGround == false90if checkResult == false91temp0 = true92else93temp2 = object.xpos94temp3 = object.ypos95if object.xvel < 096ObjectTileCollision(CSIDE_RWALL, -32, 0, PATH_A)97if checkResult == true98temp2 >>= 1699temp3 >>= 16100temp2 -= 32101temp3 += 0102Get16x16TileInfo(temp5, temp2, temp3, TILEINFO_ANGLEA)103temp5 &= 255104if temp5 == 0105temp0 = true106else107temp2 += 32108object.xpos = temp2109object.xpos <<= 16110object.ypos = temp3111object.ypos <<= 16112end if113end if114else115ObjectTileCollision(CSIDE_LWALL, 32, 0, PATH_A)116if checkResult == true117temp2 >>= 16118temp3 >>= 16119temp2 += 32120temp3 += 0121Get16x16TileInfo(temp5, temp2, temp3, TILEINFO_ANGLEA)122temp5 &= 255123if temp5 == 0124temp0 = true125else126temp2 -= 32127object.xpos = temp2128object.xpos <<= 16129object.ypos = temp3130object.ypos <<= 16131end if132end if133end if134end if135end if136137if temp0 == true138object.yvel = -0x60000139object.onGround = true140object.state = ROLLER_FALLING141else142if object.hasTarget == false143foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)144temp0 = player[currentPlayer].xpos145temp0 -= object.xpos146if temp0 < 0x300000147if temp0 >= 0148temp0 = player[currentPlayer].ypos149temp0 -= object.ypos150if temp0 >= -0x600000151if temp0 < 0x600000152temp1 = true153end if154end if155end if156end if157next158159if temp1 == true160object.hasTarget = true161object.animationTimer = 0162object.animation = ROLLER_ANI_ENDROLL163object.frame = 2164object.timer = 120165object.state = ROLLER_STANDING166end if167end if168end if169break170171case ROLLER_FALLING172object.xpos += object.xvel173object.ypos += object.yvel174object.yvel += 0x3800175if object.yvel > 0176ObjectTileCollision(CSIDE_FLOOR, 0, 14, PATH_A)177if checkResult == true178object.state = ROLLER_ROLLING179end if180end if181break182183case ROLLER_STANDING184object.timer--185if object.timer == 0186object.animation = ROLLER_ANI_BEGINROLL187object.animationTimer = 0188end if189break190191end switch192193if object.outOfBounds == true194temp0 = object.xpos195temp1 = object.ypos196object.xpos = object.startPos.x197object.ypos = object.startPos.y198if object.outOfBounds == true199object.animation = ROLLER_ANI_HIDDEN200object.onGround = false201object.hasTarget = false202object.priority = PRIORITY_BOUNDS203object.state = ROLLER_FINDTARGET204else205object.xpos = temp0206object.ypos = temp1207end if208end if209210if object.animation != ROLLER_ANI_HIDDEN211if object.frame < 2212foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)213BoxCollisionTest(C_TOUCH, object.entityPos, -15, -15, 15, 15, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)214if checkResult == true215CallFunction(Player_BadnikBreak)216end if217next218else219foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)220BoxCollisionTest(C_TOUCH, object.entityPos, -15, -15, 15, 15, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)221if checkResult == true222CallFunction(Player_Hit)223end if224next225end if226end if227228switch object.animation229case ROLLER_ANI_HIDDEN230break231232case ROLLER_ANI_ROLLING233object.frame = object.animationTimer234object.frame >>= 2235object.frame += 2236object.animationTimer++237if object.animationTimer >= 12238object.animationTimer = 0239end if240break241242case ROLLER_ANI_ENDROLL243object.animationTimer++244if object.animationTimer >= 16245object.frame--246if object.frame == 0247object.animation = ROLLER_ANI_STANDING248end if249object.animationTimer = 0250end if251break252253case ROLLER_ANI_STANDING254break255256case ROLLER_ANI_BEGINROLL257object.animationTimer++258if object.animationTimer >= 16259object.frame++260if object.frame == 3261object.animation = ROLLER_ANI_ROLLING262object.state = ROLLER_ROLLING263end if264object.animationTimer = 0265end if266break267268end switch269end event270271272event ObjectDraw273if object.animation != ROLLER_ANI_HIDDEN274DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)275end if276end event277278279event ObjectStartup280CheckCurrentStageFolder("Zone03")281if checkResult == true282LoadSpriteSheet("SYZ/Objects.gif")283SpriteFrame(-16, -33, 29, 47, 1, 179)284SpriteFrame(-16, -25, 29, 39, 31, 187)285SpriteFrame(-14, -14, 28, 28, 1, 227)286SpriteFrame(-14, -14, 28, 28, 31, 227)287SpriteFrame(-14, -14, 28, 28, 60, 227)288end if289290CheckCurrentStageFolder("Zone07")291if checkResult == true292LoadSpriteSheet("MBZ/Objects.gif")293SpriteFrame(-16, -33, 29, 47, 105, 30)294SpriteFrame(-16, -25, 29, 39, 75, 59)295SpriteFrame(-14, -14, 28, 28, 74, 1)296SpriteFrame(-14, -14, 28, 28, 104, 1)297SpriteFrame(-14, -14, 28, 28, 76, 30)298end if299300foreach (TypeName[Roller], arrayPos0, ALL_ENTITIES)301object[arrayPos0].startPos.x = object[arrayPos0].xpos302object[arrayPos0].startPos.y = object[arrayPos0].ypos303next304305// This badnik isn't featured in Debug Mode...306end event307308309// ========================310// Editor Events311// ========================312313event RSDKDraw314DrawSprite(0)315end event316317318event RSDKLoad319CheckCurrentStageFolder("Zone07")320if checkResult == true321LoadSpriteSheet("MBZ/Objects.gif")322SpriteFrame(-16, -33, 29, 47, 105, 30)323SpriteFrame(-16, -25, 29, 39, 75, 59)324SpriteFrame(-14, -14, 28, 28, 74, 1)325SpriteFrame(-14, -14, 28, 28, 104, 1)326SpriteFrame(-14, -14, 28, 28, 76, 30)327else328LoadSpriteSheet("SYZ/Objects.gif")329SpriteFrame(-16, -33, 29, 47, 1, 179)330SpriteFrame(-16, -25, 29, 39, 31, 187)331SpriteFrame(-14, -14, 28, 28, 1, 227)332SpriteFrame(-14, -14, 28, 28, 31, 227)333SpriteFrame(-14, -14, 28, 28, 60, 227)334end if335336SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")337end event338339340