Merge branch 'outpost_refactoring'

feature/prepare-cross-merge
Nuno 4 years ago committed by kaetemi
parent 796582e235
commit c2fa3133b9
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -76,6 +76,8 @@ static uint32 const hours = 60*minutes;
static uint32 const days = 24*hours; static uint32 const days = 24*hours;
CVariable<uint32> OutpostFightRoundCount("egs","OutpostFightRoundCount","number of rounds in an outpost fight", 24, 0, true); CVariable<uint32> OutpostFightRoundCount("egs","OutpostFightRoundCount","number of rounds in an outpost fight", 24, 0, true);
CVariable<uint32> OutpostInTestFightRoundCount("egs","OutpostInTestFightRoundCount","number of rounds in an outpost (in test) fight", 11, 0, true);
CVariable<float> OutpostInTestFightSquadCount("egs", "OutpostInTestFightSquadCount", "Coef for squad count per round", 1.2f, 0, true );
CVariable<uint32> OutpostFightRoundTime("egs","OutpostFightRoundTime","time of a round in an outpost fight, in seconds", 5*minutes, 0, true); CVariable<uint32> OutpostFightRoundTime("egs","OutpostFightRoundTime","time of a round in an outpost fight, in seconds", 5*minutes, 0, true);
CVariable<uint32> OutpostLevelDecrementTime("egs","OutpostLevelDecrementTime","time to decrement an outpost level in seconds (in peace time)", 2*days, 0, true); CVariable<uint32> OutpostLevelDecrementTime("egs","OutpostLevelDecrementTime","time to decrement an outpost level in seconds (in peace time)", 2*days, 0, true);
CVariable<uint32> OutpostEditingConcurrencyCheckDelay("egs", "OutpostEditingConcurrencyCheckDelay", "delay in ticks used to check if 2 actions for editing an outpost are concurrent", 50, 0, true ); CVariable<uint32> OutpostEditingConcurrencyCheckDelay("egs", "OutpostEditingConcurrencyCheckDelay", "delay in ticks used to check if 2 actions for editing an outpost are concurrent", 50, 0, true );
@ -2393,6 +2395,11 @@ void COutpost::actionPayBackMoneySpent()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
uint32 COutpost::computeRoundCount() const uint32 COutpost::computeRoundCount() const
{ {
///// Nexus test : only 11 rounds
if (getName().substr(0, 14) == "outpost_nexus_")
return OutpostInTestFightRoundCount.get();
//////
return std::min(OutpostFightRoundCount.get(), OUTPOSTENUMS::OUTPOST_MAX_SQUAD_SPAWNED); return std::min(OutpostFightRoundCount.get(), OUTPOSTENUMS::OUTPOST_MAX_SQUAD_SPAWNED);
} }
@ -2423,13 +2430,24 @@ uint32 COutpost::computeSpawnDelay(uint32 roundLevel) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
uint32 COutpost::computeSquadCountA(uint32 roundLevel) const uint32 COutpost::computeSquadCountA(uint32 roundLevel) const
{ {
return (uint32)ceil((float)(roundLevel+1)/2.f);
///// Nexus test : Number of squad increase faster
if (getName().substr(0, 14) == "outpost_nexus_")
return (uint32)ceil((float)(roundLevel+1)/OutpostInTestFightSquadCount.get());
//////
return (uint32)ceil((float)(roundLevel+1)/1.5f);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
uint32 COutpost::computeSquadCountB(uint32 roundLevel) const uint32 COutpost::computeSquadCountB(uint32 roundLevel) const
{ {
return (uint32)floor((float)(roundLevel+1)/2.f); ///// Nexus test : Number of squad increase faster
if (getName().substr(0, 14) == "outpost_nexus_")
return (uint32)floor((float)(roundLevel+1)/OutpostInTestFightSquadCount.get());
//////
return (uint32)floor((float)(roundLevel+1)/1.5f);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -3153,7 +3171,7 @@ std::string COutpost::toString() const
#define PERSISTENT_DATA\ #define PERSISTENT_DATA\
PROP2(VERSION, uint32, COutpostVersionAdapter::getInstance()->currentVersionNumber(), version = val)\ PROP2(VERSION, uint32, COutpostVersionAdapter::getInstance()->currentVersionNumber(), version = val)\
\ \
/*PROP2(_PVPType, string, OUTPOSTENUMS::toString( _PVPType );, _PVPType = OUTPOSTENUMS::toPVPType( val ); )*/\ PROP2(_PVPType, string, OUTPOSTENUMS::toString( _PVPType );, _PVPType = OUTPOSTENUMS::toPVPType( val ); )\
PROP2(_State, string, OUTPOSTENUMS::toString( _State );, _State = OUTPOSTENUMS::toOutpostState( val ); )\ PROP2(_State, string, OUTPOSTENUMS::toString( _State );, _State = OUTPOSTENUMS::toOutpostState( val ); )\
PROP2(_OwnerGuildId, uint32, _OwnerGuildId & ((1<<20)-1), _OwnerGuildId = val != 0 ? ((val & ((1<<20)-1)) | (IService::getInstance()->getShardId()<<20)) : 0)\ PROP2(_OwnerGuildId, uint32, _OwnerGuildId & ((1<<20)-1), _OwnerGuildId = val != 0 ? ((val & ((1<<20)-1)) | (IService::getInstance()->getShardId()<<20)) : 0)\
PROP2(_AttackerGuildId, uint32, _AttackerGuildId & ((1<<20)-1), _AttackerGuildId = val != 0 ? ((val & ((1<<20)-1)) | (IService::getInstance()->getShardId()<<20)) : 0)\ PROP2(_AttackerGuildId, uint32, _AttackerGuildId & ((1<<20)-1), _AttackerGuildId = val != 0 ? ((val & ((1<<20)-1)) | (IService::getInstance()->getShardId()<<20)) : 0)\

@ -611,6 +611,8 @@ public:
void setRealChallengeTime(uint32 t) { _RealChallengeTime = t; } void setRealChallengeTime(uint32 t) { _RealChallengeTime = t; }
void setChallengeTime(uint32 t) { _ChallengeTime = t; } void setChallengeTime(uint32 t) { _ChallengeTime = t; }
void setChallengeHour(uint32 t) { _ChallengeHour = t; } void setChallengeHour(uint32 t) { _ChallengeHour = t; }
void setPvpType(OUTPOSTENUMS::TPVPType type) { _PVPType = type; }
OUTPOSTENUMS::TPVPType getPvpType() { return _PVPType; }
}; };

@ -80,9 +80,9 @@ CSmartPtr<COutpost> getOutpostFromString(const std::string & outpostString, CLog
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
NLMISC_COMMAND(outpostChallengeByGuild, "Challenges an outpost", "<outpost_id> <guild_name>") NLMISC_COMMAND(outpostChallengeByGuild, "Challenges an outpost", "<outpost_id> <guild_name> <type>")
{ {
if (args.size()!=2) if (args.size() < 2)
return false; return false;
CSmartPtr<COutpost> outpost = getOutpostFromString(args[0], log); CSmartPtr<COutpost> outpost = getOutpostFromString(args[0], log);
@ -92,11 +92,20 @@ NLMISC_COMMAND(outpostChallengeByGuild, "Challenges an outpost", "<outpost_id> <
CGuild * guild = CGuildManager::getInstance()->getGuildByName( args[1] ); CGuild * guild = CGuildManager::getInstance()->getGuildByName( args[1] );
if ( guild == NULL ) if ( guild == NULL )
{ {
log.displayNL("Invalid guild '%s'", args[1].c_str()); log.displayNL("ERR: Invalid guild '%s'", args[1].c_str());
return true; return true;
} }
outpost->challengeOutpost( guild ); string error = COutpost::getErrorString(outpost->challengeOutpost( guild ));
if (error == "OUTPOST_ERROR_NONE")
{
if (args.size() > 2)
outpost->setPvpType(OUTPOSTENUMS::toPVPType(args[2]));
log.displayNL("OK");
}
else
log.displayNL("ERR: %s", error.c_str());
return true; return true;
} }

@ -49,7 +49,9 @@ using namespace NLNET;
//COutpostManager* COutpostManager::_Instance = NULL; //COutpostManager* COutpostManager::_Instance = NULL;
extern NLMISC::CVariable<bool> UseBS; extern NLMISC::CVariable<bool> UseBS;
CVariable<bool> LoadOutposts("egs", "LoadOutposts", "If false outposts won't be loaded", true, 0, true ); CVariable<bool> LoadOutposts("egs", "LoadOutposts", "If false outposts won't be loaded", true, 0, true );
CVariable<bool> OutpostInTestTeleportOutNeutrals("egs", "OutpostInTestTeleportOutNeutrals", "If true, teleport out of OP zone the neutrals", false, 0, true );
CFileDisplayer OutpostDisplayer("outposts.log"); CFileDisplayer OutpostDisplayer("outposts.log");
CLog OutpostDbgLog(CLog::LOG_DEBUG), OutpostInfLog(CLog::LOG_INFO), OutpostWrnLog(CLog::LOG_WARNING), OutpostErrLog(CLog::LOG_ERROR); CLog OutpostDbgLog(CLog::LOG_DEBUG), OutpostInfLog(CLog::LOG_INFO), OutpostWrnLog(CLog::LOG_WARNING), OutpostErrLog(CLog::LOG_ERROR);
@ -915,20 +917,31 @@ TAIAlias COutpostManager::getOutpostFromUserPosition( CCharacter *user ) const
for (uint i = 0; i < _Outposts.size(); i++) for (uint i = 0; i < _Outposts.size(); i++)
{ {
COutpost * outpost = _Outposts[i]; COutpost * outpost = _Outposts[i];
if( outpost->contains(vect, false) ) CVector nearPos;
float distance;
if( outpost->contains(vect, distance, nearPos) )
{ {
// Maybe we should check here that user is owner of the outpost if (OutpostInTestTeleportOutNeutrals.get())
// if( outpost->isCharacterInConflict(user) ) {
// { OUTPOSTENUMS::TOutpostState state = outpost->getState();
return outpost->getAlias(); bool outpostInFire = state == OUTPOSTENUMS::AttackBefore || state == OUTPOSTENUMS::AttackRound || state == OUTPOSTENUMS::DefenseBefore || state == OUTPOSTENUMS::DefenseRound;
// } if (outpost->getName().substr(0, 14) == "outpost_nexus_" && outpostInFire)
// else {
// { nlinfo("DISTANCE TO OUTPOST = %f", distance);
// OUTPOST_DBG("<CPVPManager::getPVPZoneFromUserPosition> user not in conflict"); if (distance > 20.f && user->getOutpostSide() == OUTPOSTENUMS::UnknownPVPSide)
// } {
CVector outPos = user->getOutOutpostPos();
user->teleportCharacter(outPos.x*1000.f, outPos.y*1000.f);
return CAIAliasTranslator::Invalid;
}
}
}
return outpost->getAlias();
} }
} }
user->setOutOutpostPos(vect.x, vect.y);
return CAIAliasTranslator::Invalid; return CAIAliasTranslator::Invalid;
} }

