Path: blob/master/Sonic 1/Scripts/Mission/BallHog2.txt
1487 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Ball Hog Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// This script is a copy of the normal Ball Hog script but with tile collisions removed so that the badnik can be placed on Mission Blocks89// ========================10// Aliases11// ========================1213// value0 is unused...14private alias object.value1 : object.timer15private alias object.value2 : object.originY1617// Ball Hog Bomb Aliases18private alias object.value0 : object.time19private alias object.value1 : object.bouncePos2021// Player Aliases22private alias object.value38 : player.hitboxTop23private alias object.value39 : player.hitboxBottom24private alias object.value40 : player.hitboxLeft25private alias object.value41 : player.hitboxRight262728// ========================29// Function Declarations30// ========================3132reserve function BallHog_DebugDraw33reserve function BallHog_DebugSpawn343536// ========================37// Tables38// ========================3940private table BallHog_frameTable410, 2, 3, 2, 0, 2, 3, 2, 0, 2, 3, 2, 0, 1, 042end table4344private table BallHog_frameDelayTable4520, 20, 10, 10, 20, 20, 10, 10, 20, 20, 10, 10, 20, 1046end table474849// ========================50// Function Definitions51// ========================5253private function BallHog_DebugDraw54DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)55end function565758private function BallHog_DebugSpawn59CreateTempObject(TypeName[Ball Hog], 0, object.xpos, object.ypos)60object[tempObjectPos].direction = object.direction61object[tempObjectPos].propertyValue = 162end function636465// ========================66// Events67// ========================6869event ObjectUpdate70foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)71BoxCollisionTest(C_TOUCH, object.entityPos, -12, -18, 12, 18, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)72if checkResult == true73CallFunction(Player_BadnikBreak)74end if75next7677// Sidestep a little78if object.frame == 379object.ypos += object.yvel80object.yvel += 0x95C08182// (This bit is different in BallHog2, normally tile collisions are checked here but instead we're just checking against originY directly83if object.ypos < object.originY84object.animationTimer = 285end if86end if8788// Update animation & ball lobbing89object.animationTimer--90if object.animationTimer <= 091GetTableValue(object.animationTimer, object.timer, BallHog_frameDelayTable)92GetTableValue(object.frame, object.timer, BallHog_frameTable)9394object.timer++95if object.timer >= 1496object.timer = 097end if9899if object.frame == 3100object.yvel = -0x29999101object.ypos += object.yvel102object.yvel += 0x95C0103end if104105if object.frame == 1106// Drop a bomb ball107108CreateTempObject(TypeName[Ball Hog Bomb], 0, object.xpos, object.ypos)109if object.direction == FLIP_NONE110object[tempObjectPos].xpos -= 0x40000111object[tempObjectPos].xvel = -0x10000112else113object[tempObjectPos].xpos += 0x40000114object[tempObjectPos].xvel = 0x10000115end if116117object[tempObjectPos].ypos += 0xC0000118119// This part is more new BallHog2 stuff120// Since the bomb can't check tile collisions let's just make it bounce when it's 13 pixels below the Ball Hog's own position121object[tempObjectPos].bouncePos = object.ypos122object[tempObjectPos].bouncePos += 0xD0000123124object[tempObjectPos].time = object.propertyValue125object[tempObjectPos].time *= 60126end if127end if128end event129130131event ObjectDraw132DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)133end event134135136event ObjectStartup137CheckCurrentStageFolder("Zone06")138if checkResult == true139LoadSpriteSheet("SBZ/Objects.gif")140SpriteFrame(-11, -17, 22, 37, 1, 170)141SpriteFrame(-11, -17, 22, 37, 24, 170)142SpriteFrame(-12, -12, 24, 32, 47, 175)143SpriteFrame(-11, -20, 22, 40, 72, 167)144end if145146CheckCurrentStageFolder("Zone07")147if checkResult == true148LoadSpriteSheet("MBZ/Objects.gif")149SpriteFrame(-11, -17, 22, 37, 76, 292)150SpriteFrame(-11, -17, 22, 37, 99, 292)151SpriteFrame(-12, -12, 24, 32, 122, 297)152SpriteFrame(-11, -20, 22, 40, 147, 289)153end if154155foreach (TypeName[Ball Hog], arrayPos0, ALL_ENTITIES)156temp0 = object[arrayPos0].propertyValue157temp0 &= 0x80158if temp0 != 0159object[arrayPos0].direction = FLIP_X160object[arrayPos0].propertyValue &= 0x7F161end if162163// (This line is new to BallHog2)164object[arrayPos0].originY = object[arrayPos0].ypos165next166167SetTableValue(TypeName[Ball Hog], DebugMode_ObjCount, DebugMode_TypesTable)168SetTableValue(BallHog_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)169SetTableValue(BallHog_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)170DebugMode_ObjCount++171end event172173174// ========================175// Editor Events176// ========================177178event RSDKEdit179if editor.returnVariable == true180switch editor.variableID181case EDIT_VAR_PROPVAL // property value182checkResult = object.propertyValue183break184185case 0 // bombTime186checkResult = object.propertyValue187checkResult &= 0x7F188break189190case 1 // direction191GetBit(checkResult, object.propertyValue, 7)192break193194end switch195else196switch editor.variableID197case EDIT_VAR_PROPVAL // property value198object.propertyValue = editor.variableValue199break200201case 0 // bombTime202object.propertyValue &= 0x80203editor.variableValue &= 0x7F204205object.propertyValue |= editor.variableValue206break207208case 1 // direction209CheckNotEqual(editor.variableValue, false)210SetBit(object.propertyValue, 7, checkResult)211break212213end switch214end if215end event216217218event RSDKDraw219GetBit(object.direction, object.propertyValue, 7)220DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)221end event222223224event RSDKLoad225CheckCurrentStageFolder("Zone07")226if checkResult == true227LoadSpriteSheet("MBZ/Objects.gif")228SpriteFrame(-11, -17, 22, 37, 76, 292)229SpriteFrame(-11, -17, 22, 37, 99, 292)230SpriteFrame(-12, -12, 24, 32, 122, 297)231SpriteFrame(-11, -20, 22, 40, 147, 289)232else233LoadSpriteSheet("SBZ/Objects.gif")234SpriteFrame(-11, -17, 22, 37, 1, 170)235SpriteFrame(-11, -17, 22, 37, 24, 170)236SpriteFrame(-12, -12, 24, 32, 47, 175)237SpriteFrame(-11, -20, 22, 40, 72, 167)238end if239240AddEditorVariable("bombTime")241242AddEditorVariable("direction")243SetActiveVariable("direction")244AddEnumVariable("Left", 0)245AddEnumVariable("Right", 1)246end event247248249