Path: blob/master/Sonic 1/Scripts/Mission/ReviveCrabmeat.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Crabmeat 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.canShoot1516private alias 0 : CRABMEAT_MOVING17private alias 1 : CRABMEAT_IDLE18private alias 2 : CRABMEAT_SHOOT19private alias 3 : CRABMEAT_SHOOTDELAY20private alias 4 : CRABMEAT_REVIVE2122private alias 0 : CRABMEAT_ANI_MOVING23private alias 1 : CRABMEAT_ANI_SHOOT24private alias 2 : CRABMEAT_ANI_IDLE2526// Player aliases27private alias object.value40 : player.hitboxLeft28private alias object.value38 : player.hitboxTop29private alias object.value41 : player.hitboxRight30private alias object.value39 : player.hitboxBottom3132// Revive Enemy Aliases33private alias object.value47 : object.backupType34private alias object.value46 : object.backupState35private alias object.value44 : object.backupvalueA36private alias object.value43 : object.backupvalueB37private alias object.value0 : object.target3839// Path ID Aliases40private alias 0 : PATH_A414243// ========================44// Function Declarations45// ========================4647reserve function Crabmeat_DebugDraw48reserve function Crabmeat_DebugSpawn495051// ========================52// Function Definitions53// ========================5455private function Crabmeat_DebugDraw56DrawSprite(0)57end function585960private function Crabmeat_DebugSpawn61CreateTempObject(TypeName[Crabmeat], 0, object.xpos, object.ypos)62object[tempObjectPos].startPos.x = object.xpos63object[tempObjectPos].startPos.y = object.ypos6465GetBit(temp0, object.direction, 0)66if temp0 == 067object[tempObjectPos].direction = FACING_LEFT68object[tempObjectPos].xvel = 0x800069else70object[tempObjectPos].direction = FACING_LEFT71object[tempObjectPos].xvel = -0x800072end if7374object[tempObjectPos].canShoot = false75end function767778// ========================79// Events80// ========================8182event ObjectUpdate83switch object.state84case CRABMEAT_MOVING85object.priority = PRIORITY_ACTIVE8687if object.timer < 12788object.timer++89object.xpos += object.xvel90if object.xvel > 091ObjectTileGrip(CSIDE_FLOOR, 14, 15, PATH_A)92else93ObjectTileGrip(CSIDE_FLOOR, -14, 15, PATH_A)94end if9596if checkResult == false97if object.canShoot == true98object.state = CRABMEAT_SHOOT99else100object.state = CRABMEAT_IDLE101object.canShoot = true102end if103object.timer = 0104object.animation = CRABMEAT_ANI_SHOOT105end if106ObjectTileGrip(CSIDE_FLOOR, 0, 15, PATH_A)107else108if object.canShoot == true109object.state = CRABMEAT_SHOOT110else111object.state = CRABMEAT_IDLE112object.canShoot = true113end if114115object.timer = 0116object.animation = CRABMEAT_ANI_SHOOT117end if118break119120case CRABMEAT_IDLE121if object.timer < 59122object.timer++123else124object.timer = 0125object.state = CRABMEAT_MOVING126object.animation = CRABMEAT_ANI_MOVING127object.animationTimer = 0128FlipSign(object.xvel)129end if130break131132case CRABMEAT_SHOOT133if object.timer < 59134object.timer++135else136CreateTempObject(TypeName[Crabmeat Shot], 0, object.xpos, object.ypos)137object[tempObjectPos].xpos -= 0x100000138object[tempObjectPos].xvel = -0x10000139object[tempObjectPos].yvel = -0x40000140141CreateTempObject(TypeName[Crabmeat Shot], 0, object.xpos, object.ypos)142object[tempObjectPos].xpos += 0x100000143object[tempObjectPos].xvel = 0x10000144object[tempObjectPos].yvel = -0x40000145146object.timer = 0147object.state++148object.animation = CRABMEAT_ANI_IDLE149end if150break151152case CRABMEAT_SHOOTDELAY153if object.timer < 59154object.timer++155else156object.timer = 0157object.state = CRABMEAT_MOVING158object.animation = CRABMEAT_ANI_MOVING159object.animationTimer = 0160FlipSign(object.xvel)161end if162break163164case CRABMEAT_REVIVE165object.startPos.x = object.xpos166object.startPos.y = object.ypos167168if object.propertyValue == 1169object.direction = FACING_LEFT170object.xvel = 0x8000171else172object.direction = FACING_LEFT173object.xvel = -0x8000174end if175176object.canShoot = false177object.state = CRABMEAT_MOVING178object.timer = 0179break180181end switch182183if object.outOfBounds == true184temp0 = object.xpos185temp1 = object.ypos186object.xpos = object.startPos.x187object.ypos = object.startPos.y188if object.outOfBounds == true189if object.propertyValue == 1190object.direction = FACING_LEFT191object.xvel = 0x8000192else193object.direction = FACING_LEFT194object.xvel = -0x8000195end if196197object.canShoot = false198object.state = CRABMEAT_MOVING199object.timer = 0200object.priority = PRIORITY_BOUNDS201object.animation = CRABMEAT_ANI_MOVING202object.animationTimer = 0203else204object.xpos = temp0205object.ypos = temp1206end if207end if208209foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)210BoxCollisionTest(C_TOUCH, object.entityPos, -14, -14, 14, 14, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)211if checkResult == true212CreateTempObject(TypeName[ReviveEnemy], object.propertyValue, object.startPos.x, object.startPos.y)213object[tempObjectPos].priority = PRIORITY_ACTIVE214object[tempObjectPos].target = object.entityPos215object[tempObjectPos].backupType = object.type216object[tempObjectPos].backupState = CRABMEAT_REVIVE217CallFunction(Player_BadnikBreak)218end if219next220221switch object.animation222case CRABMEAT_ANI_MOVING223object.frame = object.animationTimer224object.frame >>= 4225object.animationTimer++226object.animationTimer %= 48227break228229case CRABMEAT_ANI_SHOOT230object.frame = 0231break232233case CRABMEAT_ANI_IDLE234object.frame = 3235break236237end switch238end event239240241event ObjectDraw242DrawSprite(object.frame)243end event244245246event ObjectStartup247CheckCurrentStageFolder("Zone01")248if checkResult == true249LoadSpriteSheet("GHZ/Objects.gif")250SpriteFrame(-21, -16, 42, 31, 138, 157)251SpriteFrame(-22, -16, 44, 31, 98, 189)252SpriteFrame(-22, -16, 44, 31, 98, 221)253SpriteFrame(-24, -15, 48, 30, 143, 189)254end if255256CheckCurrentStageFolder("Zone03")257if checkResult == true258LoadSpriteSheet("SYZ/Objects.gif")259SpriteFrame(-21, -16, 42, 31, 184, 1)260SpriteFrame(-22, -16, 44, 31, 184, 34)261SpriteFrame(-22, -16, 44, 31, 184, 66)262SpriteFrame(-24, -15, 48, 30, 184, 173)263end if264265CheckCurrentStageFolder("Zone07")266if checkResult == true267LoadSpriteSheet("MBZ/Objects.gif")268SpriteFrame(-21, -16, 42, 31, 168, 81)269SpriteFrame(-22, -16, 44, 31, 211, 81)270SpriteFrame(-22, -16, 44, 31, 211, 113)271SpriteFrame(-24, -15, 48, 30, 162, 114)272end if273274foreach (TypeName[Crabmeat], arrayPos0, ALL_ENTITIES)275object[arrayPos0].startPos.x = object[arrayPos0].xpos276object[arrayPos0].startPos.y = object[arrayPos0].ypos277if object[arrayPos0].propertyValue == 1278object[arrayPos0].direction = FACING_LEFT279object[arrayPos0].xvel = 0x8000280else281object[arrayPos0].direction = FACING_LEFT282object[arrayPos0].xvel = -0x8000283end if284object[arrayPos0].canShoot = false285next286287SetTableValue(TypeName[Crabmeat], DebugMode_ObjCount, DebugMode_TypesTable)288SetTableValue(Crabmeat_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)289SetTableValue(Crabmeat_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)290DebugMode_ObjCount++291end event292293294// ========================295// Editor Events296// ========================297298event RSDKEdit299if editor.returnVariable == true300switch editor.variableID301case EDIT_VAR_PROPVAL // property value302checkResult = object.propertyValue303break304305case 0 // direction306checkResult = object.propertyValue307break308309end switch310else311switch editor.variableID312case EDIT_VAR_PROPVAL // property value313object.propertyValue = editor.variableValue314break315316case 0 // direction317object.propertyValue = editor.variableValue318break319320end switch321end if322end event323324325event RSDKDraw326DrawSprite(0)327end event328329330event RSDKLoad331CheckCurrentStageFolder("Zone01")332if checkResult == true333LoadSpriteSheet("GHZ/Objects.gif")334SpriteFrame(-21, -16, 42, 31, 138, 157)335end if336337CheckCurrentStageFolder("Zone03")338if checkResult == true339LoadSpriteSheet("SYZ/Objects.gif")340SpriteFrame(-21, -16, 42, 31, 184, 1)341end if342343CheckCurrentStageFolder("Zone07")344if checkResult == true345LoadSpriteSheet("MBZ/Objects.gif")346SpriteFrame(-21, -16, 42, 31, 168, 81)347end if348349AddEditorVariable("direction")350SetActiveVariable("direction")351AddEnumVariable("Left", 0)352AddEnumVariable("Right", 1)353end event354355356