Path: blob/master/Sonic 2/Scripts/MPZ/WallBumper.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Wall Bumper Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.hitboxT12private alias object.value1 : object.hitboxB1314// Player aliases15private alias object.type : player.type16private alias object.xvel : player.xvel17private alias object.yvel : player.yvel18private alias object.direction : player.direction19private alias object.state : player.state20private alias object.tileCollisions : player.tileCollisions21private alias object.gravity : player.gravity22private alias object.speed : player.speed23private alias object.collisionMode : player.collisionMode24private alias object.pushing : player.pushing25private alias object.controlLock : player.controlLock26private alias object.animation : player.animation27private alias object.prevAnimation : player.prevAnimation28private alias object.animationSpeed : player.animationSpeed29private alias object.frame : player.frame30private alias object.value1 : player.timer31private alias object.value25 : player.gravityStrength323334// ========================35// Events36// ========================3738event ObjectUpdate39foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)40// Check if the player's on the ground or in the air41CheckEqual(player[currentPlayer].gravity, 0)42temp0 = checkResult43CheckNotEqual(player[currentPlayer].collisionMode, 0)44temp0 &= checkResult4546if temp0 == false47BoxCollisionTest(C_TOUCH, object.entityPos, -10, object.hitboxT, 10, object.hitboxB, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)48else49BoxCollisionTest(C_TOUCH, object.entityPos, -20, object.hitboxT, 20, object.hitboxB, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)50end if5152if checkResult == true53if object.direction == FLIP_NONE54player[currentPlayer].xvel = 0x8000055else56player[currentPlayer].xvel = -0x8000057end if5859player[currentPlayer].yvel = -0x8000060player[currentPlayer].yvel -= player[currentPlayer].gravityStrength61player[currentPlayer].direction = object.direction62#platform: USE_STANDALONE63player[currentPlayer].state = Player_State_Air64#endplatform65#platform: USE_ORIGINS66player[currentPlayer].state = Player_State_Air_NoDropDash67#endplatform68player[currentPlayer].tileCollisions = true69player[currentPlayer].gravity = 170player[currentPlayer].speed = player[currentPlayer].xvel71player[currentPlayer].timer = 172player[currentPlayer].collisionMode = 073player[currentPlayer].pushing = 074player[currentPlayer].controlLock = 1575player[currentPlayer].animation = ANI_TWIRL76player[currentPlayer].prevAnimation = ANI_TWIRL77player[currentPlayer].frame = 078player[currentPlayer].animationSpeed = 907980PlaySfx(SfxName[Spring], false)81end if82next83end event848586event ObjectDraw87if player[0].type == TypeName[Debug Mode]88temp1 = object.propertyValue89temp1 &= 0x7090if temp1 == 091temp0 = -0x40000092temp1 = 893else94temp0 = -0x80000095temp1 = 1696end if9798temp0 += object.ypos99temp0 += 0x80000100temp4 = 0101while temp4 < temp1102DrawSpriteXY(0, object.xpos, temp0)103temp0 += 0x100000104temp4++105loop106end if107end event108109110event ObjectStartup111LoadSpriteSheet("Global/Display.gif")112SpriteFrame(-8, -8, 16, 16, 93, 113) // #0 - Blank control circle113114foreach (TypeName[Wall Bumper], arrayPos0, ALL_ENTITIES)115temp0 = object[arrayPos0].propertyValue116temp0 &= 0x70117if temp0 == 0118object[arrayPos0].hitboxT = 64119else120object[arrayPos0].hitboxT = 128121end if122object[arrayPos0].hitboxB = object[arrayPos0].hitboxT123FlipSign(object[arrayPos0].hitboxT)124object[arrayPos0].drawOrder = 5125next126end event127128129// ========================130// Editor Events131// ========================132133event RSDKEdit134if editor.returnVariable == true135switch editor.variableID136case EDIT_VAR_PROPVAL // property value137checkResult = object.propertyValue138break139140case 0 // type141checkResult = object.propertyValue142checkResult &= 0x70143checkResult >>= 4144break145146end switch147else148switch editor.variableID149case EDIT_VAR_PROPVAL // property value150object.propertyValue = editor.variableValue151break152153case 0 // type154editor.variableValue &= 7155editor.variableValue <<= 4156157temp0 = 0x70158Not(temp0)159object.propertyValue &= temp0160161object.propertyValue |= editor.variableValue162break163164end switch165end if166end event167168169event RSDKDraw170temp1 = object.propertyValue171temp1 &= 0x70172if temp1 == 0173temp0 = -0x400000174temp1 = 8175else176temp0 = -0x800000177temp1 = 16178end if179180temp0 += object.ypos181temp0 += 0x80000182temp4 = 0183while temp4 < temp1184DrawSpriteXY(0, object.xpos, temp0)185temp0 += 0x100000186temp4++187loop188// TODO: Draw a rectangle of the object's hitbox189end event190191192event RSDKLoad193LoadSpriteSheet("Global/Display.gif")194SpriteFrame(-8, -8, 16, 16, 93, 113) // #0 - Blank control circle195196// First bit is unused197198AddEditorVariable("type")199SetActiveVariable("type")200AddEnumVariable("4 Bumpers", 0)201AddEnumVariable("8 Bumpers", 1)202203// Direction is set via the attribute204end event205206207