@ -32,7 +32,7 @@ extern NLMISC::CLog OutpostDbgLog, OutpostInfLog, OutpostWrnLog, OutpostErrLog;
#ifdef RY_OUTPOST_TEMP_LOG #ifdef RY_OUTPOST_TEMP_LOG
#define OUTPOST_DBG nldebug #define OUTPOST_DBG nlinfo
//#define OUTPOST_INF nlinfo //#define OUTPOST_INF nlinfo
#define OUTPOST_INF nldebug #define OUTPOST_INF nldebug
#define OUTPOST_WRN nlwarning #define OUTPOST_WRN nlwarning

@ -20918,6 +20918,9 @@ void CCharacter::outpostOpenChooseSideDialog(TAIAlias outpostId)
return; return;
} }
uint8 type = (uint8)outpost->getPvpType();
bms.serial(type);
bms.serial(outpostInFire); bms.serial(outpostInFire);
bms.serial(playerGuildInConflict); bms.serial(playerGuildInConflict);
bms.serial(playerGuildIsAttacker); bms.serial(playerGuildIsAttacker);
@ -21039,10 +21042,20 @@ void CCharacter::outpostSideChosen(bool neutral, OUTPOSTENUMS::TPVPSide side)
// his guild doesn't participate in outpost conflict but player don't made a choice when op is under attack => random // his guild doesn't participate in outpost conflict but player don't made a choice when op is under attack => random
if (neutral && outpostInFire) if (neutral && outpostInFire)
{ {
if (uint32(RandomGenerator.rand(1)) == 0)
setOutpostSide(OUTPOSTENUMS::OutpostOwner); if (outpost->getName().substr(0, 14) == "outpost_nexus_")
{
nlinfo("Player are neutral in %s in fire : ", outpost->getName().c_str());
//setOutpostSide(OUTPOSTENUMS::UnknownPVPSide);
}
else else
setOutpostSide(OUTPOSTENUMS::OutpostAttacker); {
if (uint32(RandomGenerator.rand(1)) == 0)
setOutpostSide(OUTPOSTENUMS::OutpostOwner);
else
setOutpostSide(OUTPOSTENUMS::OutpostAttacker);
}
} }
else else
// his guild doesn't participate in outpost conflict so he can choose the side he wants // his guild doesn't participate in outpost conflict so he can choose the side he wants
@ -23191,6 +23204,15 @@ void CCharacter::setBuildingExitPos(sint32 x, sint32 y, sint32 cell)
_BuildingExitPos.z = cell; _BuildingExitPos.z = cell;
} }
//------------------------------------------------------------------------------
void CCharacter::setOutOutpostPos(sint32 x, sint32 y)
{
_OutOutpostPos.x = x;
_OutOutpostPos.y = y;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

@ -2370,6 +2370,12 @@ public:
/// get building exit pos /// get building exit pos
NLMISC::CVector getBuildingExitPos() const; NLMISC::CVector getBuildingExitPos() const;
/// set last outside outpost position
void setOutOutpostPos(sint32 x, sint32 y);
/// get last outside outpost position
NLMISC::CVector getOutOutpostPos() const;
/// set building exit zone /// set building exit zone
void setBuildingExitZone(uint16 zoneIdx); void setBuildingExitZone(uint16 zoneIdx);
@ -3798,6 +3804,7 @@ private:
uint16 _BuildingExitZone; uint16 _BuildingExitZone;
NLMISC::CVector _BuildingExitPos; NLMISC::CVector _BuildingExitPos;
NLMISC::CVector _OutOutpostPos;
// used for force respawn player who are in a mainland in town of this mainland // used for force respawn player who are in a mainland in town of this mainland
bool _RespawnMainLandInTown; bool _RespawnMainLandInTown;

@ -808,6 +808,14 @@ inline NLMISC::CVector CCharacter::getBuildingExitPos() const
return _BuildingExitPos; return _BuildingExitPos;
} }
//------------------------------------------------------------------------------
inline NLMISC::CVector CCharacter::getOutOutpostPos() const
{
return _OutOutpostPos;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

@ -295,9 +295,25 @@ void IPVPZone::dumpZone(NLMISC::CLog * log, bool dumpUsers) const
} }
} }
//----------------------------------------------------------------------------
bool IPVPZone::contains(const NLMISC::CVector & v, float &distance, NLMISC::CVector &nearPos) const
{
if ( !CPrimZone::contains(v, VPoints, distance, nearPos, false))
return false;
return true;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool IPVPZone::contains(const NLMISC::CVector & v, bool excludeSafeZones) const bool IPVPZone::contains(const NLMISC::CVector & v, bool excludeSafeZones) const
{ {
CVector nearPos;
float distance;
CPrimZone::contains (v, VPoints, distance, nearPos, true);
if ( !CPrimZone::contains(v) ) if ( !CPrimZone::contains(v) )
return false; return false;

@ -111,6 +111,7 @@ public:
/// returns true if the PVP zone contains the given position /// returns true if the PVP zone contains the given position
bool contains(const NLMISC::CVector & v, bool excludeSafeZones = true) const; bool contains(const NLMISC::CVector & v, bool excludeSafeZones = true) const;
bool contains(const NLMISC::CVector & v, float &distance, NLMISC::CVector &nearPos) const;
bool contains(CCharacter* user, bool excludeSafeZones = true) const; bool contains(CCharacter* user, bool excludeSafeZones = true) const;
/** /**

Loading…
Cancel
Save