Path: blob/master/Sonic 1/Scripts/SBZ/ElectricOrb.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Electric Orb Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value1 : object.interval1213// Player Aliases14private alias object.value17 : debugMode.currentSelection151617// ========================18// Function Declarations19// ========================2021reserve function ElectricOrb_DebugDraw22reserve function ElectricOrb_DebugSpawn232425// ========================26// Static Values27// ========================2829private value ElectricOrb_startDebugID = 0303132// ========================33// Function Definitions34// ========================3536private function ElectricOrb_DebugDraw37temp0 = object.direction38object.direction = debugMode.currentSelection39object.direction -= ElectricOrb_startDebugID40object.direction--41object.direction <<= 142DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)43object.direction = temp044end function454647private function ElectricOrb_DebugSpawn48temp0 = debugMode.currentSelection49temp0 -= ElectricOrb_startDebugID50temp0--51temp0 <<= 152CreateTempObject(TypeName[Electric Orb], 0, object.xpos, object.ypos)53object[tempObjectPos].direction = temp054object[tempObjectPos].drawOrder = 455end function565758// ========================59// Events60// ========================6162event ObjectUpdate63switch object.interval64default65// every 24 frames66temp0 = SBZSetup_electricOrbFrame67break6869case 270// every 12 frames71temp0 = SBZSetup_electricOrbFrame72temp0 %= 1273break7475case 476// every 6 frames77temp0 = SBZSetup_electricOrbFrame78temp0 %= 679break8081end switch8283// temp0 = timer84switch temp085case 086if SBZSetup_electricOrbTimer == 187temp0 = object.ixpos88temp0 -= camera[0].xpos89Abs(temp0)90if temp0 < screen.xcenter91temp0 = object.iypos92temp0 -= camera[0].ypos93Abs(temp0)94if temp0 < screen.ycenter95PlaySfx(SfxName[Electric Arc], false)96end if97end if98end if99break100101case 1102foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)103BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)104if checkResult == true105CallFunction(Player_LightningHit)106end if107next108break109110case 2111foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)112BoxCollisionTest(C_TOUCH, object.entityPos, -36, -8, 36, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)113if checkResult == true114CallFunction(Player_LightningHit)115end if116next117break118119case 3120foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)121BoxCollisionTest(C_TOUCH, object.entityPos, -36, -8, 36, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)122if checkResult == true123CallFunction(Player_LightningHit)124end if125next126break127128case 4129case 5130foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)131BoxCollisionTest(C_TOUCH, object.entityPos, -64, -8, 64, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)132if checkResult == true133CallFunction(Player_LightningHit)134end if135next136break137138end switch139end event140141142event ObjectDraw143switch object.interval144default145DrawSpriteFX(SBZSetup_electricOrbFrame, FX_FLIP, object.xpos, object.ypos)146break147148case 2149temp0 = SBZSetup_electricOrbFrame150temp0 %= 12151DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)152break153154case 4155temp0 = SBZSetup_electricOrbFrame156temp0 %= 6157DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)158break159160end switch161end event162163164event ObjectStartup165LoadSpriteSheet("SBZ/Objects.gif")166167// Orb frames168SpriteFrame(-8, -8, 16, 32, 58, 479)169SpriteFrame(-8, -8, 16, 32, 75, 479)170SpriteFrame(-36, -10, 76, 34, 92, 477)171SpriteFrame(-36, -10, 76, 34, 169, 477)172SpriteFrame(-64, -10, 132, 34, 246, 477)173SpriteFrame(-64, -10, 132, 34, 379, 477)174SpriteFrame(-8, -8, 16, 32, 58, 479)175SpriteFrame(-8, -8, 16, 32, 58, 479)176SpriteFrame(-8, -8, 16, 32, 58, 479)177SpriteFrame(-8, -8, 16, 32, 58, 479)178SpriteFrame(-8, -8, 16, 32, 58, 479)179SpriteFrame(-8, -8, 16, 32, 58, 479)180SpriteFrame(-8, -8, 16, 32, 58, 479)181SpriteFrame(-8, -8, 16, 32, 58, 479)182SpriteFrame(-8, -8, 16, 32, 58, 479)183SpriteFrame(-8, -8, 16, 32, 58, 479)184SpriteFrame(-8, -8, 16, 32, 58, 479)185SpriteFrame(-8, -8, 16, 32, 58, 479)186SpriteFrame(-8, -8, 16, 32, 58, 479)187SpriteFrame(-8, -8, 16, 32, 58, 479)188SpriteFrame(-8, -8, 16, 32, 58, 479)189SpriteFrame(-8, -8, 16, 32, 58, 479)190SpriteFrame(-8, -8, 16, 32, 58, 479)191SpriteFrame(-8, -8, 16, 32, 58, 479)192193foreach (TypeName[Electric Orb], arrayPos0, ALL_ENTITIES)194object[arrayPos0].interval = object[arrayPos0].propertyValue195object[arrayPos0].interval >>= 1196object[arrayPos0].interval &= 3197object[arrayPos0].interval <<= 1198object[arrayPos0].propertyValue &= 1199if object[arrayPos0].propertyValue == 1200object[arrayPos0].direction = FLIP_Y201else202object[arrayPos0].direction = FLIP_NONE203end if204object[arrayPos0].drawOrder = 4205next206207temp0 = 0208ElectricOrb_startDebugID = DebugMode_ObjCount209ElectricOrb_startDebugID--210while temp0 < 2211SetTableValue(TypeName[Electric Orb], DebugMode_ObjCount, DebugMode_TypesTable)212SetTableValue(ElectricOrb_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)213SetTableValue(ElectricOrb_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)214DebugMode_ObjCount++215temp0++216loop217end event218219220// ========================221// Editor Events222// ========================223224event RSDKEdit225if editor.returnVariable == true226switch editor.variableID227case EDIT_VAR_PROPVAL // property value228checkResult = object.propertyValue229break230231case 0 // direction232checkResult = object.propertyValue233checkResult &= 1234break235236case 1 // interval237checkResult = object.propertyValue238checkResult >>= 1239checkResult &= 3240break241242end switch243else244switch editor.variableID245case EDIT_VAR_PROPVAL // property value246object.propertyValue = editor.variableValue247break248249case 0 // direction250temp0 = editor.variableValue251temp0 &= 1252253object.propertyValue &= 0xFE254object.propertyValue |= temp0255break256257case 1 // interval258temp0 = editor.variableValue259temp0 &= 3260261object.propertyValue &= 0xF1262object.propertyValue |= temp0263break264265end switch266end if267end event268269270event RSDKDraw271GetBit(object.direction, object.propertyValue, 0)272object.direction <<= 1273DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)274end event275276277event RSDKLoad278LoadSpriteSheet("SBZ/Objects.gif")279SpriteFrame(-8, -8, 16, 32, 58, 479)280281AddEditorVariable("direction")282SetActiveVariable("direction")283AddEnumVariable("Up", 0)284AddEnumVariable("Down", 1)285286AddEditorVariable("interval")287SetActiveVariable("interval")288AddEnumVariable("Every 24 Frames", 0)289AddEnumVariable("Every 12 Frames", 1)290AddEnumVariable("Every 6 Frames", 2)291end event292293294