Path: blob/master/Sonic 1/Scripts/MZ/Fireball.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Fireball 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.interval13private alias object.value2 : object.fireballDir14private alias object.value3 : object.finalY1516private alias 0 : FIREBALL_SPAWNER17private alias 1 : FIREBALL_MOVE_GRAVITY18private alias 2 : FIREBALL_MOVE_UP19private alias 3 : FIREBALL_MOVE_DOWN20private alias 4 : FIREBALL_MOVE_LEFT21private alias 5 : FIREBALL_MOVE_RIGHT22private alias 6 : FIREBALL_DISSIPATE2324// Player Aliases25private alias object.value17 : debugMode.currentSelection2627// Path ID Aliases28private alias 0 : PATH_A293031// ========================32// Function Declarations33// ========================3435reserve function Fireball_DebugDraw36reserve function Fireball_DebugSpawn373839// ========================40// Static Values41// ========================4243private value Fireball_startDebugID = 0444546// ========================47// Function Definitions48// ========================4950private function Fireball_DebugDraw51temp0 = debugMode[0].currentSelection52temp0 -= Fireball_startDebugID53temp1 = object.direction5455switch temp056case 057object.direction = FLIP_Y58DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)59break6061case 162if object.direction == FLIP_NONE63object.direction = FLIP_Y64end if6566DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)67break6869case 270DrawSpriteFX(3, FX_FLIP, object.xpos, object.ypos)71break7273end switch74object.direction = temp175end function767778private function Fireball_DebugSpawn79CreateTempObject(TypeName[Fireball], 0, object.xpos, object.ypos)80object[tempObjectPos].interval = 6081temp0 = debugMode[0].currentSelection82temp0 -= Fireball_startDebugID83switch temp084case 085object[tempObjectPos].propertyValue = FIREBALL_MOVE_GRAVITY86object[tempObjectPos].yvel = -0x4000087object[tempObjectPos].fireballDir = FLIP_Y88break8990case 191if object.direction == FLIP_NONE92object[tempObjectPos].propertyValue = FIREBALL_MOVE_UP93object[tempObjectPos].yvel = -0x2000094object[tempObjectPos].fireballDir = FLIP_Y95else96object[tempObjectPos].propertyValue = FIREBALL_MOVE_DOWN97object[tempObjectPos].yvel = 0x2000098object[tempObjectPos].fireballDir = FLIP_NONE99end if100break101102case 2103if object.direction == FLIP_NONE104object[tempObjectPos].propertyValue = FIREBALL_MOVE_RIGHT105object[tempObjectPos].xvel = 0x20000106object[tempObjectPos].fireballDir = FLIP_NONE107else108object[tempObjectPos].propertyValue = FIREBALL_MOVE_LEFT109object[tempObjectPos].xvel = -0x20000110object[tempObjectPos].fireballDir = FLIP_X111end if112break113114end switch115end function116117118// ========================119// Events120// ========================121122event ObjectUpdate123switch object.state124case FIREBALL_SPAWNER125object.timer++126if object.timer == object.interval127object.timer = 0128temp0 = object.ixpos129temp0 -= camera[0].xpos130Abs(temp0)131if temp0 < screen.xcenter132temp0 = object.iypos133temp0 -= camera[0].ypos134Abs(temp0)135if temp0 < screen.ycenter136CreateTempObject(TypeName[Fireball], 0, object.xpos, object.ypos)137object[tempObjectPos].state = object.propertyValue138object[tempObjectPos].xvel = object.xvel139object[tempObjectPos].yvel = object.yvel140object[tempObjectPos].finalY = object.ypos141object[tempObjectPos].fireballDir = object.fireballDir142PlaySfx(SfxName[Small Fireball], false)143end if144end if145end if146break147148case FIREBALL_MOVE_GRAVITY149object.yvel += 0x1800150object.ypos += object.yvel151if object.yvel > 0152object.fireballDir = FLIP_NONE153end if154155if object.ypos > object.finalY156object.type = TypeName[Blank Object]157end if158159object.frame = object.animationTimer160object.frame /= 12161object.direction = object.animationTimer162object.direction /= 6163object.direction &= FLIP_X164object.direction += object.fireballDir165object.animationTimer++166object.animationTimer %= 24167break168169case FIREBALL_MOVE_UP170object.ypos += object.yvel171object.frame = object.animationTimer172object.frame /= 12173object.direction = object.animationTimer174object.direction /= 6175object.direction &= FLIP_X176object.direction += object.fireballDir177object.animationTimer++178object.animationTimer %= 24179180ObjectTileCollision(CSIDE_ROOF, 0, -8, PATH_A)181if checkResult == true182object.state = FIREBALL_DISSIPATE183object.frame = 2 // dissipate (V)184end if185186if object.outOfBounds == true187object.type = TypeName[Blank Object]188end if189break190191case FIREBALL_MOVE_DOWN192object.ypos += object.yvel193object.frame = object.animationTimer194object.frame /= 12195object.direction = object.animationTimer196object.direction /= 6197object.direction &= FLIP_X198object.direction += object.fireballDir199object.animationTimer++200object.animationTimer %= 24201202ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)203if checkResult == true204object.state = FIREBALL_DISSIPATE205object.frame = 2 // dissipate (V)206end if207208if object.outOfBounds == true209object.type = TypeName[Blank Object]210end if211break212213case FIREBALL_MOVE_LEFT214object.xpos += object.xvel215object.frame = object.animationTimer216object.frame /= 12217object.frame += 3218object.direction = object.animationTimer219object.direction /= 6220object.direction &= FLIP_X221object.direction <<= 1 // turn it into either FLIP_Y or FLIP_NONE222object.direction += object.fireballDir223object.animationTimer++224object.animationTimer %= 24225226ObjectTileCollision(CSIDE_RWALL, -8, 0, PATH_A)227if checkResult == true228object.state = FIREBALL_DISSIPATE229object.frame = 5 // dissipate (H)230end if231232if object.outOfBounds == true233object.type = TypeName[Blank Object]234end if235break236237case FIREBALL_MOVE_RIGHT238object.xpos += object.xvel239object.frame = object.animationTimer240object.frame /= 12241object.frame += 3242object.direction = object.animationTimer243object.direction /= 6244object.direction &= FLIP_X245object.direction <<= 1 // turn it into either FLIP_Y or FLIP_NONE246object.direction += object.fireballDir247object.animationTimer++248object.animationTimer %= 24249250ObjectTileCollision(CSIDE_LWALL, 8, 0, PATH_A)251if checkResult == true252object.state = FIREBALL_DISSIPATE253object.frame = 5 // dissipate (H)254end if255256if object.outOfBounds == true257object.type = TypeName[Blank Object]258end if259break260261case FIREBALL_DISSIPATE262object.timer++263if object.timer == 8264object.type = TypeName[Blank Object]265end if266break267268end switch269270if object.state > FIREBALL_SPAWNER271foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)272BoxCollisionTest(C_TOUCH, object.entityPos, -6, -6, 6, 6, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)273if checkResult == true274CallFunction(Player_FireHit)275end if276next277end if278end event279280281event ObjectDraw282if object.state > FIREBALL_SPAWNER283DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)284end if285end event286287288event ObjectStartup289LoadSpriteSheet("MZ/Objects.gif")290SpriteFrame(-7, -23, 15, 31, 52, 114) // Vertical 1 - #0291SpriteFrame(-8, -24, 16, 32, 68, 114) // Vertical 2 - #1292SpriteFrame(-8, -15, 16, 23, 85, 114) // Vertical Dissipate - #2293SpriteFrame(-23, -8, 31, 15, 103, 114) // Horizontal 1 - #3294SpriteFrame(-24, -8, 32, 15, 102, 130) // Horizontal 2 - #4295SpriteFrame(-15, -8, 23, 16, 135, 114) // Horizontal Dissipate - #5296297foreach (TypeName[Fireball], arrayPos0, ALL_ENTITIES)298object[arrayPos0].interval = object[arrayPos0].propertyValue299object[arrayPos0].interval >>= 4300object[arrayPos0].interval *= 30301object[arrayPos0].interval += 30302303object[arrayPos0].propertyValue &= 7304switch object[arrayPos0].propertyValue305case 0306object[arrayPos0].propertyValue = FIREBALL_MOVE_GRAVITY307object[arrayPos0].yvel = -0x40000308object[arrayPos0].fireballDir = FLIP_Y309break310311case 1312object[arrayPos0].propertyValue = FIREBALL_MOVE_GRAVITY313object[arrayPos0].yvel = -0x50000314object[arrayPos0].fireballDir = FLIP_Y315break316317case 2318object[arrayPos0].propertyValue = FIREBALL_MOVE_GRAVITY319object[arrayPos0].yvel = -0x60000320object[arrayPos0].fireballDir = FLIP_Y321break322323case 3324object[arrayPos0].propertyValue = FIREBALL_MOVE_GRAVITY325object[arrayPos0].yvel = -0x70000326object[arrayPos0].fireballDir = FLIP_Y327break328329case 4330object[arrayPos0].propertyValue = FIREBALL_MOVE_UP331object[arrayPos0].yvel = -0x20000332object[arrayPos0].fireballDir = FLIP_Y333break334335case 5336object[arrayPos0].propertyValue = FIREBALL_MOVE_DOWN337object[arrayPos0].yvel = 0x20000338object[arrayPos0].fireballDir = FLIP_NONE339break340341case 6342object[arrayPos0].propertyValue = FIREBALL_MOVE_LEFT343object[arrayPos0].xvel = -0x20000344object[arrayPos0].fireballDir = FLIP_X345break346347case 7348object[arrayPos0].propertyValue = FIREBALL_MOVE_RIGHT349object[arrayPos0].xvel = 0x20000350object[arrayPos0].fireballDir = FLIP_NONE351break352353end switch354next355356temp0 = 0357Fireball_startDebugID = DebugMode_ObjCount358while temp0 < 3359SetTableValue(TypeName[Fireball], DebugMode_ObjCount, DebugMode_TypesTable)360SetTableValue(Fireball_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)361SetTableValue(Fireball_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)362DebugMode_ObjCount++363temp0++364loop365end event366367368// ========================369// Editor Events370// ========================371372event RSDKEdit373if editor.returnVariable == true374switch editor.variableID375case EDIT_VAR_PROPVAL // property value376checkResult = object.propertyValue377break378379case 0 // type380checkResult = object.propertyValue381checkResult &= 7382break383384case 1 // interval385checkResult = object.propertyValue386checkResult >>= 4387checkResult &= 0x0F388break389390end switch391else392switch editor.variableID393case EDIT_VAR_PROPVAL // property value394object.propertyValue = editor.variableValue395break396397case 0 // type398temp0 = 7399Not(temp0)400object.propertyValue &= temp0401402editor.variableValue &= 7403object.propertyValue |= editor.variableValue404break405406case 1 // interval407object.propertyValue &= 0x0F408409editor.variableValue &= 15410object.propertyValue |= editor.variableValue411break412413end switch414end if415end event416417418event RSDKDraw419temp1 = object.direction420421temp0 = object.propertyValue422temp0 &= 7423switch temp0424case 0425object.frame = 0426object.direction = FLIP_Y427break428429case 1430object.frame = 0431object.direction = FLIP_Y432break433434case 2435object.frame = 0436object.direction = FLIP_Y437break438439case 3440object.frame = 0441object.direction = FLIP_Y442break443444case 4445object.frame = 0446object.direction = FLIP_Y447break448449case 5450object.frame = 0451object.direction = FLIP_NONE452break453454case 6455object.frame = 3456object.direction = FLIP_X457break458459case 7460object.frame = 3461object.direction = FLIP_NONE462break463464end switch465466DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)467object.direction = temp1468end event469470471event RSDKLoad472LoadSpriteSheet("MZ/Objects.gif")473SpriteFrame(-7, -23, 15, 31, 52, 114) // Vertical 1 - #0474SpriteFrame(-8, -24, 16, 32, 68, 114) // Vertical 2 - #1475SpriteFrame(-8, -15, 16, 23, 85, 114) // Vertical Dissipate - #2476SpriteFrame(-23, -8, 31, 15, 103, 114) // Horizontal 1 - #3477SpriteFrame(-24, -8, 32, 15, 102, 130) // Horizontal 2 - #4478SpriteFrame(-15, -8, 23, 16, 135, 114) // Horizontal Dissipate - #5479480AddEditorVariable("type")481SetActiveVariable("type")482AddEnumVariable("Eject Up (Slowest)", 0)483AddEnumVariable("Eject Up (Slow)", 1)484AddEnumVariable("Eject Up (Fast)", 2)485AddEnumVariable("Eject Up (Fastest)", 3)486AddEnumVariable("Travel Up", 4)487AddEnumVariable("Travel Down", 5)488AddEnumVariable("Travel Left", 6)489AddEnumVariable("Travel Right", 7)490491AddEditorVariable("interval")492SetActiveVariable("interval")493AddEnumVariable("Every 30 Frames", 0)494AddEnumVariable("Every 60 Frames", 1)495AddEnumVariable("Every 90 Frames", 2)496AddEnumVariable("Every 120 Frames", 3)497AddEnumVariable("Every 150 Frames", 4)498AddEnumVariable("Every 180 Frames", 5)499AddEnumVariable("Every 210 Frames", 6)500AddEnumVariable("Every 240 Frames", 7)501AddEnumVariable("Every 270 Frames", 8)502AddEnumVariable("Every 300 Frames", 9)503AddEnumVariable("Every 330 Frames", 10)504AddEnumVariable("Every 360 Frames", 11)505AddEnumVariable("Every 390 Frames", 12)506AddEnumVariable("Every 420 Frames", 13)507AddEnumVariable("Every 450 Frames", 14)508AddEnumVariable("Every 480 Frames", 15)509end event510511512