Uses float to calculate latency for sabrina phrases
This commit is contained in:
parent
0cfefb65f7
commit
1020c758b9
12 changed files with 38 additions and 31 deletions
|
@ -1085,7 +1085,7 @@ void CGameItem::resetEnchantment()
|
||||||
_SapLoad = 0;
|
_SapLoad = 0;
|
||||||
_Enchantment.clear();
|
_Enchantment.clear();
|
||||||
contReset( _Enchantment );
|
contReset( _Enchantment );
|
||||||
_LatencyEndDate = 0;
|
_LatencyEndDate = 0.0f;
|
||||||
|
|
||||||
if (getInventory() != NULL)
|
if (getInventory() != NULL)
|
||||||
getInventory()->onItemChanged(getInventorySlot(), INVENTORIES::TItemChangeFlags(INVENTORIES::itc_enchant));
|
getInventory()->onItemChanged(getInventorySlot(), INVENTORIES::TItemChangeFlags(INVENTORIES::itc_enchant));
|
||||||
|
@ -1351,7 +1351,7 @@ void CGameItem::clear()
|
||||||
_Destroyable = true;
|
_Destroyable = true;
|
||||||
_Dropable = true;
|
_Dropable = true;
|
||||||
// _SlotImage = 0xFFFF;
|
// _SlotImage = 0xFFFF;
|
||||||
_LatencyEndDate = 0;
|
_LatencyEndDate = 0.0f;
|
||||||
// _Parent = NULL;
|
// _Parent = NULL;
|
||||||
_Inventory = NULL;
|
_Inventory = NULL;
|
||||||
_InventorySlot = INVENTORIES::INVALID_INVENTORY_SLOT;
|
_InventorySlot = INVENTORIES::INVALID_INVENTORY_SLOT;
|
||||||
|
|
|
@ -651,9 +651,9 @@ public :
|
||||||
bool getStats(const std::string &stats, std::string &final );
|
bool getStats(const std::string &stats, std::string &final );
|
||||||
|
|
||||||
/// accessors to the action latency end date
|
/// accessors to the action latency end date
|
||||||
inline NLMISC::TGameCycle getLatencyEndDate(){ return _LatencyEndDate; }
|
inline float getLatencyEndDate(){ return _LatencyEndDate; }
|
||||||
|
|
||||||
inline void setLatencyEndDate( NLMISC::TGameCycle latencyEndDate ){ _LatencyEndDate = latencyEndDate; }
|
inline void setLatencyEndDate( float latencyEndDate ){ _LatencyEndDate = latencyEndDate; }
|
||||||
|
|
||||||
/// set the max sap load craft parameter
|
/// set the max sap load craft parameter
|
||||||
inline void setMaxSapLoad(float value)
|
inline void setMaxSapLoad(float value)
|
||||||
|
@ -950,7 +950,7 @@ private:
|
||||||
/// string associated with this item
|
/// string associated with this item
|
||||||
std::string _PhraseId;
|
std::string _PhraseId;
|
||||||
/// tick when the proc will be available again
|
/// tick when the proc will be available again
|
||||||
NLMISC::TGameCycle _LatencyEndDate;
|
float _LatencyEndDate;
|
||||||
/// image of the item in bag / equipment
|
/// image of the item in bag / equipment
|
||||||
// uint16 _SlotImage;
|
// uint16 _SlotImage;
|
||||||
NLMISC::TGameCycle _TotalSaleCycle;
|
NLMISC::TGameCycle _TotalSaleCycle;
|
||||||
|
|
|
@ -88,7 +88,7 @@ void CCombatActionDynamicEffect::applyOnEntity( CEntityBase *entity, float succe
|
||||||
TGameCycle endDate;
|
TGameCycle endDate;
|
||||||
if ( _UsePhraseLatencyAsDuration == true && _CombatPhrase != 0)
|
if ( _UsePhraseLatencyAsDuration == true && _CombatPhrase != 0)
|
||||||
{
|
{
|
||||||
endDate = _CombatPhrase->latencyEndDate();
|
endDate = (TGameCycle) _CombatPhrase->latencyEndDate();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,7 +88,7 @@ void CCombatActionSimpleEffect::applyOnEntity( CEntityBase *entity, float succes
|
||||||
TGameCycle endDate;
|
TGameCycle endDate;
|
||||||
if ( _UsePhraseLatencyAsDuration == true && _CombatPhrase != 0)
|
if ( _UsePhraseLatencyAsDuration == true && _CombatPhrase != 0)
|
||||||
{
|
{
|
||||||
endDate = _CombatPhrase->latencyEndDate();
|
endDate = (TGameCycle)_CombatPhrase->latencyEndDate();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,7 +131,7 @@ CCombatWeapon::CCombatWeapon(CGameItemPtr itemPtr)
|
||||||
if (itemPtr->hitRate() != 0)
|
if (itemPtr->hitRate() != 0)
|
||||||
{
|
{
|
||||||
//getGameTimeStep() is actually a double and hitRate() a float, so the precision difference will make a cast of the result fail (for example, with hitRate() == 10.0f, the cast will give a value of 9 and not 10
|
//getGameTimeStep() is actually a double and hitRate() a float, so the precision difference will make a cast of the result fail (for example, with hitRate() == 10.0f, the cast will give a value of 9 and not 10
|
||||||
LatencyInTicks = uint16 ( (10.0f / uint16(itemPtr->hitRate()) ) / float(CTickEventHandler::getGameTimeStep()) );
|
LatencyInTicks = (10.0f / itemPtr->hitRate() ) / float(CTickEventHandler::getGameTimeStep());
|
||||||
}
|
}
|
||||||
|
|
||||||
Quality = (uint16)itemPtr->recommended();
|
Quality = (uint16)itemPtr->recommended();
|
||||||
|
@ -298,7 +298,7 @@ void CCombatAttackerAI::initFromRowId( const TDataSetRow &rowId )
|
||||||
_RightHandWeapon.Damage = (float)form->getCreatureDamagePerHit() * BotDamageFactor;
|
_RightHandWeapon.Damage = (float)form->getCreatureDamagePerHit() * BotDamageFactor;
|
||||||
|
|
||||||
_RightHandWeapon.DmgType = DMGTYPE::SLASHING;
|
_RightHandWeapon.DmgType = DMGTYPE::SLASHING;
|
||||||
_RightHandWeapon.LatencyInTicks = (uint16)form->getAttackLatency();
|
_RightHandWeapon.LatencyInTicks = (float)form->getAttackLatency();
|
||||||
_RightHandWeapon.Family = ITEMFAMILY::MELEE_WEAPON;
|
_RightHandWeapon.Family = ITEMFAMILY::MELEE_WEAPON;
|
||||||
_RightHandWeapon.Skill = BarehandCombatSkill;
|
_RightHandWeapon.Skill = BarehandCombatSkill;
|
||||||
_RightHandWeapon.SabrinaCost = (uint16)_SkillValue;
|
_RightHandWeapon.SabrinaCost = (uint16)_SkillValue;
|
||||||
|
@ -417,7 +417,7 @@ void CCombatAttackerNpc::initFromRowId( const TDataSetRow &rowId )
|
||||||
{
|
{
|
||||||
// get speed, dmg type, skill and family
|
// get speed, dmg type, skill and family
|
||||||
_RightHandWeapon = CCombatWeapon(entity->getRightHandItem());
|
_RightHandWeapon = CCombatWeapon(entity->getRightHandItem());
|
||||||
_RightHandWeapon.LatencyInTicks = (uint16)form->getAttackLatency();
|
_RightHandWeapon.LatencyInTicks = (float)form->getAttackLatency();
|
||||||
|
|
||||||
// check ammo
|
// check ammo
|
||||||
if (entity->getAmmoItem() != NULL && entity->getAmmoItem()->getStaticForm() != NULL && entity->getAmmoItem()->getStaticForm()->Family == ITEMFAMILY::AMMO)
|
if (entity->getAmmoItem() != NULL && entity->getAmmoItem()->getStaticForm() != NULL && entity->getAmmoItem()->getStaticForm()->Family == ITEMFAMILY::AMMO)
|
||||||
|
@ -427,7 +427,7 @@ void CCombatAttackerNpc::initFromRowId( const TDataSetRow &rowId )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_RightHandWeapon.LatencyInTicks = (uint16)form->getAttackLatency();
|
_RightHandWeapon.LatencyInTicks = (float)form->getAttackLatency();
|
||||||
_RightHandWeapon.Family = ITEMFAMILY::MELEE_WEAPON;
|
_RightHandWeapon.Family = ITEMFAMILY::MELEE_WEAPON;
|
||||||
_RightHandWeapon.Skill = BarehandCombatSkill;
|
_RightHandWeapon.Skill = BarehandCombatSkill;
|
||||||
_RightHandWeapon.DmgType = DMGTYPE::BLUNT;
|
_RightHandWeapon.DmgType = DMGTYPE::BLUNT;
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* do not forget to update the operator= if attributes change
|
/* do not forget to update the operator= if attributes change
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
uint16 LatencyInTicks;
|
float LatencyInTicks;
|
||||||
float Damage;
|
float Damage;
|
||||||
uint16 Quality;
|
uint16 Quality;
|
||||||
DMGTYPE::EDamageType DmgType;
|
DMGTYPE::EDamageType DmgType;
|
||||||
|
@ -111,7 +111,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
LatencyInTicks = 0;
|
LatencyInTicks = 0.0f;
|
||||||
Damage = 0;
|
Damage = 0;
|
||||||
Quality = 0;
|
Quality = 0;
|
||||||
DmgType = DMGTYPE::UNDEFINED;
|
DmgType = DMGTYPE::UNDEFINED;
|
||||||
|
|
|
@ -382,7 +382,7 @@ void CCombatPhrase::init()
|
||||||
_CriticalHit = false;
|
_CriticalHit = false;
|
||||||
|
|
||||||
_ExecutionEndDate = 0;
|
_ExecutionEndDate = 0;
|
||||||
_LatencyEndDate = 0;
|
_LatencyEndDate = 0.0f;
|
||||||
|
|
||||||
_SabrinaCost = 0;
|
_SabrinaCost = 0;
|
||||||
_SabrinaRelativeCost = 1.0f;
|
_SabrinaRelativeCost = 1.0f;
|
||||||
|
@ -892,7 +892,7 @@ bool CCombatPhrase::evaluate()
|
||||||
_NotEnoughStaminaMsg = false;
|
_NotEnoughStaminaMsg = false;
|
||||||
_NotEnoughHpMsg = false;
|
_NotEnoughHpMsg = false;
|
||||||
_DisengageOnEnd = false;
|
_DisengageOnEnd = false;
|
||||||
_LatencyEndDate = 0;
|
_LatencyEndDate = 0.0f;
|
||||||
_ExecutionEndDate = 0;
|
_ExecutionEndDate = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1702,7 +1702,7 @@ bool CCombatPhrase::launch()
|
||||||
{
|
{
|
||||||
H_AUTO(CCombatPhrase_launch);
|
H_AUTO(CCombatPhrase_launch);
|
||||||
|
|
||||||
_LatencyEndDate = 0;
|
_LatencyEndDate = 0.0f;
|
||||||
_ApplyDate = 0;
|
_ApplyDate = 0;
|
||||||
|
|
||||||
if ( !_Attacker )
|
if ( !_Attacker )
|
||||||
|
@ -1846,7 +1846,7 @@ bool CCombatPhrase::launch()
|
||||||
float latency;
|
float latency;
|
||||||
if(_LeftWeapon.LatencyInTicks != 0)
|
if(_LeftWeapon.LatencyInTicks != 0)
|
||||||
{
|
{
|
||||||
latency = float(_HitRateModifier + std::max( MinTwoWeaponsLatency.get(), std::max(_RightWeapon.LatencyInTicks, _LeftWeapon.LatencyInTicks)) + _Ammo.LatencyInTicks);
|
latency = float(_HitRateModifier + std::max( float(MinTwoWeaponsLatency.get()), std::max(_RightWeapon.LatencyInTicks, _LeftWeapon.LatencyInTicks)) + _Ammo.LatencyInTicks);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2177,8 +2177,15 @@ bool CCombatPhrase::launch()
|
||||||
|
|
||||||
// set latency end date
|
// set latency end date
|
||||||
const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();
|
const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();
|
||||||
_LatencyEndDate = time + (NLMISC::TGameCycle)latency;
|
if(_LatencyEndDate > 0)
|
||||||
|
{
|
||||||
|
_LatencyEndDate += latency;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_LatencyEndDate = (float)time + latency;
|
||||||
|
}
|
||||||
|
nlwarning("_LatencyEndDate : %f, latency: %f", _LatencyEndDate, latency);
|
||||||
// compute the apply date
|
// compute the apply date
|
||||||
if (_Targets[0].Target!=NULL && actingEntity->getEntityRowId() == _Targets[0].Target->getEntityRowId())
|
if (_Targets[0].Target!=NULL && actingEntity->getEntityRowId() == _Targets[0].Target->getEntityRowId())
|
||||||
{
|
{
|
||||||
|
@ -2322,8 +2329,8 @@ bool CCombatPhrase::launchAttack(CEntityBase * actingEntity, bool rightHand, boo
|
||||||
// now we use the weapon speed factor as a divisor of wear per action
|
// now we use the weapon speed factor as a divisor of wear per action
|
||||||
// (a weapon twice as fast will wear twice as slow)
|
// (a weapon twice as fast will wear twice as slow)
|
||||||
nlassert(ReferenceWeaponLatencyForWear > 0);
|
nlassert(ReferenceWeaponLatencyForWear > 0);
|
||||||
const uint16 latency = (rightHand ? _RightWeapon.LatencyInTicks : _LeftWeapon.LatencyInTicks);
|
const float latency = (rightHand ? _RightWeapon.LatencyInTicks : _LeftWeapon.LatencyInTicks);
|
||||||
const float wearFactor = (float)latency / (float)ReferenceWeaponLatencyForWear;
|
const float wearFactor = latency / (float)ReferenceWeaponLatencyForWear;
|
||||||
|
|
||||||
if (rightHand)
|
if (rightHand)
|
||||||
{
|
{
|
||||||
|
@ -3365,7 +3372,7 @@ void CCombatPhrase::stop()
|
||||||
CCharacter *character = PlayerManager.getChar(_Attacker->getEntityRowId());
|
CCharacter *character = PlayerManager.getChar(_Attacker->getEntityRowId());
|
||||||
if (character)
|
if (character)
|
||||||
{
|
{
|
||||||
character->dateOfNextAllowedAction( _LatencyEndDate );
|
character->dateOfNextAllowedAction((NLMISC::TGameCycle)_LatencyEndDate );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -716,7 +716,7 @@ void CFgProspectionPhrase::apply()
|
||||||
MBEHAV::CBehaviour behav = player->getBehaviour(); // keep arguments
|
MBEHAV::CBehaviour behav = player->getBehaviour(); // keep arguments
|
||||||
behav.Behaviour = MBEHAV::PROSPECTING_END;
|
behav.Behaviour = MBEHAV::PROSPECTING_END;
|
||||||
PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, behav );
|
PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, behav );
|
||||||
_LatencyEndDate = ForageSourceSpawnDelay.get(); // wait a short time before spawning the source(s) (to let animation/fx time)
|
_LatencyEndDate =(float)ForageSourceSpawnDelay.get(); // wait a short time before spawning the source(s) (to let animation/fx time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1566,9 +1566,9 @@ bool CMagicPhrase::launch()
|
||||||
// add post cast latency, only for non instant cast
|
// add post cast latency, only for non instant cast
|
||||||
const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();
|
const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();
|
||||||
if (_DivineInterventionOccured||_ShootAgainOccured?_BaseCastingTime:_CastingTime)
|
if (_DivineInterventionOccured||_ShootAgainOccured?_BaseCastingTime:_CastingTime)
|
||||||
_LatencyEndDate = time + PostCastLatency + _PostCastTime;
|
_LatencyEndDate = (float)time + PostCastLatency + _PostCastTime;
|
||||||
else
|
else
|
||||||
_LatencyEndDate = 0 + _PostCastTime;
|
_LatencyEndDate = 0.0f + _PostCastTime;
|
||||||
|
|
||||||
// compute the apply date
|
// compute the apply date
|
||||||
if ( !_Targets.empty() && _ActorRowId != _Targets[0].getId())
|
if ( !_Targets.empty() && _ActorRowId != _Targets[0].getId())
|
||||||
|
@ -1898,7 +1898,7 @@ void CMagicPhrase::enchantPhrase(CCharacter * user,float successFactor)
|
||||||
|
|
||||||
_Targets.resize(1);
|
_Targets.resize(1);
|
||||||
// user->setActionFlag( RYZOMACTIONFLAGS::Attacks, true );
|
// user->setActionFlag( RYZOMACTIONFLAGS::Attacks, true );
|
||||||
_LatencyEndDate = 0;//time + _HitRateModifier + weapon.LatencyInTicks + ammo.SpeedInTicks ;
|
_LatencyEndDate = 0.0f;//time + _HitRateModifier + weapon.LatencyInTicks + ammo.SpeedInTicks ;
|
||||||
// _BeingProcessed = false;
|
// _BeingProcessed = false;
|
||||||
|
|
||||||
} // enchantPhrase //
|
} // enchantPhrase //
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
_Idle = false;
|
_Idle = false;
|
||||||
_ExecutionEndDate = 0;
|
_ExecutionEndDate = 0;
|
||||||
_ApplyDate = ~0; // ensure apply() never called before launch()
|
_ApplyDate = ~0; // ensure apply() never called before launch()
|
||||||
_LatencyEndDate = 0; // by default, time between apply() and end() is immediate
|
_LatencyEndDate = 0.0f; // by default, time between apply() and end() is immediate
|
||||||
_PhraseBookIndex = 0;
|
_PhraseBookIndex = 0;
|
||||||
_NextCounter = 0;
|
_NextCounter = 0;
|
||||||
_IsStatic = false;
|
_IsStatic = false;
|
||||||
|
@ -98,7 +98,7 @@ public:
|
||||||
inline NLMISC::TGameCycle applyDate() const { return _ApplyDate; }
|
inline NLMISC::TGameCycle applyDate() const { return _ApplyDate; }
|
||||||
|
|
||||||
/// get latency end date
|
/// get latency end date
|
||||||
inline NLMISC::TGameCycle latencyEndDate() const { return _LatencyEndDate; }
|
inline float latencyEndDate() const { return _LatencyEndDate; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* build the phrase from bricks, actor and main target
|
* build the phrase from bricks, actor and main target
|
||||||
|
@ -207,7 +207,7 @@ protected:
|
||||||
/// apply date
|
/// apply date
|
||||||
NLMISC::TGameCycle _ApplyDate;
|
NLMISC::TGameCycle _ApplyDate;
|
||||||
/// latency end date
|
/// latency end date
|
||||||
NLMISC::TGameCycle _LatencyEndDate;
|
float _LatencyEndDate;
|
||||||
/// index in client phrase book (0 = not in the phrase book)
|
/// index in client phrase book (0 = not in the phrase book)
|
||||||
uint16 _PhraseBookIndex;
|
uint16 _PhraseBookIndex;
|
||||||
/// next counter
|
/// next counter
|
||||||
|
|
|
@ -758,7 +758,7 @@ bool CSpecialPowerPhrase::launch()
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
void CSpecialPowerPhrase::apply()
|
void CSpecialPowerPhrase::apply()
|
||||||
{
|
{
|
||||||
_LatencyEndDate = 0;
|
_LatencyEndDate = 0.0f;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// apply effect
|
// apply effect
|
||||||
|
|
|
@ -279,7 +279,7 @@ void CTimedActionPhrase::apply()
|
||||||
// keep a ptr on this to prevent it to be deleted when timed action is deconnection
|
// keep a ptr on this to prevent it to be deleted when timed action is deconnection
|
||||||
CSPhrasePtr selfPtr = this;
|
CSPhrasePtr selfPtr = this;
|
||||||
|
|
||||||
_LatencyEndDate = 0;
|
_LatencyEndDate = 0.0f;
|
||||||
|
|
||||||
CEntityBase *actor = CEntityBaseManager::getEntityBasePtr(_ActorRowId);
|
CEntityBase *actor = CEntityBaseManager::getEntityBasePtr(_ActorRowId);
|
||||||
if (!actor)
|
if (!actor)
|
||||||
|
|
Loading…
Reference in a new issue