Advertisement
Guest User

SMASH_User.c

a guest
Apr 10th, 2020
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 22.43 KB | None | 0 0
  1. // SRB2FLAME - Unique code for SSB:SS (SMASH)
  2. // Code which is unique/exclusive to its define.
  3. // By Flame
  4.  
  5. #include "../../../doomstat.h"
  6. #include "../../../doomdef.h"
  7.  
  8. #include "../../../g_game.h"
  9. #include "../../../p_local.h"
  10. #include "../../../r_main.h"
  11. #include "../../../z_zone.h"
  12. #include "../../../s_sound.h"
  13.  
  14. #include "../../../r_sky.h"
  15. #include "../../../i_video.h"
  16.  
  17. #include "../../FL_Common.h"
  18. #include "SMASH_User.h"
  19.  
  20. #if defined(SMASH)
  21.  
  22. //
  23. // P_SetAllSectorLightLevel
  24. // Fades the light level in EVERY sector to a new value
  25. // param level The final light value in these sectors.
  26. //
  27. static void P_SetAllSectorLightlevel(INT32 level)
  28. {
  29.     size_t k = 0;
  30.     sector_t *sector = &sectors[k];
  31.  
  32.     for (k = 0; k < numsectors; k++, sector++)
  33.     {
  34.         //P_RemoveLighting(sector); // remove the old lighting effect first
  35.         if (sector->ceilingpic == skyflatnum) // Only for the sky.
  36.         {
  37.             if (rendermode == render_soft)
  38.                 sectors[k].lightlevel = level;
  39.             else
  40.                 sectors[k].lightlevel = level - 30;
  41.         }
  42.         else // Everything else is a little darker
  43.         {
  44.             if (rendermode == render_soft)
  45.                 sectors[k].lightlevel = level - 40;
  46.             else // extremly darker in OpenGL.
  47.                 sectors[k].lightlevel = level - 60;
  48.         }
  49.     }
  50. }
  51.  
  52. //
  53. // P_LookForPlayersH
  54. // Looks for a player to hit, if true we go after the player - Used in P_PlayerSpecialAtk
  55. //
  56. static boolean P_LookForPlayersH(player_t *player)
  57. {
  58.     mobj_t *mo;
  59.     thinker_t *think;
  60.     mobj_t *closestmo = NULL;
  61.  
  62.     for (think = thinkercap.next; think != &thinkercap; think = think->next)
  63.     {
  64.         if (think->function.acp1 != (actionf_p1)P_MobjThinker)
  65.             continue; // not a mobj thinker
  66.  
  67.         mo = (mobj_t *)think;
  68.  
  69.         if (mo->type != MT_PLAYER)
  70.             continue;
  71.  
  72.         if (mo == player->mo)
  73.             continue;
  74.  
  75.         if (!mo->player)
  76.             continue;
  77.  
  78.         if (mo->health <= 0) // dead
  79.             continue;
  80.  
  81.         if (mo->player->powers[pw_super]
  82.         || mo->player->powers[pw_flashing]
  83.         || mo->player->powers[pw_invulnerability]
  84.         || (cv_matchtype.value == 1 && mo->player->skincolor == player->skincolor)
  85.         || (cv_matchtype.value == 2 && mo->player->skin == player->skin))
  86.             continue;
  87.  
  88.         if (mo->y != player->mo->y)
  89.             continue;
  90.  
  91.         //if (mo->z > player->mo->z+MAXSTEPMOVE)
  92.         //  continue; // Don't home upwards!
  93.  
  94.         if (P_AproxDistance(P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y),
  95.             player->mo->z-mo->z) > RING_DIST)
  96.             continue; // out of range
  97.  
  98.         if (closestmo && P_AproxDistance(P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y),
  99.             player->mo->z-mo->z) > P_AproxDistance(P_AproxDistance(player->mo->x-closestmo->x,
  100.             player->mo->y-closestmo->y), player->mo->z-closestmo->z))
  101.             continue;
  102.  
  103.         if (!P_CheckSight(player->mo, mo))
  104.             continue; // out of sight
  105.  
  106.         closestmo = mo;
  107.     }
  108.  
  109.     if (closestmo)
  110.     {
  111.         // Found a target monster
  112.         P_SetTarget(&player->mo->tracer, closestmo);
  113.         player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, player->mo->tracer->x, player->mo->tracer->y);
  114.         return true;
  115.     }
  116.  
  117.     return false;
  118. }
  119.  
  120. #ifdef SMASHCAM
  121. #define CAMERA_MAXMOVE (numplayers == 1 ? 20*FRACUNIT : (players[displayplayer].powers[pw_flashing] || players[displayplayer].powers[pw_super] ? 30*FRACUNIT : (players[secondarydisplayplayer].powers[pw_flashing] || players[secondarydisplayplayer].powers[pw_super]) && twodlevel ? 30*FRACUNIT : 18*FRACUNIT))
  122. fixed_t P_SSBSSCamera(camera_t *thiscam) // Dynamic 2D camera.
  123. {
  124.     // Oh boy, lets set up what we will need..
  125.     size_t i, numplayers = 0;
  126.     fixed_t numpeeps = FRACUNIT, current = 0;
  127.     fixed_t centerX = 0, farthestplayerX = 0;
  128.     fixed_t centerZ = 0, farthestplayerZ = 0;
  129.     fixed_t NewDist;
  130.     mobj_t *cammin = P_GetMobjForType(MT_CAMMIN);
  131.     mobj_t *cammax = P_GetMobjForType(MT_CAMMAX);
  132.  
  133.     // Find the center of all of the players and use that as the focus point.
  134.     // SSNTails 07-21-2006
  135.     for (i = 0; i < MAXPLAYERS; i++) // Calculate central X and central Z
  136.     {
  137.         if (!playeringame[i])
  138.             continue;
  139.  
  140.         if (!players[i].mo)
  141.             continue;
  142.  
  143.         if (!players[i].lives)
  144.             continue;
  145.  
  146.         if (!players[i].health)
  147.             continue;
  148.  
  149.         numplayers++;
  150.  
  151.         // Is the player of Espio using his/her final smash?
  152.         if ((players[i].mo->flameflags & FLF_FINALSMASHUSE)
  153.             && ((players[i].mo->flags2 & MF2_DONTDRAW) == MF2_DONTDRAW)
  154.             && players[i].skin == 5)
  155.             continue; // Ignore them, look for the next player.
  156.  
  157.         centerX = FixedMul(centerX, FixedDiv(numpeeps-FRACUNIT, numpeeps));
  158.         centerX += FixedMul(players[i].mo->x, FixedDiv(FRACUNIT, numpeeps));
  159.  
  160.         centerZ = FixedMul(centerZ, FixedDiv(numpeeps-FRACUNIT, numpeeps));
  161.         centerZ += FixedMul(players[i].mo->z, FixedDiv(FRACUNIT, numpeeps));
  162.  
  163.         numpeeps += FRACUNIT;
  164.     }
  165.  
  166.     // Don't move the camera when all of the players are dead.
  167.     if (numplayers == 0)
  168.         return 0;
  169.  
  170.     // Move the camera's X
  171.     {
  172.         fixed_t dist = centerX-(thiscam->x+thiscam->momx);
  173.  
  174.         if (dist > 0)
  175.         {
  176.             if (dist > CAMERA_MAXMOVE)
  177.                 thiscam->x += CAMERA_MAXMOVE;
  178.             else
  179.                 thiscam->x += dist;
  180.         }
  181.         else if (dist < 0)
  182.         {
  183.             if (dist < -CAMERA_MAXMOVE)
  184.                 thiscam->x += -CAMERA_MAXMOVE;
  185.             else
  186.                 thiscam->x += dist;
  187.         }
  188.  
  189.         if (cammin && thiscam->x < cammin->x)
  190.             thiscam->x = cammin->x;
  191.         else if (cammax && thiscam->x > cammax->x)
  192.             thiscam->x = cammax->x;
  193.     }
  194.  
  195.     // Move the camera's Z
  196.     centerZ += cv_cam_height.value;
  197.     {
  198.         fixed_t dist = centerZ-(thiscam->z+thiscam->momz);
  199.  
  200.         if (dist > 0)
  201.         {
  202.             if (dist > CAMERA_MAXMOVE)
  203.                 thiscam->z += CAMERA_MAXMOVE;
  204.             else
  205.                 thiscam->z += dist;
  206.         }
  207.         else if (dist < 0)
  208.         {
  209.             if (dist < -CAMERA_MAXMOVE)
  210.                 thiscam->z += -CAMERA_MAXMOVE;
  211.             else
  212.                 thiscam->z += dist;
  213.         }
  214.  
  215.         if (cammin && thiscam->z < cammin->z)
  216.         {
  217.             thiscam->z = cammin->z;
  218.         }
  219.         else if (cammax && thiscam->z > cammax->z)
  220.         {
  221.             thiscam->z = cammax->z;
  222.         }
  223.     }
  224.  
  225.     for (i = 0; i < MAXPLAYERS; i++) // Calculate farthest players
  226.     {
  227.         if (!playeringame[i])
  228.             continue;
  229.  
  230.         if (!players[i].mo)
  231.             continue;
  232.  
  233.         if (!players[i].lives)
  234.             continue;
  235.  
  236.         if (!players[i].health)
  237.             continue;
  238.  
  239.         if ((players[i].mo->flameflags & FLF_FINALSMASHUSE)
  240.             && ((players[i].mo->flags2 & MF2_DONTDRAW) == MF2_DONTDRAW)
  241.             && players[i].skin == 5)
  242.             continue;
  243.  
  244.         current = abs(players[i].mo->x-centerX);
  245.  
  246.         if (current > farthestplayerX)
  247.             farthestplayerX = current;
  248.  
  249.         current = abs(players[i].mo->z-centerZ);
  250.  
  251.         if (current > farthestplayerZ)
  252.             farthestplayerZ = current;
  253.     }
  254.  
  255.     // Subtract a little so the player isn't right on the edge of the camera.
  256.     NewDist = -(farthestplayerX + farthestplayerZ + 64*FRACUNIT);
  257.  
  258.     // Move the camera's Y
  259.     {
  260.         fixed_t dist = NewDist-(thiscam->y+thiscam->momy);
  261.  
  262.         if (dist > 0)
  263.         {
  264.             if (dist > CAMERA_MAXMOVE)
  265.                 thiscam->y += CAMERA_MAXMOVE;
  266.             else
  267.                 thiscam->y += dist;
  268.         }
  269.         else if (dist < 0)
  270.         {
  271.             if (dist < -CAMERA_MAXMOVE)
  272.                 thiscam->y += -CAMERA_MAXMOVE;
  273.             else
  274.                 thiscam->y += dist;
  275.         }
  276.  
  277.         // This may seem backward but its not.
  278.         if (cammin && thiscam->y > cammin->y)
  279.         {
  280.             thiscam->y = cammin->y;
  281.         }
  282.         else if (cammax && thiscam->y < cammax->y)
  283.         {
  284.             thiscam->y = cammax->y;
  285.         }
  286.     }
  287.  
  288.     return 0;
  289. }
  290. #undef CAMERA_MAXMOVE
  291. #endif // SMASHCAM
  292.  
  293. //
  294. // P_SmashEtc
  295. //
  296. // Handles lighting and darkening, for when the player has powers[pw_finalsmash]
  297. // And some player->shielding stuff.
  298. //
  299. void P_SmashEtc(player_t *player, ticcmd_t *cmd)
  300. {
  301.     mobj_t *mo;
  302.     mo = player->mo;
  303.  
  304.     if (mo->fuse)
  305.         mo->fuse--;
  306.  
  307.     ////////////////////////////
  308.     // Lighting and darkening //
  309.     ////////////////////////////
  310.     if (player->powers[pw_finalsmash] || player->powers[pw_super])
  311.     {
  312.         if (player->powers[pw_finalsmash])
  313.         {
  314.             if (player->powers[pw_sectorlight] > 170)
  315.                 player->powers[pw_sectorlight] -= 4; // Smooth fade to dark.
  316.             else if (!player->powers[pw_sectorlight])
  317.                 player->powers[pw_sectorlight] = 255;
  318.         }
  319.         else if (player->powers[pw_super])
  320.         {
  321.             if (player->powers[pw_sectorlight] < 255)
  322.                 player->powers[pw_sectorlight] += 4; // Smooth fade to light.
  323.         }
  324.  
  325.         P_SetAllSectorLightlevel(player->powers[pw_sectorlight]);
  326.     }
  327.     else if (!(player->powers[pw_finalsmash] || player->powers[pw_super]) && player->powers[pw_sectorlight] != 0)
  328.     {
  329.         if (player->powers[pw_sectorlight] < 255)
  330.             player->powers[pw_sectorlight] += 4;
  331.  
  332.         P_SetAllSectorLightlevel(player->powers[pw_sectorlight]);
  333.     }
  334.  
  335.     //////////////////
  336.     // Shield stuff //
  337.     //////////////////
  338.     if (!player->exiting && !(mo->state == &states[mo->info->painstate]
  339.         || player->powers[pw_flashing] || player->powers[pw_super])
  340.         && !(mo->reactiontime || player->pflags & PF_STASIS || player->powers[pw_nocontrol]))
  341.     {
  342.         if ((cmd->buttons & BT_SHIELD) && player->speed < 10 && !mo->momz && P_IsObjectOnGround(mo) && !player->shielding)
  343.         {
  344.             P_ResetScore(player);
  345.             // P_SetPlayerMobjState(mo, S_PLAY_GUARD);
  346.             P_SetPlayerMobjState(mo, S_PLAY_STND);
  347.             player->shielding = true;
  348.         }
  349.         else if ((cmd->buttons & BT_SHIELD) && player->shielding)
  350.         {
  351.             mo->momx = player->cmomx;
  352.             mo->momy = player->cmomy;
  353.  
  354.             if (!player->shieldspawned)
  355.             {
  356.                 /*mobj_t *item;
  357.                 // Now spawn the shield circle.
  358.                 P_SpawnSpinMobj(player, MT_SHIELD);*/
  359.                 player->shieldspawned = true;
  360.             }
  361.         }
  362.         else if (!(cmd->buttons & BT_SHIELD) && player->shielding && player->shieldspawned)
  363.         {
  364.             //P_SetMobjState(item, S_DISS);
  365.             player->shielding = false;
  366.             player->shieldspawned = false;
  367.         }
  368.  
  369.         if (player->shielding && player->shieldspawned && player->shieldtimer <= 120) // SHIELD BREAK!
  370.         {
  371.             //S_PlaySound(NULL, sfx_shieldbreak);
  372.             P_SetObjectMomZ(mo, 10*FRACUNIT, false);
  373.             P_SetPlayerMobjState(mo, S_PLAY_PAIN);
  374.             player->shielding = false;
  375.             player->shieldspawned = false;
  376.             player->shieldtimer = SHIELDLIFE;
  377.             mo->reactiontime = SHIELDLIFE/2; // Make the player unable to move!
  378.         }
  379.     }
  380. }
  381.  
  382. //
  383. // P_PlayerSpecialAtk
  384. //
  385. // Variety of Special Attacks are listed here. Common stuff for Smash bros.
  386. //
  387. // Standard B is a special homing attack (Does not apply for Tails, Knuckles, Espio or Amy)
  388. // Up + B launches you into the air
  389. // Side + B brings you into a spindash (Does not apply for Amy)
  390. // Down + B puts you into a spindash and revs it up. (Does not apply for Amy)
  391. // Down B, standard B, side B, and up B all in one if statement! :D
  392. //
  393. void P_PlayerSpecialAtk(player_t *player, ticcmd_t *cmd)
  394. {
  395.     mobj_t *mo;
  396.     mo = player->mo;
  397.  
  398.     if (player->pflags & PF_STASIS || player->powers[pw_nocontrol])
  399.         return;
  400.  
  401.     /////////////////////
  402.     // SPECIAL ATTACKS //
  403.     /////////////////////
  404.     if ((twodlevel || (mo->flags2 & MF2_TWOD)) // This moveset is for 2D levels ONLY
  405.     && !(mo->state-states == S_PLAY_PAIN
  406.     || (player->powers[pw_super] && player->skin == 0) // If the player isn't super and if the skin isn't sonic
  407.     || mo->reactiontime // Can you move!?
  408.     || player->exiting
  409.     || player->shielding // Do not do anything if you're shielding
  410.     || (mo->flameflags & FLF_SMASHABILITYUSE))) // The player didn't already use their Up + B special
  411.     {
  412.         // Standard B
  413.         // Homing attack
  414.         if ((cmd->buttons & BT_B)
  415.         && !cmd->sidemove && !cmd->forwardmove
  416.         && !((cmd->buttons & BT_DUCK)
  417.         || (player->pflags & PF_JUMPDOWN)
  418.         || (player->pflags & PF_STARTDASH)
  419.         || (player->pflags & PF_SPINNING)
  420.         || (player->pflags & PF_USEDOWN)
  421.         || player->spectator))
  422.         {
  423.             if ((player->pflags & PF_SUPERREADY) && !player->powers[pw_super] // Ready to turn super and not super already?
  424.             && !player->powers[pw_jumpshield] && !player->powers[pw_forceshield]
  425.             && !player->powers[pw_watershield] && !player->powers[pw_ringshield]
  426.             && !player->powers[pw_bombshield] && !player->powers[pw_invulnerability]
  427.             && !(maptol & TOL_NIGHTS) // don't turn 'regular super' in nights levels
  428.             /*&& (player->charflags & SF_ALLOWSUPER)*/ && player->powers[pw_finalsmash])
  429.             {
  430.                 P_ResetPlayer(player);
  431.                 mo->momx = mo->momy = mo->momz = 0;
  432.                 P_DoSuperTransformation(player, true);
  433.                 player->powers[pw_finalsmash] = false;
  434.                 player->pflags |= PF_USEDOWN;
  435.                 player->pflags &= ~PF_SUPERREADY;
  436.                 if (player->skin != 3)
  437.                     mo->reactiontime = TICRATE;
  438.             }
  439.             else if (/*(player->charflags & SF_HOMING)*/ // Only for characters with a homing ability
  440.             (player->charability == CA_HOMINGTHOK)
  441.             && !(player->pflags & PF_JUMPDOWN)
  442.             && (player->skin == 0
  443.             || player->skin == 3)
  444.             && !(player->pflags & PF_SPINNING)
  445.             && !player->weapondelay)
  446.             {
  447.                 mo->momx /= 2;
  448.                 // Special Homing attack routine:
  449.                 if (P_IsObjectOnGround(mo)) // First check if the player is on the ground
  450.                 {
  451.                     if (mo->eflags & MFE_UNDERWATER)
  452.                         P_SetObjectMomZ(mo, 8*FRACUNIT, false);
  453.                     else
  454.                         P_SetObjectMomZ(mo, 6*FRACUNIT, false);
  455.                 }
  456.                 else if (!P_IsObjectOnGround(mo)) // Otherwise if not on the ground...
  457.                 {
  458.                     // Smooth stop in the air
  459.                     /*if (mo->momz < 0)
  460.                         mo->momz += FRACUNIT
  461.                     if (mo->momz > 0)
  462.                         mo->momz -= FRACUNIT;
  463.                     else if (mo->momz == 0)*/
  464.                         mo->momz = 0;
  465.                 }
  466.                 S_StartSound(player, sfx_spin);
  467.                 P_SetPlayerMobjState(mo, S_PLAY_ATK1); // Have the player rise up and go into a spin.
  468.  
  469.                 player->pflags |= PF_JUMPED;
  470.  
  471.                 if (((player->charability == CA_HOMINGTHOK))
  472.                 && !player->homing)
  473.                 {
  474.                     // Search for any other players in range and NOT YOURSELF
  475.                     if (P_LookForPlayersH(player))
  476.                     {
  477.                         if (mo->tracer) // Have a tracer?
  478.                             player->homing = TICRATE;// Then do the homing attack function!
  479.                     }
  480.                 }
  481.                 mo->flameflags |= FLF_SMASHABILITYUSE;
  482.                 player->secondjump = 1; // Prevent the double jump
  483.             }
  484.             player->pflags |= PF_USEDOWN;
  485.         }
  486.         // Up + B
  487.         // Catapult Launch
  488.         else if ((player->pflags & PF_JUMPDOWN) && cmd->buttons & BT_B
  489.         && !((player->pflags & PF_STARTDASH)
  490.         || (player->pflags & PF_SPINNING)
  491.         || (player->pflags & PF_USEDOWN)))
  492.         {
  493.             // Catapult the player upward
  494.             /*if (mo->eflags & MFE_UNDERWATER)
  495.                 P_SetObjectMomZ(mo, (player->jumpfactor/5)*(FRACUNIT/2), false);
  496.             else*/
  497.                 P_SetObjectMomZ(mo, (player->jumpfactor/6)*FRACUNIT, false);
  498.  
  499.             if (player->speed >= 8)
  500.             {
  501.                 if (mo->angle == 0)
  502.                     mo->momx = 5*FRACUNIT;
  503.                 else if (mo->angle == ANGLE_180)
  504.                     mo->momx = -(5*FRACUNIT);
  505.             }
  506.  
  507.             if (mo->info->attacksound && !player->spectator)
  508.                 S_StartSound(mo, mo->info->attacksound);
  509.  
  510.             P_SetPlayerMobjState(mo, S_PLAY_ATK1);
  511.             player->pflags &= ~PF_JUMPED; // If true, the jump height can be cut, we don't want that.
  512.             player->secondjump = 1; // Prevent the double jump
  513.             mo->flameflags |= FLF_SMASHABILITYUSE;
  514.             player->pflags |= PF_THOKKED;
  515.         }
  516.         // If not moving up or down, and travelling faster than a speed of four while not holding
  517.         // down the spin button and not spinning.
  518.         // AKA Just go into a spin on the ground, you idiot. ;)
  519.         // Side + B
  520.         // Spindash
  521.         else if ((cmd->buttons & BT_B)
  522.         && !player->climbing
  523.         //&& !mo->momz && onground // You CAN be in the air to use this now.
  524.         && cmd->sidemove
  525.         && (player->charability2 == CA2_SPINDASH)
  526.         && !((player->pflags & PF_JUMPDOWN)
  527.         || (player->pflags & PF_USEDOWN)
  528.         || (player->pflags & PF_SPINNING)))
  529.         {
  530.             // Old stuff here for refrence.
  531.             /* P_ResetScore(player);
  532.              * player->pflags |= PF_SPINNING;
  533.              * P_SetPlayerMobjState(mo, S_PLAY_ATK1);
  534.              * S_StartSound(mo, sfx_spin);
  535.              * player->pflags |= PF_USEDOWN;
  536.              * if (mo->eflags & MF_VERTICALFLIP)
  537.              *  mo->z = mo->ceilingz - P_GetPlayerSpinHeight(player);
  538.              * mo->flameflags |= FLF_SMASHABILITYUSE; */
  539.  
  540.             if (cmd->buttons & BT_B) // Then start the spindash with B
  541.             {
  542.                 P_ResetScore(player);
  543.                 player->mo->momx = player->cmomx;
  544.                 player->mo->momy = player->cmomy;
  545.                 player->pflags |= PF_STARTDASH;
  546.                 player->pflags |= PF_SPINNING;
  547.                 player->dashspeed = FRACUNIT/NEWTICRATERATIO;
  548.                 P_SetPlayerMobjState(player->mo, S_PLAY_ATK1);
  549.                 player->pflags |= PF_USEDOWN;
  550.                 if (player->mo->eflags & MFE_VERTICALFLIP)
  551.                     player->mo->z = player->mo->ceilingz - P_GetPlayerSpinHeight(player);
  552.                 player->sidespin = true; // Be prepared to bounce if airborne.
  553.             }
  554.         }
  555.         // Spin Charge
  556.         else if (!cmd->sidemove
  557.         && (player->charability2 == CA2_SPINDASH)
  558.         && (cmd->buttons & BT_DUCK) // Duck first...
  559.         && !((player->pflags & PF_JUMPDOWN)
  560.         || (player->pflags & PF_USEDOWN)
  561.         || (player->pflags & PF_SPINNING)))
  562.         {
  563.             if (cmd->buttons & BT_B) // Then start the spin charge with B
  564.             {
  565.                 P_ResetScore(player);
  566.                 player->mo->momx = player->cmomx;
  567.                 player->mo->momy = player->cmomy;
  568.                 player->pflags |= PF_STARTDASH;
  569.                 player->pflags |= PF_SPINNING;
  570.                 player->dashspeed = FRACUNIT/NEWTICRATERATIO;
  571.                 P_SetPlayerMobjState(player->mo, S_PLAY_ATK1);
  572.                 player->pflags |= PF_USEDOWN;
  573.                 if (player->mo->eflags & MFE_VERTICALFLIP)
  574.                     player->mo->z = player->mo->ceilingz - P_GetPlayerSpinHeight(player);
  575.                 player->sidespin = false; // Be prepared to NOT bounce if airborne.
  576.             }
  577.             else if (P_IsObjectOnGround(mo) && !(player->pflags & PF_STARTDASH || player->pflags & PF_SPINNING))
  578.             {
  579.                 player->dashspeed = 0;
  580.                 P_SetPlayerMobjState(mo, S_PLAY_ATK4); // Ducking
  581.                 //P_GetPlayerSpinHeight(player);
  582.                 mo->height = P_GetPlayerSpinHeight(player);
  583.                 mo->momx = player->speed = cmd->sidemove /= 2;
  584.                 //CONS_Printf("The player is ready to spindash\n");
  585.             }
  586.         }
  587.         else if ((cmd->buttons & BT_B) && (player->pflags & PF_STARTDASH)) // Rev up the spindash
  588.         {
  589.             player->dashspeed += FRACUNIT/NEWTICRATERATIO;
  590.  
  591.             if ((leveltime % (TICRATE/10)) == 0)
  592.             {
  593.                 if (!player->spectator)
  594.                     S_StartSound(mo, sfx_spndsh); // Make the rev sound!
  595.  
  596.                 if (!(mo->flameflags & FLF_FINALSMASHUSE && player->skin == 5) && !player->spectator)
  597.                     P_SpawnGhostMobj(mo);
  598.             }
  599.         }
  600.     }
  601.     else if (!(twodlevel || (mo->flags2 & MF2_TWOD)) // If it's NOT a 2D level...
  602.     && !(mo->state-states == S_PLAY_PAIN
  603.     || (player->powers[pw_super] && player->skin == 0)
  604.     || mo->reactiontime // Can you move!?
  605.     || player->exiting
  606.     || player->shielding))
  607.     {
  608.  
  609.         // You just have your Down + B which is changed to your standard B and Side/Moving B move.
  610.         // Standard B
  611.         // Spin Charge
  612.         if ((cmd->buttons & BT_B)
  613.         && !(player->pflags & PF_USEDOWN)
  614.         && player->speed < 5)
  615.         {
  616.             if ((player->pflags & PF_SUPERREADY) && !player->powers[pw_super] // Ready to turn super and not super already?
  617.             && !player->powers[pw_jumpshield] && !player->powers[pw_forceshield]
  618.             && !player->powers[pw_watershield] && !player->powers[pw_ringshield]
  619.             && !player->powers[pw_bombshield] && !player->powers[pw_invulnerability]
  620.             && !(maptol & TOL_NIGHTS) // don't turn 'regular super' in nights levels
  621.             /*&& (player->charflags & SF_ALLOWSUPER)*/ && player->powers[pw_finalsmash])
  622.             {
  623.                 P_ResetPlayer(player);
  624.                 mo->momx = mo->momy = mo->momz = 0;
  625.                 P_DoSuperTransformation(player, true);
  626.                 player->powers[pw_finalsmash] = false;
  627.                 player->pflags |= PF_USEDOWN;
  628.                 player->pflags &= ~PF_SUPERREADY;
  629.                 if (player->skin != 3)
  630.                     mo->reactiontime = TICRATE;
  631.             }
  632.             else if ((player->charability2 == CA2_SPINDASH)
  633.             && player->speed < 5
  634.             && !mo->momz && P_IsObjectOnGround(mo)
  635.             && !(player->pflags & PF_SPINNING))
  636.             {
  637.                 P_ResetScore(player);
  638.                 mo->momx = player->cmomx;
  639.                 mo->momy = player->cmomy;
  640.                 player->pflags |= PF_STARTDASH;
  641.                 player->pflags |= PF_SPINNING;
  642.                 player->dashspeed = FRACUNIT/NEWTICRATERATIO;
  643.                 P_SetPlayerMobjState(mo, S_PLAY_ATK1);
  644.                 player->pflags |= PF_USEDOWN;
  645.                 if (mo->eflags & MFE_VERTICALFLIP)
  646.                     mo->z = mo->ceilingz - P_GetPlayerSpinHeight(player);
  647.             }
  648.         }
  649.         else if ((cmd->buttons & BT_B) && (player->pflags & PF_STARTDASH)) // Rev up the spindash
  650.         {
  651.             player->dashspeed += FRACUNIT/NEWTICRATERATIO;
  652.  
  653.             if ((leveltime % (TICRATE/10)) == 0)
  654.             {
  655.                 if (!player->spectator)
  656.                     S_StartSound(mo, sfx_spndsh); // Make the rev sound!
  657.                 // Now spawn the color thok circle.
  658.  
  659.                 if (!(mo->flameflags & FLF_FINALSMASHUSE && (player->skin == 5)))
  660.                     P_SpawnGhostMobj(mo);
  661.             }
  662.         }
  663.         // If not moving up or down, and travelling faster than a speed of four while not holding
  664.         // down the spin button and not spinning.
  665.         // AKA Just go into a spin on the ground, you idiot. ;)
  666.         // Side/Moving + B
  667.         // Spin Dash
  668.         else if ((cmd->buttons & BT_B)
  669.         && !player->climbing
  670.         && !mo->momz && P_IsObjectOnGround(mo) && player->speed > 5
  671.         && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING) && (player->charability2 == CA2_SPINDASH))
  672.         {
  673.             P_ResetScore(player);
  674.             player->pflags |= PF_SPINNING;
  675.             P_SetPlayerMobjState(mo, S_PLAY_ATK1);
  676.             if (!player->spectator)
  677.                 S_StartSound(mo, sfx_spin);
  678.             player->pflags |= PF_USEDOWN;
  679.             if (mo->eflags & MFE_VERTICALFLIP)
  680.                 mo->z = mo->ceilingz - P_GetPlayerSpinHeight(player);
  681.         }
  682.     }
  683.  
  684.     // Oh dear, important collision detection with the ground?
  685.     if (P_IsObjectOnGround(mo) && (player->pflags & PF_SPINNING) && !(player->pflags & PF_STARTDASH)
  686.         && (player->rmomx < 5*FRACUNIT/NEWTICRATERATIO
  687.         && player->rmomx > -5*FRACUNIT/NEWTICRATERATIO)
  688.         && (player->rmomy < 5*FRACUNIT/NEWTICRATERATIO
  689.         && player->rmomy > -5*FRACUNIT/NEWTICRATERATIO))
  690.     {
  691.         if (GETSECSPECIAL(player->mo->subsector->sector->special, 4) == 7 || (mo->ceilingz - mo->floorz < P_GetPlayerHeight(player)))
  692.             P_InstaThrust(mo, mo->angle, 10*FRACUNIT);
  693.         else
  694.         {
  695.             player->pflags &= ~PF_SPINNING;
  696.             P_SetPlayerMobjState(mo, S_PLAY_STND);
  697.             mo->momx = player->cmomx;
  698.             mo->momy = player->cmomy;
  699.             P_ResetScore(player);
  700.             if (mo->eflags & MFE_VERTICALFLIP)
  701.                 mo->z = player->mo->ceilingz - P_GetPlayerHeight(player);
  702.         }
  703.     }
  704.  
  705.     // Catapult the player from a spindash rev!
  706.     if (!(player->pflags & PF_USEDOWN) && player->dashspeed && (player->pflags & PF_STARTDASH) && (player->pflags & PF_SPINNING))
  707.     {
  708.         if (player->powers[pw_ingoop])
  709.             player->dashspeed = 0;
  710.  
  711.         player->pflags &= ~PF_STARTDASH;
  712.         if (!(gametype == GT_RACE && leveltime < 4*TICRATE))
  713.         {
  714.             if (!P_IsObjectOnGround(mo))
  715.             {
  716.                 if (player->sidespin == true)
  717.                     P_SetObjectMomZ(player->mo, 8*FRACUNIT, false);
  718.                 else // Just to be nice.
  719.                     P_SetObjectMomZ(player->mo, FRACUNIT, false);
  720.                 P_InstaThrust(player->mo, player->mo->angle, player->dashspeed/2+1); // catapult forward ho!!
  721.                 player->mo->flameflags |= FLF_SMASHABILITYUSE;
  722.                 player->secondjump = 1; // Prevent double jump.
  723.             }
  724.             else
  725.                 P_InstaThrust(player->mo, player->mo->angle, player->dashspeed); // catapult forward ho!!
  726.  
  727.             if (!player->spectator)
  728.                 S_StartSound(mo, sfx_zoom);
  729.         }
  730.         player->dashspeed = 0;
  731.     }
  732.  
  733.     if ((player->pflags & PF_SPINNING)
  734.         && !(player->mo->state >= &states[S_PLAY_ATK1]
  735.         && player->mo->state <= &states[S_PLAY_ATK4]))
  736.         P_SetPlayerMobjState(player->mo, S_PLAY_ATK1);
  737. }
  738. #endif // SMASH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement