Path: blob/master/Sonic 1/Scripts/Special/GemBlock.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Gem Block Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.propertyValue : object.color1213private alias object.value0 : object.timer14private alias object.value1 : object.storedColor1516private alias 0 : BLOCK_GEM_IDLE17private alias 1 : BLOCK_GEM_ACTIVATED1819// Player aliases20private alias object.value10 : debugMode.currentSelection212223// ========================24// Function Declarations25// ========================2627reserve function GemBlock_DebugDraw28reserve function GemBlock_DebugSpawn293031// ========================32// Static Values33// ========================3435private value GemBlock_startDebugID = 0363738// ========================39// Function Definitions40// ========================4142private function GemBlock_DebugDraw43temp4 = debugMode[0].currentSelection44temp4 -= GemBlock_startDebugID45DrawSprite(temp4)46end function474849private function GemBlock_DebugSpawn50temp4 = debugMode[0].currentSelection51temp4 -= GemBlock_startDebugID52temp5 = TypeName[Gem Block]53CallFunction(DebugMode_PlaceBlock)54object[arrayPos0].drawOrder = 455object[arrayPos0].groupID = GROUP_BLOCKS56end function575859// ========================60// Events61// ========================6263event ObjectUpdate64if object.state == BLOCK_GEM_ACTIVATED65object.color = object.timer66object.color >>= 167object.color &= 368object.timer++69if object.timer == 1670object.priority = PRIORITY_BOUNDS71object.timer = 072object.color = object.storedColor73object.color++74if object.color == 475object.type = TypeName[Blank Object]76else77object.state = BLOCK_GEM_IDLE78end if7980SpecialSetup_gemBlockBusy = false81end if8283foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)84CallFunction(SpecialSetup_PlayerBlockCol)85next86else87foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)88CallFunction(SpecialSetup_PlayerBlockCol)89if SpecialSetup_gemBlockBusy == false90if checkResult > 091object.state = BLOCK_GEM_ACTIVATED92object.priority = PRIORITY_ACTIVE93SpecialSetup_gemBlockBusy = true94object.storedColor = object.color95if Player_isWinner == false96PlaySfx(SfxName[Gem Block], false)97end if98end if99end if100next101end if102end event103104105event ObjectDraw106CallFunction(SpecialSetup_GetBlockPos)107temp2 = SpecialSetup_gemBlockTimer108temp2 /= 5109switch temp2110case 0111object.direction = FLIP_NONE112break113114case 1115object.direction = FLIP_X116break117118case 2119object.direction = FLIP_XY120break121122case 3123object.direction = FLIP_Y124break125126end switch127128DrawSpriteFX(object.propertyValue, FX_FLIP, temp0, temp1)129end event130131132event ObjectStartup133LoadSpriteSheet("Special/Objects.gif")134135// Gem frames136SpriteFrame(-12, -12, 24, 24, 301, 76)137SpriteFrame(-12, -12, 24, 24, 326, 76)138SpriteFrame(-12, -12, 24, 24, 351, 76)139SpriteFrame(-12, -12, 24, 24, 376, 76)140141foreach (TypeName[Gem Block], arrayPos0, ALL_ENTITIES)142object[arrayPos0].groupID = GROUP_BLOCKS143next144145// Add this to the debug object list four times for the four types of gems146temp0 = 0147GemBlock_startDebugID = DebugMode_ObjCount148while temp0 < 4149SetTableValue(TypeName[Gem Block], DebugMode_ObjCount, DebugMode_TypeTable)150SetTableValue(GemBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)151SetTableValue(GemBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)152DebugMode_ObjCount++153temp0++154loop155end event156157158// ========================159// Editor Events160// ========================161162event RSDKEdit163if editor.returnVariable == true164switch editor.variableID165case EDIT_VAR_PROPVAL // property value166checkResult = object.propertyValue167checkResult &= 3168break169170case 0 // color171checkResult = object.propertyValue172checkResult &= 3173break174175end switch176else177switch editor.variableID178case EDIT_VAR_PROPVAL // property value179object.propertyValue = editor.variableValue180object.propertyValue &= 3181break182183case 0 // color184object.propertyValue = temp0185object.propertyValue &= 3186break187188end switch189end if190end event191192193event RSDKDraw194DrawSprite(object.propertyValue)195end event196197198event RSDKLoad199LoadSpriteSheet("Special/Objects.gif")200SpriteFrame(-12, -12, 24, 24, 301, 76)201SpriteFrame(-12, -12, 24, 24, 326, 76)202SpriteFrame(-12, -12, 24, 24, 351, 76)203SpriteFrame(-12, -12, 24, 24, 376, 76)204205AddEditorVariable("color")206SetActiveVariable("color")207AddEnumVariable("Blue", 0)208AddEnumVariable("Green", 1)209AddEnumVariable("Yellow", 2)210AddEnumVariable("Pink", 3)211end event212213214