Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shield formula like Nostalrius #238

Open
peonso opened this issue Aug 30, 2020 · 0 comments
Open

Shield formula like Nostalrius #238

peonso opened this issue Aug 30, 2020 · 0 comments

Comments

@peonso
Copy link
Collaborator

peonso commented Aug 30, 2020

change on https://github.com/TwistedScorpio/OTHire/blob/master/source/player.cpp
both int32_t Player::getDefense() const and float Player::getDefenseFactor() const

float Player::getDefenseFactor() const
{
	switch(fightMode){
		case FIGHTMODE_ATTACK:
		{
			return 0.6f;
			break;
		}

		case FIGHTMODE_BALANCED:
		{
			return 1.0f;
			break;
		}

		case FIGHTMODE_DEFENSE:
		{
			return 1.8f;
			break;
		}

		default:
			return 1.0f;
			break;
	}
}

int32_t Player::getDefense() const
{
	int32_t defenseSkill = getSkill(SKILL_FIST, SKILL_LEVEL);
	int32_t defenseValue = 5;
	float defenseFactor = getDefenseFactor();
	const Item* weapon = NULL;
	const Item* shield = NULL;
	getShieldAndWeapon(shield, weapon);

	if(weapon){
		defenseValue = weapon->getDefense() + 1;
		defenseSkill = getWeaponSkill(weapon);
	}

	if(shield){
		defenseValue = shield->getDefense() + 1;
		defenseSkill = getSkill(SKILL_SHIELD, SKILL_LEVEL);
	}

	if(defenseSkill == 0)
		return 0;

	if(vocation && vocation->getBaseDefense() != 1.0){
		defenseValue = int32_t(defenseValue * vocation->getBaseDefense());
	}
	
	// Nostalrius use this to default to full def when you are not attacking anything, we don't have access to this variables, so it's not implemented
	/* if ((followCreature || !attackedCreature) && earliestAttackTime <= OTSYS_TIME()) {
		defenseFactor = 1.8;
	} */
	
	int32_t randresult1 = (uint32_t)random_range(0, 99);
	int32_t randresult2 = (uint32_t)random_range(0, 99);

	return ((int32_t)std::floor((float)((5 * defenseSkill + 50)* defenseValue * defenseFactor * (randresult1+randresult2) / 2 / 10000.)));
}
@peonso peonso added this to the Version 1.0 milestone Aug 30, 2020
@peonso peonso mentioned this issue Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant