Game role behavior control method and device, electronic equipment and storage medium
By monitoring the target locking of threat characters, choosing a path evasion strategy and building a path network, it solves the problem that AI characters can hardly avoid threats and anthropomorphism in asymmetric competitive games, and achieves the effect of efficient task execution and anthropomorphism.
Patent Information
- Application Number
- CN202510732570.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-03
- Publication Date
- 2025-08-29
AI Technical Summary
In asymmetric competitive games, AI characters find it difficult to efficiently avoid threats when performing tasks and have low anthropomorphism. The existing technology solutions are large in computing or have a long training cycle, making it difficult to adapt to game content updates.
By monitoring the target locking of threat roles, selecting evasive path strategies, building a path network and calculating the optimal path points, combining dynamic and static path strategies to control the movement of controlled roles, reducing the computational complexity and improving the degree of anthropomorphism.
It realizes that AI characters can perform tasks efficiently when they are not locked as targets, and at the same time, they adopt reasonable avoidance behaviors, which improves the degree of anthropomorphism and player experience of the game, and reduces the consumption of computing resources.
Smart Images

Figure CN120550408A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of games, and more specifically, to a method, device, electronic device and storage medium for controlling the behavior of a game character. Background Art
[0002] This section is intended to provide a background or context to embodiments of the invention that are recited in the claims. No statement herein is admitted to be prior art by inclusion in this section.
[0003] In asymmetric competitive games, such as 1v4 (one hunter versus four survivors), the survivors' primary task is to complete specific tasks in the shortest possible time and ultimately escape to victory. Due to the uneven distribution of players, AI characters are often introduced to shorten matchmaking wait times.
[0004] In related technologies, non-target AI survivors (i.e., characters not locked by the supervisor) mainly adopt the following schemes when performing tasks: First, when the supervisor approaches, the survivor is far away and enters an evasive state, and waits until the supervisor is far away before re-performing the task. This scheme reduces the efficiency of task execution and the behavior pattern is fixed, with a low degree of anthropomorphism; second, when the supervisor approaches, the survivor's behavior does not change (continues to perform the task), which may cause the supervisor to quickly switch the non-target survivor to an attack target, making the non-target survivor vulnerable to attack; third, the full-process imitation learning and reinforcement learning method is adopted, but this scheme requires a large amount of player data, and has a long training cycle. It is sensitive to game content updates and is difficult to deploy in actual games.
[0005] Therefore, a game character behavior control method is needed that can ensure that the AI character can perform tasks efficiently, avoid threats intelligently, and has a small amount of computation and a high degree of anthropomorphism. Summary of the Invention
[0006] In this context, embodiments of the present invention are intended to provide a method, apparatus, electronic device, and storage medium for controlling the behavior of a game character, so as to at least partially solve the above-mentioned problems existing in the related art.
[0007] In a first aspect of an embodiment of the present invention, a method for controlling the behavior of a game character is provided, comprising: in response to detecting a threatening character, determining the target locking status of the threatening character; when a controlled character is not a locked target of the threatening character, selecting an avoidance path strategy according to the current behavior state of the controlled character, the avoidance path strategy including a dynamic path strategy with the position of the threatening character as a reference point and a static path strategy with the task target position of the controlled character as a reference point; constructing a corresponding path network based on the selected avoidance path strategy, the path network including a set of path points reachable by the controlled character; selecting an optimal path point on the path network corresponding to the selected avoidance path strategy based on the position of the threatening character; and controlling the controlled character to move toward the optimal path point.
[0008] In a second aspect of an embodiment of the present invention, a game character behavior control device is provided, comprising: a state monitoring module for determining the target locking status of the threatening character in response to detecting a threatening character; a strategy selection module for selecting an avoidance path strategy according to the current behavior state of the controlled character when the controlled character does not belong to the locked target of the threatening character, the avoidance path strategy including a dynamic path strategy with the position of the threatening character as a reference point and a static path strategy with the task target position of the controlled character as a reference point; a path construction module for constructing a corresponding path network based on the selected avoidance path strategy, the path network including a set of path points reachable by the controlled character; a path planning module for selecting an optimal path point on the path network corresponding to the selected avoidance path strategy based on the position of the threatening character; and a behavior control module for controlling the controlled character to move toward the optimal path point.
[0009] In a third aspect of the embodiments of the present invention, an electronic device is provided, comprising: a memory storing computer-executable instructions that can be executed by a processor; and a processor for executing the computer-executable instructions to perform the steps in the above-mentioned game character behavior control method.
[0010] In a fourth aspect of the embodiments of the present invention, a computer-readable storage medium is provided, which stores a computer program, and when the program is executed by a processor, the steps in the above-mentioned game character behavior control method are implemented.
[0011] Through the technical solution provided by the present disclosure, the system can intelligently select the appropriate avoidance path strategy according to the behavioral state of the controlled character, construct a path network composed of reachable path points, and calculate the optimal path point based on the position of the threatening character to achieve intelligent avoidance behavior of the controlled character. This avoidance method based on the combination of dynamic and static path networks not only allows the AI character to still perform tasks efficiently when it is not locked as a target, but also can adopt reasonable avoidance behaviors for different scenarios. Compared with the traditional simple avoidance or ignoring threat solutions, it significantly improves the intelligence and naturalness of the AI character's behavior, making its performance closer to the decision-making mode of real players, and improving the degree of anthropomorphism of the game and the player experience. At the same time, due to the use of geometric calculations and simple rules instead of relying on complex machine learning models, the computing resource consumption and implementation complexity are greatly reduced, and the system operation efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily apparent by reading the following detailed description with reference to the accompanying drawings, in which several embodiments of the present invention are shown by way of example and not limitation, in which:
[0013] Figure 1 A schematic diagram of an implementation environment for a game character behavior control method provided by an embodiment of the present disclosure;
[0014] Figure 2 A flowchart of a method for controlling game character behavior provided by an embodiment of the present disclosure;
[0015] Figure 3 A schematic diagram of the distribution of initial path points on an initial circular path provided by an embodiment of the present disclosure;
[0016] Figure 4 A schematic diagram of an optimal path point selected on a dynamic path network provided by an embodiment of the present disclosure;
[0017] Figure 5 A schematic diagram of an optimal path point selected on a static path network provided by an embodiment of the present disclosure;
[0018] Figure 6 A schematic diagram of the structure of a game character behavior control device provided by an embodiment of the present disclosure;
[0019] Figure 7 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure.
[0020] In the drawings, the same or corresponding reference numerals denote the same or corresponding parts. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the embodiments described are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present disclosure.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] The accompanying drawings are schematic illustrations of the present disclosure and are not necessarily drawn to scale. Some of the block diagrams shown in the accompanying drawings may be functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, or in hardware modules or integrated circuits, or in networks, processors or microcontrollers. The embodiments can be implemented in various forms and should not be construed as being limited to the examples set forth herein. The features, structures or characteristics described in the present disclosure may be combined in one or more embodiments in any suitable manner. In the description below, many specific details are provided to provide a full description of the embodiments of the present disclosure. However, those skilled in the art will appreciate that one or more specific details may be omitted when implementing the technical solution of the present disclosure, or that other methods, components, devices, steps, etc. may be used to replace one or more specific details.
[0024] Figure 1The system architecture diagram of the operating environment of this exemplary embodiment is shown. The system architecture may include a terminal device 110 and a server 120. Among them, the terminal device 110 may be a mobile phone, tablet computer, personal computer, smart wearable device, game console and other devices, which have a display function and can display a graphical user interface. The graphical user interface may include an operating system interface or an application interface, etc. An application is installed on the terminal device 110, such as a game program. The server 120 generally refers to the background system that provides application services in this exemplary embodiment, and can be a single server or a cluster of multiple servers. For example, a game server program is deployed on the server 120 for executing game data processing on the server side. The terminal device 110 and the server 120 can be connected via a wired or wireless communication link for data transmission. The method in one of the exemplary embodiments of the present disclosure can be executed by any one or more of the terminal device 110 and the server 120.
[0025] In one embodiment, the above method can be implemented and executed based on a cloud interaction system. The cloud interaction system can be the above system architecture. Various cloud applications, such as cloud gaming, can be run within the cloud interaction system. Taking cloud gaming as an example, cloud gaming can be a gaming method based on cloud computing. In the cloud gaming operating mode, the main body of the game program and the main body of the game screen presentation are separated. The storage and operation of the in-game control and interaction methods are completed on the cloud gaming server (such as the aforementioned server 120). The cloud gaming client (such as the aforementioned terminal device 110) is responsible for receiving and sending data and presenting the game screen. For example, the cloud gaming client can be a display device with data transmission capabilities close to the user, such as a mobile terminal, television, computer, or PDA; while the cloud gaming server in the cloud performs information processing. When playing the game, the user operates the cloud gaming client to send operation instructions to the cloud gaming server. The cloud gaming server runs the game according to the operation instructions, encodes and compresses the game screen and other data, and returns it to the cloud gaming client via the network. Finally, the cloud gaming client decodes and outputs the game screen.
[0026] In one embodiment, the above method can be implemented solely by the terminal device 110. For example, without deploying the server 120, the terminal device 110 can run an application in a standalone environment to implement the game function and execute the above method.
[0027] See also Figure 2According to one embodiment of the present disclosure, a method for controlling the behavior of a game character is provided. The method includes: in response to detecting a threatening character, determining the target lock status of the threatening character; when the controlled character is not the threatening character's lock target, selecting an avoidance path strategy based on the controlled character's current behavior state, the avoidance path strategy including a dynamic path strategy with the threatening character's position as a reference point and a static path strategy with the controlled character's mission target position as a reference point; constructing a corresponding path network based on the selected avoidance path strategy, the path network including a set of path points reachable by the controlled character; selecting an optimal path point on the path network corresponding to the selected avoidance path strategy based on the threatening character's position; and controlling the controlled character to move toward the optimal path point. In this way, the AI-controlled game character can intelligently avoid threats during the game, effectively performing tasks while avoiding being discovered by the threatening character, thereby improving the anthropomorphism of the AI character in the game.
[0028] Optionally, responding to the detection of a threatening character means that during the game, the system monitors the appearance and movement of threatening characters (such as supervisors and pursuers in asymmetric competitive games) in the game environment in real time. Monitoring methods can include distance detection, field of view detection, and area trigger detection. Distance detection is based on the Euclidean distance or Manhattan distance between the controlled character and the threatening character. When the distance between the two is less than a preset threshold (such as 100 units in game units), a monitoring response is triggered. Field of view detection is based on the field of view of the threatening character. When the controlled character enters the field of view of the threatening character, a monitoring response is triggered. Area trigger detection sets a trigger in a specific area of the game map. When the threatening character and the controlled character appear in the trigger area at the same time, a monitoring response is triggered. Real-time monitoring can be driven by the game engine's tick (the game clock cycle refers to the minimum time unit updated by the game engine at a fixed time interval, such as 30 or 60 times per second) to ensure timely response. In this way, the system can quickly detect potential threats and provide basic information for subsequent avoidance decisions.
[0029] Optionally, determining the threat character's target lock status involves analyzing the target of the threat character's current attack or pursuit intent. Target lock status can be determined based on a variety of factors, including the threat character's orientation and movement direction, the target of the threat character's skill release, the threat character's gaze direction, and the threat character's historical behavior patterns. Orientation and movement direction are determined by analyzing the angle between the threat character's orientation vector and its movement vector. If the angle is small and consistently directed toward a specific game character, the character is considered locked. Skill release targets are determined by monitoring the target selection of the threat character's skills to directly identify their attack intent. Gaze direction is determined by analyzing the direction of the threat character's head or gaze. Historical behavior patterns are determined by recording the threat character's recent pursuit and attack behavior to identify the target they are continuously focusing on. The system can combine these factors and use a weighted calculation to determine the final target lock determination. This allows the controlled character to accurately determine whether they are being observed by the threat character and decide whether to activate evasion mechanisms.
[0030] Optionally, a controlled character refers to a game character controlled by an AI system, typically acting as a survivor or escaper in asymmetric competitive games. When a controlled character is not a target of a threatening character, the system has determined, through the aforementioned determination, that the threatening character's current attack or pursuit intent is not directed at the AI-controlled controlled character, but rather at another character in the game (such as a player-controlled character or another AI character). In this case, while the controlled character is temporarily safe, it must still act with caution to avoid becoming a new target. The determination of non-target status can also include a threat level calculation, which calculates the potential threat level of the threatening character to the controlled character. When the threat level falls below a certain threshold (e.g., 30%), the controlled character is considered non-target. The threat level calculation can be based on a combination of environmental factors, such as a distance attenuation function, line of sight obstruction, and obstacles between characters. If the controlled character is confirmed to be non-target, the system will enter a more sophisticated behavioral decision-making phase, rather than simply moving away or avoiding the target, reflecting the complexity and anthropomorphism of AI behavior. This allows the system to maximize task execution efficiency while ensuring the safety of the controlled character.
[0031] Optionally, an avoidance path strategy can be selected based on the controlled character's current behavioral state. This means the system intelligently selects the most appropriate avoidance strategy based on the controlled character's current behavioral pattern. Behavioral states can be categorized into various types, such as heading to the mission target, executing the mission, assisting teammates, and recovering. Behavioral states can be determined based on information such as the controlled character's current actions, location, interactive objects, and mission queue. Based on different behavioral states, the system needs to select different avoidance strategies to balance mission execution efficiency and safety. This state-based strategy selection mechanism makes AI behavior more flexible and adaptable to complex and changing game environments. This allows the controlled character to make decisions that better meet actual needs based on its own state, enhancing the rationality and credibility of AI behavior.
[0032] Optional avoidance path strategies include dynamic path strategies based on the threat actor's location as a reference point and static path strategies based on the controlled actor's mission objective as a reference point. These strategies represent two different avoidance strategies. The dynamic path strategy uses the threat actor's location as a core reference point, constructing a dynamic avoidance zone centered around the threat actor. The controlled actor moves around this zone to maintain a safe distance. This strategy features dynamic path adjustments based on the threat actor's location, making it suitable for situations where the controlled actor encounters a threat while moving. The static path strategy uses the controlled actor's mission objective (such as a fixed facility like a cipher machine or gate) as a core reference point, constructing a static path network surrounding the mission objective. The controlled actor moves along this network to avoid threats while remaining close to the mission objective. This strategy features a relatively fixed path, primarily circling the mission objective area. It is suitable for situations where the controlled actor has arrived at the mission location and needs to continue the mission. The choice between the two strategies depends on the controlled actor's current state and its relative position to the mission objective. This allows the system to flexibly respond to different scenarios, improving the controlled actor's survivability and mission completion efficiency in various scenarios.
[0033] Optionally, building a corresponding path network based on the selected avoidance path strategy means that the system generates a path system consisting of multiple path points based on the selected strategy (dynamic or static). All these path points on the path network constitute candidate nodes for actually selecting the avoidance path, and the controlled character can further choose to travel to a certain path point on the path network for optimal avoidance. The process of building a path network involves multiple steps such as determining the reference point (the location of the threatening character or the location of the mission target), setting the network range, and generating and verifying the points. The constructed path network will undergo feasibility verification to ensure that all path points are within the reachable area of the controlled character, and to avoid path points falling into obstacles or inaccessible areas. In this way, the system can provide the controlled character with a verified and reliable mobile path selection space.
[0034] Optionally, the system selects the optimal pathpoint within the path network corresponding to the selected avoidance strategy based on the threat character's location. This means that the system uses the threat character's real-time location information to identify the next target point within the established path network that is most suitable for the controlled character to reach. The criteria for selecting the optimal pathpoint vary depending on the strategy, but the core principle is to balance safety and mission efficiency, minimizing the impact on current behavior while ensuring maximum safety. The selection process considers multiple factors, including location safety (distance from the threat), movement efficiency (distance from the target), terrain advantages (high ground, cover, etc.), and historical paths (to avoid wandering behavior caused by repeated paths). The system can use a weighted scoring mechanism to comprehensively evaluate each candidate pathpoint and select the one with the highest score as the optimal pathpoint. Scoring weights can be dynamically adjusted based on game type, character characteristics, and mission priority, making decision-making more flexible and adaptable. This allows the controlled character to choose the most effective movement route for mission execution while ensuring safety.
[0035] Optionally, controlling the controlled character to move toward the optimal path point means that the system uses the selected optimal path point as the moving target and drives the controlled character to move from the current position to the point. The movement control process involves multiple links such as path calculation, speed control, steering management and animation transition. Path calculation can use methods such as A* algorithm, navigation grid or potential field method to determine the best path from the current position to the target point. In addition, in order to ensure the safety of the controlled character, controlling the controlled character to move toward the optimal path point can be controlling the controlled character to move toward the optimal path point along the generated path network, that is, the movement path generated by the path-finding algorithm is as close as possible to the generated path network. In this way, the movement behavior of the controlled character can meet the avoidance requirements while minimizing the interference with the task execution efficiency under the current behavior mode.
[0036] In an optional embodiment, selecting an avoidance path strategy based on the controlled character's current behavior state includes selecting a dynamic path strategy when the controlled character is moving toward a mission target, and selecting a static path strategy when the controlled character is executing a mission. This allows the system to select the most appropriate avoidance strategy based on the controlled character's different behavior states, ensuring both safety and mission efficiency.
[0037] Optionally, when the controlled character is in the moving-towards-the-mission-target state, it has identified a target (e.g., a cipher machine to be repaired, a door to be opened, a teammate to be rescued, etc.) and is en route but has not yet reached the target. This state is determined based on multiple criteria: the consistency of the controlled character's current movement vector with the target direction, the distance between the controlled character and the target, and the priority of the target in the controlled character's task queue. The moving-towards-the-mission-target state is characterized by the controlled character having a clear movement direction and destination but not yet interacting with the target. In this state, the controlled character's primary goal is to reach the target efficiently and safely. Therefore, the threat avoidance strategy needs to maintain the overall direction of travel toward the target as much as possible while ensuring safety. As the controlled character moves toward the target, a dynamic avoidance path network centered around the threat character's position is employed. This strategy is based on the following considerations: When the controlled character is in the moving state, its position is relatively flexible, allowing for more freedom in planning its movement path to avoid threats. Furthermore, since the controlled character's primary goal is to reach a specific location, the path planning needs to ensure that it remains as close to the target as possible while avoiding threats. The dynamic path strategy constructs an evasion path centered around the threat character, directly avoiding the threat's perception range and dynamically adjusting as the threat character's position changes to maintain path safety. Furthermore, the dynamic path strategy allows the system to continuously evaluate the relationship between the current position and the target during the evasion process. When the path detours to a favorable position, it can choose to exit the evasion path and proceed directly to the target, thereby improving movement efficiency. This allows the controlled character to advance toward the target in a relatively efficient manner while maintaining safety.
[0038] Optionally, when the controlled character is in the Executing Task state, it means that the controlled character has arrived at the task target and is performing specific task operations. This state is determined based on the degree of overlap between the controlled character's position and the task interaction point, the controlled character's current animation state (such as repair animation, healing animation, etc.), and the task execution flag in the system. The Executing Task state is characterized by the controlled character remaining at a specific location for a period of time to complete a specific interaction process, such as repairing a cipher machine, healing a teammate, or opening a door. In this state, the controlled character's freedom of movement is restricted, typically requiring them to remain within a specific range of the task target (e.g., 1-3 units in game units), otherwise their task progress may be interrupted. Therefore, the threat avoidance strategy requires finding a relatively safe location while ensuring that the controlled character does not stray too far from the task area. When the controlled character is in the Executing Task state, a static avoidance path network is employed. This strategy is based on the following considerations: when the controlled character is in the Executing Task state, its range of movement is limited to the area surrounding the task target, requiring it to remain within this specific range to continue the task. Furthermore, the controlled character desires to be able to continue the task rather than completely abandoning progress if a threat is perceived that is not directly targeting the target. The static path strategy constructs an evasive path centered around a fixed mission objective, ensuring that the controlled character never strays too far from the mission objective and can quickly return to the mission execution location once the threat is neutralized or displaced. The core of the static path strategy is to find a relatively safe location around the mission objective, allowing the controlled character to temporarily avoid the threatening character as it approaches, without completely abandoning the mission area. Furthermore, this strategy considers the continuity and efficiency of mission execution, minimizing the distance and time the controlled character travels, thereby reducing efficiency losses caused by mission interruptions. This allows the controlled character to maximize mission execution efficiency while maintaining basic safety.
[0039] In an optional embodiment, the path network is constructed by the following steps: creating an initial circular path centered at a reference point; determining the distribution of initial path points along the initial circular path based on the controlled character's mobility; verifying that each path point is within a traversable area; performing adjacent replacement or deletion processing on untraversable path points; and generating a final circular path network based on the updated path points. In this way, the system can construct an effective path network that takes into account the actual constraints of the game environment, providing reliable movement options for the controlled character.
[0040] Optionally, creating an initial circular path centered around a reference point means the system constructs a theoretical circular path with a selected reference point (the threat character's location in a dynamic path strategy or the mission target location in a static path strategy) as the center and an appropriate radius. The choice of reference point directly affects the location and shape of the path network. For dynamic path strategies, the reference point updates in real time as the threat character moves; for static path strategies, the reference point remains fixed at the mission target location. Determining the radius value requires considering multiple factors: the threat character's perception range (typically, the radius is set slightly larger than the threat character's maximum perception range), the size and openness of the game map, the controlled character's movement speed, and the space required for mission execution. A larger radius provides a safer avoidance distance but may increase movement time, while a smaller radius improves efficiency but increases risk. The system dynamically adjusts the radius value based on factors such as the game difficulty setting, the threat character type, and the controlled character's abilities, finding a balance between safety and efficiency. For unusual terrain or boundary conditions, the initial circular path may require deformation adjustments, such as compressing the circle into an ellipse near the map edge to accommodate the available space. In this way, the system can create a basic path framework, providing a basis for subsequent path point generation.
[0041] Optionally, the distribution of initial waypoints on the initial circular path is determined based on the controlled character's mobility. This means that the system calculates the number of waypoints that should be placed on the circular path and the spacing between them based on parameters such as the controlled character's movement speed and steering flexibility. The number and distribution density of waypoints directly affect the accuracy and smoothness of evasive maneuvers. The waypoint distribution calculation is generally based on the following formula: Where r is the radius of the selected circular path, s is the controlled character's movement speed, and t is the game tick frequency (the game clock cycle, which refers to the minimum time unit updated by the game engine at a fixed time interval, such as 30 or 60 times per second). This formula ensures that the distance between adjacent waypoints does not exceed the maximum distance the controlled character can move in a single tick, thereby ensuring smooth path changes. The system adjusts parameters for characters with different mobility: fast-moving characters require fewer waypoints to maintain the same control accuracy; characters with flexible steering can appropriately reduce the number of waypoints because they can adjust direction more quickly. In addition, in games with high visual performance requirements, the waypoint density may be further increased to ensure that the controlled character's movement appears natural and smooth, without noticeable turning jumps. In this way, the system can generate an initial waypoint distribution with an appropriate density based on the character's characteristics.
[0042] Optional verification of each waypoint's location within a traversable area involves checking whether each preliminarily determined waypoint is within an area that the controlled character can actually reach and stay in. This verification process typically utilizes the game's navigation mesh or collision detection system. A traversable area refers to an area where the controlled character can normally traverse without being blocked by obstacles, excluding impassable areas such as walls, deep water, steep cliffs, and dense obstacles. Verification methods include point queries (directly checking whether a point is within the traversable area), raycasting (shooting rays from the center to the point to detect any obstructing obstacles), and path reachability testing (attempting to calculate a path from the current position to the point and checking whether a feasible path exists). This verification process takes into account the controlled character's special mobility abilities, such as jumping and climbing, which may affect the accessibility of certain areas for a specific character. For points in borderline situations (such as partially traversable areas), the system performs more detailed verification, including checking the openness of the surrounding area and the availability of escape routes. This ensures that all generated waypoints are actually reachable and usable by the controlled character.
[0043] Optionally, the neighboring replacement or deletion of non-walkable path points refers to the corrective measures taken by the system when it finds that an initial path point is located in an non-walkable area (such as inside an obstacle or an inaccessible location). Neighboring replacement means that the system searches for the nearest walkable point within a certain radius around the non-walkable path point (for example, within 10% of the distance from the original path point to the center point) with the non-walkable path point as the center. The search method can be grid scanning (dividing the surrounding area into grids for point-by-point inspection), spiral expansion search (expanding the search range spirally from the center outward), or random sampling search (randomly sampling multiple points within the search range for inspection). If a suitable walkable position is found within the search range, the original non-walkable path point is replaced with the new position. If no suitable walkable position is found within the search range, or the nearest walkable position found is too close to the threat role, the system will choose to delete the path point.
[0044] The following is an example of building a circular avoidance circle. Figure 3 As shown, a circle with a reference point as the center and a radius of r is drawn, where r is the maximum distance that the supervisor character can perceive the survivor character. Assuming the tick frequency in the game is t, the distance that the survivor can move in one tick is: Then the equal parts of a circle are: After segmentation, we get a series of points A1, A2, A3, ..., A on the circumference. n , these points are the initial path point distribution on the circular avoidance circle. Check the above path points in order to determine whether they are the points where the controlled character can walk. If point A mThere is no waypoint for the controlled character to walk at the corresponding position, then m Find the circle with the center and radius ρ that is the same as A m The nearest waypoint position where the controlled character can walk. The radius ρ can be selected as small as possible, such as 0.1*r. If the above method can be used to find the new position A' m , then delete position A m , where the new position A' is used m Replace. If the above method still cannot find the new position A' m , then delete A directly m Position, start to the next A m+1 The above judgment is made based on the location.
[0045] Optionally, the deletion operation needs to ensure that the spacing between remaining path points is not too large to maintain the continuity and smoothness of the path. If the spacing is too large due to deletion, the system can insert new intermediate points between adjacent path points, verify the intermediate points, and perform appropriate adjacent replacement or deletion processing to ensure the uniform distribution of the final path. This allows the system to handle various obstacles and restrictions in the game environment and generate a practical and usable path network.
[0046] Optionally, the system generates a final circular path network based on the updated waypoints. This involves connecting the verified and processed set of waypoints to form a complete circular path network that can be used by the controlled character. The resulting circular path network is cached and indexed for subsequent path selection and movement planning. This allows the system to provide a high-quality path network that both considers the actual limitations of the game environment and meets avoidance requirements.
[0047] In an optional implementation, if the dynamic path strategy is selected, the optimal pathpoint is selected by taking the pathpoint on the path network that maximizes the angle between the target and threat character directions. The target direction is the direction of the line connecting the controlled character and the pathpoint, and the threat character direction is the direction of the line connecting the controlled character and the threat character. This allows the system to select a pathpoint that effectively avoids the threat while maintaining a forward trajectory toward the target, improving avoidance efficiency.
[0048] Optionally, the path point on the path network that maximizes the angle between the target direction and the threat role direction is used as the optimal path point, which means that the system selects the best avoidance position by calculating the geometric angle relationship. Figure 4As shown, the system calculates the angle θ between the direction vector from the controlled character's position to each point on the path network (target direction) and the direction vector from the controlled character's position to the threat character's position (threat direction). The point that maximizes this angle θ is selected as the target. This angle is calculated using the vector dot product formula: cos(θ) = (v1·v2) / (|v1|·|v2|), where v1 and v2 are the target and threat character direction vectors, respectively, and θ is the angle between them. Unlike static path networks, a dynamic path network has any point at the maximum distance from the threat character. Therefore, theoretically, any point on the dynamic path network can be selected as a target point for avoidance. However, to avoid closing the distance with the threat character while traveling to the target point, a point on the dynamic circle is searched for that maximizes θ, allowing the controlled character to maintain as much distance from the threat character as possible. The maximum angle strategy simulates the natural behavior pattern of real players when avoiding threats, usually choosing to go sideways. This method can avoid risks while keeping attention on threats, and improve the anthropomorphism of AI behavior.
[0049] In an optional embodiment, if the static path strategy is selected, the optimal pathpoint is selected by determining the closest mapping point of the threat character on the path network; then selecting the pathpoint on the path network that is farthest from the mapping point as the optimal pathpoint. This allows the system to select the pathpoint farthest from the threat character for the controlled character, maximizing the safe distance while maintaining proximity to the mission objective.
[0050] Optionally, determining the threat character's closest projection point on the path network involves calculating the distance from the threat character's current location to each point on the static path network and finding the point with the shortest distance as the threat character's projection or projection point on the path network. Distance calculation typically uses Euclidean distance (straight-line distance) or other appropriate distance metrics based on the game's terrain characteristics. The projection point represents the point of most direct impact of the threat character's current location on the static path network and serves as an important reference for subsequent safe point selection. There are several methods for calculating the projection point. The simplest method is to traverse all points on the path network, calculate the distance from each point to the threat character, and select the point with the shortest distance. A more efficient method is to use spatial partitioning techniques (such as octrees or kd-trees) to quickly locate candidate points and then select the closest point among these candidate points. For regularly shaped path networks, analytical methods can also be used to directly calculate the projection point location. The projection point calculation also takes into account walkability and visibility factors to ensure that the selected projection point accurately represents the threat's impact location. This allows the system to accurately determine the threat character's impact point on the static path network, providing a basis for subsequent safe point selection.
[0051] Optionally, as shown in Figure 5, the path point on the path network farthest from the mapping point is selected as the optimal path point. This means that after determining the threat character's mapping point, the system calculates the distance from all path points on the path network to that mapping point and selects the path point with the farthest distance as the controlled character's moving target. Distance calculation can use straight-line distance or path distance along the path network (i.e., distance measured along the network path). The core concept of selecting the farthest point is to maintain the maximum possible safe distance between the controlled character and the threat character while remaining on the path network surrounding the mission objective. This ensures safety and maintains the possibility of mission execution. Since the static path network is centered around a static target (such as a cipher machine or gate), when the threat character pursues others, the controlled character's mission objective remains unchanged. They only need to hide around the target to avoid being discovered and attacked by the threat character while pursuing others. Therefore, the farthest point from the threat character's mapping position in the static path network is the moving target.
[0052] Optionally, between multiple candidate points that are close in distance (the difference is less than a preset threshold, such as 10% of the network diameter), the system will consider secondary selection factors, such as other avoidance advantages of the point (line of sight obstruction, high ground advantage, etc.), historical safety records, or the ease of movement of the currently controlled character. The system also maintains the usage time of the current path point. If you stay at the same point for a long time (exceeding a preset time, such as 5 seconds), even if the point is still the farthest point, it will be forced to switch to the next best point to avoid the behavior being too static and predictable, so as to make the avoidance behavior more humane.
[0053] In an optional implementation, if the dynamic path strategy is selected, after the controlled character moves to the optimal path point, the following steps are repeated: constructing an updated path network based on the updated location of the threat character; selecting the next optimal path point on the updated path network based on the updated location of the threat character; and controlling the controlled character to move to the next optimal path point. This allows the system to continuously update the avoidance path based on the real-time location of the threat character, maintaining the effectiveness and adaptability of the avoidance behavior.
[0054] Optionally, an updated path network is constructed based on the threat character's updated position. This means that after the controlled character reaches the selected optimal path point, the system obtains the threat character's latest position information in real time and regenerates a dynamic path network centered around it. This step ensures that the path network always uses the threat character's current position as a reference point, maintaining the effectiveness of evasion. The update frequency typically aligns with the controlled character's arrival at the path point, but in cases where the threat character moves faster, the update frequency may be increased to ensure the real-time performance of the path network. The update process reuses the aforementioned path network construction method, including creating a circular path centered around the new reference point, determining the path point distribution, verifying walkability, and performing necessary replacement or deletion processing. Path network updates also take into account dynamic changes in the game environment, such as new obstacles or opening passages. This allows the system to maintain a valid path network centered around the threat character's current position, providing an accurate basis for subsequent path selection.
[0055] Optionally, selecting the next optimal path point on the updated path network based on the updated position of the threatening character means that the system uses the aforementioned maximum angle strategy to recalculate and select the most suitable moving target on the newly constructed path network. This step ensures that the moving target of the controlled character always makes decisions based on the latest environmental conditions and can dynamically respond to changes in the position of the threatening character. The selection process takes into account the current position of the controlled character (usually the path point just arrived), the updated position of the threatening character, and the positional relationship of the final mission target, calculates the angle formed by each candidate path point, and selects the point with the largest angle as the next moving target. In this way, the system can continuously provide the controlled character with the most suitable moving target for the current situation, realizing intelligent and adaptable dynamic avoidance behavior.
[0056] Optionally, this series of steps is repeated, allowing the controlled character to continuously respond to changes in the threat character's position. Ideally, the system triggers a full update loop when the controlled character reaches each waypoint. However, in situations where the threat character moves rapidly or changes behavior suddenly, the update frequency may be increased, even triggering updates before the controlled character reaches the target point. To avoid excessive computational overhead, the system sets trigger conditions, such as when the threat character's position changes by exceeding a threshold, when the threat character's behavior changes, or when the environment changes significantly, before executing a full update loop. During this loop, a historical record is maintained to prevent the controlled character from falling into repetitive movement patterns (such as pacing back and forth). A "boredom mechanism" is introduced when necessary to force a change in strategy selection. This continuous feedback loop ensures effective, long-term dynamic avoidance behavior, enabling the controlled character to demonstrate intelligence and adaptability in complex and changing environments.
[0057] In an alternative implementation, after the controlled character reaches the optimal path point, if the distance between the optimal path point and the mission objective meets a preset condition, the dynamic path strategy is exited and the character moves toward the mission objective based on a preset pathfinding algorithm. This allows the system to naturally transition from avoidance to mission execution at the appropriate time, avoiding excessive avoidance that could reduce mission efficiency and improving the naturalness and goal-directedness of the controlled character's behavior.
[0058] Optionally, the distance between the optimal path point and the mission target meets the preset conditions, which means that the system continuously monitors the spatial relationship between the controlled character's current position (i.e., the most recently reached path point) and the mission target during the dynamic avoidance process, and determines whether it is safe to end the avoidance state and turn to directly execute the mission based on specific conditions. This preset condition is usually set based on the straight-line distance, that is, whether the Euclidean distance from the controlled character's current position to the mission target is less than a preset threshold (such as 1.5-2 times the mission interaction range). In addition, to improve intelligence, multiple evaluation factors can also be included: for example, the relative position relationship, that is, whether the mission target is located outside the angle area formed by the controlled character and the threatening character, ensuring that the threatening character is not on the path that the controlled character must take to reach the mission target; the line of sight obstruction factor, checking whether there are sufficient line of sight obstructions (such as walls, tall obstacles) on the straight-line path from the controlled character to the mission target, which can effectively hide the controlled character's movement trajectory and avoid being discovered by the threatening character. The system can perform weighted calculations on these factors, and only when the comprehensive score exceeds the preset threshold will the distance condition be determined to meet the requirements. This multi-factor evaluation mechanism ensures that the controlled character can end the evasive behavior safely and efficiently and naturally transition to the task execution state.
[0059] Optionally, exiting the dynamic pathing strategy means that, based on the aforementioned conditions, the system decides to terminate the circular path network-based avoidance behavior and instead adopt a more direct, goal-oriented behavior. Moving to the mission objective using a pre-set pathfinding algorithm means that after exiting the dynamic pathing strategy, the system activates the game's standard navigation system and path planning algorithm to guide the controlled character along the optimal path (typically the shortest or safest path that takes into account obstacles and terrain) to the mission objective. Pre-set pathfinding algorithms are typically based on A or its variants (such as Theta and JPS) and are capable of finding the shortest path through complex environments without obstacles. When invoking the pathfinding algorithm, the system passes in specific parameters, such as the target location coordinates (the exact location of the mission objective or the interaction point), movement constraints (such as weighting of impassable obstacles and hazardous areas), and path optimization preferences (such as smoothness, safety, or speed priority). The pathfinding process generates a series of waypoints, or waypoints, forming a complete path from the current location to the mission objective. The system controls the controlled character's movement along these waypoints sequentially, handling details such as turns, acceleration, and deceleration to ensure smooth movement. Compared to the special movement controls in the evasive state, this standard pathing movement is more direct and efficient, focusing on reaching the target quickly rather than avoiding threats.
[0060] In an optional implementation, if the static avoidance path strategy is selected, after the controlled character reaches the optimal path point, the following steps are repeated: selecting the next optimal path point on the path network based on the updated position of the threat character; and controlling the controlled character to move to the next optimal path point. This allows the system to continuously update the optimal avoidance position based on the real-time position of the threat character, maintaining the controlled character's safety around the mission objective.
[0061] Optionally, the system selects the next optimal pathpoint on the path network based on the threat character's updated position. This means that after the controlled character reaches an optimal pathpoint, the system obtains the threat character's latest location information and, without changing the static path network structure, recalculates the threat character's mapping point on the network as described above. The next optimal pathpoint is then determined based on the new mapping point. This process first uses the game's perception system to obtain the threat character's real-time location coordinates. The distance from this location to each point on the static path network is then calculated, identifying the pathpoint with the shortest distance as the mapping point. The distance from each point on the path network to the mapping point is then calculated based on the new mapping point, and the point with the longest distance is selected as the next optimal pathpoint. Because the static path network is constructed around the mission objective, this method ensures that the controlled character always seeks the safest position around the mission objective, rather than aimlessly moving away from the threat. As the threat character moves, the mapping point changes accordingly, and the optimal pathpoint is updated accordingly, resulting in continuous dynamic avoidance behavior, while still centered around the mission objective. This provides a more focused approach to mission completion than dynamic path strategies.
[0062] Optionally, repetition of these steps forms a closed-loop feedback system, enabling the controlled character to continuously respond to changes in the threat character's position and find the safest position around the mission objective. This mechanism ensures that the controlled character continuously seeks the safest position within the static path network while maintaining focus on the mission objective, demonstrating a highly anthropomorphic "temporarily avoiding but not distancing oneself from the mission" behavior pattern. The repetition mechanism in the static path strategy differs significantly from the dynamic path strategy. In the static strategy, the path network structure remains unchanged, with only the selection of optimal path points updated based on the threat character's position. In the dynamic strategy, the entire path network is rebuilt based on the threat character's position. The repetition of the static strategy is also task-oriented, with the controlled character periodically focusing on the mission objective during movement, ready to resume mission execution when conditions permit.
[0063] Optionally, in actual game environments, the repeated execution of the static path strategy also requires special case handling. When a threat character enters the path network (e.g., directly approaching the mission objective), the path network radius may be temporarily expanded or a dynamic path strategy may be switched. When multiple threat characters appear simultaneously, the system calculates the overall threat distribution, potentially determining a separate mapping point for each threat, and then selecting the path point with the greatest overall distance. These special case handling mechanisms ensure the robustness and effectiveness of the static path strategy in a variety of complex game scenarios.
[0064] In an optional embodiment, the method further includes: recording the time when the controlled character first enters a path point on the path network; monitoring the duration of the controlled virtual character's movement along the path network; and when the duration exceeds a preset time, blocking the current mission objective and selecting a new one. In this way, the system can prevent the controlled character from looping around the path network indefinitely, ensuring smooth game progression and efficient mission execution.
[0065] Optionally, recording the time when the controlled character first enters a waypoint on the path network means that when the system detects that the controlled character changes from a normal movement or task execution state to an avoidance state and starts moving on the path network, it records the time point when this change occurs. The system monitors the spatial position and behavioral state of the controlled character to determine when it enters the path network range and starts to perform avoidance behavior. For example, the timing can be started when the controlled character first constructs the path network and moves to the first waypoint on the path network. Accurately recording this time point is critical for subsequent monitoring of the avoidance duration, determining whether it has timed out, and implementing relevant behavioral adjustments. It is the basis for preventing the character from excessively avoiding and ensuring the progress of the task.
[0066] Optionally, monitoring the duration of the controlled virtual character's movement based on the path network means that the system continues to track the accumulated time of the controlled character in the avoidance state after recording the first entry time. This monitoring process includes: timing update - obtaining the current game time in each game logic update cycle (tick); time difference calculation - subtracting the current time from the recorded first entry time to obtain the length of time the character has been in the avoidance state. For example, a timer is started when it is confirmed that the controlled character first enters a path point on the path network, and each tick compares the difference between the current time and the timer: Δt = cur_time - timer, where cur_time is the current time, timer is the timer time, and Δt is the difference between the current time and the timer, that is, the duration of the controlled virtual character's avoidance based on the path network.
[0067] Optionally, when the duration exceeds a preset time, the current mission objective is blocked and a new one is selected. This means that based on the monitoring results above, the system determines that the controlled character's avoidance behavior on a single path network has persisted for too long, potentially leading to an ineffective loop. In this case, the system proactively interrupts the current mission objective and directs the character to another feasible task. For example, when using a dynamic path avoidance strategy, if the controlled character's mission objective is within the dynamic path network, continuously avoiding the dynamic path is meaningless and lacks intelligence. When using a static path avoidance strategy, if the threat character remains stationary or near the mission objective, continuously avoiding the static path is also a waste of time and lacks flexibility. This process involves marking the current mission objective as temporarily unavailable, removing it from the list of available tasks or lowering its priority to prevent the character from immediately reselecting the same objective. A new optimal mission objective is selected from the remaining available tasks in the game based on factors such as distance, importance, and difficulty. Finally, the controlled character's behavior state is transitioned from the avoidance state to the new mission state, clearing the path network and avoidance parameters associated with the old task. The preset duration is usually determined based on game design requirements, task type, and difficulty level, and is optimized during the game balance adjustment process to ensure that promising tasks are not abandoned too early, nor is too much time wasted on unfinished tasks.
[0068] In an optional implementation, if the dynamic path avoidance strategy is selected, after selecting a new mission target, the system determines whether the new mission target's location is within the threat character's perception range. If the new mission target's location is not within the perception range, the system moves toward the new mission target based on a preset pathfinding algorithm. If the new mission target's location is within the perception range, the system continues to search for other optional mission targets. This ensures that the controlled character chooses a safe and reachable target when switching missions, avoiding direct movement from one dangerous area to another.
[0069] Optionally, determining whether the new mission target location is within the threat character's perception range involves the system evaluating the safety of the target location relative to the threat character after selecting the new mission target. This determination process can, for example, be performed by measuring the straight-line distance or actual path distance from the threat character's current location to the new mission target location; or by verifying the presence of line-of-sight obstructions between the threat character and the mission target through ray casting or similar techniques, assessing the likelihood of visual detection; or by evaluating the proportion of the path from the current location to the mission target that is within the threat character's possible perception range. The system can also comprehensively consider these factors and determine the final safety assessment result through a weighted scoring or hierarchical judgment model. This multi-dimensional perception range determination more accurately simulates the risk assessment process in real games than a simple distance check, improving the rationality of decision-making.
[0070] Optionally, if the new mission target location is not within the perception range, movement to the new mission target based on a preset pathfinding algorithm means that after the system confirms that the newly selected mission target is safe enough, it starts the standard navigation program to guide the controlled character to that location. For example, using A*, navigation mesh, or similar algorithms, the optimal path from the current position to the mission target is calculated, taking into account obstacles, terrain, and possible shortcuts. The preset pathfinding algorithm is usually a standard pathfinding system provided by the game engine. By switching the mission target, exiting the avoidance mode, and switching to the regular navigation mode, the diversity of the controlled character's avoidance behavior over a long period of time is further enriched, and the intelligence of the automated decision-making is improved.
[0071] Optionally, if the new mission target is within the perception range, the system continues to search for other optional mission targets. This means that if the system discovers that the newly selected mission target is still unsafe, it abandons the selection and initiates a new round of mission screening. If a completely safe mission target cannot be found after multiple iterations, the system may implement a degenerate strategy, such as selecting the relatively safest mission, temporarily performing exploration or hiding behaviors, or in extreme cases, re-evaluating the currently blocked original mission. This iterative search mechanism ensures that the system will do its best to find the next action target for the controlled character that is both valuable and relatively safe, avoiding dangerous situations caused by hasty decisions.
[0072] In an optional implementation, if the static avoidance strategy is selected, after selecting a new target, the system determines whether the new target's location is within the threat character's perception range. If it is not, the system moves toward the new target based on a pre-set pathfinding algorithm. If it is, the system switches to a dynamic avoidance strategy. This allows the system to intelligently switch avoidance strategies based on the security status of the environment, ensuring that the controlled character can take the most appropriate action in each situation.
[0073] Optionally, determine whether the new mission target location is within the threat actor's perception range. Similar to the dynamic path strategy, the static path strategy requires evaluating the target location's safety. The same approach as above can be used to determine the safety of the new target location relative to the threat actor.
[0074] Optionally, if the new mission target location is not within the perception range, the system will move towards the new mission target location based on the preset pathfinding algorithm, indicating that the system has confirmed the path is safe and can end the static avoidance behavior and switch to regular mission-oriented movement. During this transition, the system will clear the static path network structure and related calculation state related to the current mission target, and use the game's navigation system to calculate the precise path from the current location to the new mission target, taking into account terrain, obstacles, and optimal distance, thereby completing the switch to avoidance mode.
[0075] Optionally, if the new mission target location is within the threat actor's perception range, the avoidance path strategy is switched to a dynamic path strategy, indicating that the system recognizes that the static strategy is no longer applicable in the new environment and needs to adopt an avoidance method more suitable for moving within the threat activity area. This strategy switch involves constructing a new dynamic path network centered on the threat actor, calculating the traversable points on the network, abandoning the original path plan that repeatedly detoured on the static path network, and instead calculating the optimal path points on the dynamic network. This strategy switch reflects the system's ability to flexibly adjust its behavioral strategy based on environmental conditions, improving the adaptability and effectiveness of the overall behavior.
[0076] The above embodiments enable the AI character to intelligently avoid threats while performing tasks by dynamically selecting different avoidance path strategies based on the behavioral state of the controlled character, and constructing and updating the path network in real time based on the position of the threatening character. When the controlled character is in a state of moving toward the task target, a dynamic path strategy can help the character move around the threatening character without being detected; when the controlled character is in a state of performing tasks, a static path strategy can allow the character to flexibly avoid threats around the task target. This avoidance method based on dynamic and static path networks improves the efficiency of task execution, enhances the anthropomorphism of the AI character's behavior, and greatly enhances the gaming experience. At the same time, due to the use of geometric calculations and simple rules instead of relying on complex machine learning models, the computing resource consumption and implementation complexity are greatly reduced, thereby improving the system's operating efficiency. In addition, by setting timeout control and target shielding mechanisms, this method avoids the AI character's behavioral dead loop in specific situations, further optimizing the smoothness and realism of the game.
[0077] Corresponding to the above method embodiment, the embodiment of the present invention provides a game character behavior control device, see Figure 6The device includes: a state monitoring module for determining the target locking status of the threatening role in response to detecting the threatening role; a strategy selection module for selecting an avoidance path strategy according to the current behavior state of the controlled role when the controlled role does not belong to the locked target of the threatening role, the avoidance path strategy including a dynamic path strategy with the position of the threatening role as a reference point and a static path strategy with the task target position of the controlled role as a reference point; a path construction module for constructing a corresponding path network based on the selected avoidance path strategy, the path network including a set of path points reachable by the controlled role; a path planning module for selecting an optimal path point on the path network corresponding to the selected avoidance path strategy based on the position of the threatening role; and a behavior control module for controlling the controlled role to move to the optimal path point.
[0078] In an optional implementation, the strategy selection module is specifically configured to select a dynamic path strategy when the controlled character is in a state of moving toward a task target; and select a static path strategy when the controlled character is in a state of executing a task.
[0079] In an optional embodiment, the path construction module includes an initial path creation unit for creating an initial circular path with a reference point as the center; a path point distribution unit for determining the distribution of initial path points on the initial circular path based on the mobility of the controlled character; a path point verification unit for verifying whether each path point is located in a walkable area; a path point processing unit for performing adjacent replacement or deletion processing on non-walkable path points; and a path network generation unit for generating a final circular path network based on the updated path points.
[0080] In an optional embodiment, the path planning module includes a dynamic path point selection unit, which is used to select the path point on the path network that makes the angle between the target direction and the threat role direction the largest when the selected avoidance path strategy is the dynamic path strategy as the optimal path point, the target direction is the direction of the line connecting the controlled role and the path point, and the threat role direction is the direction of the line connecting the controlled role and the threat role.
[0081] In an optional embodiment, the path planning module includes a mapping point determination unit for determining the nearest mapping point of the threat role on the path network when the selected avoidance path strategy is a static path strategy; and a static path point selection unit for selecting the path point on the path network that is farthest from the mapping point as the optimal path point.
[0082] In an optional embodiment, the device also includes a dynamic path update module, which is used to repeat the following operations if the selected avoidance path strategy is a dynamic path strategy: after the controlled character moves to the optimal path point, build an updated path network based on the updated position of the threatening character; select the next optimal path point on the updated path network based on the updated position of the threatening character; and control the controlled character to move to the next optimal path point.
[0083] In an optional embodiment, the device also includes a dynamic path exit module, which is used to exit the dynamic path strategy when the controlled character moves to the optimal path point, if the distance between the optimal path point and the task target meets the preset conditions, and move towards the task target based on the preset path finding algorithm.
[0084] In an optional embodiment, the device also includes a static path update module, which is used to repeat the following operations if the selected avoidance path strategy is a static path strategy: after the controlled character moves to the optimal path point, select the next optimal path point on the path network based on the updated position of the threatening character; and control the controlled character to move to the next optimal path point.
[0085] In an optional embodiment, the device also includes a timeout processing module for recording the time when the controlled character first enters a path point on the path network; monitoring the duration of the controlled virtual character's movement based on the path network; when the duration exceeds a preset time, blocking the current task target and selecting a new task target.
[0086] In an optional implementation, if the selected avoidance path strategy is a dynamic path strategy, the timeout processing module is also used to determine whether the position of the new task target is within the perception range of the threat role after selecting the new task target; if the position of the new task target is not within the perception range, move to the new task target based on a preset pathfinding algorithm; if the position of the new task target is within the perception range, continue to search for other optional task targets.
[0087] In an optional embodiment, if the selected avoidance path strategy is a static path strategy, the timeout processing module is also used to determine whether the new task target position is within the perception range of the threat role after selecting the new task target; if the new task target position is not within the perception range, move to the new task target position based on a preset path-finding algorithm; if the new task target position is within the perception range, switch the avoidance path strategy to a dynamic path strategy.
[0088] The game character behavior control device provided in the embodiment of the present disclosure has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding content in the aforementioned method embodiment.
[0089] It should be noted that although several units / modules or sub-units / modules of the device are mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of the present invention, the features and functions of two or more units / modules described above may be embodied in one unit / module. Conversely, the features and functions of one unit / module described above may be further divided and embodied by multiple units / modules.
[0090] The embodiment of the present invention further provides an electronic device, such as Figure 7 The electronic device includes a processor and a memory. The memory stores computer-executable instructions that can be executed by the processor. The processor executes the computer-executable instructions to implement any of the game character behavior control methods in the embodiments of the present disclosure. The specific implementation method and the resulting technical effects are described in the method embodiments and will not be repeated here.
[0091] Figure 7 1 is a schematic diagram of the structure of an electronic device. The electronic device 1100 includes a processor 1101 having one or more processing cores, a memory 1102 having one or more computer-readable storage media, and a computer program stored on the memory 1102 and executable on the processor. The processor 1101 is electrically connected to the memory 1102. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not limit the electronic device and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0092] The processor 1101 is the control center of the electronic device 1100. It uses various interfaces and lines to connect the various parts of the entire electronic device 1100. By running or loading software programs and / or modules stored in the memory 1102 and calling data stored in the memory 1102, it executes various functions of the electronic device 1100 and processes data, thereby monitoring the electronic device 1100 as a whole.
[0093] Optionally, the electronic device 1100 further includes: a touch screen 1103, a radio frequency circuit 1104, an audio circuit 1105, an input unit 1106, and a power supply 1107. The processor 1101 is electrically connected to the touch screen 1103, the radio frequency circuit 1104, the audio circuit 1105, the input unit 1106, and the power supply 1107, respectively. Those skilled in the art will appreciate that Figure 7 The electronic device structure shown in the figure does not constitute a limitation to the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0094] The present invention also provides a computer-readable storage medium storing a computer program configured to execute any of the game character behavior control methods of the present invention when executed by a processor. The specific implementation methods and resulting technical effects are described in the method embodiments and are not further detailed here.
[0095] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, terminal device, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0096] In the description of the present invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They are not intended to indicate or imply that the devices or components referred to must have, be constructed, or operate in a specific orientation, and therefore should not be construed as limitations on the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0097] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed by the present invention, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A method for controlling game character behavior, comprising: In response to detecting the threat actor, determining a target locking status of the threat actor; When the controlled character is not a target of the threatening character, an evasion path strategy is selected according to the current behavior state of the controlled character, wherein the evasion path strategy includes a dynamic path strategy with the threatening character's position as a reference point and a static path strategy with the controlled character's mission target position as a reference point; Constructing a corresponding path network based on the selected avoidance path strategy, the path network including a set of path points reachable by the controlled role; Selecting an optimal path point on a path network corresponding to the selected avoidance path strategy based on the location of the threat role; The controlled character is controlled to move toward the optimal path point.
2. The method according to claim 1, characterized in that The selecting of an avoidance path strategy according to the current behavior state of the controlled character includes: When the controlled character is in the state of moving towards the mission target, the dynamic path strategy is selected; When the controlled role is in the task execution state, the static path strategy is selected.
3. The method according to claim 1, characterized in that The path network is constructed by the following steps: Create an initial circular path centered at the reference point; Determining the distribution of initial path points on the initial circular path according to the movement ability of the controlled character; Verify whether each path point is in a walkable area; Perform adjacent replacement or deletion on unwalkable path points; Generate the final circular path network based on the updated path points.
4. The method according to claim 1, wherein If the selected avoidance path strategy is a dynamic path strategy, the optimal path point is selected in the following manner: The path point on the path network that maximizes the angle between the target direction and the threat role direction is taken as the optimal path point, wherein the target direction is the direction of the line connecting the controlled role and the path point, and the threat role direction is the direction of the line connecting the controlled role and the threat role.
5. The method according to claim 1, wherein If the selected avoidance path strategy is a static path strategy, the optimal path point is selected in the following manner: Determining the nearest mapping point of the threat actor on the path network; The path point on the path network that is farthest from the mapping point is taken as the optimal path point.
6. The method according to claim 1, wherein The method further comprises: If the selected avoidance path strategy is the dynamic path strategy, after the controlled character moves to the optimal path point, repeat the following steps: constructing an updated path network based on the updated location of the threat actor; selecting a next optimal path point on the updated path network based on the updated position of the threat actor; Control the controlled character to move to the next optimal path point.
7. The method according to any one of claims 1 or 6, characterized in that The method further comprises: When the controlled character moves to the optimal path point, if the distance between the optimal path point and the mission target meets the preset conditions, the dynamic path strategy is exited and the character moves towards the mission target based on the preset path-finding algorithm.
8. The method according to claim 1, characterized in that The method further comprises: If the selected avoidance path strategy is the static path strategy, after the controlled character moves to the optimal path point, repeat the following steps: selecting a next optimal path point on the path network based on the updated position of the threat actor; Control the controlled character to move to the next optimal path point.
9. The method according to any one of claims 6 or 8, further comprising: Recording the time when the controlled character first enters a path point on the path network; monitoring the duration of movement of the controlled virtual character based on the path network; When the duration exceeds the preset time, the current task target is blocked and a new task target is selected.
10. The method according to claim 9, characterized in that If the selected avoidance path strategy is a dynamic path strategy, after selecting a new task target, determine whether the location of the new task target is within the perception range of the threat role; If the new task target position is not within the sensing range, move towards the new task target based on a preset pathfinding algorithm; If the location of the new mission target is within the perception range, continue searching for other optional mission targets.
11. The method according to claim 9, characterized in that If the selected avoidance path strategy is a static path strategy, after selecting a new task target, determine whether the location of the new task target is within the perception range of the threat role; If the new task target location is not within the sensing range, move to the new task target location based on a preset pathfinding algorithm; If the new task target position is within the perception range, the avoidance path strategy is switched to a dynamic path strategy.
12. A game character behavior control device, comprising: A status monitoring module, configured to determine a target locking status of the threat role in response to detecting the threat role; a strategy selection module configured to select an evasion path strategy based on the current behavior state of the controlled character when the controlled character is not a target of the threatening character, wherein the evasion path strategy includes a dynamic path strategy based on the position of the threatening character as a reference point and a static path strategy based on the mission target position of the controlled character as a reference point; a path construction module, configured to construct a corresponding path network based on the selected avoidance path strategy, wherein the path network includes a set of path points reachable by the controlled role; A path planning module, configured to select an optimal path point on a path network corresponding to the selected avoidance path strategy based on the location of the threat role; The behavior control module is used to control the controlled character to move toward the optimal path point.
13. An electronic device, characterized in that: include: a memory storing computer-executable instructions that can be executed by a processor; A processor, configured to execute the computer-executable instructions to implement the method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that A computer program is stored, and when the program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.