From d3c656e8b8867ebe1dd07126220fd40245bbc3ca Mon Sep 17 00:00:00 2001 From: collett Date: Sat, 7 Mar 2020 17:57:00 +0900 Subject: [PATCH] implement whm lily --- src/common/Common.h | 1 + src/world/Action/Action.cpp | 25 ++++++++++++++ src/world/Actor/Player.cpp | 68 +++++++++++++++++++++++++++++++++++++ src/world/Actor/Player.h | 6 ++++ 4 files changed, 100 insertions(+) diff --git a/src/common/Common.h b/src/common/Common.h index fda36620..801fe967 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -587,6 +587,7 @@ namespace Sapphire::Common // AetherflowStack = 30, // Status = 32, PLDGauge = 41, + WHMLily = 57, // RDMGaugeBoth = 74, //// RDMGaugeBlack = 75, // not right? // DRGGauge3Eyes = 76, diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 1d661920..5b94fa05 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -808,6 +808,31 @@ bool Action::Action::primaryCostCheck( bool subtractCosts ) return false; } + case Common::ActionPrimaryCostType::WHMLily: + { + auto pPlayer = m_pSource->getAsPlayer(); + if( pPlayer ) + { + auto lily = pPlayer->gaugeWhmGetLily(); + if( lily >= m_primaryCost ) + { + if( subtractCosts ) + { + lily -= m_primaryCost; + auto bloodLily = pPlayer->gaugeWhmGetBloodLily(); + if( pPlayer->getLevel() >= 74 ) + { + bloodLily = std::min( 3, bloodLily + m_primaryCost ); + } + pPlayer->gaugeWhmSetLilies( lily, bloodLily ); + } + + return true; + } + } + return false; + } + // free casts, likely just pure ogcds case Common::ActionPrimaryCostType::None: { diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index 27f9c3d9..fc9d320b 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -1124,6 +1124,7 @@ void Sapphire::Entity::Player::update( uint64_t tickCount ) if( !isAlive() ) return; + int64_t interval = tickCount - m_lastUpdate; m_lastUpdate = tickCount; if( !checkAction() ) @@ -1165,6 +1166,35 @@ void Sapphire::Entity::Player::update( uint64_t tickCount ) } } + switch( getClass() ) + { + case Common::ClassJob::Conjurer: + case Common::ClassJob::Whitemage: + { + if( hasStateFlag( Common::PlayerStateFlag::InCombat ) ) + { + if( gaugeWhmGetLily() < 3 ) + { + auto lilyTimer = gaugeWhmGetLilyTimer(); + lilyTimer += interval; + if( lilyTimer >= 30000 ) + { + gaugeWhmSetLilyTimer( 0 ); // packet is sent together with following lily update + gaugeWhmSetLilies( gaugeWhmGetLily() + 1, gaugeWhmGetBloodLily() ); + } + else + { + gaugeWhmSetLilyTimer( lilyTimer ); // don't send any packet, the client increases the timer by itself + } + } + else + { + gaugeWhmSetLilyTimer( 0 ); + } + } + }; + } + Chara::update( tickCount ); } @@ -1464,13 +1494,17 @@ void Sapphire::Entity::Player::onMobAggro( BNpcPtr pBNpc ) { hateListAdd( pBNpc ); queuePacket( makeActorControl( getId(), ToggleAggro, 1 ) ); + setStateFlag( Common::PlayerStateFlag::InCombat ); } void Sapphire::Entity::Player::onMobDeaggro( BNpcPtr pBNpc ) { hateListRemove( pBNpc ); if( m_actorIdTohateSlotMap.empty() ) + { queuePacket( makeActorControl( getId(), ToggleAggro ) ); + unsetStateFlag( Common::PlayerStateFlag::InCombat ); + } } bool Sapphire::Entity::Player::isLogin() const @@ -2201,6 +2235,7 @@ void Sapphire::Entity::Player::sendActorGauge() void Sapphire::Entity::Player::gaugeWarSetIb( uint8_t value ) { + assert( value >= 0 && value <= 100 ); auto oldValue = gaugeWarGetIb(); if( ( oldValue == 0 && value != 0 ) || ( oldValue != 0 && value == 0 ) ) @@ -2224,6 +2259,7 @@ uint8_t Sapphire::Entity::Player::gaugeWarGetIb() void Sapphire::Entity::Player::gaugePldSetOath( uint8_t value ) { + assert( value >= 0 && value <= 100 ); auto oldValue = gaugePldGetOath(); m_gauge.pld.oathGauge = value; if( oldValue != value ) @@ -2233,4 +2269,36 @@ void Sapphire::Entity::Player::gaugePldSetOath( uint8_t value ) uint8_t Sapphire::Entity::Player::gaugePldGetOath() { return m_gauge.pld.oathGauge; +} + +uint8_t Sapphire::Entity::Player::gaugeWhmGetLily() +{ + return m_gauge.whm.lilies; +} + +uint8_t Sapphire::Entity::Player::gaugeWhmGetBloodLily() +{ + return m_gauge.whm.bloodLilies; +} + +void Sapphire::Entity::Player::gaugeWhmSetLilies( uint8_t liles, uint8_t bloodLilies ) +{ + assert( liles >= 0 && liles <= 3 ); + assert( bloodLilies >= 0 && bloodLilies <= 3 ); + m_gauge.whm.lilies = liles; + m_gauge.whm.bloodLilies = bloodLilies; + sendActorGauge(); +} + +void Sapphire::Entity::Player::gaugeWhmSetLilyTimer( uint16_t value, bool sendPacket ) +{ + assert( value >= 0 && value <= 30000 ); + m_gauge.whm.lilyTimer = value; + if( sendPacket ) + sendActorGauge(); +} + +uint16_t Sapphire::Entity::Player::gaugeWhmGetLilyTimer() +{ + return m_gauge.whm.lilyTimer; } \ No newline at end of file diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index e92e24d2..480d13fb 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -982,6 +982,12 @@ namespace Sapphire::Entity void gaugePldSetOath( uint8_t value ); uint8_t gaugePldGetOath(); + uint8_t gaugeWhmGetLily(); + uint8_t gaugeWhmGetBloodLily(); + void gaugeWhmSetLilies( uint8_t liles, uint8_t bloodLilies ); + void gaugeWhmSetLilyTimer( uint16_t value, bool sendPacket = false ); + uint16_t gaugeWhmGetLilyTimer(); + ////////////////////////////////////////////////////////////////////////////////////////////////////// Common::HuntingLogEntry& getHuntingLogEntry( uint8_t index );