Merge branch 'fixes'

feature/prepare-cross-merge
Ulukyn 4 years ago committed by kaetemi
parent 578ae687df
commit 72d29ef8f6
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -42,6 +42,8 @@ using namespace RYAI_MAP_CRUNCH;
static bool VerboseLog = false;
#define LOG if (!VerboseLog) { } else nlinfo
extern CAIVector randomPos(double dispersionRadius);
//////////////////////////////////////////////////////////////////////////////
// CSpawnBotNpc //
//////////////////////////////////////////////////////////////////////////////
@ -1151,6 +1153,7 @@ void CBotNpc::init()
{
_ChatProfile = NULL;
_MaxHitRangeForPC = -1.0f;
_DispersionRadius = 0;
// _MissionIconFlags.IsMissionStepIconDisplayable = true;
// _MissionIconFlags.IsMissionGiverIconDisplayable = true;
@ -1169,7 +1172,24 @@ CSpawnBotNpc const* CBotNpc::getSpawn() const
void CBotNpc::getSpawnPos(CAIVector& triedPos, RYAI_MAP_CRUNCH::CWorldPosition& pos, RYAI_MAP_CRUNCH::CWorldMap const& worldMap, CAngle& spawnTheta)
{
if (_StartPos.isNull())
if (_DispersionRadius > 0)
{
RYAI_MAP_CRUNCH::CWorldPosition wp;
CAIVector rpos = _FirstPosition;
uint32 maxTries = 100;
do
{
rpos = _FirstPosition;
rpos += randomPos(_DispersionRadius);
--maxTries;
}
while (!worldMap.setWorldPosition(AITYPES::vp_auto, wp, rpos) && maxTries>0);
if (maxTries > 0 ) {
nlinfo("set pos %f,%f", rpos.x().asDouble(), rpos.x().asDouble());
_StartPos.setXY(rpos);
}
}
else if (_StartPos.isNull())
calcSpawnPos(worldMap);
if (isStuck() || IsRingShard)

@ -255,6 +255,8 @@ public:
void setVisualProperties(std::string input);
inline void saveFirstPosition(CAIVector pos, uint8 value) { _FirstPosition = pos, _DispersionRadius = value; }
inline void setMaxHitRangeForPlayer(float maxHitRange) { _MaxHitRangeForPC = maxHitRange; }
// void setMissionStepIconHidden(bool hide) { _MissionIconFlags.IsMissionStepIconDisplayable = !hide; }
// void setMissionGiverIconHidden(bool hide) { _MissionIconFlags.IsMissionGiverIconDisplayable = !hide; }
@ -343,6 +345,8 @@ protected:
// spawn place -------------------------------
CAIPos _StartPos;
CAIVector _FirstPosition;
uint8 _DispersionRadius;
std::vector<NLMISC::CSheetId> _LootList;

@ -218,6 +218,7 @@ void CAIInstance::initInstance(string const& continentName, uint32 instanceNumbe
_LastSpawnAlias = (900 + _InstanceNumber) << LigoConfig.getDynamicAliasSize();
_LastStateAlias = 0;
_LastGroupAlias = (900 + _InstanceNumber) << LigoConfig.getDynamicAliasSize();
sendInstanceInfoToEGS();
@ -344,9 +345,10 @@ CGroup* CAIInstance::findGroup(uint32 alias)
void CAIInstance::findGroup(std::vector<CGroup*>& result, std::string const& name)
{
std::map<std::string, std::vector<NLMISC::CDbgPtr<CGroup> > >::iterator it(_GroupFromNames.find(name));
if (it != _GroupFromNames.end())
if (it != _GroupFromNames.end()) {
result.insert(result.end(), it->second.begin(), it->second.end());
}
}
void CAIInstance::addMissionInfo(std::string const& missionName, uint32 alias)
{
@ -647,8 +649,9 @@ std::vector<std::string> CAIInstance::getMultiLineInfoString() const
#include "ai_bot_npc.h"
#include "ai_profile_npc.h"
inline
static CAIVector randomPos(double dispersionRadius)
extern CAIVector randomPos(double dispersionRadius);
CAIVector randomPos(double dispersionRadius)
{
if (dispersionRadius<=0.)
{
@ -684,14 +687,15 @@ CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const&
return NULL;
}
_LastGroupAlias++;
string name = botsName.empty() ? NLMISC::toString("event_group_%u", _LastGroupAlias):botsName;
// Create a group
CGroupNpc* grp = new CGroupNpc(_EventNpcManager, NULL, RYAI_MAP_CRUNCH::Nothing);
CGroupNpc* grp = new CGroupNpc(_EventNpcManager, _LastGroupAlias, name, RYAI_MAP_CRUNCH::Nothing);
// Register it in the manager
_EventNpcManager->groups().addAliasChild(grp);
// Set the group parameters
grp->setAutoSpawn(false);
string name = botsName.empty() ? NLMISC::toString("event_group_%u", grp->getChildIndex()):botsName;
grp->setName(name);
grp->clearParameters();
@ -727,9 +731,17 @@ CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const&
nlinfo("Stucked !");
bot->setStuck(true);
}
float angle = 0.f;
if (orientation < (NLMISC::Pi * 2.0) && orientation > (-NLMISC::Pi * 2.0))
angle = (float)orientation;
else
angle = randomAngle();
// Spawn all randomly except if only 1 bot
if (nbBots > 1)
if (nbBots > 1 || dispersionRadius > 1)
{
bot->saveFirstPosition(pos, dispersionRadius);
RYAI_MAP_CRUNCH::CWorldMap const& worldMap = CWorldContainer::getWorldMap();
RYAI_MAP_CRUNCH::CWorldPosition wp;
uint32 maxTries = 100;
@ -742,14 +754,10 @@ CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const&
while (!worldMap.setWorldPosition(AITYPES::vp_auto, wp, rpos) && maxTries>0);
if (maxTries<=0)
rpos = pos;
}
float angle = 0.f;
if (orientation < (NLMISC::Pi * 2.0) && orientation > (-NLMISC::Pi * 2.0))
angle = (float)orientation;
bot->setStartPos(pos.x().asDouble(), pos.y().asDouble(), angle, AITYPES::vp_auto);
}
else
angle = randomAngle();
bot->setStartPos(rpos.x().asDouble(),rpos.y().asDouble(), angle, AITYPES::vp_auto);
}
}

@ -246,6 +246,7 @@ private:
/// event npc Manager.
CMgrNpc* _EventNpcManager;
uint32 _LastGroupAlias;
uint32 _LastSpawnAlias;
uint32 _LastStateAlias;

@ -3926,7 +3926,21 @@ void CGrpProfileFaction::checkTargetsAround()
const uint32 playerRadius=assistPlayers||attackPlayers?thisGrpNpc._AggroRange:0;
const uint32 botRadius=assistBots||attackBots?thisGrpNpc._AggroRange:0;
Vision.updateBotsAndPlayers(thisGrpNpc.getAIInstance(), centerPos, playerRadius, botRadius);
CCont<CBot >::iterator itBot=_Grp->bots().begin();
uint32 cellValue = 0;
CBot* bot = *itBot;
if (bot)
{
CSpawnBot* spawnBot = bot->getSpawnObj();
if (spawnBot)
{
CMirrorPropValueRO<uint32> cell( TheDataset, spawnBot->dataSetRow(), DSPropertyCELL );
cellValue = cell();
} else
nlinfo("BOT NOT SPAWN TO GET CELL");
}
Vision.updateBotsAndPlayers(thisGrpNpc.getAIInstance(), centerPos, playerRadius, botRadius, cellValue);
}
// Assist players

