From 1547f027cab55863b8cd2416b3c527d5ea59d2c9 Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 5 Oct 2023 12:42:11 +0200 Subject: [PATCH] Improve follow player code, remove useless check of Ai in setEquipement --- ryzom/server/src/ai_service/ai_profile_npc.cpp | 52 ++++++++++++---------- .../src/ai_service/doc/doxycfg/commondoc.cfg | 40 ++++++++--------- ryzom/server/src/ai_service/nf_grp_npc.cpp | 3 -- 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/ryzom/server/src/ai_service/ai_profile_npc.cpp b/ryzom/server/src/ai_service/ai_profile_npc.cpp index fd338e518..04bf51ca0 100644 --- a/ryzom/server/src/ai_service/ai_profile_npc.cpp +++ b/ryzom/server/src/ai_service/ai_profile_npc.cpp @@ -2357,8 +2357,19 @@ void CGrpProfileFollowPlayer::updateProfile(uint ticksSinceLastUpdate) return; } - _PathCont.setDestination(plrPtr->wpos()); - _PathPos._Angle = plrPtr->theta(); + //_PathCont.setDestination(plrPtr->wpos()); + //_PathPos._Angle = plrPtr->theta(); + double const distContDestToRealDest = plrPtr->wpos().toAIVector().quickDistTo(_PathCont.getDestination()); + if (distContDestToRealDest > 4) // update only each 4 meters. + { + _PathCont.setDestination(plrPtr->wpos()); + _PathPos._Angle = plrPtr->theta(); + } + + // Need to wait for a correct position before moving? + CAIVector const& dest = _PathCont.getDestination(); + if (dest.x()==0 || dest.y()==0) + return; for (uint i = 0; i < pgrp.bots().size(); ++i) { @@ -2371,33 +2382,28 @@ void CGrpProfileFollowPlayer::updateProfile(uint ticksSinceLastUpdate) if (!sbot) continue; - // Need to wait for a correct position before moving? - CAIVector const& dest = _PathCont.getDestination(); - if (dest.x()==0 || dest.y()==0) - return; - - static const std::string runParameter("running"); - float dist; - if (sbot->getPersistent().getOwner()->getSpawnObj()->checkProfileParameter(runParameter)) + float dist; + if (sbot->getPersistent().getOwner()->getSpawnObj()->checkProfileParameter("running")) dist = sbot->runSpeed()*ticksSinceLastUpdate; else dist = sbot->walkSpeed()*ticksSinceLastUpdate; - // Move - CFollowPath::TFollowStatus const status = CFollowPath::getInstance()->followPath( - sbot, - _PathPos, - _PathCont, - dist, - 0.f, - 0.5f); - - if (status==CFollowPath::FOLLOW_NO_PATH) + if ((_PathCont.getDestination() - sbot->wpos().toAIVector()).quickNorm() > 6.f) { - nlwarning("Problem with following player"); - } - + // Move + CFollowPath::TFollowStatus const status = CFollowPath::getInstance()->followPath( + sbot, + _PathPos, + _PathCont, + dist, + _DispersionRadius/10.f, + 0.5f); + if (status==CFollowPath::FOLLOW_NO_PATH) + { + nlwarning("Problem with following player"); + } + } } } diff --git a/ryzom/server/src/ai_service/doc/doxycfg/commondoc.cfg b/ryzom/server/src/ai_service/doc/doxycfg/commondoc.cfg index 1d48c0c84..561e35982 100644 --- a/ryzom/server/src/ai_service/doc/doxycfg/commondoc.cfg +++ b/ryzom/server/src/ai_service/doc/doxycfg/commondoc.cfg @@ -6,7 +6,7 @@ # (C) 2001 Radon Labs GmbH #------------------------------------------------------------------------------ -# If you have dot (http://www.research.att.com/sw/tools/graphviz/) +# If you have dot (http://www.research.att.com/sw/tools/graphviz/) # on your system, then you can uncomment this line for more detailed graphs. # HAVE_DOT = YES @@ -27,7 +27,7 @@ BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ALWAYS_DETAILED_SEC = NO FULL_PATH_NAMES = NO -STRIP_FROM_PATH = +STRIP_FROM_PATH = INTERNAL_DOCS = NO CLASS_DIAGRAMS = YES DETAILS_AT_TOP = YES @@ -35,7 +35,7 @@ DETAILS_AT_TOP = YES # Setting this to NO, drops the .CHM size from 5mb to 3mb. SOURCE_BROWSER = YES -INLINE_SOURCES = NO +INLINE_SOURCES = YES STRIP_CODE_COMMENTS = YES CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO @@ -47,13 +47,13 @@ INLINE_INFO = YES SORT_MEMBER_DOCS = NO DISTRIBUTE_GROUP_DOC = NO TAB_SIZE = 4 -ENABLED_SECTIONS = +ENABLED_SECTIONS = GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES -ALIASES = "cmd=\par Script Command:\n" -ALIASES += "input=\par Command Input:\n" -ALIASES += "output=\par Command Output:\n" +ALIASES = "cmd=\par Script Command:\n" +ALIASES += "input=\par Command Input:\n" +ALIASES += "output=\par Command Output:\n" ALIASES += "info=\par Command Description:\n" ALIASES += "classinfo=\par Class Description:\n" ALIASES += "scriptclass=\file\n\par Class:\n" @@ -63,19 +63,19 @@ QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = NO WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = +WARN_LOGFILE = FILE_PATTERNS = *.h *.cc *.cpp *.dox RECURSIVE = NO -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -IMAGE_PATH = -INPUT_FILTER = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +IMAGE_PATH = +INPUT_FILTER = FILTER_SOURCE_FILES = NO ALPHABETICAL_INDEX = NO COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = +IGNORE_PREFIX = GENERATE_HTML = YES HTML_OUTPUT = html @@ -93,8 +93,8 @@ GENERATE_LATEX = NO LATEX_OUTPUT = latex COMPACT_LATEX = NO PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = +EXTRA_PACKAGES = +LATEX_HEADER = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO @@ -103,7 +103,7 @@ GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = GENERATE_MAN = NO MAN_OUTPUT = man @@ -114,10 +114,10 @@ ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = REFERENCED_BY_RELATION = NO REFERENCES_RELATION = NO diff --git a/ryzom/server/src/ai_service/nf_grp_npc.cpp b/ryzom/server/src/ai_service/nf_grp_npc.cpp index 0a67aea43..ad9ac13ce 100644 --- a/ryzom/server/src/ai_service/nf_grp_npc.cpp +++ b/ryzom/server/src/ai_service/nf_grp_npc.cpp @@ -2745,9 +2745,6 @@ void setEquipment_s_(CStateInstance* entity, CScriptStack& stack) stack.pop(); IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); - CAIInstance* const aiInstance = dynamic_cast(managerParent); - if (!aiInstance) - return; std::vector args; std::vector equipements; -- 2.11.4.GIT