From 1be159ba7dd1f29acd2a2c1aa2802ade849c0a9d Mon Sep 17 00:00:00 2001 From: hexagon-recursion Date: Sat, 28 Dec 2024 20:41:28 +0300 Subject: [PATCH] SatCom: add searchall and improve search --- help/cbot/E/search.txt | 31 +++++++++++++++++++++++++++---- help/cbot/E/searchall.txt | 13 +++++++++++++ help/generic/E/cbot.txt | 1 + 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 help/cbot/E/searchall.txt diff --git a/help/cbot/E/search.txt b/help/cbot/E/search.txt index 184dff226..dee3f1db8 100644 --- a/help/cbot/E/search.txt +++ b/help/cbot/E/search.txt @@ -1,8 +1,8 @@ \b;Instruction \c;search\n; Syntax: -\s;\c;search ( category, position );\n; +\s;\c;search ( category, center, min, max, sens, filter );\n; -Detects the object of the given category that is closest to the given position. Similar to \c;\l;radar();\u cbot\radar;\n;, but can search starting from the specific point instead of the actual bot's position. +Detects an object of the given category in a given radius from a given center. Similar to \c;\l;radar();\u cbot\radar;\n;, but can search starting from the specific point instead of the actual bot's position. \t;category: \c;\l;int\u cbot\int;\n; o \l;Category\u cbot\category; of the objects that should be detected. For example, when you are looking for an ant, write \c;search(AlienAnt)\n;. @@ -16,8 +16,31 @@ o \l;Array\u cbot\array; of categories of the objects that should be detected. F \s;object grabberNearestThePoint = search(bots, p);\n; o Keyword \const;Any\norm; if you are looking for any object (including even plants and so on). -\t;position: \c;\l;point\u cbot\point;\n; (default value: \c;\l;this\u cbot\this;.\l;position\u cbot\object;\n;) -\c;search\n; returns the object of the given category that is closest to the position indicated here. +\t;center: \c;\l;point\u cbot\point;\n; (default value: \c;\l;this\u cbot\this;.\l;position\u cbot\object;\n;) +The center of the search area. + +\t;min: \c;\l;float\u cbot\float;\n; (default value: \c;0\n;) +Minimum detection distance, in meters. Objects that are closer to the center than the minimum distance will not be detected. + +\t;max: \c;\l;float\u cbot\float;\n; (default value: \c;1000\n;) +Maximum detection distance, in meters. Objects that are farther away from the center than the maximum distance will not be detected. + +\t;sens: \c;\l;float\u cbot\float;\n; (default value: \c;1\n;) +Determines which way the objects are detected. With value \c;1\n;, returns the object closest to the center. With value \c;-1\n;, the farthest object in the area will be returned. + +\t;filter: \c;\l;int\u cbot\int;\n; (default value: \c;\const;FilterNone\norm;\n;) +Determines which type of objects should be detected. Especially useful in use with an \l;array\u cbot\array; or \const;Any\norm;. The following filters are available: + +\c;\const;FilterNone\norm; \n;Detects everything (default) +\c;\const;FilterOnlyLanding\norm; \n;Detects only objects being on the ground +\c;\const;FilterOnlyFlying\norm; \n;Detects only objects not being on the ground +\c;\const;FilterFriendly\norm; \n;Detects only allies (objects in the same team) +\c;\const;FilterEnemy\norm; \n;Detects only enemies (objects in an other team except neutral) +\c;\const;FilterNeutral\norm; \n;Detects only neutral objects (e.g. resources) + +The last three are mainly useful in \l;code battles\u battles;. You can also pass a team ID to search only for objects from a specific team. Attention: you should use \const;FilterNeutral\norm; instead of \c;0\n; or else it will not work. + +Filters and IDs can be mixed using bitwise OR operator \c;|\n;, for example \c;search(Any, position, 0, 1000, 1, 2 | FilterOnlyLanding);\n; will only detect an object from team \c;2\n; that is on the ground. Attention: you can specify only one team ID at once, but you can specify several filters at once. \t;Return value: \c;\l;object\u cbot\object;\n; Characteristics of the object that has been found. The value \c;\l;null\u cbot\null;\n; means that no object of this category has been found. diff --git a/help/cbot/E/searchall.txt b/help/cbot/E/searchall.txt new file mode 100644 index 000000000..609c7ba23 --- /dev/null +++ b/help/cbot/E/searchall.txt @@ -0,0 +1,13 @@ +\b;Instruction \c;searchall\n; +\c;searchall\n; is an enhancement of the \c;\l;search\u cbot\search;()\n; instruction -- it detects all objects matching the given criteria. + +\b;For specialists +\t;Syntax: +\s;\c;searchall ( category, center, min, max, sens, filter );\n; + +The instruction works generally the same as the \c;\l;search\u cbot\search;();\n; instruction with the only difference being that it returns an \l;array\u cbot\array; of \l;objects\u cbot\object; instead of one object. If no object is found, an empty array (\c;\l;null\u cbot\null;\n;) is returned. + +The order of objects in the returned array is sorted by distance and depends on the \c;sens\n; parameter. The first object in the array is the object which would be returned by the \c;search();\n; function called with the exactly same parameters. + +\t;See also +\c;\l;search\u cbot\search;();\n;, \l;programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;. diff --git a/help/generic/E/cbot.txt b/help/generic/E/cbot.txt index 08d5f55f0..7db4f4924 100644 --- a/help/generic/E/cbot.txt +++ b/help/generic/E/cbot.txt @@ -31,6 +31,7 @@ Constants like \l;categories\u cbot\category; are displayed like that: \const;co \c;\l;radar\u cbot\radar; \n;Advanced object detection \c;\l;radarall\u cbot\radarall; \n;Advanced multiple objects detection \c;\l;search\u cbot\search; \n;Object detection from a specific point +\c;\l;searchall\u cbot\searchall; \n;Detection of multiple objects from a specific point \c;\l;direction\u cbot\direct; \n;Calculates a rotation angle \c;\l;distance\u cbot\dist; \n;Calculates a distance \c;\l;distance2d\u cbot\dist2d; \n;Calculates a distance