@ -54,11 +54,11 @@ public:
virtual ~CAIVision() {}
template <class VectorClass>
void updateBotsAndPlayers(CAIInstance *aii, const VectorClass &xy,uint32 playerRadiusInMeters,uint32 botRadiusInMeters)
void updateBotsAndPlayers(CAIInstance *aii, const VectorClass &xy,uint32 playerRadiusInMeters,uint32 botRadiusInMeters, uint32 cell=0)
{
// _lastUpdate=CTimeInterface::gameCycle();
updatePlayers(aii, xy, playerRadiusInMeters);
updateBots(aii, xy, botRadiusInMeters);
updatePlayers(aii, xy, playerRadiusInMeters, cell);
updateBots(aii, xy, botRadiusInMeters, cell);
}
void clear ()
@ -191,7 +191,7 @@ private:
template <class VectorClass>
void updateBots(CAIInstance *aii, const VectorClass &xy,uint32 botRadiusInMeters)
void updateBots(CAIInstance *aii, const VectorClass &xy, uint32 botRadiusInMeters, uint32 cell)
{
H_AUTO(VisionUpdateBots);
@ -211,7 +211,9 @@ private:
for (it = aii->botMatrix().beginEntities(tbl,xy); !it.end(); ++it)
{
CAIEntityPhysical const* phys = const_cast<T*>(&*it)->getSpawnObj();
if (phys && phys->aipos().quickDistTo(aiVectorXy) < botRadiusInMeters)
CMirrorPropValueRO<uint32> botCell( TheDataset, phys->dataSetRow(), DSPropertyCELL );
if ((cell >= 0 || botCell() == cell) && phys && phys->aipos().quickDistTo(aiVectorXy) < botRadiusInMeters)
{
_bots.push_back(const_cast<T*>(&*it));
}
@ -219,7 +221,7 @@ private:
}
template <class VectorClass>
void updatePlayers(CAIInstance *aii, const VectorClass &xy,uint32 playerRadiusInMeters)
void updatePlayers(CAIInstance *aii, const VectorClass &xy, uint32 playerRadiusInMeters, uint32 cell = 0)
{
H_AUTO(VisionUpdatePlayers);
@ -238,10 +240,8 @@ private:
for (it = aii->playerMatrix().beginEntities(tbl,xy); !it.end(); ++it)
{
CAIEntityPhysical const* phys = const_cast<T*>(&*it)->getSpawnObj();
CMirrorPropValueRO<uint32> cell( TheDataset, phys->dataSetRow(), DSPropertyCELL );
if (phys && phys->aipos().quickDistTo(aiVectorXy) < playerRadiusInMeters)
CMirrorPropValueRO<uint32> botCell( TheDataset, phys->dataSetRow(), DSPropertyCELL );
if ((cell >= 0 || botCell() == cell) && phys && phys->aipos().quickDistTo(aiVectorXy) < playerRadiusInMeters)
{
_players.push_back(const_cast<T*>(&*it));
}

@ -1145,7 +1145,7 @@ void sAggroLost(TDataSetRow playerBot, TDataSetRow targetBot)
void sAggroGain(TDataSetRow playerBot, TDataSetRow targetBot)
{
CAIEntityPhysical *entity=CAIS::instance().getEntityPhysical(playerBot); // necessary ?
CAIEntityPhysical *entity=CAIS::instance().getEntityPhysical(playerBot);
if ( !entity
|| CMirrors::getEntityId(playerBot).getType()!=RYZOMID::player)
return;
@ -1153,6 +1153,9 @@ void sAggroGain(TDataSetRow playerBot, TDataSetRow targetBot)
CAIGainAggroMsg msg(targetBot, playerBot, false);
msg.send("EGS");
if (entity->getActionFlags() & RYZOMACTIONFLAGS::InWater)
return;
CAIEntityPhysical *botEntity = CAIEntityPhysicalLocator::getInstance()->getEntity(targetBot);
CSpawnBotNpc* bot = dynamic_cast<CSpawnBotNpc*>(botEntity);
if (bot && bot->getPersistent().getOwner()) {

@ -195,7 +195,7 @@ IScriptContext* CStateInstance::findContext(NLMISC::TStringId const strId)
#endif
std::vector<CGroup*> grps;
this->getGroup()->getAIInstance()->findGroup(grps, CStringMapper::unmap(strId));
if (grps.size()==1)
if (grps.size() >= 1)
return grps.back()->getPersistentStateInstance();
else
return NULL;

@ -770,7 +770,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
string usedlang = senderLang;
if (EnableDeepL && !senderClient.dontSendTranslation(senderLang))
if (EnableDeepL)
{
chatType = "dynamic";
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
@ -790,7 +790,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
source_lang = mongoText.substr(6, 2);
string sourceText = mongoText.substr(9, endOfOriginal-9);
strFindReplace(sourceText, ")", "}");
mongoText = "["+source_lang+"](http://chat.ryzom.com/channel/pub-universe-"+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
mongoText = "["+source_lang+"](http://chat.ryzom.com/channel/pub-uni-"+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
}
else
{
@ -813,6 +813,11 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
chatInGroup( grpId, ucstr.substr(1), sender );
}
else if (senderClient.dontSendTranslation(senderLang))
{
sendToAllUni = true;
chatInGroup( grpId, ucstr, sender );
}
else
{
_Log.displayNL("%s|%s|*|%s-*|%s", "universe", fullName.c_str(), senderLang.c_str(), ucstr.toUtf8().c_str());
@ -1034,7 +1039,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
if (haveOriginMessage) // Only send untranslated message
canSendChat = false;
}
else if (!translatedLang.empty() && translatedLang != SM->getLanguageCodeString(co->Language))
else if (!translatedLang.empty() && co && translatedLang != SM->getLanguageCodeString(co->Language))
canSendChat = false;
}
@ -1157,7 +1162,7 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
if (!areOriginal)
continue;
}
else if (usedlang != SM->getLanguageCodeString(co->Language))
else if (co == NULL || usedlang != SM->getLanguageCodeString(co->Language))
continue;
}
@ -1921,6 +1926,7 @@ void CChatManager::sendFarChat(const string &name, const ucstring& ucstr, const
{
string usedlang = "";
string source_lang = "";
string mongoText = ucstr.toUtf8();
string::size_type endOfOriginal = mongoText.find("}@{");
@ -1940,15 +1946,17 @@ void CChatManager::sendFarChat(const string &name, const ucstring& ucstr, const
else if (chan == "universe")
{
chatId = "FACTION_"+toUpper(usedlang);
rc_channel = "pub-universe-";
rc_channel = "pub-uni-";
}
string source_lang = usedlang;
if (endOfOriginal != string::npos)
{
if (mongoText.size() > 9)
source_lang = mongoText.substr(6, 2);
else
source_lang = usedlang;
string sourceText = mongoText.substr(9, endOfOriginal-9);
strFindReplace(sourceText, ")", "}");
mongoText = "["+source_lang+"](http://chat.ryzom.com/channel/"+rc_channel+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
@ -1985,7 +1993,7 @@ void CChatManager::sendFarChat(const string &name, const ucstring& ucstr, const
NLMISC::CEntityId receiverId = TheDataset.getEntityId(dcc->getClient()->getID());
CCharacterInfos* co = IOS->getCharInfos(receiverId);
if (!EnableDeepL || usedlang.empty() || usedlang == SM->getLanguageCodeString(co->Language))
if (!EnableDeepL || usedlang.empty() || (co != NULL && usedlang == SM->getLanguageCodeString(co->Language)))
sendFarChat((CChatGroup::TGroupType)12, dcc->getClient()->getID(), ucstr.substr(startPos), ucstring("~")+ucstring(name), *chanId);
dcc = dcc->getNextChannelSession(); // next session in this channel
}

Loading…
Cancel
Save