Path: blob/master/Sonic 1/Scripts/Enemies/BallHog.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Ball Hog Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value1 : object.timer1213// Ball Hog Bomb Aliases14private alias object.value0 : object.time1516// Player Aliases17private alias object.value40 : player.hitboxLeft18private alias object.value38 : player.hitboxTop19private alias object.value41 : player.hitboxRight20private alias object.value39 : player.hitboxBottom2122// Path ID Aliases23private alias 0 : PATH_A242526// ========================27// Function Declarations28// ========================2930reserve function BallHog_DebugDraw31reserve function BallHog_DebugSpawn323334// ========================35// Tables36// ========================3738private table BallHog_frameTable390, 2, 3, 2, 0, 2, 3, 2, 0, 2, 3, 2, 0, 1, 040end table4142private table BallHog_frameDelayTable4320, 20, 10, 10, 20, 20, 10, 10, 20, 20, 10, 10, 20, 1044end table454647// ========================48// Function Definitions49// ========================5051private function BallHog_DebugDraw52DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)53end function545556private function BallHog_DebugSpawn57CreateTempObject(TypeName[Ball Hog], 0, object.xpos, object.ypos)58object[tempObjectPos].direction = object.direction59object[tempObjectPos].propertyValue = 160end function616263// ========================64// Events65// ========================6667event ObjectUpdate68foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)69BoxCollisionTest(C_TOUCH, object.entityPos, -12, -18, 12, 18, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)70if checkResult == true71CallFunction(Player_BadnikBreak)72end if73next7475// Sidestep a little76if object.frame == 377object.ypos += object.yvel78object.yvel += 0x95C079ObjectTileCollision(CSIDE_FLOOR, 0, 20, PATH_A)80if checkResult == false81object.animationTimer = 282end if83end if8485// Update animation & ball lobbing86object.animationTimer--87if object.animationTimer <= 088GetTableValue(object.animationTimer, object.timer, BallHog_frameDelayTable)89GetTableValue(object.frame, object.timer, BallHog_frameTable)9091object.timer++92if object.timer >= 1493object.timer = 094end if9596if object.frame == 397object.yvel = -0x2999998object.ypos += object.yvel99object.yvel += 0x95C0100end if101102if object.frame == 1103// Drop a bomb ball104105CreateTempObject(TypeName[Ball Hog Bomb], 0, object.xpos, object.ypos)106if object.direction == FLIP_NONE107object[tempObjectPos].xpos -= 0x40000108object[tempObjectPos].xvel = -0x10000109else110object[tempObjectPos].xpos += 0x40000111object[tempObjectPos].xvel = 0x10000112end if113114object[tempObjectPos].ypos += 0xC0000115object[tempObjectPos].time = object.propertyValue116object[tempObjectPos].time *= 60117end if118end if119end event120121122event ObjectDraw123DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)124end event125126127event ObjectStartup128CheckCurrentStageFolder("Zone06")129if checkResult == true130LoadSpriteSheet("SBZ/Objects.gif")131SpriteFrame(-11, -17, 22, 37, 1, 170)132SpriteFrame(-11, -17, 22, 37, 24, 170)133SpriteFrame(-12, -12, 24, 32, 47, 175)134SpriteFrame(-11, -20, 22, 40, 72, 167)135end if136137CheckCurrentStageFolder("Zone07")138if checkResult == true139LoadSpriteSheet("MBZ/Objects.gif")140SpriteFrame(-11, -17, 22, 37, 76, 292)141SpriteFrame(-11, -17, 22, 37, 99, 292)142SpriteFrame(-12, -12, 24, 32, 122, 297)143SpriteFrame(-11, -20, 22, 40, 147, 289)144end if145146foreach (TypeName[Ball Hog], arrayPos0, ALL_ENTITIES)147temp0 = object[arrayPos0].propertyValue148temp0 &= 0x80149if temp0 != 0150object[arrayPos0].direction = FLIP_X151object[arrayPos0].propertyValue &= 0x7F152end if153next154155SetTableValue(TypeName[Ball Hog], DebugMode_ObjCount, DebugMode_TypesTable)156SetTableValue(BallHog_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)157SetTableValue(BallHog_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)158DebugMode_ObjCount++159end event160161162// ========================163// Editor Events164// ========================165166event RSDKEdit167if editor.returnVariable == true168switch editor.variableID169case EDIT_VAR_PROPVAL // property value170checkResult = object.propertyValue171break172173case 0 // bombTime174checkResult = object.propertyValue175checkResult &= 0x7F176break177178case 1 // direction179GetBit(checkResult, object.propertyValue, 7)180break181182end switch183else184switch editor.variableID185case EDIT_VAR_PROPVAL // property value186object.propertyValue = editor.variableValue187break188189case 0 // bombTime190object.propertyValue &= 0x80191editor.variableValue &= 0x7F192193object.propertyValue |= editor.variableValue194break195196case 1 // direction197CheckNotEqual(editor.variableValue, false)198SetBit(object.propertyValue, 7, checkResult)199break200201end switch202end if203end event204205206event RSDKDraw207GetBit(object.direction, object.propertyValue, 7)208DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)209end event210211212event RSDKLoad213CheckCurrentStageFolder("Zone07")214if checkResult == true215LoadSpriteSheet("MBZ/Objects.gif")216SpriteFrame(-11, -17, 22, 37, 76, 292)217SpriteFrame(-11, -17, 22, 37, 99, 292)218SpriteFrame(-12, -12, 24, 32, 122, 297)219SpriteFrame(-11, -20, 22, 40, 147, 289)220else221LoadSpriteSheet("SBZ/Objects.gif")222SpriteFrame(-11, -17, 22, 37, 1, 170)223SpriteFrame(-11, -17, 22, 37, 24, 170)224SpriteFrame(-12, -12, 24, 32, 47, 175)225SpriteFrame(-11, -20, 22, 40, 72, 167)226end if227228AddEditorVariable("bombTime")229230AddEditorVariable("direction")231SetActiveVariable("direction")232AddEnumVariable("Left", 0)233AddEnumVariable("Right", 1)234end event235236237