A continued explanation of 1.02's blocking system

Guides and how to's on anything related to JK2, whether it's about modding or in-game topics.
Post Reply
User avatar
Boothand
Administrator
Posts: 986
Joined: 24 Feb 2015, 08:21
Contact:

A continued explanation of 1.02's blocking system

Post by Boothand »

How the random blocking works

This code runs after we've determined that the attacker hit outside our blocking box.
Read this first if you haven't yet.
Short summary: Blocking box blocks for sure.

So this is what matters when we know that we are not attacking and the saber hit somewhere on the front or side-ish of our character, ready to defend.

Original baseJK code:

Code: Select all

if (attackStr == FORCE_LEVEL_3)
{
	if (self->client->ps.fd.forcePowerLevel[FP_SABERDEFEND] >= FORCE_LEVEL_3)
	{
		if (Q_irand(1, 10) < 3)
		{
			return 0;
		}
	}
	else
	{
		return 0;
	}
}
Translation of above:

(if he hits outside my invisible blocking box, hence this code runs)
  1. If attacker uses red style...
  2. Then, if I have full saber defense (you always have in NF gametype), generate random number from 1 to 10. If it's below 3, I can't block.
  3. If I don't have full saber defense, I can't block.

Code: Select all

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)
		{
			return 0;
		}
	}
	else
	{
		return 0;
	}
}
  1. If attacker uses yellow style
  2. Generate random number from 1 to 10, if it's below 3, continue (otherwise, I can block for sure):
  3. If I have full saber defense, I can block
  4. If I only have saber defense 2, I have 40% chance of failure
  5. If defense 1 or below, fail.
So basically, in NF gametype I can always block yellow


Code: Select all

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)
	return 0;
}
If attacker uses blue style, and I don't have saber defense, AND I'm super unlucky (1/20th chance), I can't block.

Conclusion:
In the NF gametype, you can always block attacks hitting the front of your character (and about to the middle of the sides), UNLESS the attacker uses red style, in which case there's a 20% chance to fail.
Post Reply
Created by Matti from StylesFactory.pl and Warlords of Draenor (modified by jk2.info)
Powered by phpBB® Forum Software © phpBB Limited