Path: blob/master/Sonic 1/Scripts/Enemies/Jaws.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Jaws Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.swimTimer12private alias object.value1 : object.swimDuration13private alias object.value3 : object.startPos.x1415// Player Aliases16private alias object.value40 : player.hitboxLeft17private alias object.value38 : player.hitboxTop18private alias object.value41 : player.hitboxRight19private alias object.value39 : player.hitboxBottom202122// ========================23// Function Declarations24// ========================2526reserve function Jaws_DebugDraw27reserve function Jaws_DebugSpawn282930// ========================31// Function Definitions32// ========================3334private function Jaws_DebugDraw35DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)36end function373839private function Jaws_DebugSpawn40CreateTempObject(TypeName[Jaws], 0, object.xpos, object.ypos)41object[tempObjectPos].direction = object.direction42object[tempObjectPos].startPos.x = object.xpos43if object[tempObjectPos].direction == FLIP_NONE44object[tempObjectPos].xvel = -0x400045else46object[tempObjectPos].xvel = 0x400047end if48object[tempObjectPos].swimTimer = 12049end function505152// ========================53// Events54// ========================5556event ObjectUpdate57object.priority = PRIORITY_ACTIVE58object.xpos += object.xvel5960object.swimTimer--61if object.swimTimer == 062object.direction ^= FLIP_X63FlipSign(object.xvel)64object.swimTimer = object.swimDuration65end if6667if object.outOfBounds == true68temp0 = object.xpos69object.xpos = object.startPos.x70if object.outOfBounds == true71object.xpos = object.startPos.x72object.priority = PRIORITY_BOUNDS73object.direction = object.propertyValue74object.direction >>= 775if object.direction == FLIP_NONE76object.xvel = -0x400077else78object.xvel = 0x400079end if80object.swimTimer = object.propertyValue81object.swimTimer &= 0x7F82object.swimTimer <<= 683object.swimDuration = object.swimTimer84else85object.xpos = temp086end if87end if8889// Check interaction with players90foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)91BoxCollisionTest(C_TOUCH, object.entityPos, -16, -12, 16, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)92if checkResult == true93CallFunction(Player_BadnikBreak)94end if95next9697object.frame = object.animationTimer98object.frame >>= 399object.animationTimer++100object.animationTimer &= 15101end event102103104event ObjectDraw105DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)106end event107108109event ObjectStartup110// Load sheet and sprites depending on which zone the player is currently in111CheckCurrentStageFolder("Zone04")112if checkResult == true113LoadSpriteSheet("LZ/Objects.gif")114SpriteFrame(-16, -12, 48, 24, 1, 105)115SpriteFrame(-16, -12, 45, 24, 1, 130)116SpriteFrame(-16, -12, 48, 24, 1, 155)117SpriteFrame(-16, -12, 45, 24, 47, 129)118end if119120CheckCurrentStageFolder("Zone07")121if checkResult == true122LoadSpriteSheet("MBZ/Objects.gif")123SpriteFrame(-16, -12, 48, 24, 1, 264)124SpriteFrame(-16, -12, 45, 24, 99, 264)125SpriteFrame(-16, -12, 48, 24, 50, 264)126SpriteFrame(-16, -12, 45, 24, 145, 264)127end if128129foreach (TypeName[Jaws], arrayPos0, ALL_ENTITIES)130object[arrayPos0].startPos.x = object[arrayPos0].xpos131object[arrayPos0].direction = object[arrayPos0].propertyValue132object[arrayPos0].direction >>= 7133if object[arrayPos0].direction == FLIP_NONE134object[arrayPos0].xvel = -0x4000135else136object[arrayPos0].xvel = 0x4000137end if138139object[arrayPos0].swimTimer = object[arrayPos0].propertyValue140object[arrayPos0].swimTimer &= 0x7F141object[arrayPos0].swimTimer <<= 6142object[arrayPos0].swimDuration = object[arrayPos0].swimTimer143next144145// Add Jaws to the debug object list146SetTableValue(TypeName[Jaws], DebugMode_ObjCount, DebugMode_TypesTable)147SetTableValue(Jaws_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)148SetTableValue(Jaws_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)149DebugMode_ObjCount++150end event151152153// ========================154// Editor Events155// ========================156157event RSDKEdit158if editor.returnVariable == true159switch editor.variableID160case EDIT_VAR_PROPVAL // property value161checkResult = object.propertyValue162break163164case 0 // swimDuration165checkResult = object.propertyValue166checkResult &= 0x7F167break168169case 1 // direction170GetBit(checkResult, object.propertyValue, 7)171break172173end switch174else175switch editor.variableID176case EDIT_VAR_PROPVAL // property value177object.propertyValue = editor.variableValue178break179180case 0 // swimDuration181object.propertyValue &= 0x80182editor.variableValue &= 0x7F183184object.propertyValue |= editor.variableValue185break186187case 1 // direction188CheckNotEqual(editor.variableValue, false)189SetBit(object.propertyValue, 7, checkResult)190break191192end switch193end if194end event195196197event RSDKDraw198GetBit(object.direction, object.propertyValue, 7)199DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)200201if editor.showGizmos == true202editor.drawingOverlay = true203204temp0 = object.propertyValue205temp0 &= 0x7C206temp0 <<= 20207GetBit(checkResult, object.propertyValue, 7)208SetBit(temp0, 31, checkResult)209temp0 += object.xpos210DrawLine(object.xpos, object.ypos, temp0, object.ypos, 0xFF, 0xFF, 0x00)211212editor.drawingOverlay = false213end if214end event215216217event RSDKLoad218CheckCurrentStageFolder("Zone07")219if checkResult == true220LoadSpriteSheet("MBZ/Objects.gif")221SpriteFrame(-16, -12, 48, 24, 1, 264)222else223LoadSpriteSheet("LZ/Objects.gif")224SpriteFrame(-16, -12, 48, 24, 1, 105)225end if226227AddEditorVariable("swimDuration")228SetActiveVariable("swimDuration")229230AddEditorVariable("direction")231SetActiveVariable("direction")232AddEnumVariable("Left", 0)233AddEnumVariable("Right", 1)234end event235236237