Path: blob/master/Sonic 2/Scripts/CNZ/TriBumper.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Tri Bumper Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011// Types12private alias 0 : TRIBUMPER_SMALL_L13private alias 1 : TRIBUMPER_SMALL_R14private alias 2 : TRIBUMPER_LARGE_U15private alias 3 : TRIBUMPER_LARGE_D16private alias 4 : TRIBUMPER_LARGE_L17private alias 5 : TRIBUMPER_LARGE_R1819// Player Aliases20private alias object.state : player.state21private alias object.xpos : player.xpos22private alias object.ypos : player.ypos23private alias object.xvel : player.xvel24private alias object.yvel : player.yvel25private alias object.speed : player.speed26private alias object.gravity : player.gravity27private alias object.animation : player.animation28private alias object.tileCollisions : player.tileCollisions2930private alias object.value1 : player.timer31private alias object.value36 : player.flyCarryTimer // Tails assist lockout timer323334// ========================35// Function Declarations36// ========================3738reserve function TriBumper_SetPlayerVelocity39reserve function TriBumper_HandleBump404142// ========================43// Function Definitions44// ========================4546private function TriBumper_SetPlayerVelocity47ATan2(temp0, player[currentPlayer].xvel, player[currentPlayer].yvel)48temp0 -= temp349temp1 = temp050Abs(temp1)51FlipSign(temp0)52temp0 += 25653temp0 += temp354temp0 &= 25555if temp1 >= 5656temp0 = temp357end if58Cos256(player[currentPlayer].xvel, temp0)59player[currentPlayer].xvel *= -0xA0060Sin256(player[currentPlayer].yvel, temp0)61player[currentPlayer].yvel *= -0xA0062end function636465private function TriBumper_HandleBump66if player[currentPlayer].state == Player_State_Carried67player[1].flyCarryTimer = 3068end if6970CheckEqual(player[currentPlayer].animation, ANI_GLIDING)71temp2 = checkResult72CheckEqual(player[currentPlayer].animation, ANI_GLIDING_STOP)73temp2 |= checkResult74CheckEqual(player[currentPlayer].animation, ANI_FLYING)75temp2 |= checkResult76CheckEqual(player[currentPlayer].state, Player_State_TubeRoll)77temp2 |= checkResult78CheckEqual(player[currentPlayer].state, Player_State_TubeAirRoll)79temp2 |= checkResult80if player[currentPlayer].animation != ANI_GLIDING81player[currentPlayer].speed = player[currentPlayer].xvel82player[currentPlayer].timer = 083end if8485if temp2 == false86#platform: USE_STANDALONE87player[currentPlayer].state = Player_State_Air88#endplatform89#platform: USE_ORIGINS90player[currentPlayer].state = Player_State_Air_NoDropDash91#endplatform92// Bug Details:93// This code wasn't updated in Origins Plus to include ANI_HAMMER_JUMP, so94// Amy will always start walking if she hits a Bumper with her hammer out95if player[currentPlayer].animation != ANI_JUMPING96if player[currentPlayer].animation != ANI_RUNNING97player[currentPlayer].animation = ANI_WALKING98end if99end if100end if101player[currentPlayer].gravity = GRAVITY_AIR102player[currentPlayer].tileCollisions = true103PlaySfx(SfxName[CNZ Bumper], false)104end function105106107// ========================108// Events109// ========================110111event ObjectUpdate112switch object.propertyValue113case TRIBUMPER_SMALL_L114foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)115BoxCollisionTest(C_TOUCH, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)116if checkResult == true117temp0 = object.ypos118temp0 -= player[currentPlayer].ypos119FlipSign(temp0)120if temp0 >= 0x200000121player[currentPlayer].yvel = 0xA0000122CallFunction(TriBumper_HandleBump)123else124temp0 = object.xpos125temp0 -= player[currentPlayer].xpos126FlipSign(temp0)127if temp0 >= 0x200000128player[currentPlayer].xvel = 0xA0000129CallFunction(TriBumper_HandleBump)130else131temp0 = object.xpos132temp0 -= player[currentPlayer].xpos133if temp0 >= 0x200000134temp0 = 0x200000135end if136temp0 += object.ypos137temp0 -= 0x80000138temp1 = player[currentPlayer].ypos139temp1 += 0xE0000140temp0 -= temp1141if temp0 < 0142temp3 = 32143CallFunction(TriBumper_SetPlayerVelocity)144CallFunction(TriBumper_HandleBump)145end if146end if147end if148end if149next150break151152case TRIBUMPER_SMALL_R153foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)154BoxCollisionTest(C_TOUCH, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)155if checkResult == true156temp0 = object.ypos157temp0 -= player[currentPlayer].ypos158FlipSign(temp0)159if temp0 >= 0x200000160player[currentPlayer].yvel = 0xA0000161CallFunction(TriBumper_HandleBump)162else163temp0 = object.xpos164temp0 -= player[currentPlayer].xpos165if temp0 >= 0x200000166player[currentPlayer].xvel = -0xA0000167CallFunction(TriBumper_HandleBump)168else169temp0 = object.xpos170temp0 -= player[currentPlayer].xpos171FlipSign(temp0)172if temp0 >= 0x200000173temp0 = 0x200000174end if175temp0 += object.ypos176temp0 -= 0x80000177temp1 = player[currentPlayer].ypos178temp1 += 0xE0000179temp0 -= temp1180if temp0 < 0181temp3 = 96182CallFunction(TriBumper_SetPlayerVelocity)183CallFunction(TriBumper_HandleBump)184end if185end if186end if187end if188next189break190191case TRIBUMPER_LARGE_U192foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)193BoxCollisionTest(C_TOUCH, object.entityPos, -64, -8, 64, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)194if checkResult == true195temp0 = object.ypos196temp0 -= player[currentPlayer].ypos197FlipSign(temp0)198if temp0 >= 0x80000199player[currentPlayer].yvel = 0xA00200CallFunction(TriBumper_HandleBump)201else202temp0 = object.xpos203temp0 -= player[currentPlayer].xpos204if temp0 >= 0x400000205player[currentPlayer].xvel = -0xA0000206CallFunction(TriBumper_HandleBump)207else208FlipSign(temp0)209if temp0 >= 0x400000210player[currentPlayer].xvel = 0xA0000211CallFunction(TriBumper_HandleBump)212else213if temp0 < 0214temp3 = 56215else216temp3 = 72217end if218CallFunction(TriBumper_SetPlayerVelocity)219CallFunction(TriBumper_HandleBump)220end if221end if222end if223end if224next225break226227case TRIBUMPER_LARGE_D228foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)229BoxCollisionTest(C_TOUCH, object.entityPos, -64, -8, 64, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)230if checkResult == true231temp0 = object.ypos232temp0 -= player[currentPlayer].ypos233if temp0 >= 0x80000234player[currentPlayer].yvel = -0xA0000235CallFunction(TriBumper_HandleBump)236else237temp0 = object.xpos238temp0 -= player[currentPlayer].xpos239if temp0 >= 0x400000240player[currentPlayer].xvel = -0xA0000241CallFunction(TriBumper_HandleBump)242else243FlipSign(temp0)244if temp0 >= 0x400000245player[currentPlayer].xvel = 0xA0000246CallFunction(TriBumper_HandleBump)247else248if temp0 < 0249temp3 = 200250else251temp3 = 184252end if253CallFunction(TriBumper_SetPlayerVelocity)254CallFunction(TriBumper_HandleBump)255end if256end if257end if258end if259next260break261262case TRIBUMPER_LARGE_L263foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)264BoxCollisionTest(C_TOUCH, object.entityPos, -8, -64, 8, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)265if checkResult == true266temp0 = object.xpos267temp0 -= player[currentPlayer].xpos268FlipSign(temp0)269if temp0 >= 0x80000270player[currentPlayer].xvel = 0xA0000271CallFunction(TriBumper_HandleBump)272else273temp0 = object.ypos274temp0 -= player[currentPlayer].ypos275if temp0 >= 0x400000276player[currentPlayer].yvel = -0xA0000277CallFunction(TriBumper_HandleBump)278else279FlipSign(temp0)280if temp0 >= 0x400000281player[currentPlayer].yvel = 0xA0000282CallFunction(TriBumper_HandleBump)283else284if temp0 < 0285temp3 = 8286else287temp3 = 248288end if289CallFunction(TriBumper_SetPlayerVelocity)290CallFunction(TriBumper_HandleBump)291end if292end if293end if294end if295next296break297298case TRIBUMPER_LARGE_R299foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)300BoxCollisionTest(C_TOUCH, object.entityPos, -8, -64, 8, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)301if checkResult == true302temp0 = object.xpos303temp0 -= player[currentPlayer].xpos304if temp0 >= 0x80000305player[currentPlayer].xvel = 0xA0000306CallFunction(TriBumper_HandleBump)307else308temp0 = object.ypos309temp0 -= player[currentPlayer].ypos310if temp0 >= 0x400000311player[currentPlayer].yvel = -0xA0000312CallFunction(TriBumper_HandleBump)313else314FlipSign(temp0)315if temp0 >= 0x400000316player[currentPlayer].yvel = 0xA0000317CallFunction(TriBumper_HandleBump)318else319if temp0 < 0320temp3 = 120321else322temp3 = 136323end if324CallFunction(TriBumper_SetPlayerVelocity)325CallFunction(TriBumper_HandleBump)326end if327end if328end if329end if330next331break332333end switch334end event335336337// ========================338// Editor Events339// ========================340341event RSDKEdit342if editor.returnVariable == true343switch editor.variableID344case EDIT_VAR_PROPVAL // property value345checkResult = object.propertyValue346break347348case 0 // type349checkResult = object.propertyValue350checkResult %= 6351break352353end switch354else355switch editor.variableID356case EDIT_VAR_PROPVAL // property value357object.propertyValue = editor.variableValue358break359360case 0 // type361editor.variableValue %= 6362object.propertyValue = editor.variableValue363break364365end switch366end if367end event368369370event RSDKDraw371DrawSprite(0)372end event373374375event RSDKLoad376LoadSpriteSheet("Global/Display.gif")377SpriteFrame(-16, -16, 32, 32, 1, 143)378379AddEditorVariable("type")380SetActiveVariable("type")381AddEnumVariable("Small (Facing Left)", TRIBUMPER_SMALL_L)382AddEnumVariable("Small (Facing Right)", TRIBUMPER_SMALL_R)383AddEnumVariable("Large (Facing Up)", TRIBUMPER_LARGE_U)384AddEnumVariable("Large (Facing Down)", TRIBUMPER_LARGE_D)385AddEnumVariable("Large (Facing Left)", TRIBUMPER_LARGE_L)386AddEnumVariable("Large (Facing Right)", TRIBUMPER_LARGE_R)387end event388389390