Path: blob/master/Sonic 2/Scripts/Global/InvisibleBlock.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Invisible Block Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.width12private alias object.value1 : object.height13private alias object.value2 : object.killTimerP114private alias object.value3 : object.killTimerP21516private alias 0 : INVISIBLEBLOCK_SOLID // regular invis block17private alias 1 : INVISIBLEBLOCK_EJECT_L // ejects the player out (to the left)18private alias 2 : INVISIBLEBLOCK_EJECT_R // ejects the player out (to the right)1920// Player Aliases21private alias object.type : player.type22private alias object.state : player.state23private alias object.xpos : player.xpos24private alias object.speed : player.speed25private alias object.gravity : player.gravity26private alias object.collisionLeft : player.collisionLeft27private alias object.collisionRight : player.collisionRight282930// ========================31// Function Declarations32// ========================3334reserve function InvisibleBlock_DebugDraw35reserve function InvisibleBlock_DebugSpawn363738// ========================39// Static Values40// ========================4142// MPZ shortens this, to kill the player fast43private value InvisibleBlock_killDelay = 8444546// ========================47// Function Definitions48// ========================4950private function InvisibleBlock_DebugDraw51temp0 = object.xpos52temp1 = object.ypos53temp0 -= 0x8000054temp1 -= 0x8000055DrawSpriteXY(0, temp0, temp1)5657temp0 += 0x10000058DrawSpriteXY(0, temp0, temp1)5960temp0 -= 0x10000061temp1 += 0x10000062DrawSpriteXY(0, temp0, temp1)6364temp0 += 0x10000065DrawSpriteXY(0, temp0, temp1)66end function676869private function InvisibleBlock_DebugSpawn70CreateTempObject(TypeName[Invisible Block], 17, object.xpos, object.ypos)71object[tempObjectPos].drawOrder = 572object[tempObjectPos].width = 1673object[tempObjectPos].height = 1674end function757677// ========================78// Events79// ========================8081event ObjectUpdate82temp0 = object.width83FlipSign(temp0)84temp1 = object.height85FlipSign(temp1)8687// Note: state is editable and is set via the editor8889switch object.state90case INVISIBLEBLOCK_SOLID91foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)92if player[currentPlayer].state != Player_State_LedgePullUp93BoxCollisionTest(C_SOLID, object.entityPos, temp0, temp1, object.width, object.height, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)94switch checkResult95case COL_NONE96temp0 += 297temp1 += 298temp2 = object.width99temp3 = object.height100temp2 -= 2101temp3 -= 2102BoxCollisionTest(C_TOUCH, object.entityPos, temp0, temp1, temp2, temp3, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)103if checkResult == true104player[currentPlayer].gravity = GRAVITY_GROUND105end if106107if currentPlayer == 0108object.killTimerP1 = 0109else110object.killTimerP2 = 0111end if112break113114case COL_BOTTOM115if player[currentPlayer].gravity == GRAVITY_GROUND116if currentPlayer == 0117object.killTimerP1++118if object.killTimerP1 > InvisibleBlock_killDelay119CallFunction(Player_Kill)120end if121else122object.killTimerP2++123if object.killTimerP2 > InvisibleBlock_killDelay124CallFunction(Player_Kill)125end if126end if127end if128break129end switch130end if131next132break133134case INVISIBLEBLOCK_EJECT_L135foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)136if player[currentPlayer].state != Player_State_LedgePullUp137BoxCollisionTest(C_TOUCH, object.entityPos, temp0, temp1, object.width, object.height, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)138if checkResult == true139if player[currentPlayer].gravity == GRAVITY_GROUND140player[currentPlayer].xpos = player[currentPlayer].collisionRight141FlipSign(player[currentPlayer].xpos)142player[currentPlayer].xpos -= object.width143player[currentPlayer].xpos <<= 16144player[currentPlayer].xpos += object.xpos145if player[currentPlayer].speed > 0146player[currentPlayer].speed = 0147end if148end if149end if150end if151next152break153154case INVISIBLEBLOCK_EJECT_R155foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)156if player[currentPlayer].state != Player_State_LedgePullUp157BoxCollisionTest(C_TOUCH, object.entityPos, temp0, temp1, object.width, object.height, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)158if checkResult == true159if player[currentPlayer].gravity == GRAVITY_GROUND160player[currentPlayer].xpos = player[currentPlayer].collisionLeft161FlipSign(player[currentPlayer].xpos)162player[currentPlayer].xpos += object.width163player[currentPlayer].xpos <<= 16164player[currentPlayer].xpos += object.xpos165if player[currentPlayer].speed < 0166player[currentPlayer].speed = 0167end if168end if169end if170end if171next172break173174end switch175end event176177178event ObjectDraw179if player[0].type == TypeName[Debug Mode]180temp0 = object.xpos181temp1 = object.ypos182temp2 = object.propertyValue183temp4 = temp2184temp4 &= 240185temp4 <<= 15186temp2 >>= 4187temp2++188temp6 = temp2189temp3 = object.propertyValue190temp3 &= 15191temp5 = temp3192temp5 <<= 19193temp3++194temp0 -= temp4195temp4 = temp0196temp1 -= temp5197while temp3 > 0198while temp2 > 0199DrawSpriteXY(object.state, temp0, temp1)200temp0 += 0x100000201temp2--202loop203temp2 = temp6204temp0 = temp4205temp1 += 0x100000206temp3--207loop208end if209end event210211212event ObjectStartup213LoadSpriteSheet("Global/Display.gif")214SpriteFrame(-8, -7, 16, 14, 1, 176)215SpriteFrame(-8, -7, 16, 14, 17, 176)216SpriteFrame(-8, -7, 16, 14, 1, 190)217218foreach (TypeName[Invisible Block], arrayPos0, ALL_ENTITIES)219object[arrayPos0].drawOrder = 5220object[arrayPos0].width = object[arrayPos0].propertyValue221object[arrayPos0].width &= 0xF0222object[arrayPos0].width += 16223object[arrayPos0].width >>= 1224object[arrayPos0].height = object[arrayPos0].propertyValue225object[arrayPos0].height &= 15226object[arrayPos0].height++227object[arrayPos0].height <<= 3228next229230CheckCurrentStageFolder("Zone09")231if checkResult == true232InvisibleBlock_killDelay = 1233end if234235SetTableValue(TypeName[Invisible Block], DebugMode_ObjCount, DebugMode_TypesTable)236SetTableValue(InvisibleBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)237SetTableValue(InvisibleBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)238DebugMode_ObjCount++239end event240241242// ========================243// Editor Events244// ========================245246event RSDKEdit247if editor.returnVariable == true248switch editor.variableID249case EDIT_VAR_PROPVAL // property value250checkResult = object.propertyValue251break252253case 0 // width254checkResult = object.propertyValue255checkResult >>= 4256checkResult &= 0xF257break258259case 1 // height260checkResult = object.propertyValue261checkResult &= 0xF262break263264case 2 // type265checkResult = object.state266break267268end switch269else270switch editor.variableID271case EDIT_VAR_PROPVAL // property value272object.propertyValue = editor.variableValue273break274275case 0 // width276temp0 = editor.variableValue277temp0 &= 0xF278temp0 <<= 4279280object.propertyValue &= 0x0F281object.propertyValue |= temp0282break283284case 1 // height285temp0 = editor.variableValue286temp0 &= 0xF287288object.propertyValue &= 0xF0289object.propertyValue |= temp0290break291292case 2 // type293object.state = editor.variableValue294break295296end switch297end if298end event299300301event RSDKDraw302temp0 = object.xpos303temp1 = object.ypos304temp2 = object.propertyValue305306temp4 = temp2307temp4 &= 0xF0308temp4 <<= 15309temp2 >>= 4310temp2++311temp6 = temp2312313temp3 = object.propertyValue314temp3 &= 0x0F315temp5 = temp3316temp5 <<= 19317temp3++318319temp0 -= temp4320temp4 = temp0321temp1 -= temp5322while temp3 > 0323while temp2 > 0324DrawSpriteXY(object.state, temp0, temp1)325temp0 += 0x100000326temp2--327loop328temp2 = temp6329temp0 = temp4330temp1 += 0x100000331temp3--332loop333end event334335336event RSDKLoad337LoadSpriteSheet("Global/Display.gif")338SpriteFrame(-8, -7, 16, 14, 1, 176)339SpriteFrame(-8, -7, 16, 14, 17, 176)340SpriteFrame(-8, -7, 16, 14, 1, 190)341342AddEditorVariable("width")343AddEditorVariable("height")344345AddEditorVariable("type")346SetActiveVariable("type")347AddEnumVariable("Solid", INVISIBLEBLOCK_SOLID)348AddEnumVariable("Eject left", INVISIBLEBLOCK_EJECT_L)349AddEnumVariable("Eject right", INVISIBLEBLOCK_EJECT_R)350end event351352353