Path: blob/master/Sonic 1/Scripts/Enemies/Splats.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Splats Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.flipDir12private alias object.value1 : object.startPos.x13private alias object.value2 : object.startPos.y1415private alias object.value17 : debugMode.currentSelection1617// Player aliases18private alias object.value40 : player.hitboxLeft19private alias object.value38 : player.hitboxTop20private alias object.value41 : player.hitboxRight21private alias object.value39 : player.hitboxBottom2223// Path ID Aliases24private alias 0 : PATH_A252627// ========================28// Function Declarations29// ========================3031reserve function Splats_DebugDraw32reserve function Splats_DebugSpawn3334// ========================35// Static Values36// ========================3738private value Splats_startDebugID = 0394041// ========================42// Function Definitions43// ========================4445private function Splats_DebugDraw46temp0 = debugMode[0].currentSelection47temp0 -= Splats_startDebugID48DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)49end function505152private function Splats_DebugSpawn53temp0 = debugMode[0].currentSelection54temp0 -= Splats_startDebugID55temp0 <<= 15657CreateTempObject(TypeName[Splats], temp0, object.xpos, object.ypos)5859object[tempObjectPos].direction = object.direction60object[tempObjectPos].startPos.x = object.xpos61object[tempObjectPos].startPos.y = object.ypos6263if object[tempObjectPos].direction == FLIP_NONE64object[tempObjectPos].xvel = -0x1000065else66object[tempObjectPos].xvel = 0x1000067end if68end function697071// ========================72// Events73// ========================7475event ObjectUpdate76object.priority = PRIORITY_ACTIVE77object.xpos += object.xvel78object.ypos += object.yvel79object.yvel += 0x38008081if object.yvel > 082ObjectTileCollision(CSIDE_FLOOR, 0, 16, PATH_A)83temp0 = checkResult84ObjectTileCollision(CSIDE_FLOOR, 0, 17, PATH_A)85temp0 |= checkResult86ObjectTileCollision(CSIDE_FLOOR, 0, 18, PATH_A)87temp0 |= checkResult88ObjectTileCollision(CSIDE_FLOOR, 0, 19, PATH_A)89temp0 |= checkResult90ObjectTileCollision(CSIDE_FLOOR, 0, 20, PATH_A)91temp0 |= checkResult92if temp0 == true93GetBit(temp0, object.propertyValue, 1)94if temp0 == true95if object.flipDir == true96FlipSign(object.xvel)97object.direction ^= FLIP_X98end if99100object.flipDir ^= true101end if102103object.yvel = -0x40000104end if105end if106107if object.outOfBounds == true108temp0 = object.xpos109temp1 = object.ypos110object.xpos = object.startPos.x111object.ypos = object.startPos.y112113if object.outOfBounds == true114GetBit(temp0, object.propertyValue, 0)115if temp0 == FLIP_NONE116object.direction = FLIP_NONE117object.xvel = -0x10000118else119object.direction = FLIP_X120object.xvel = 0x10000121end if122object.priority = PRIORITY_BOUNDS123object.state = 0124else125object.xpos = temp0126object.ypos = temp1127end if128end if129130foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)131BoxCollisionTest(C_TOUCH, object.entityPos, -10, -20, 6, 20, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)132if checkResult == true133CallFunction(Player_BadnikBreak)134end if135next136end event137138139event ObjectDraw140if object.yvel < 0141DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)142else143DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)144end if145end event146147148event ObjectStartup149CheckCurrentStageFolder("Zone01")150if checkResult == true151LoadSpriteSheet("GHZ/Objects.gif")152SpriteFrame(-11, -15, 21, 40, 214, 211)153SpriteFrame(-11, -19, 21, 40, 192, 211)154end if155156CheckCurrentStageFolder("Zone07")157if checkResult == true158LoadSpriteSheet("MBZ/Objects.gif")159SpriteFrame(-11, -15, 21, 40, 220, 254)160SpriteFrame(-11, -19, 21, 40, 198, 254)161end if162163foreach (TypeName[Splats], arrayPos0, ALL_ENTITIES)164object[arrayPos0].startPos.x = object[arrayPos0].xpos165object[arrayPos0].startPos.y = object[arrayPos0].ypos166167GetBit(temp0, object[arrayPos0].propertyValue, 0)168if temp0 == false169object[arrayPos0].direction = FLIP_NONE170object[arrayPos0].xvel = -0x10000171else172object[arrayPos0].direction = FLIP_X173object[arrayPos0].xvel = 0x10000174end if175next176177temp0 = 0178Splats_startDebugID = DebugMode_ObjCount179while temp0 < 2180SetTableValue(TypeName[Splats], DebugMode_ObjCount, DebugMode_TypesTable)181SetTableValue(Splats_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)182SetTableValue(Splats_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)183DebugMode_ObjCount++184temp0++185loop186end event187188189// ========================190// Editor Events191// ========================192193event RSDKEdit194if editor.returnVariable == true195switch editor.variableID196case EDIT_VAR_PROPVAL // property value197checkResult = object.propertyValue198checkResult &= 3199break200201case 0 // direction202GetBit(checkResult, object.propertyValue, 0)203break204205case 1 // behaviour206GetBit(checkResult, object.propertyValue, 1)207break208209end switch210else211switch editor.variableID212case EDIT_VAR_PROPVAL // property value213object.propertyValue = editor.variableValue214break215216case 0 // direction217CheckNotEqual(editor.variableValue, false)218SetBit(object.propertyValue, 0, checkResult)219break220221case 1 // behaviour222CheckNotEqual(editor.variableValue, false)223SetBit(object.propertyValue, 1, checkResult)224break225226end switch227end if228end event229230231event RSDKDraw232GetBit(object.direction, object.propertyValue, 0)233DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)234end event235236237event RSDKLoad238CheckCurrentStageFolder("Zone07")239if checkResult == true240LoadSpriteSheet("MBZ/Objects.gif")241SpriteFrame(-11, -15, 21, 40, 220, 254)242else243LoadSpriteSheet("GHZ/Objects.gif")244SpriteFrame(-11, -15, 21, 40, 214, 211)245end if246247AddEditorVariable("direction")248SetActiveVariable("direction")249AddEnumVariable("Left", 0)250AddEnumVariable("Right", 1)251252AddEditorVariable("behaviour")253SetActiveVariable("behaviour")254AddEnumVariable("Never Change Directions", 0)255AddEnumVariable("Change Direction On Each Bounce", 1)256end event257258259