Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // #define DEBUGSD
- int WP_SaberCanBlock(gentity_t *self, vec3_t point, int dflags, int mod, qboolean projectile, int attackStr)
- {
- qboolean thrownSaber = qfalse;
- float blockFactor = 0;
- if (!self || !self->client || !point)
- {
- return 0;
- }
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "WP_SaberCanBlock attackStr=%d... ", attackStr);
- #endif
- if (attackStr == 8)
- {
- attackStr = 0;
- thrownSaber = qtrue;
- }
- if (BG_SaberInAttack(self->client->ps.saberMove))
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, saber in attack\n");
- #endif
- return 0;
- }
- if (PM_InSaberAnim(self->client->ps.torsoAnim) && !self->client->ps.saberBlocked &&
- self->client->ps.saberMove != LS_READY && self->client->ps.saberMove != LS_NONE)
- {
- if ( self->client->ps.saberMove < LS_PARRY_UP || self->client->ps.saberMove > LS_REFLECT_LL )
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, saber is in some animation\n");
- #endif
- return 0;
- }
- }
- if (self->client->ps.saberHolstered)
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, saber holstered\n");
- #endif
- return 0;
- }
- if (self->client->ps.usingATST)
- {
- return 0;
- }
- if (self->client->ps.weapon != WP_SABER)
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, not using saber\n");
- #endif
- return 0;
- }
- if (self->client->ps.weaponstate == WEAPON_RAISING)
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, saber is raising\n");
- #endif
- return 0;
- }
- if (self->client->ps.saberInFlight)
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, saber in flight\n");
- #endif
- return 0;
- }
- if ((self->client->pers.cmd.buttons & BUTTON_ATTACK)/* &&
- (projectile || attackStr == FORCE_LEVEL_3)*/)
- { //don't block when the player is trying to slash, if it's a projectile or he's doing a very strong attack
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, i am holding attack button\n");
- #endif
- return 0;
- }
- if (attackStr == FORCE_LEVEL_3)
- {
- if (self->client->ps.fd.forcePowerLevel[FP_SABERDEFEND] >= FORCE_LEVEL_3)
- {
- if (Q_irand(1, 10) < 3)
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, he is using strong attack and RNG decides that this shall not be blocked (i picked a number between 1 and 10, and it was below 3\n");
- #endif
- return 0;
- }
- }
- else
- {
- return 0;
- }
- }
- if (attackStr == FORCE_LEVEL_2 && Q_irand(1, 10) < 3)
- {
- if (self->client->ps.fd.forcePowerLevel[FP_SABERDEFEND] >= FORCE_LEVEL_3)
- {
- //do nothing for now
- }
- else if (self->client->ps.fd.forcePowerLevel[FP_SABERDEFEND] >= FORCE_LEVEL_2)
- {
- if (Q_irand(1, 10) < 5)
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, he is using medium attack and RNG decides that this shall not be blocked (i picked a number between 1 and 10, and it was below 5\n");
- #endif
- return 0;
- }
- }
- else
- {
- return 0;
- }
- }
- if (attackStr == FORCE_LEVEL_1 && !self->client->ps.fd.forcePowerLevel[FP_SABERDEFEND] &&
- Q_irand(1, 40) < 3)
- { //if I have no defense level at all then I might be unable to block a level 1 attack (but very rarely)
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, he is using fast attack and RNG decides that this shall not be blocked (i picked a number between 1 and 40, and it was below 3\n");
- #endif
- return 0;
- }
- if (SaberAttacking(self))
- { //attacking, can't block now
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, SaberAttacking(self)\n");
- #endif
- //FIXME: Do a "saber box" check here to see if the enemy saber hit this guy's saber
- return 0;
- }
- if (self->client->ps.saberMove != LS_READY &&
- !self->client->ps.saberBlocking)
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, saberMove != LS_READY && !self->client->ps.saberBlocking\n");
- #endif
- return 0;
- }
- if (self->client->ps.saberBlockTime >= level.time)
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, self->client->ps.saberBlockTime >= level.time\n");
- #endif
- return 0;
- }
- if (self->client->ps.forceHandExtend != HANDEXTEND_NONE)
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, forceHandExtend != HANDEXTEND_NONE\n");
- #endif
- return 0;
- }
- if (self->client->ps.fd.forcePowerLevel[FP_SABERDEFEND] == FORCE_LEVEL_3)
- {
- blockFactor = 0.05f;
- }
- else if (self->client->ps.fd.forcePowerLevel[FP_SABERDEFEND] == FORCE_LEVEL_2)
- {
- blockFactor = 0.6f;
- }
- else if (self->client->ps.fd.forcePowerLevel[FP_SABERDEFEND] == FORCE_LEVEL_1)
- {
- blockFactor = 0.9f;
- }
- else
- { //for now we just don't get to autoblock with no def
- return 0;
- }
- if (thrownSaber)
- {
- blockFactor -= 0.25f;
- }
- if (!InFront( point, self->client->ps.origin, self->client->ps.viewangles, blockFactor )) //orig 0.2f
- {
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "no, !InFront (blockFactor=%.2f)\n", blockFactor);
- #endif
- return 0;
- }
- WP_SaberBlockNonRandom(self, point, projectile);
- #ifdef DEBUGSD
- CV_SendClientPrint(self - g_entities, "yes, blocking it!\n");
- #endif
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement