@ -596,6 +596,8 @@ CCharacter::CCharacter(): CEntityBase(false),
_CurrentParryLevel = 1 ;
_BaseParryLevel = 1 ;
_BaseResistance = 1 ;
_SkillUsedForDodge = SKILLS : : SF ;
_CurrentParrySkill = BarehandCombatSkill ;
@ -671,6 +673,8 @@ CCharacter::CCharacter(): CEntityBase(false),
_CustomMissionsParams . clear ( ) ;
_FriendVisibility = VisibleToAll ;
initDatabase ( ) ;
} // CCharacter //
@ -1414,6 +1418,7 @@ uint32 CCharacter::tickUpdate()
}
}
bool updatePVP = false ;
{
H_AUTO ( CharacterUpdateOutpost ) ;
@ -1425,6 +1430,7 @@ uint32 CCharacter::tickUpdate()
{
stopOutpostLeavingTimer ( ) ;
setOutpostAlias ( 0 ) ;
updatePVP = true ;
}
CSmartPtr < COutpost > outpost = COutpostManager : : getInstance ( ) . getOutpostFromAlias ( outpostAlias ) ;
@ -1435,10 +1441,12 @@ uint32 CCharacter::tickUpdate()
{
stopOutpostLeavingTimer ( ) ;
setOutpostAlias ( 0 ) ;
updatePVP = true ;
}
else
{
outpost - > fillCharacterOutpostDB ( this ) ;
updatePVP = true ;
}
}
}
@ -1447,26 +1455,27 @@ uint32 CCharacter::tickUpdate()
{
H_AUTO ( CharacterUpdatePVPMode ) ;
if ( _PVPSafeLastTimeChange + 20 < CTickEventHandler : : getGameCycle ( ) )
if ( _PVPSafeLastTimeChange + 20 < CTickEventHandler : : getGameCycle ( ) | | updatePVP )
{
bool update = false ;
_PVPSafeLastTimeChange = CTickEventHandler : : getGameCycle ( ) ;
if ( _PVPSafeLastTime ! = getSafeInPvPSafeZone ( ) )
{
_PVPSafeLastTime = ! _PVPSafeLastTime ;
update = true ;
update PVP = true ;
}
if ( _PVPInSafeZoneLastTime ! = CPVPManager2 : : getInstance ( ) - > inSafeZone ( getPosition ( ) ) )
{
_PVPInSafeZoneLastTime = ! _PVPInSafeZoneLastTime ;
update = true ;
update PVP = true ;
}
if ( update ) {
if ( updatePVP )
{
CPVPManager2 : : getInstance ( ) - > setPVPModeInMirror ( this ) ;
updatePVPClanVP ( ) ;
_HaveToUpdatePVPMode = false ;
}
}
@ -1484,7 +1493,7 @@ uint32 CCharacter::tickUpdate()
if ( getPvPRecentActionFlag ( ) = = false )
{
CMirrorPropValue < TYPE_ PVP_MODE > propPvpMode ( TheDataset , TheDataset . getDataSetRow ( _Id ) , DSProperty PVP_MODE ) ;
CMirrorPropValue < TYPE_ EVENT_FACTION_ID > propPvpMode ( TheDataset , TheDataset . getDataSetRow ( _Id ) , DSProperty EVENT_FACTION_ID ) ;
if ( propPvpMode . getValue ( ) & PVP_MODE : : PvpFactionFlagged )
{
CPVPManager2 : : getInstance ( ) - > setPVPModeInMirror ( this ) ;
@ -1721,6 +1730,8 @@ void CCharacter::deathOccurs( void )
CPVPManager2 : : getInstance ( ) - > playerDies ( this ) ;
CBuildingManager : : getInstance ( ) - > removeTriggerRequest ( getEntityRowId ( ) ) ;
if ( _TimeDeath < CTickEventHandler : : getGameTime ( ) )
{
if ( _Mode . getValue ( ) . Mode = = MBEHAV : : DEATH )
@ -2878,14 +2889,7 @@ void CCharacter::postLoadTreatment()
{
tickets [ slot ] = true ;
// init pet inventory
const uint32 petMaxWeight = 0xFFFFFFFF ; // no weight limit
const uint32 petMaxBulk = _PlayerPets [ i ] . getAnimalMaxBulk ( ) ;
const INVENTORIES : : TInventory petInvId = ( INVENTORIES : : TInventory ) ( i + INVENTORIES : : pet_animal ) ;
CPetInventory * petInventory = dynamic_cast < CPetInventory * > ( ( CInventoryBase * ) _Inventory [ petInvId ] ) ;
if ( petInventory )
petInventory - > initPetInventory ( i , petMaxWeight , petMaxBulk ) ;
initPetInventory ( i ) ;
}
}
}
@ -3000,6 +3004,13 @@ void CCharacter::postLoadTreatment()
computeMiscBonus ( ) ;
}
CPlayer * p = PlayerManager . getPlayer ( PlayerManager . getPlayerId ( getId ( ) ) ) ;
if ( ! p - > isTrialPlayer ( ) )
{
CBankAccessor_PLR : : getCHARACTER_INFO ( ) . getRING_XP_CATALYSER ( ) . setLevel ( _PropertyDatabase , 250 ) ;
CBankAccessor_PLR : : getCHARACTER_INFO ( ) . getRING_XP_CATALYSER ( ) . setCount ( _PropertyDatabase , 999 ) ;
}
{
H_AUTO ( CItemServiceManager ) ;
CItemServiceManager : : getInstance ( ) - > initPersistentServices ( this ) ;
@ -5200,15 +5211,10 @@ bool CCharacter::addCharacterAnimal( const CSheetId& PetTicket, uint32 Price, CG
pet . Slot = ptr - > getInventorySlot ( ) ;
// init pet inventory
const uint32 petMaxWeight = 0xFFFFFFFF ; // no weight limit
const uint32 petMaxBulk = _PlayerPets [ i ] . getAnimalMaxBulk ( ) ;
const INVENTORIES : : TInventory petInvId = ( INVENTORIES : : TInventory ) ( i + INVENTORIES : : pet_animal ) ;
CPetInventory * petInventory = dynamic_cast < CPetInventory * > ( ( CInventoryBase * ) _Inventory [ petInvId ] ) ;
if ( petInventory )
petInventory - > initPetInventory ( i , petMaxWeight , petMaxBulk ) ;
else
if ( ! initPetInventory ( i ) )
{
return false ;
}
return spawnCharacterAnimal ( i ) ;
}
@ -6356,7 +6362,7 @@ void CCharacter::removePetCharacterAfterDeath( uint32 index )
{
TLogContext_Item_PetDespawn logContext ( _Id ) ;
// pet founded
if ( index < MAX_ PACK _ANIMAL )
if ( index < MAX_ INVENTORY _ANIMAL )
{
// reset despawn timer
// _PropertyDatabase.setProp( _DataIndexReminder->PACK_ANIMAL.BEAST[index].DESPAWN, 0 );
@ -6766,12 +6772,15 @@ void CCharacter::setAnimalName( uint8 petIndex, ucstring customName )
animal . setCustomName ( customName ) ;
sendPetCustomNameToClient ( petIndex ) ;
if ( ! customName . empty ( ) )
{
TDataSetRow row = animal . SpawnedPets ;
NLNET : : CMessage msgout ( " CHARACTER_NAME " ) ;
msgout . serial ( row ) ;
msgout . serial ( customName ) ;
sendMessageViaMirror ( " IOS " , msgout ) ;
}
}
//-----------------------------------------------------------------------------
void CCharacter : : sendPetCustomNameToClient ( uint8 petIndex )
@ -6932,7 +6941,10 @@ double CCharacter::addXpToSkillInternal( double XpGain, const std::string& ContS
uint32 ringCatalyserLvl = 0 ;
uint32 ringCatalyserCount = 0 ;
if ( addXpMode ! = AddXpToSkillBranch )
// Don't take away cats if free trial limit reached and there is no DP.
bool bConsumeCats = ! ( bFreeTrialLimitReached & & _DeathPenalties - > isNull ( ) ) ;
if ( bConsumeCats & & ( addXpMode ! = AddXpToSkillBranch ) )
{
if ( _XpCatalyserSlot ! = INVENTORIES : : INVALID_INVENTORY_SLOT )
{
@ -6952,6 +6964,12 @@ double CCharacter::addXpToSkillInternal( double XpGain, const std::string& ContS
}
}
}
if ( ! p - > isTrialPlayer ( ) )
{
xpBonus = XpGain ;
}
XpGain + = xpBonus + ringXpBonus ;
// update death penalty
@ -8869,7 +8887,7 @@ void CCharacter::setDatabase()
_IneffectiveAuras . activate ( ) ;
_ConsumableOverdoseEndDates . activate ( ) ;
// init the RRPs
//RingRewar s dPoints.initDb();
//RingRewar dPoints.initDb();
} // setDatabase //
@ -8931,7 +8949,8 @@ void CCharacter::startTradeItemSession( uint16 session )
nlwarning ( " fame %u is INVALID " , ( uint ) bot - > getRace ( ) ) ;
fame = MinFameToTrade ;
}
else if ( fame < MinFameToTrade & & bot - > getOrganization ( ) ! = getOrganization ( ) )
if ( ( bot - > getOrganization ( ) = = 0 & & fame < MinFameToTrade ) | | ( bot - > getOrganization ( ) ! = 0 & & bot - > getOrganization ( ) ! = getOrganization ( ) ) )
{
SM_STATIC_PARAMS_1 ( params , STRING_MANAGER : : bot ) ;
params [ 0 ] . setEIdAIAlias ( _CurrentInterlocutor , CAIAliasTranslator : : getInstance ( ) - > getAIAlias ( _CurrentInterlocutor ) ) ;
@ -8939,6 +8958,9 @@ void CCharacter::startTradeItemSession( uint16 session )
npcTellToPlayerEx ( bot - > getEntityRowId ( ) , _EntityRowId , txt ) ;
return ;
}
else if ( bot - > getOrganization ( ) ! = 0 & & bot - > getOrganization ( ) = = getOrganization ( ) )
fame = 0 ;
float fameFactor = 1.0f ;
if ( bot - > getForm ( ) - > getFaction ( ) ! = CStaticFames : : INVALID_FACTION_INDEX )
@ -9036,7 +9058,8 @@ void CCharacter::startTradePhrases(uint16 session)
{
nlwarning ( " fame %u is INVALID " , ( uint ) bot - > getRace ( ) ) ;
}
if ( fame < MinFameToTrade & & bot - > getOrganization ( ) ! = getOrganization ( ) )
if ( ( bot - > getOrganization ( ) = = 0 & & fame < MinFameToTrade ) | | ( bot - > getOrganization ( ) ! = 0 & & bot - > getOrganization ( ) ! = getOrganization ( ) ) )
{
SM_STATIC_PARAMS_1 ( params , STRING_MANAGER : : bot ) ;
params [ 0 ] . setEIdAIAlias ( _CurrentInterlocutor , CAIAliasTranslator : : getInstance ( ) - > getAIAlias ( _CurrentInterlocutor ) ) ;
@ -9045,7 +9068,6 @@ void CCharacter::startTradePhrases(uint16 session)
return ;
}
// *** Set right rolemaster flags and race in Database
uint8 flags = 0 ;
if ( bot - > isSellingCharacteristics ( ) )
@ -9806,7 +9828,8 @@ void CCharacter::sellItem( INVENTORIES::TInventory inv, uint32 slot, uint32 quan
nlwarning ( " fame %u is INVALID " , ( uint ) bot - > getRace ( ) ) ;
fame = MinFameToTrade ;
}
else if ( fame < MinFameToTrade & & bot - > getOrganization ( ) ! = getOrganization ( ) )
if ( ( bot - > getOrganization ( ) = = 0 & & fame < MinFameToTrade ) | | ( bot - > getOrganization ( ) ! = 0 & & bot - > getOrganization ( ) ! = getOrganization ( ) ) )
{
SM_STATIC_PARAMS_1 ( params , STRING_MANAGER : : bot ) ;
params [ 0 ] . setEIdAIAlias ( _CurrentInterlocutor , CAIAliasTranslator : : getInstance ( ) - > getAIAlias ( _CurrentInterlocutor ) ) ;
@ -9818,6 +9841,8 @@ void CCharacter::sellItem( INVENTORIES::TInventory inv, uint32 slot, uint32 quan
return ;
}
else if ( bot - > getOrganization ( ) ! = 0 & & bot - > getOrganization ( ) = = getOrganization ( ) )
fame = 0 ;
CInventoryPtr child = _Inventory [ inv ] ;
if ( child - > getSlotCount ( ) > slot & & child - > getItem ( slot ) ! = NULL )
@ -9853,6 +9878,13 @@ void CCharacter::sellItem( INVENTORIES::TInventory inv, uint32 slot, uint32 quan
return ;
}
// You cannot exchange genesis named items
if ( item - > getPhraseId ( ) . find ( " genesis_ " ) = = 0 )
{
nlwarning ( " Character %s tries to sell '%s' " , _Id . toString ( ) . c_str ( ) , item - > getPhraseId ( ) . c_str ( ) ) ;
return ;
}
if ( ! ITEMFAMILY : : isSellableByPlayer ( itemForm - > Family ) )
{
nlwarning ( " <CCharacter sellItem> character %s try to sell an unsealable item %s, must not permited by client " , _Id . toString ( ) . c_str ( ) , sheet . toString ( ) . c_str ( ) ) ;
@ -10206,7 +10238,7 @@ void CCharacter::setOrganizationStatus(uint32 status)
//-----------------------------------------------------------------------------
void CCharacter : : changeOrganizationStatus ( sint32 status )
{
if ( status < 0 & & abs ( status ) > _OrganizationStatus )
if ( status < 0 & & abs ( status ) > ( sint32 ) _OrganizationStatus )
_OrganizationStatus = 0 ;
else
_OrganizationStatus + = status ;
@ -10216,7 +10248,7 @@ void CCharacter::changeOrganizationStatus(sint32 status)
//-----------------------------------------------------------------------------
void CCharacter : : changeOrganizationPoints ( sint32 points )
{
if ( points < 0 & & abs ( points ) > _OrganizationPoints )
if ( points < 0 & & abs ( points ) > ( sint32 ) _OrganizationPoints )
_OrganizationPoints = 0 ;
else
_OrganizationPoints + = points ;
@ -11161,14 +11193,14 @@ bool CCharacter::validateExchange()
sint32 ticketDelta = c - > _ExchangeView - > getPetTicketExchanged ( ITEM_TYPE : : MEKTOUB_PACKER_TICKET ) - _ExchangeView - > getPetTicketExchanged ( ITEM_TYPE : : MEKTOUB_PACKER_TICKET ) ;
if ( ! checkAnimalCount ( packerSheet , false , ticketDelta ) )
{
sendDynamicSystemMessage ( getId ( ) , " ANIMAL_PLAYER_HAVE_MAX () " ) ;
sendDynamicSystemMessage ( getId ( ) , " ANIMAL_PLAYER_HAVE_MAX " ) ;
c - > sendDynamicSystemMessage ( c - > getId ( ) , " ANIMAL_INTERLOCUTOR_HAVE_MAX " ) ;
invalidateExchange ( ) ;
return false ;
}
if ( ! c - > checkAnimalCount ( packerSheet , false , - ticketDelta ) )
{
c - > sendDynamicSystemMessage ( getId ( ) , " ANIMAL_PLAYER_HAVE_MAX () " ) ;
c - > sendDynamicSystemMessage ( getId ( ) , " ANIMAL_PLAYER_HAVE_MAX " ) ;
sendDynamicSystemMessage ( c - > getId ( ) , " ANIMAL_INTERLOCUTOR_HAVE_MAX " ) ;
invalidateExchange ( ) ;
return false ;
@ -11180,14 +11212,14 @@ bool CCharacter::validateExchange()
sint32 ticketDelta = c - > _ExchangeView - > getPetTicketExchanged ( ITEM_TYPE : : MEKTOUB_MOUNT_TICKET ) - _ExchangeView - > getPetTicketExchanged ( ITEM_TYPE : : MEKTOUB_MOUNT_TICKET ) ;
if ( ! checkAnimalCount ( mountSheet , false , ticketDelta ) )
{
sendDynamicSystemMessage ( getId ( ) , " ANIMAL_PLAYER_HAVE_MAX () " ) ;
sendDynamicSystemMessage ( getId ( ) , " ANIMAL_PLAYER_HAVE_MAX " ) ;
c - > sendDynamicSystemMessage ( c - > getId ( ) , " ANIMAL_INTERLOCUTOR_HAVE_MAX " ) ;
invalidateExchange ( ) ;
return false ;
}
if ( ! c - > checkAnimalCount ( mountSheet , false , - ticketDelta ) )
{
c - > sendDynamicSystemMessage ( getId ( ) , " ANIMAL_PLAYER_HAVE_MAX () " ) ;
c - > sendDynamicSystemMessage ( getId ( ) , " ANIMAL_PLAYER_HAVE_MAX " ) ;
sendDynamicSystemMessage ( c - > getId ( ) , " ANIMAL_INTERLOCUTOR_HAVE_MAX " ) ;
invalidateExchange ( ) ;
return false ;
@ -11285,21 +11317,23 @@ void CCharacter::removeExchangeItems(vector<CGameItemPtr >& itemRemoved, vector<
// addExchangeItems
//
//-----------------------------------------------
void CCharacter : : addExchangeItems ( CCharacter * trader , vector < CGameItemPtr > & itemToAdd , vector < CPetAnimal > & playerPetsAdd )
void CCharacter : : addExchangeItems ( CCharacter * trader , vector < CGameItemPtr > & itemToAdd , vector < CPetAnimal > & playerPetsAdd ed )
{
// inform AI
CPetSetOwner msgAI ;
bool updatePetDataBase = false ;
for ( uint32 p = 0 ; p < playerPetsAdd . size ( ) ; + + p )
for ( uint32 p = 0 ; p < playerPetsAdd ed . size ( ) ; + + p )
{
sint32 i = getFreePetSlot ( ) ;
if ( i > = 0 )
{
_PlayerPets [ i ] = playerPetsAdd [ p ] ;
_PlayerPets [ i ] = playerPetsAdd ed [ p ] ;
_PlayerPets [ i ] . OwnerId = _Id ;
initPetInventory ( i ) ;
if ( _PlayerPets [ i ] . PetStatus = = CPetAnimal : : waiting_spawn )
{
spawnCharacterAnimal ( i ) ;
@ -13567,7 +13601,7 @@ void CCharacter::sendUrl(const string &url, const string &salt)
if ( ! salt . empty ( ) )
{
string checksum = salt + url ;
control = " &hmac= " + getHMacSHA1 ( ( uint8 * ) & url [ 0 ] , ( uint32 ) url . size ( ) , ( uint8 * ) & salt [ 0 ] , ( uint32 ) salt . size ( ) ) . toString ( ) ; ;
control = " &hmac= " + getHMacSHA1 ( ( uint8 * ) & url [ 0 ] , ( uint32 ) url . size ( ) , ( uint8 * ) & salt [ 0 ] , ( uint32 ) salt . size ( ) ) . toString ( ) ;
}
nlinfo ( url . c_str ( ) ) ;
@ -14309,16 +14343,14 @@ void CCharacter::setAuraFlagDates()
const NLMISC : : TGameCycle time = CTickEventHandler : : getGameCycle ( ) ;
uint32 flag = BRICK_FLAGS : : Aura - BRICK_FLAGS : : BeginPowerFlags ;
if ( ( _ForbidAuraUseEndDate > time ) & & ( _ForbidAuraUseEndDate - time < 72000 ) )
if ( ( _ForbidAuraUseEndDate < time ) | | ( _ForbidAuraUseEndDate - time > 72000 ) )
{
_ForbidAuraUseStartDate = 0 ;
_ForbidAuraUseEndDate = 0 ;
}
_PowerFlagTicks [ flag ] . StartTick = _ForbidAuraUseStartDate ;
_PowerFlagTicks [ flag ] . EndTick = _ForbidAuraUseEndDate ;
}
else
{
_PowerFlagTicks [ flag ] . StartTick = 0 ;
_PowerFlagTicks [ flag ] . EndTick = 0 ;
}
} // setAuraFlagDates //
@ -14605,28 +14637,32 @@ uint32 CCharacter::getCarriedWeight()
}
//--------------------------------------------------------------
// CCharacter::getResistScore()
// CCharacter::getMagicResistance()
//--------------------------------------------------------------
uint32 CCharacter : : getMagicResistance ( RESISTANCE_TYPE : : TResistanceType magicResistanceType ) const
{
uint32 val = getUnclampedMagicResistance ( magicResistanceType ) ;
NLMISC : : clamp ( val , ( uint32 ) 0 , ( uint32 ) ( ( _BaseResistance + MaxMagicResistanceBonus ) * 100 ) ) ;
return val ;
}
//--------------------------------------------------------------
// CCharacter::getMagicResistance()
//--------------------------------------------------------------
uint32 CCharacter : : getMagicResistance ( EFFECT_FAMILIES : : TEffectFamily effectFamily )
{
RESISTANCE_TYPE : : TResistanceType resistanceType = EFFECT_FAMILIES : : getAssociatedResistanceType ( effectFamily ) ;
if ( resistanceType = = RESISTANCE_TYPE : : None )
return 0 ;
else
return _MagicResistance [ resistanceType ] ;
} // getResistScore //
return getMagicResistance ( resistanceType ) ;
}
//--------------------------------------------------------------
// CCharacter::get ResistScor e()
// CCharacter::getMagicResistance()
//--------------------------------------------------------------
uint32 CCharacter : : getMagicResistance ( DMGTYPE : : EDamageType dmgType )
{
RESISTANCE_TYPE : : TResistanceType resistanceType = DMGTYPE : : getAssociatedResistanceType ( dmgType ) ;
if ( resistanceType = = RESISTANCE_TYPE : : None )
return 0 ;
else
return _MagicResistance [ resistanceType ] ;
} // getResistScore //
return getMagicResistance ( resistanceType ) ;
}
//--------------------------------------------------------------
// addPlayerToFriendList
@ -14650,20 +14686,52 @@ void CCharacter::addPlayerToIgnoreList(const ucstring &name)
TCharConnectionState CCharacter : : isFriendCharVisualyOnline ( const NLMISC : : CEntityId & friendId )
{
TCharConnectionState ret = ccs_offline ;
if ( CEntityIdTranslator : : getInstance ( ) - > isEntityOnline ( friendId ) )
{
if ( PlayerManager . hasBetterCSRGrade ( friendId , _Id , true ) )
{
// better CSR grade return always 'offline' status
return ccs_offline ;
}
ret = ccs_online ;
}
// Handle friend preference setting
CCharacter * friendChar = PlayerManager . getChar ( friendId ) ;
if ( friendChar ! = NULL )
{
volatile TFriendVisibility friendMode = friendChar - > getFriendVisibility ( ) ;
switch ( friendMode )
{
case VisibleToGuildOnly :
{
uint32 fgid = friendChar - > getGuildId ( ) ;
uint32 mgid = this - > getGuildId ( ) ;
bool inSameGuild = ( mgid ! = 0 ) & & ( fgid = = mgid ) ;
if ( ! inSameGuild )
{
return ccs_offline ;
}
}
break ;
case VisibleToGuildAndFriends :
if ( this - > isIgnoredBy ( friendId ) )
{
return ccs_offline ;
}
break ;
case VisibleToAll : // fallthrough
default :
break ; // no-op
}
}
// Additional online check for ring shard :
// - a contact is online only if it is in the same ring session
if ( ret = = ccs_online & & IsRingShard )
{
CCharacter * friendChar = PlayerManager . getChar ( friendId ) ;
if ( friendChar = = NULL ) // not found ! set offline
ret = ccs_offline ;
else
@ -14849,7 +14917,7 @@ void CCharacter::addPlayerToFriendList(const NLMISC::CEntityId &id)
// if player not found
if ( id = = CEntityId : : Unknown )
{
PHRASE_UTILITIES : : sendDynamicSystemMessage ( _EntityRowId , " OPERATION_ OFFLINE " ) ;
PHRASE_UTILITIES : : sendDynamicSystemMessage ( _EntityRowId , " OPERATION_ NOTEXIST " ) ;
return ;
}
@ -14921,12 +14989,12 @@ void CCharacter::addPlayerToLeagueList(const NLMISC::CEntityId &id)
// if player not found
if ( id = = CEntityId : : Unknown )
{
PHRASE_UTILITIES : : sendDynamicSystemMessage ( _EntityRowId , " OPERATION_ OFFLINE " ) ;
PHRASE_UTILITIES : : sendDynamicSystemMessage ( _EntityRowId , " OPERATION_ NOTEXIST " ) ;
return ;
}
// check not already in list
const uint size = _LeagueList . size ( ) ;
const uint size = ( uint ) _LeagueList . size ( ) ;
for ( uint i = 0 ; i < size ; + + i )
{
if ( _LeagueList [ i ] . EntityId . getShortId ( ) = = id . getShortId ( ) )
@ -14990,14 +15058,12 @@ void CCharacter::addPlayerToLeagueList(const NLMISC::CEntityId &id)
//--------------------------------------------------------------
void CCharacter : : addPlayerToIgnoreList ( const NLMISC : : CEntityId & id )
{
// if player not found
// Boris 2006-09-19 : allow adding offline player to ignore list
// if (id == CEntityId::Unknown || PlayerManager.getChar(id)==NULL)
// {
// // player not found => message
// PHRASE_UTILITIES::sendDynamicSystemMessage( _EntityRowId, "OPERATION_OFFLINE");
// return;
// }
if ( id = = CEntityId : : Unknown )
{
// player not found => message
PHRASE_UTILITIES : : sendDynamicSystemMessage ( _EntityRowId , " OPERATION_NOTEXIST " ) ;
return ;
}
// check not already ignored
const uint size = ( uint ) _IgnoreList . size ( ) ;
@ -15416,25 +15482,50 @@ void CCharacter::contactListRefChange(const NLMISC::CEntityId &id, TConctactList
}
//--------------------------------------------------------------
// CCharacter::isIgnoredBy()
//--------------------------------------------------------------
bool CCharacter : : isIgnoredBy ( const NLMISC : : CEntityId & id )
{
const uint size = ( uint ) _IsIgnoredBy . size ( ) ;
for ( uint i = 0 ; i < size ; + + i )
{
if ( _IsIgnoredBy [ i ] . getShortId ( ) = = id . getShortId ( ) )
{
return true ;
}
}
return false ;
}
//--------------------------------------------------------------
// CCharacter::referencedAsFriendBy()
// CCharacter:: isFriendOf ()
//--------------------------------------------------------------
void CCharacter : : referencedAsFriendBy ( const NLMISC : : CEntityId & id )
bool CCharacter : : isFriendOf ( const NLMISC : : CEntityId & id )
{
// check this entity isn't already in the list
const uint size = ( uint ) _IsFriendOf . size ( ) ;
for ( uint i = 0 ; i < size ; + + i )
{
if ( _IsFriendOf [ i ] . getShortId ( ) = = id . getShortId ( ) )
{
return ;
return true ;
}
}
return false ;
}
//--------------------------------------------------------------
// CCharacter::referencedAsFriendBy()
//--------------------------------------------------------------
void CCharacter : : referencedAsFriendBy ( const NLMISC : : CEntityId & id )
{
if ( isFriendOf ( id ) )
{
return ;
}
// not found -> add it
_IsFriendOf . push_back ( id ) ;
}
//--------------------------------------------------------------
@ -17454,6 +17545,18 @@ void CCharacter::pvpActionMade()
//-----------------------------------------------------------------------------
void CCharacter : : setPVPFlagDatabase ( )
{
// Fix for when negative ticks were saved
if ( ( _PVPRecentActionTime > CTickEventHandler : : getGameCycle ( ) )
| | ( _PVPFlagLastTimeChange > CTickEventHandler : : getGameCycle ( ) )
| | ( _PVPFlagTimeSettedOn > CTickEventHandler : : getGameCycle ( ) + TimeForSetPVPFlag ) )
{
_PVPRecentActionTime = 0 ;
_PVPFlagLastTimeChange = 0 ;
_PVPFlagTimeSettedOn = 0 ;
_PVPSafeLastTimeChange = 0 ;
_PVPFlag = false ;
}
uint32 activationTime ;
if ( _PVPFlag = = true )
activationTime = _PVPFlagLastTimeChange + TimeForSetPVPFlag ;
@ -17788,6 +17891,7 @@ void CCharacter::setOutpostAlias( uint32 id )
CBankAccessor_PLR : : getCHARACTER_INFO ( ) . getPVP_OUTPOST ( ) . setRIGHT_TO_BANISH ( _PropertyDatabase , hasRightToBanish ) ;
CPVPManager2 : : getInstance ( ) - > setPVPModeInMirror ( this ) ;
updatePVPClanVP ( ) ;
}
//-----------------------------------------------------------------------------
@ -18539,48 +18643,49 @@ void CCharacter::updateMagicProtectionAndResistance()
_MaxAbsorption = ( getSkillBaseValue ( getBestSkill ( ) ) * MaxAbsorptionFactor ) / 100 ;
// magic resistance
sint32 baseResistance = ( sint32 ) ( _Skills . _Skills [ SKILLS : : SF ] . MaxLvlReached * MagicResistFactorForCombatSkills ) + MagicResistSkillDelta ;
if ( baseResistance < ( ( sint32 ) ( _Skills . _Skills [ SKILLS : : SM ] . MaxLvlReached * MagicResistFactorForMagicSkills ) + MagicResistSkillDelta ) )
baseResistance = ( sint32 ) ( _Skills . _Skills [ SKILLS : : SM ] . MaxLvlReached * MagicResistFactorForMagicSkills ) + MagicResistSkillDelta ;
if ( baseResistance < ( ( sint32 ) ( _Skills . _Skills [ SKILLS : : SH ] . MaxLvlReached * MagicResistFactorForForageSkills ) + MagicResistSkillDelta ) )
baseResistance = ( sint32 ) ( _Skills . _Skills [ SKILLS : : SH ] . MaxLvlReached * MagicResistFactorForForageSkills ) + MagicResistSkillDelta ;
clamp ( baseResistance , 0 , 225 ) ;
_BaseResistance = ( sint32 ) ( _Skills . _Skills [ SKILLS : : SF ] . MaxLvlReached * MagicResistFactorForCombatSkills ) + MagicResistSkillDelta ;
sint32 magicResist = ( ( sint32 ) ( _Skills . _Skills [ SKILLS : : SM ] . MaxLvlReached * MagicResistFactorForMagicSkills ) + MagicResistSkillDelta ) ;
_BaseResistance = max ( _BaseResistance , magicResist ) ;
sint32 forageResist = ( ( sint32 ) ( _Skills . _Skills [ SKILLS : : SH ] . MaxLvlReached * MagicResistFactorForForageSkills ) + MagicResistSkillDelta ) ;
_BaseResistance = max ( _BaseResistance , forageResist ) ;
clamp ( _BaseResistance , 0 , 225 ) ;
// set up base
for ( uint32 i = 0 ; i < RESISTANCE_TYPE : : NB_RESISTANCE_TYPE ; + + i )
{
_MagicResistance [ i ] = ( uint32 ) baseResistance * 100 ;
_MagicResistance [ i ] = ( uint32 ) _BaseResistance * 100 ;
}
switch ( i )
{
case RESISTANCE_TYPE : : Desert :
if ( _Race = = EGSPD : : CPeople : : Fyros )
// correct for race
switch ( _Race )
{
_MagicResistance [ i ] + = HominRacialResistance * 100 ;
}
case EGSPD : : CPeople : : Fyros :
_MagicResistance [ RESISTANCE_TYPE : : Desert ] + = HominRacialResistance * 100 ;
break ;
case RESISTANCE_TYPE : : Forest :
if ( _Race = = EGSPD : : CPeople : : Matis )
{
_MagicResistance [ i ] + = HominRacialResistance * 100 ;
}
case EGSPD : : CPeople : : Matis :
_MagicResistance [ RESISTANCE_TYPE : : Forest ] + = HominRacialResistance * 100 ;
break ;
case RESISTANCE_TYPE : : Lacustre :
if ( _Race = = EGSPD : : CPeople : : Tryker )
{
_MagicResistance [ i ] + = HominRacialResistance * 100 ;
}
case EGSPD : : CPeople : : Tryker :
_MagicResistance [ RESISTANCE_TYPE : : Lacustre ] + = HominRacialResistance * 100 ;
break ;
case RESISTANCE_TYPE : : Jungle :
if ( _Race = = EGSPD : : CPeople : : Zorai )
{
_MagicResistance [ i ] + = HominRacialResistance * 100 ;
}
case EGSPD : : CPeople : : Zorai :
_MagicResistance [ RESISTANCE_TYPE : : Jungle ] + = HominRacialResistance * 100 ;
break ;
default :
break ;
}
// correct for current region
for ( uint32 i = 0 ; i < RESISTANCE_TYPE : : NB_RESISTANCE_TYPE ; + + i )
{
_MagicResistance [ i ] = ( uint32 ) ( ( sint32 ) max ( ( sint32 ) 0 , ( ( sint32 ) _MagicResistance [ i ] ) + getRegionResistanceModifier ( ( RESISTANCE_TYPE : : TResistanceType ) i ) * ( sint32 ) 100 ) ) ;
clamp ( _MagicResistance [ i ] , ( uint32 ) 0 , ( uint32 ) ( ( baseResistance + MaxMagicResistanceBonus ) * 100 ) ) ;
}
// protection
@ -18663,7 +18768,7 @@ void CCharacter::updateMagicProtectionAndResistance()
for ( uint i = 0 ; i < RESISTANCE_TYPE : : NB_RESISTANCE_TYPE ; + + i )
{
CBankAccessor_PLR : : getCHARACTER_INFO ( ) . getMAGIC_RESISTANCE ( ) . getArray ( i ) . setVALUE ( _PropertyDatabase , checkedCast < uint16 > ( _MagicResistance[ i ] ) ) ;
CBankAccessor_PLR : : getCHARACTER_INFO ( ) . getMAGIC_RESISTANCE ( ) . getArray ( i ) . setVALUE ( _PropertyDatabase , checkedCast < uint16 > ( getUnclampedMagicResistance( ( RESISTANCE_TYPE : : TResistanceType ) i ) ) ) ;
}
// _PropertyDatabase.setProp("CHARACTER_INFO:MAGIC_RESISTANCE:Desert", _MagicResistance[RESISTANCE_TYPE::Desert]);
// _PropertyDatabase.setProp("CHARACTER_INFO:MAGIC_RESISTANCE:Forest", _MagicResistance[RESISTANCE_TYPE::Forest]);
@ -20120,7 +20225,9 @@ void CCharacter::setEnterCriticalZoneProposalQueueId(uint32 queueId)
uint32 CCharacter : : getMagicProtection ( PROTECTION_TYPE : : TProtectionType magicProtectionType ) const
{
uint32 val = getUnclampedMagicProtection ( magicProtectionType ) ; NLMISC : : clamp ( val , ( uint32 ) 0 , MaxMagicProtection ) ; return val ;
uint32 val = getUnclampedMagicProtection ( magicProtectionType ) ;
NLMISC : : clamp ( val , ( uint32 ) 0 , MaxMagicProtection ) ;
return val ;
}
@ -20612,3 +20719,21 @@ void CCharacter::sendNpcMissionGiverTimer(bool force)
CUnifiedNetwork : : getInstance ( ) - > send ( NLNET : : TServiceId ( _Id . getDynamicId ( ) ) , msgout ) ;
}
}
//------------------------------------------------------------------------------
bool CCharacter : : initPetInventory ( uint8 index )
{
// init pet inventory
const uint32 petMaxWeight = 0xFFFFFFFF ; // no weight limit
const uint32 petMaxBulk = _PlayerPets [ index ] . getAnimalMaxBulk ( ) ;
const INVENTORIES : : TInventory petInvId = ( INVENTORIES : : TInventory ) ( index + INVENTORIES : : pet_animal ) ;
CPetInventory * petInventory = dynamic_cast < CPetInventory * > ( ( CInventoryBase * ) _Inventory [ petInvId ] ) ;
if ( petInventory )
{
petInventory - > initPetInventory ( index , petMaxWeight , petMaxBulk ) ;
return true ;
}
return false ;
}