mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-05 02:07:46 +00:00
only block when a shield is on
This commit is contained in:
parent
2986d4dff1
commit
df8686f308
6 changed files with 31 additions and 13 deletions
|
@ -793,6 +793,10 @@ void Sapphire::Entity::Chara::setAgentId( uint32_t agentId )
|
||||||
m_agentId = agentId;
|
m_agentId = agentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Sapphire::Entity::Chara::canBlock()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
float Sapphire::Entity::Chara::getRadius() const
|
float Sapphire::Entity::Chara::getRadius() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -250,6 +250,8 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
virtual void autoAttack( CharaPtr pTarget );
|
virtual void autoAttack( CharaPtr pTarget );
|
||||||
|
|
||||||
|
virtual bool canBlock();
|
||||||
|
|
||||||
virtual void onDeath() {};
|
virtual void onDeath() {};
|
||||||
|
|
||||||
virtual void onDamageTaken( Chara& pSource ) {};
|
virtual void onDamageTaken( Chara& pSource ) {};
|
||||||
|
|
|
@ -2420,6 +2420,16 @@ void Sapphire::Entity::Player::clearBuyBackMap()
|
||||||
m_shopBuyBackMap.clear();
|
m_shopBuyBackMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Sapphire::Entity::Player::canBlock()
|
||||||
|
{
|
||||||
|
if( auto item = getEquippedSecondaryWeapon() )
|
||||||
|
{
|
||||||
|
if( item->getCategory() == ItemUICategory::Shield )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Sapphire::Entity::Player::gaugeClear()
|
void Sapphire::Entity::Player::gaugeClear()
|
||||||
{
|
{
|
||||||
std::memset( &m_gauge, 0, sizeof( m_gauge ) );
|
std::memset( &m_gauge, 0, sizeof( m_gauge ) );
|
||||||
|
|
|
@ -136,7 +136,7 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
void checkEvent( uint32_t eventId );
|
void checkEvent( uint32_t eventId );
|
||||||
|
|
||||||
|
bool canBlock() override;
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -183,14 +183,16 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CalcStats::dodgeProbability( const Sapphire::Entity::Chara& chara )
|
float CalcStats::dodgeProbability( Sapphire::Entity::Chara& chara )
|
||||||
{
|
{
|
||||||
// dummy value: 5% for players.
|
// dummy value: 5% for players.
|
||||||
return chara.isPlayer() ? 5 : 0;
|
return chara.isPlayer() ? 5 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CalcStats::blockProbability( const Chara& chara )
|
float CalcStats::blockProbability( Chara& chara )
|
||||||
{
|
{
|
||||||
|
if( !chara.canBlock() )
|
||||||
|
return 0;
|
||||||
auto level = chara.getLevel();
|
auto level = chara.getLevel();
|
||||||
auto blockRate = static_cast< float >( chara.getStatValue( Common::BaseParam::BlockRate ) );
|
auto blockRate = static_cast< float >( chara.getStatValue( Common::BaseParam::BlockRate ) );
|
||||||
auto levelVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::DIV ] );
|
auto levelVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::DIV ] );
|
||||||
|
@ -205,7 +207,7 @@ float CalcStats::blockProbability( const Chara& chara )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CalcStats::parryProbability( const Sapphire::Entity::Chara& chara )
|
float CalcStats::parryProbability( Sapphire::Entity::Chara& chara )
|
||||||
{
|
{
|
||||||
// dummy value: 10% for players.
|
// dummy value: 10% for players.
|
||||||
float result = chara.isPlayer() ? 10 : 0;
|
float result = chara.isPlayer() ? 10 : 0;
|
||||||
|
@ -844,7 +846,7 @@ float CalcStats::calcAbsorbHP( Sapphire::Entity::CharaPtr pChara, float damage )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CalcStats::calcDodge( const Sapphire::Entity::Chara& chara )
|
bool CalcStats::calcDodge( Sapphire::Entity::Chara& chara )
|
||||||
{
|
{
|
||||||
if( dodgeProbability( chara ) > getRandomNumber0To100() )
|
if( dodgeProbability( chara ) > getRandomNumber0To100() )
|
||||||
{
|
{
|
||||||
|
@ -853,7 +855,7 @@ bool CalcStats::calcDodge( const Sapphire::Entity::Chara& chara )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CalcStats::calcBlock( const Sapphire::Entity::Chara& chara, float damage )
|
float CalcStats::calcBlock( Sapphire::Entity::Chara& chara, float damage )
|
||||||
{
|
{
|
||||||
if( blockProbability( chara ) > getRandomNumber0To100() )
|
if( blockProbability( chara ) > getRandomNumber0To100() )
|
||||||
{
|
{
|
||||||
|
@ -862,7 +864,7 @@ float CalcStats::calcBlock( const Sapphire::Entity::Chara& chara, float damage )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CalcStats::calcParry( const Sapphire::Entity::Chara& chara, float damage )
|
float CalcStats::calcParry( Sapphire::Entity::Chara& chara, float damage )
|
||||||
{
|
{
|
||||||
if( parryProbability( chara ) > getRandomNumber0To100() )
|
if( parryProbability( chara ) > getRandomNumber0To100() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,14 +16,14 @@ namespace Sapphire::Math
|
||||||
|
|
||||||
static uint32_t calculateMaxHp( Sapphire::Entity::PlayerPtr pPlayer );
|
static uint32_t calculateMaxHp( Sapphire::Entity::PlayerPtr pPlayer );
|
||||||
|
|
||||||
static float dodgeProbability( const Sapphire::Entity::Chara& chara );
|
static float dodgeProbability( Sapphire::Entity::Chara& chara );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Calculates the probability of a block happening
|
* @brief Calculates the probability of a block happening
|
||||||
*/
|
*/
|
||||||
static float blockProbability( const Sapphire::Entity::Chara& chara );
|
static float blockProbability( Sapphire::Entity::Chara& chara );
|
||||||
|
|
||||||
static float parryProbability( const Sapphire::Entity::Chara& chara );
|
static float parryProbability( Sapphire::Entity::Chara& chara );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Calculates the probability of a direct hit happening
|
* @brief Calculates the probability of a direct hit happening
|
||||||
|
@ -155,11 +155,11 @@ namespace Sapphire::Math
|
||||||
|
|
||||||
static float calcAbsorbHP( Sapphire::Entity::CharaPtr pChara, float damage );
|
static float calcAbsorbHP( Sapphire::Entity::CharaPtr pChara, float damage );
|
||||||
|
|
||||||
static bool calcDodge( const Sapphire::Entity::Chara& chara );
|
static bool calcDodge( Sapphire::Entity::Chara& chara );
|
||||||
|
|
||||||
static float calcBlock( const Sapphire::Entity::Chara& chara, float damage );
|
static float calcBlock( Sapphire::Entity::Chara& chara, float damage );
|
||||||
|
|
||||||
static float calcParry( const Sapphire::Entity::Chara& chara, float damage );
|
static float calcParry( Sapphire::Entity::Chara& chara, float damage );
|
||||||
|
|
||||||
static float getRandomNumber0To100();
|
static float getRandomNumber0To100();
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue