Control Method, Device, Computer Equipment and Storage Medium for Non-Player Characters
By predicting the movement range of the player character in the game and controlling the NPC for surround and chase, the problem of poor experience when NPC chasing the player character is solved, improving the challenge and interactivity of the game.
Patent Information
- Application Number
- CN202310270298.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2043-03-17
AI Technical Summary
In the game, when multiple NPCs chase the player character, the player character can easily get rid of the NPC's pursuit, resulting in a poor gaming experience.
By obtaining the position and movement speed of the player character, predicting its movement range, and determining the target non-player character based on the position and movement range of the non-player character, controlling it to surround and chase the target position.
It improves the gaming experience of gamers, making it more difficult for NPCs to be easily removed by player characters, and increases the challenge and interactivity of the game.
Smart Images

Figure CN116351059B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and particularly to a method and device for controlling non-player characters, a computer device, and a storage medium. Background Art
[0002] With the development of the Internet, a large number of different types of games have emerged to meet the daily entertainment needs of users.
[0003] In some games, there are designed NPCs (non-player characters). Players can interact with the designed NPCs in the game (such as chatting, attacking, and defending) by operating their own characters. In a general PVE (Player VS Environment) dungeon, the player character usually battles with multiple NPCs. Before attacking the player character, the NPCs will have the behavior of chasing the player character. For example, multiple NPCs chase the player character simultaneously.
[0004] In the related art, when multiple NPCs chase the player character, they move towards the player character according to a preset movement method to attack the player character. However, when the NPCs chase the player character in the preset movement method, the player character can easily get rid of the pursuit of the NPCs, resulting in a poor gaming experience for the player. Summary of the Invention
[0005] Embodiments of the present application provide a method and device for controlling non-player characters, a computer device, and a storage medium, which can improve the gaming experience of game players.
[0006] Embodiments of the present application provide a method for controlling non-player characters, including:
[0007] Obtaining a first position and a moving speed of a player character in a game scene of a target game;
[0008] Predicting a moving range of the player character in the game scene based on the first position and the moving speed;
[0009] Determining target non-player characters that need to surround and chase the player character among the non-player characters according to a second position of the non-player characters in the game scene and the moving range;
[0010] Determining a target position corresponding to the target non-player characters surrounding and chasing the player character based on a positional relationship between the target non-player characters and the moving range;
[0011] Controlling the target non-player characters to move towards the target position.
[0012] Correspondingly, an embodiment of the present application further provides a control device for non-player characters, including:
[0013] An acquisition unit, configured to acquire the first position and moving speed of the player character in the game scene of the target game;
[0014] A first prediction unit, configured to predict the moving range of the player character in the game scene based on the first position and the moving speed;
[0015] A first determination unit, configured to determine, according to the second position of the non-player character in the game scene and the moving range, the target non-player character among the non-player characters that needs to surround and pursue the player character;
[0016] A second determination unit, configured to determine, based on the positional relationship between the target non-player character and the moving range, the target position corresponding to the target non-player character surrounding and pursuing the player character;
[0017] A control unit, configured to control the target non-player character to move towards the target position.
[0018] In some embodiments, the first prediction unit includes:
[0019] A first determination subunit, configured to acquire the duration of the player character's movement in the game scene;
[0020] A first calculation subunit, configured to calculate the moving distance of the player character in the game scene according to the duration and the moving speed;
[0021] A second determination subunit, configured to determine the moving range based on the first position and the moving distance.
[0022] In some embodiments, the first determination unit includes:
[0023] A third determination subunit, configured to determine the target non-player character based on the non-player characters whose second positions are outside the moving range.
[0024] In some embodiments, the second determination unit includes:
[0025] A fourth determination subunit, configured to determine the position connection line between the target non-player character and the player character in the game scene;
[0026] A fifth determination subunit, configured to determine the target position based on the intersection point of the position connection line and the moving range.
[0027] In some embodiments, the second determination unit includes:
[0028] The sixth determination subunit is configured to determine the nearest non-player character closest to the player character from multiple target non-player characters;
[0029] The seventh determination subunit is configured to determine the position connection line between the nearest non-player character and the player character in the game scene;
[0030] The eighth determination subunit is configured to determine a first target position corresponding to the nearest non-player character based on the intersection point of the position connection line and the movement range;
[0031] The sixth determination subunit is configured to determine second target positions corresponding to other non-player characters in the target player characters respectively based on the first target position corresponding to the nearest non-player character.
[0032] In some embodiments, the sixth determination subunit is specifically configured to:
[0033] Determine the number of other non-player characters;
[0034] Based on the first target position and the number of characters, determine candidate positions for the number of characters from the edge of the movement range;
[0035] Determine the candidate position closest to each other non-player character as the second target position corresponding to each other non-player character.
[0036] In some embodiments, the control unit includes:
[0037] The control subunit is configured to control the nearest non-player character to move towards the first target position, and control each other non-player character to move towards the corresponding second target position respectively.
[0038] In some embodiments, the sixth determination subunit is specifically configured to:
[0039] Determine the number of other non-player characters;
[0040] Based on the first target position, determine a starting division position for dividing the edge of the movement range; according to the total length of the edge of the movement range and the number of target non-player characters, calculate an interval distance for dividing the edge of the movement range; based on the starting division position and the interval distance, divide the edge of the movement range to obtain candidate positions for the number of characters;
[0041] Determine the candidate position closest to each other non-player character as the second target position corresponding to each other non-player character.
[0042] In some embodiments, the device further includes:
[0043] A response unit, configured to obtain the post - movement position of the player character in response to the movement of the player character in the game scene;
[0044] A second prediction unit, configured to predict the changed movement range of the player character in the game scene based on the post - movement position and the movement speed.
[0045] In some embodiments, the first determination unit includes:
[0046] A ninth determination subunit, configured to determine a target non - player character among the non - player characters that needs to surround and pursue the player character according to the second position of the non - player characters in the game scene and the changed movement range.
[0047] Correspondingly, an embodiment of the present application further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the game control provided in any embodiment of the present application.
[0048] Correspondingly, an embodiment of the present application further provides a storage medium, storing a plurality of instructions, which are suitable for being loaded by a processor to execute the game control as described above.
[0049] In the embodiments of the present application, by obtaining the first position and the movement speed of the player character in the game scene, predicting the movement range of the player character in the game scene according to the first position and the movement speed, then, according to the movement range and the second position of the non - player characters in the game scene, determining a target non - player character among the non - player characters that needs to surround and pursue the player character; based on the positional relationship between the target non - player character and the movement range, determining a target position corresponding to the target non - player character surrounding and pursuing the player character, and further controlling the target non - player character to move towards the target position, so as to implement the surrounding and pursuit of the player character by multiple non - player characters in the game scene, thereby improving the player's game experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0051] Figure 1 It is a schematic diagram of a scene of a control system for non - player characters provided by an embodiment of the present application.
[0052] Figure 2A flowchart of a method for controlling a non-player character provided in an embodiment of the present application.
[0053] Figure 3 A schematic diagram of an application scenario of a non-player character control method provided in an embodiment of the present application.
[0054] Figure 4 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0055] Figure 5 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0056] Figure 6 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0057] Figure 7 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0058] Figure 8 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0059] Figure 9 A flowchart of another method for controlling a non-player character provided in an embodiment of the present application.
[0060] Figure 10 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0061] Figure 11 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0062] Figure 12 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0063] Figure 13 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0064] Figure 14 A schematic diagram of an application scenario of another non-player character control method provided in an embodiment of the present application.
[0065] Figure 15 This is a structural block diagram of a control device for a non-player character provided in an embodiment of the present application.
[0066] Figure 16Schematic structural diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0067] Next, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.
[0068] An embodiment of the present application provides a method, apparatus, storage medium, and computer device for controlling a non-player character. Specifically, the method for controlling a non-player character in the embodiment of the present application can be executed by a computer device, where the computer device can be a terminal or a server, etc. The terminal can be a smart phone, a tablet computer, a notebook computer, a touch screen, a game console, a personal computer (PC), a personal digital assistant (PDA), etc. The terminal can also include a client, and the client can be a game application client, a browser client with a game program, an instant messaging client, etc. The server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0069] For example, when the method for controlling a non-player character runs on a terminal, the terminal device stores a game application program and is used to present a virtual scene in the game screen. The terminal device is used to interact with the user through a graphical user interface. For example, the game application program is downloaded and installed on the terminal device and run. The manner in which the terminal device provides the graphical user interface to the user can include various ways. For example, it can be rendered and displayed on the display screen of the terminal device, or the graphical user interface can be presented through holographic projection. For example, the terminal device can include a touch display screen and a processor. The touch display screen is used to present the graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The graphical user interface includes a game screen. The processor is used to run the game, generate the graphical user interface, respond to the operation instructions, and control the display of the graphical user interface on the touch display screen.
[0070] For example, when the control method of the non-player character runs on a server, it can be a cloud game. A cloud game refers to a game mode based on cloud computing. In the operation mode of a cloud game, the running entity of the game application and the entity presenting the game screen are separated. The storage and operation of the control method of the non-player character are completed on the cloud game server. The presentation of the game screen is completed on the cloud game client. The cloud game client is mainly used for receiving and sending game data and presenting the game screen. For example, the cloud game client can be a display device with data transmission function near the user side, such as a mobile terminal, a television, a computer, a palm computer, a personal digital assistant, etc. However, the terminal device for processing game data is the cloud game server in the cloud. When playing a game, the user operates the cloud game client to send an operation instruction to the cloud game server. The cloud game server runs the game according to the operation instruction, encodes and compresses data such as the game screen, returns it to the cloud game client through the network. Finally, the game screen is decoded and output through the cloud game client.
[0071] Please refer to Figure 1 , Figure 1 which is a schematic diagram of the scenario of a control system for a non-player character provided by an embodiment of this application. The system may include at least one terminal, at least one server, at least one database, and a network. The terminal held by the user can be connected to the servers of different games through the network. The terminal is any device with computing hardware that can support and execute software products corresponding to games. In addition, the terminal has one or more multi-touch sensitive screens for sensing and obtaining inputs of touch or swipe operations performed by the user at multiple points on one or more touch display screens. In addition, when the system includes multiple terminals, multiple servers, and multiple networks, different terminals can be connected to each other through different networks and through different servers. The network can be a wireless network or a wired network. For example, the wireless network can be a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc. In addition, different terminals can also use their own Bluetooth network or hotspot network to connect to other terminals or to the server, etc. For example, multiple users can be online through different terminals, connect through an appropriate network, and synchronize with each other to support multi-player games. In addition, the system may include multiple databases. The multiple databases are coupled to different servers and can continuously store information related to the game environment in the database when different users are online for multi-player games.
[0072] Embodiments of the present application provide a method for controlling a non-player character, which can be executed by a terminal or a server. Embodiments of the present application will be described by taking the method for controlling a non-player character executed by a terminal as an example. Among them, the terminal includes a touch display screen and a processor. The touch display screen is used to present a graphical user interface and receive operation instructions generated by a user acting on the graphical user interface. When the user operates on the graphical user interface through the touch display screen, the graphical user interface can control the content on the local terminal in response to the received operation instructions, or can also control the content of the peer server in response to the received operation instructions. For example, the operation instructions generated by the user acting on the graphical user interface include instructions for starting a game application. The processor is configured to start the game application after receiving the instruction for starting the game application provided by the user. In addition, the processor is configured to render and draw a graphical user interface associated with the game on the touch display screen. The touch display screen is a multi-touch sensitive screen capable of sensing touch or swipe operations performed simultaneously by multiple points on the screen. When the user performs a touch operation on the graphical user interface with a finger, when the graphical user interface detects the touch operation, it controls different virtual objects in the game to perform actions corresponding to the touch operation. For example, the game can be any one of games such as casual games, action games, role-playing games, strategy games, sports games, puzzle games, etc. Among them, the game can include a virtual scene of the game. In addition, the virtual scene of the game can include one or more virtual objects controlled by a user (or player), such as a virtual character. In addition, the virtual scene of the game can also include one or more obstacles, such as railings, ditches, walls, etc., to limit the movement of the virtual object, for example, to limit the movement of one or more objects to a specific area within the virtual scene. Optionally, the virtual scene of the game also includes one or more elements, such as skills, scores, character health status, energy, etc., to provide assistance to the player, provide virtual services, increase scores related to the player's performance, etc. In addition, the graphical user interface can also present one or more indicators to provide indication information to the player. For example, the game can include a virtual object controlled by the player and one or more other virtual objects (such as enemy characters). In one embodiment, one or more other virtual objects are controlled by other players of the game. For example, one or more other virtual objects can be controlled by a computer, such as a robot using an artificial intelligence (AI) algorithm, to implement a human-computer battle mode. For example, a virtual object has various skills or abilities used by a game player to achieve a goal. For example, a virtual object has one or more weapons, props, tools, etc. that can be used to eliminate other objects in the game. Such skills or abilities can be activated by a game player using one of multiple preset touch operations on the touch display screen of the terminal. The processor can be configured to present a corresponding game screen in response to the operation instructions generated by the user's touch operation.
[0073] It should be noted thatFigure 1 The scene schematic diagram of the control system of the non-player character shown is only an example. The image processing system and the scene described in the embodiments of the present application are for more clearly explaining the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those of ordinary skill in the art can know that with the evolution of the control system of the non-player character and the emergence of new business scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
[0074] Based on the above problems, the embodiments of the present application provide a first control method, device, computer device and storage medium for non-player characters, which can improve the gaming experience of game players. The following will be described in detail respectively. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.
[0075] The embodiments of the present application provide a control method for non-player characters. This method can be executed by a terminal or a server. The embodiments of the present application will be described by taking the control method of non-player characters being executed by the terminal as an example.
[0076] Please refer to Figure 2 , Figure 2 , which is a schematic flowchart of a control method for non-player characters provided by the embodiments of the present application. The specific process of this control method for non-player characters can be as follows:
[0077] 101. Obtain the first position and moving speed of the player character in the game scene of the target game.
[0078] In the embodiments of the present application, a game interface is provided through a terminal device. The game interface displays at least part of the game scene of the target game and the player character located in the game scene. Among them, the player character refers to a virtual character controlled by the current game player through the terminal device in the game scene.
[0079] Among them, the first position refers to the coordinate position where the player character is currently located in the game scene. For example, the first position can be (x0, y0). The moving speed refers to the speed at which the player character moves in the game scene.
[0080] 102. Based on the first position and the moving speed, predict the moving range of the player character in the game scene.
[0081] Among them, the moving range refers to the range within which the player character is predicted to move in the game scene in a future period of time according to the first position and the moving speed of the player character in the game scene.
[0082] In some embodiments, in order to accurately predict the movement range, the step of "predicting the movement range of the player character in the game scene based on the first position and the movement speed" may include the following operations:
[0083] Obtain the duration of the player character's movement in the game scene;
[0084] Calculate the movement distance of the player character in the game scene according to the duration and the movement speed;
[0085] Determine the movement range based on the first position and the movement distance.
[0086] Wherein, the duration refers to the movement duration of the player character starting from the current time in the game scene.
[0087] In some embodiments, the duration can be preset. For example, the duration can be set according to the historical movement information of the player character in the game scene. Specifically, the historical movement information can be the movement duration of the player character controlled by the current game player in the game scene each time during the historical time. The average value of the multiple movement durations is used as the set duration.
[0088] In some embodiments, the duration can be adjusted according to the actual situation. For example, it can be adjusted according to the game skills or game items used by the player character. The preset duration corresponding to a game skill or game item can be preset, and then the preset duration corresponding to the game skill or game item currently used by the player character is determined as the movement duration of the current movement.
[0089] Wherein, calculating the movement distance of the player character in the game scene according to the duration and the movement speed may include: calculating the product of the duration and the movement speed to obtain the movement distance.
[0090] Specifically, a circle is determined from the game scene with the first position as the center and the movement distance as the radius as the movement range.
[0091] For example, please refer to Figure 3 , Figure 3 is a schematic diagram of an application scenario of a control method for non-player characters provided by an embodiment of the present application. In Figure 3 In the shown game scene, the position where the player character is located is position P, the movement speed can be: V, and the movement duration can be: T. The movement distance L = V * T is calculated according to the movement speed and the duration. Then, in the game scene, a circular area is determined with position P as the center and the movement distance L as the radius as the movement range of the player character within the duration T.
[0092] In the embodiments of the present application, the moving range of the player character is calculated according to a preset formula. Specifically, the preset formula can be as follows:
[0093] (x - x0) 2 +(y - y0) 2 ≤(vt) 2 ;
[0094] Wherein, x0 and y0 refer to the coordinate values corresponding to the first position of the player character; v refers to the moving speed of the player character, t refers to the moving time, and vt refers to the moving distance. x and y refer to the coordinate values corresponding to any position within the moving range of the player character.
[0095] 103. Determine the target non-player characters among the non-player characters that need to surround and pursue the player character according to the second position of the non-player character in the game scene and the moving range.
[0096] In the embodiments of the present application, the game scene may further include non-player characters. Among them, non-player characters refer to virtual characters in the game scene that are not controlled by game players. For example, non-player characters can be monster characters set in the game scene, etc. The number of non-player characters can be multiple.
[0097] Wherein, the second position refers to the coordinate position where the non-player character is currently located in the game scene. For example, the second position can be (x1, y1).
[0098] In some embodiments, in order to improve the player's game experience, the step of "determining the target non-player characters among the non-player characters that need to surround and pursue the player character according to the second position of the non-player character in the game scene and the moving range" may include:
[0099] Determine the target non-player characters based on the non-player characters whose second position is outside the moving range.
[0100] Among them, the non-game characters that are not within the moving range in the game scene are used as the target non-player characters that need to surround and pursue the player character. Thus, it can be ensured that the non-player characters that are far away from the player character in the game scene pursue the player character at close range.
[0101] Among them, to determine whether a non-player character is within the moving range, the second position of the non-player character can be calculated with the preset formula, and it can be judged whether the non-player character is within the moving range according to the calculation result.
[0102] Specifically, substitute the second position (x1, y1) of the non-player character into the preset formula for calculation, that is, calculate (x1 - x0) 2 +(y1 - y0) 2, obtain the calculation result. If the calculation result is less than or equal to (vt) 2 then it can be determined that the non-player character is within the moving range; if the calculation result is greater than (vt) 2 , then it can be determined that the non-player character is not within the moving range.
[0103] In the embodiments of the present application, for a non-player character within the moving range, since the distance from the player character is relatively close, the current pursuit state of the player character can be maintained.
[0104] For example, please refer to Figure 4 , Figure 4 which is a schematic diagram of the application scenario of another control method for non-player characters provided by the embodiments of the present application. In Figure 4 the shown game scenario, it includes player character A, non-player character B, non-player character C, non-player character D, and non-player character E. According to the second positions of each non-player character, it is determined that the non-player character within the moving range is non-player character E, and the non-player characters not within the moving range are: non-player character B, non-player character C, and non-player character D.
[0105] In some embodiments, the position of the player character in the game scenario may change. In order to set the moving position of the non-player character in real time according to the position of the player character, after the step "predict the moving range of the player character in the game scenario based on the first position and the moving speed", the following steps may further be included:
[0106] Respond to the movement of the player character in the game scenario and obtain the post-movement position of the player character;
[0107] Predict the changed moving range of the player character in the game scenario based on the post-movement position and the moving speed.
[0108] Among them, the movement of the player in the game scenario can be that the current game player controls the player character to move from the first position to the post-movement position in the game scenario through the terminal device.
[0109] Specifically, predicting the changed moving range based on the post-movement position and the moving speed can be calculated according to the above calculation method for predicting the moving range. Refer to the description of the above steps, and details will not be elaborated here.
[0110] In some embodiments, if the player character changes and the moving range is the changed moving range, then the step "determine the target non-player characters among the non-player characters that need to surround and pursue the player character according to the second positions of the non-player characters in the game scenario and the moving range" may include the following operations:
[0111] Determine the target non-player characters among the non-player characters that need to surround and pursue the player character based on the second position of the non-player characters in the game scene and the changed movement range.
[0112] Specifically, determine the target non-player characters based on the non-player characters whose second positions are outside the changed movement range.
[0113] 104. Based on the positional relationship between the target non-player characters and the movement range, determine the target positions corresponding to the target non-player characters surrounding and pursuing the player character.
[0114] In the embodiments of the present application, after predicting the movement range corresponding to the player character according to the position of the player character in the game scene, non-player characters outside the movement range can be controlled to surround and pursue the player character, that is, control multiple non-player characters outside the movement range to pursue the player character in a way of surrounding the player character.
[0115] Among them, the target position is also the position where the target non-player character surrounds and pursues the player character.
[0116] In some embodiments, in order to enhance the pursuit effect of the non-player characters on the player character, the step of "based on the positional relationship between the target non-player characters and the movement range, determine the target positions corresponding to the target non-player characters surrounding and pursuing the player character" may include the following operations:
[0117] Determine the position connection line between the target non-player characters and the player character in the game scene;
[0118] Based on the intersection point of the position connection line and the movement range, determine the target position.
[0119] In the embodiments of the present application, the target positions corresponding to each target non-player character can be determined from the edge of the movement range.
[0120] For example, please refer to Figure 5 , Figure 5 which is a schematic diagram of the application scenario of another control method for non-player characters provided by the embodiments of the present application. In the Figure 5 shown game scene, non-player character C is the target non-player character outside the movement range of player character A. Connect the positions of player character A and non-player character C to obtain a position connection line, and obtain the intersection point of this position connection line and the movement range as position O, then it can be determined that position O is the target position for non-player character C to surround and pursue player character A.
[0121] In some embodiments, if there are multiple target non-player characters, the step of "determining the target position corresponding to the encircling pursuit of the player character by the target non-player character based on the positional relationship between the target non-player character and the movement range" may include the following operations:
[0122] Determine the nearest non-player character closest to the player character from among the multiple target non-player characters;
[0123] Determine the position connection line between the nearest non-player character and the player character in the game scene;
[0124] Based on the intersection point of the position connection line and the movement range, determine the first target position corresponding to the nearest non-player character;
[0125] Based on the first target position corresponding to the nearest non-player character, determine the second target positions corresponding to the other non-player characters among the target player characters respectively.
[0126] Specifically, when there are multiple target non-player characters outside the movement range of the player character in the game scene, first determine the first target position of the nearest target non-player character to the player character within the movement range according to the positional relationship between the nearest target non-player character and the movement range, and then determine the second target positions corresponding to the other target non-player characters respectively from the movement range based on this first target position, so as to control multiple target non-player characters to surround the player character.
[0127] For example, please refer to Figure 6 , Figure 6 which is a schematic diagram of an application scenario of another control method for non-player characters provided by an embodiment of the present application. In Figure 6 the shown game scene, non-player character B, non-player character C, and non-player character D are target non-player characters outside the movement range of player character A.
[0128] First, determine the target non-player character closest to player character A from among the multiple target non-player characters, which can be target non-player character C, that is, use target non-player character C as the nearest non-player character. Then, connect the positions of player character A and non-player character C to obtain a position connection line, and obtain the intersection point of this position connection line and the movement range as position O, then it can be determined that position O is the first target position for non-player character C to encircle and pursue player character A. Furthermore, the second target positions for other player characters to encircle and pursue player character A can be determined based on this first target position.
[0129] In some embodiments, the step of "based on the first target position corresponding to the nearest non-player character, determining the second target positions corresponding to the other non-player characters among the target player characters respectively" may include the following operations:
[0130] Determine the number of other non-player characters;
[0131] Based on the first target position and the number of characters, determine candidate positions for the number of characters from the edge of the movement range;
[0132] Determine the candidate position closest to each other non-player character as the second target position corresponding to each other non-player character.
[0133] Herein, other non-player characters refer to the target non-player characters other than the nearest non-player character among the target non-player characters.
[0134] Specifically, after determining the first target position corresponding to the nearest non-player character from the edge of the movement range, the second target position corresponding to other non-player characters can be determined from the edge of the movement range based on the first target position and the number of other non-player characters.
[0135] In some embodiments, in order to improve the collaborative performance of multiple non-player characters in surrounding and chasing the player character, the step of "based on the first target position and the number of characters, determine candidate positions for the number of characters from the edge of the movement range" may include the following operations:
[0136] Determine the starting division position for dividing the edge of the movement range based on the first target position;
[0137] Calculate the interval distance for dividing the edge of the movement range according to the total length of the edge of the movement range and the number of target non-player characters;
[0138] Based on the starting division position and the interval distance, divide the edge of the movement range to obtain candidate positions for the number of characters.
[0139] Wherein, calculating the interval distance for dividing the edge of the movement range according to the total length of the edge of the movement range and the number of target non-player characters may include: calculating the ratio of the total length to the number of target non-player characters to obtain the interval distance, that is, evenly dividing the edge of the movement range according to the number of target document characters.
[0140] For example, please refer to Figure 7 , Figure 7 which is a schematic diagram of an application scenario of another control method for non-player characters provided by an embodiment of the present application. In Figure 7 the shown game scenario, the edge of the movement range can be circular.
[0141] After determining the first target position O corresponding to the non-player character C on the edge of the movement range, the circle can be evenly divided into 3 equal parts according to the number of target non-player characters. When dividing, the first target position can be used as the starting division position, and the value obtained by dividing the circumference of the circle by the number of target non-player characters is used as the interval distance L1. Starting from the first target position, a candidate position can be determined every interval distance L1 on the circle, and candidate positions P and candidate positions Q can be obtained.
[0142] Further, after determining candidate position P and candidate position Q, a second target position can be selected for other player characters from the candidate positions respectively.
[0143] In some embodiments, in order to quickly control the target non-player characters to quickly surround and pursue the player characters, the candidate position closest to each other non-player character can be selected from the candidate positions as the second target position corresponding to each other non-player character.
[0144] For example, please continue to refer to Figure 7 , for the other non-player character B, the candidate position closest to the other non-player character B is: candidate position P, then candidate position P can be used as the second target position corresponding to the other non-player character B; for the other non-player character D, the candidate position closest to the other non-player character D is: candidate position Q, then candidate position Q can be used as the second target position corresponding to the other non-player character D.
[0145] 105. Control the target non-player character to move towards the target position.
[0146] Specifically, after determining the target position corresponding to the target non-player character on the edge of the movement range, the target non-player character can be controlled to move towards the target position, so as to form a surrounding pursuit of the player character.
[0147] In some embodiments, when the number of target non-player characters is multiple, in order to improve the cooperation of multiple target non-player characters, the step of "controlling the target non-player character to move towards the target position" may include the following steps:
[0148] Control the nearest non-player character to move towards the first target position, and control each other non-player character to move towards the corresponding second target position respectively.
[0149] For example, please refer to Figure 8 , Figure 8 is a schematic diagram of an application scenario of another control method for non-player characters provided by the embodiment of the present application. In Figure 8In the shown game scenario, the target non-player characters include: non-player character B, non-player character C, and non-player character D. Among them, the target non-player character C is the nearest non-player character, and the corresponding first target position is position O; the second target position corresponding to non-player character B is position P; the second target position corresponding to non-player character D is position Q.
[0150] Thus, it is possible to control non-player character B to move towards position P, control non-player character D to move towards position Q, and control non-player character C to move towards position O, so as to achieve multiple non-player characters forming an encircling pursuit of player character A at the edge of the movement range.
[0151] The embodiment of the present application discloses a method for controlling non-player characters, and the method includes: obtaining the first position and movement speed of a player character in the game scenario of a target game; predicting the movement range of the player character in the game scenario based on the first position and movement speed; determining, according to the second positions of non-player characters in the game scenario and the movement range, the target non-player characters that need to conduct an encircling pursuit of the player character among the non-player characters; determining the target positions corresponding to the encircling pursuit of the player character by the target non-player characters based on the positional relationship between the target non-player characters and the movement range; controlling the target non-player characters to move towards the target positions. In this way, the game experience of game players can be improved.
[0152] According to the content introduced above, the following will give examples to further illustrate the method for controlling non-player characters of the present application. Please refer to Figure 9 , Figure 9 which is a schematic flowchart of another method for controlling non-player characters provided by an embodiment of the present application. Taking the specific application of this method for controlling non-player characters in the case where a player character in a game is surrounded by multiple non-player characters and controlling the non-player characters to pursue the player character as an example, the specific process can be as follows:
[0153] 201. The terminal displays the game interface of the target game.
[0154] Specifically, please refer to Figure 10 , please refer to Figure 10 , Figure 10 which is a schematic diagram of an application scenario of another method for controlling non-player characters provided by an embodiment of the present application. In the Figure 10 shown game interface, a partial game scenario of the target game, a player character and multiple non-player characters in the game scenario are displayed. Among them, the player character is a virtual character controlled by the game player of the current terminal, and the multiple non-player characters are virtual characters controlled by the terminal.
[0155] 202. The terminal obtains the first position of the player character in the game scenario and the second positions of each non-player character.
[0156] Specifically, the first position of the player character obtained by the terminal in the game scene can be (x0, y0), and the second positions of each non-player character obtained in the game scene can be (x1, y1).
[0157] 203. The terminal determines the moving range of the player character within a specified time according to the first position.
[0158] Specifically, the moving speed of the player character in the game scene is obtained, and according to the first position, the moving speed, and the specified time, the moving range of the player character in the game scene can be determined.
[0159] For example, the first position of the player character in the game scene can be (x0, y0), the moving speed of the player character can be v, and the speed can remain unchanged during the moving process. Set an algorithm parameter t, that is, the specified time, which can be used to predict the moving range of the player character within t time. t can be adjusted according to the actual situation as a parameter. Then within t time, according to the preset formula (x - x0) 2 +(y - y0) 2 ≤(vt) 2 , the moving range of the player character can be calculated, which can be a circular area.
[0160] For example, please refer to Figure 11 , please refer to Figure 11 , Figure 11 is a schematic diagram of an application scenario of another non-player character control method provided by an embodiment of the present application. In Figure 11 In the shown game scene, according to the first position of the player character in the game scene and the moving speed of the player character, according to the preset formula, the moving range of the player character in the game scene within the specified time is calculated.
[0161] 204. The terminal determines a target non-player character that surrounds and chases the player character from multiple non-player characters according to the second position.
[0162] Specifically, according to the second positions of each non-player character, the non-player characters whose second positions are outside the moving range are determined as target non-player characters.
[0163] For example, please refer to Figure 12 , Figure 12 is a schematic diagram of an application scenario of another non-player character control method provided by an embodiment of the present application. In Figure 12 In the shown game scene, it includes a player character, a first non-player character, a second non-player character, and a third non-player character. Determining the target non-player characters outside the moving range according to the second positions of each non-player character may include: the first non-player character, the second non-player character, and the third non-player character.
[0164] 205. The terminal determines the first target non-player character that is the closest to the player character from the target non-player characters.
[0165] Please continue to refer to Figure 12 , the target non-player characters may include: the first non-player character, the second non-player character, and the third non-player character. Among them, the first target non-player character that is the closest to the player character may be: the third non-player character.
[0166] 206. The terminal determines a first target position where the first target non-player character surrounds the player character from the edge of the movement range according to the positional relationship between the first target non-player character and the movement range.
[0167] For example, please refer to Figure 13 , Figure 13 is a schematic diagram of an application scenario of another control method for non-player characters provided by an embodiment of the present application. In Figure 13 the shown game scenario, a connection line is generated based on the positions of the player character and the third non-player character that is the closest in the game scenario, and the intersection position P1 of the connection line and the edge of the movement range is obtained as the first target position where the third non-player character surrounds the player character.
[0168] 207. The terminal determines a second target position corresponding to the second target non-player character from the edge of the movement range according to the first target position and the number of target non-player characters.
[0169] First, obtain the number of target non-player characters, which may be n. Then, taking the first target position as a reference, the edge (circle) of the movement range is evenly divided into n equal parts, and n equal positions, namely (x1, y1), (x1, y2),... (xn, yn), can be obtained on the edge circle of the movement range.
[0170] Furthermore, for each equal position on the edge circle, find the target non-player character that is the closest to each equal position, and set it as the target position corresponding to each target non-player character surrounding the player character.
[0171] 208. The terminal controls the first target non-player character to move towards the first target position, and controls the second target non-player character to move towards the second target position.
[0172] For example, please refer to Figure 14 , Figure 14A schematic diagram of an application scenario of another method for controlling a non-player character provided by an embodiment of the present application. Determining a plurality of equal-position locations from the edge circle of the movement range may include: position P1, position P2, and position P3. From each non-player character, the non-player character closest to position P1 may be determined as the third non-player character, so that the third non-player character can be controlled to move towards position P1; the non-player character closest to position P2 may be determined as the second non-player character, so that the second non-player character can be controlled to move towards position P2; the non-player character closest to position P3 may be determined as the first non-player character, so that the first non-player character can be controlled to move towards position P3.
[0173] An embodiment of the present application discloses a method for controlling a non-player character. The method includes: a terminal displays a game interface of a target game, obtains a first position of a player character and second positions of each non-player character in the game scene, determines a movement range of the player character within a specified time according to the first position, determines target non-player characters that surround and pursue the player character from multiple non-player characters according to the second positions, determines a first target non-player character closest to the player character from the target non-player characters, determines a first target position for the first target non-player character to surround the player character from the edge of the movement range according to the positional relationship between the first target non-player character and the movement range, determines a second target position corresponding to a second target non-player character from the edge of the movement range according to the first target position and the number of target non-player characters, controls the first target non-player character to move towards the first target position, and controls the second target non-player character to move towards the second target position. In this way, the game experience of game players is improved.
[0174] To facilitate better implementation of the method for controlling a non-player character provided by an embodiment of the present application, an embodiment of the present application further provides a control device for a non-player character based on the above method for controlling a non-player character. The meanings of the nouns are the same as those in the above method for controlling a non-player character, and the specific implementation details can refer to the description in the method embodiment.
[0175] Please refer to Figure 15 , Figure 15 A structural block diagram of a control device for a non-player character provided by an embodiment of the present application. The device includes:
[0176] An acquisition unit 301, configured to acquire a first position and a movement speed of a player character in a game scene of a target game;
[0177] A first prediction unit 302, configured to predict a movement range of the player character in the game scene based on the first position and the movement speed;
[0178] The first determination unit 303 is configured to determine, according to the second position of the non-player character in the game scene and the movement range, a target non-player character among the non-player characters that needs to surround and pursue the player character;
[0179] The second determination unit 304 is configured to determine, based on the positional relationship between the target non-player character and the movement range, a target position corresponding to the target non-player character surrounding and pursuing the player character;
[0180] The control unit 305 is configured to control the target non-player character to move towards the target position.
[0181] In some embodiments, the first prediction unit 302 may include:
[0182] The first determination subunit is configured to obtain the duration of movement of the player character in the game scene;
[0183] The first calculation subunit is configured to calculate the movement distance of the player character in the game scene according to the duration and the movement speed;
[0184] The second determination subunit is configured to determine the movement range based on the first position and the movement distance.
[0185] In some embodiments, the first determination unit 303 may include:
[0186] The third determination subunit is configured to determine the target non-player character based on the non-player characters whose second positions are outside the movement range.
[0187] In some embodiments, the second determination unit 304 may include:
[0188] The fourth determination subunit is configured to determine the position connection line between the target non-player character and the player character in the game scene;
[0189] The fifth determination subunit is configured to determine the target position based on the intersection point of the position connection line and the movement range.
[0190] In some embodiments, the second determination unit 304 may include:
[0191] The sixth determination subunit is configured to determine the nearest non-player character closest to the player character from among a plurality of target non-player characters;
[0192] The seventh determination subunit is configured to determine the position connection line between the nearest non-player character and the player character in the game scene;
[0193] An eighth determination subunit, configured to determine a first target position corresponding to the nearest non-player character based on an intersection point of the position connection line and the movement range;
[0194] A sixth determination subunit, configured to determine second target positions corresponding to other non-player characters among the target player characters respectively based on the first target position corresponding to the nearest non-player character.
[0195] In some embodiments, the sixth determination subunit may specifically be configured to:
[0196] Determine the number of other non-player characters;
[0197] Based on the first target position and the number of characters, determine candidate positions for the number of characters from the edge of the movement range;
[0198] Determine the candidate position closest to each other non-player character as the second target position corresponding to each other non-player character.
[0199] In some embodiments, the control unit 305 may include:
[0200] A control subunit, configured to control the nearest non-player character to move towards the first target position, and control each other non-player character to move towards the corresponding second target position respectively.
[0201] In some embodiments, the sixth determination subunit may specifically be configured to:
[0202] Determine the number of other non-player characters;
[0203] Determine a starting division position for dividing the edge of the movement range based on the first target position; calculate an interval distance for dividing the edge of the movement range according to the total length of the edge of the movement range and the number of target non-player characters; divide the edge of the movement range based on the starting division position and the interval distance to obtain candidate positions for the number of characters;
[0204] Determine the candidate position closest to each other non-player character as the second target position corresponding to each other non-player character.
[0205] In some embodiments, the device may further include:
[0206] A response unit, configured to obtain a post-movement position of the player character in response to the player character moving in the game scene;
[0207] A second prediction unit, configured to predict a changed movement range of the player character in the game scene based on the post-movement position and the movement speed.
[0208] In some embodiments, the first determination unit includes:
[0209] A ninth determination subunit, configured to determine, according to a second position of a non-player character in the game scenario and the changed movement range, a target non-player character among the non-player characters that needs to surround and pursue the player character.
[0210] An embodiment of the present application discloses a control device for non-player characters. The acquisition unit 301 acquires a first position and a movement speed of a player character in a game scenario of a target game; the first prediction unit 302 predicts a movement range of the player character in the game scenario based on the first position and the movement speed; the first determination unit 303 determines, according to a second position of a non-player character in the game scenario and the movement range, a target non-player character among the non-player characters that needs to surround and pursue the player character; the second determination unit 304 determines a target position corresponding to the target non-player character surrounding and pursuing the player character based on a positional relationship between the target non-player character and the movement range; the control unit 305 controls the target non-player character to move towards the target position. In this way, the game experience of game players can be improved.
[0211] Correspondingly, an embodiment of the present application further provides a computer device, and this computer device may be a terminal. As Figure 16 shown, Figure 16 is a schematic structural diagram of the computer device provided by the embodiment of the present application. The computer device 600 includes a processor 601 with one or more processing cores, a memory 602 with one or more computer-readable storage media, and a computer program stored on the memory 602 and executable on the processor. Among them, the processor 601 is electrically connected to the memory 602. Those skilled in the art can understand that the structural diagram of the computer device shown in the figure does not constitute a limitation on the computer device, and it may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0212] The processor 601 is the control center of the computer device 600, connects various parts of the entire computer device 600 through various interfaces and lines, executes various functions of the computer device 600 and processes data by running or loading software programs and / or modules stored in the memory 602, and calling data stored in the memory 602, so as to perform overall monitoring of the computer device 600.
[0213] In the embodiments of the present application, the processor 601 in the computer device 600 will load the instructions corresponding to the processes of one or more application programs into the memory 602 according to the following steps, and the processor 601 will run the application programs stored in the memory 602 to implement various functions:
[0214] Obtain the first position and moving speed of the player character in the game scene of the target game;
[0215] Based on the first position and the moving speed, predict the moving range of the player character in the game scene;
[0216] According to the second position of the non-player characters in the game scene and the moving range, determine the target non-player characters among the non-player characters that need to surround and pursue the player character;
[0217] Based on the positional relationship between the target non-player character and the moving range, determine the target position corresponding to the target non-player character surrounding and pursuing the player character;
[0218] Control the target non-player character to move towards the target position.
[0219] In some embodiments, based on the first position and the moving speed, predicting the moving range of the player character in the game scene includes:
[0220] Obtain the duration of the player character's movement in the game scene;
[0221] Calculate the moving distance of the player character in the game scene according to the duration and the moving speed;
[0222] Based on the first position and the moving distance, determine the moving range.
[0223] In some embodiments, according to the second position of the non-player characters in the game scene and the moving range, determining the target non-player characters among the non-player characters that need to surround and pursue the player character includes:
[0224] Based on the non-player characters whose second positions are outside the moving range, determine the target non-player characters.
[0225] In some embodiments, based on the positional relationship between the target non-player character and the moving range, determining the target position corresponding to the target non-player character surrounding and pursuing the player character includes:
[0226] Determine the position connection line between the target non-player character and the player character in the game scene;
[0227] Based on the intersection point of the position connection line and the moving range, determine the target position.
[0228] In some embodiments, there are multiple target non-player characters;
[0229] Based on the positional relationship between the target non-player characters and the movement range, determining the target positions corresponding to the target non-player characters surrounding and chasing the player character includes:
[0230] Determining the nearest non-player character closest to the player character from among the multiple target non-player characters;
[0231] Determining the position connection line between the nearest non-player character and the player character in the game scene;
[0232] Based on the intersection point of the position connection line and the movement range, determining the first target position corresponding to the nearest non-player character;
[0233] Based on the first target position corresponding to the nearest non-player character, determining the second target positions corresponding to the other non-player characters among the target player characters respectively.
[0234] In some embodiments, based on the first target position corresponding to the nearest non-player character, determining the second target positions corresponding to the other non-player characters among the target player characters respectively includes:
[0235] Determining the number of the other non-player characters;
[0236] Based on the first target position and the number of characters, determining candidate positions for the number of characters from the edge of the movement range;
[0237] Determining the candidate position closest to each of the other non-player characters as the second target position corresponding to each of the other non-player characters.
[0238] In some embodiments, controlling the target non-player characters to move towards the target positions includes:
[0239] Controlling the nearest non-player character to move towards the first target position, and controlling each of the other non-player characters to move towards the corresponding second target position respectively.
[0240] In some embodiments, based on the first target position and the number of characters, determining candidate positions for the number of characters from the edge of the movement range includes:
[0241] Based on the first target position, determining the starting division position for dividing the edge of the movement range;
[0242] According to the total length of the edge of the movement range and the number of target non-player characters, calculating the interval distance for dividing the edge of the movement range;
[0243] Based on the starting division position and the interval distance, dividing the edge of the movement range to obtain candidate positions for the number of characters.
[0244] In some embodiments, after predicting the moving range of the player character in the game scene based on the first position and the moving speed, it further includes:
[0245] In response to the movement of the player character in the game scene, obtain the post-movement position of the player character;
[0246] Predict the post-change moving range of the player character in the game scene based on the post-movement position and the moving speed;
[0247] According to the second position of the non-player characters in the game scene and the moving range, determine the target non-player characters among the non-player characters that need to surround and pursue the player character, including:
[0248] According to the second position of the non-player characters in the game scene and the post-change moving range, determine the target non-player characters among the non-player characters that need to surround and pursue the player character.
[0249] This solution obtains the first position and the moving speed of the player character in the game scene, predicts the moving range of the player character in the game scene according to the first position and the moving speed, and then, according to the moving range and the second position of the non-player characters in the game scene, determines the target non-player characters among the non-player characters that need to surround and pursue the player character; based on the positional relationship between the target non-player characters and the moving range, determine the target positions corresponding to the target non-player characters surrounding and pursuing the player character, and then control the target non-player characters to move towards the target positions, so as to achieve the surrounding and pursuit of the player character by multiple non-player characters in the game scene, thereby improving the player's gaming experience.
[0250] For the specific implementation of each of the above operations, reference can be made to the previous embodiments and will not be elaborated here.
[0251] Optionally, as Figure 16 shown, the computer device 600 further includes: a touch display screen 603, a radio frequency circuit 604, an audio circuit 605, an input unit 606, and a power supply 607. Among them, the processor 601 is electrically connected to the touch display screen 603, the radio frequency circuit 604, the audio circuit 605, the input unit 606, and the power supply 607 respectively. Those skilled in the art can understand that Figure 16 the computer device structure shown in
[0252] The touch display screen 603 can be used to display a graphical user interface and receive operation instructions generated by a user's interaction with the graphical user interface. The touch display screen 603 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the computer device. These graphical user interfaces can be composed of graphics, text, icons, videos, and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. The touch panel can be used to collect touch operations of the user on or near it (such as operations of the user using a finger, a stylus, or any suitable object or accessory on or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute the corresponding program. Optionally, the touch panel can include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the touch position of the user and detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 601, and can receive and execute commands sent by the processor 601. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 601 to determine the type of touch event. Subsequently, the processor 601 provides a corresponding visual output on the display panel according to the type of touch event. In the embodiments of the present application, the touch panel and the display panel can be integrated into the touch display screen 603 to implement input and output functions. However, in some embodiments, the touch panel and the touch panel can be implemented as two independent components to implement input and output functions. That is, the touch display screen 603 can also be used as part of the input unit 606 to implement the input function.
[0253] The radio frequency circuit 604 can be used to receive and transmit radio frequency signals to establish wireless communication with a network device or other computer devices through wireless communication, and receive and transmit signals with the network device or other computer devices.
[0254] The audio circuit 605 can be used to provide an audio interface between the user and the computer device through a speaker and a microphone. The audio circuit 605 can transmit the electrical signal converted from the received audio data to the speaker, and the speaker converts it into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 605 and then converted into audio data. After the audio data is output to the processor 601 for processing, it is sent to another computer device through the radio frequency circuit 604, or the audio data is output to the memory 602 for further processing. The audio circuit 605 may also include an earphone jack to provide communication between the peripheral earphone and the computer device.
[0255] The input unit 606 can be used to receive input numerical, character information or user feature information (such as fingerprint, iris, face information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0256] The power supply 607 is used to supply power to each component of the computer device 600. Optionally, the power supply 607 can be logically connected to the processor 601 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 607 can also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0257] Although Figure 16 not shown in the figure, the computer device 600 may also include a camera, a sensor, a Wi-Fi module, a Bluetooth module, etc., which will not be elaborated here.
[0258] In the above embodiments, the descriptions of each embodiment have their own focuses. For parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0259] As can be seen from the above, the computer device provided in this embodiment can obtain the first position and moving speed of the player character in the game scene of the target game; based on the first position and the moving speed, predict the moving range of the player character in the game scene; according to the second position of the non-player character in the game scene and the moving range, determine the target non-player character among the non-player characters that needs to surround and pursue the player character; based on the positional relationship between the target non-player character and the moving range, determine the target position corresponding to the target non-player character surrounding and pursuing the player character; control the target non-player character to move towards the target position.
[0260] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling relevant hardware through instructions. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0261] Therefore, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored. The computer programs can be loaded by a processor to execute the steps in any non-player character control method provided by the embodiment of the present application. For example, the computer program can execute the following steps:
[0262] Obtain the first position and moving speed of the player character in the game scene of the target game;
[0263] Predict the moving range of the player character in the game scene based on the first position and the moving speed;
[0264] Based on the second position of the non-player characters in the game scene and the moving range, determine the target non-player characters among the non-player characters that need to surround and pursue the player character;
[0265] Based on the positional relationship between the target non-player characters and the moving range, determine the target positions corresponding to the target non-player characters surrounding and pursuing the player character;
[0266] Control the target non-player characters to move towards the target positions.
[0267] In some embodiments, predicting the moving range of the player character in the game scene based on the first position and the moving speed includes:
[0268] Obtain the duration of the player character's movement in the game scene;
[0269] Calculate the moving distance of the player character in the game scene according to the duration and the moving speed;
[0270] Based on the first position and the moving distance, determine the moving range.
[0271] In some embodiments, determining the target non-player characters among the non-player characters that need to surround and pursue the player character based on the second position of the non-player characters in the game scene and the moving range includes:
[0272] Based on the non-player characters whose second positions are outside the moving range, determine the target non-player characters.
[0273] In some embodiments, determining the target positions corresponding to the target non-player characters surrounding and pursuing the player character based on the positional relationship between the target non-player characters and the moving range includes:
[0274] Determine the position connection line between the target non-player characters and the player character in the game scene;
[0275] Based on the intersection point of the position connection line and the moving range, determine the target position.
[0276] In some embodiments, there are multiple target non-player characters;
[0277] Based on the positional relationship between the target non-player characters and the moving range, determining the target positions corresponding to the target non-player characters surrounding and pursuing the player character includes:
[0278] Determine the nearest non-player character closest to the player character from among the multiple target non-player characters;
[0279] Determine the position connection line between the nearest non-player character and the player character in the game scene;
[0280] Based on the intersection point of the position connection line and the movement range, determine the first target position corresponding to the nearest non-player character;
[0281] Based on the first target position corresponding to the nearest non-player character, determine the second target positions corresponding to the other non-player characters among the target player characters respectively.
[0282] In some embodiments, based on the first target position corresponding to the nearest non-player character, determining the second target positions corresponding to the other non-player characters among the target player characters respectively includes:
[0283] Determine the number of other non-player characters;
[0284] Based on the first target position and the number of characters, determine candidate positions for the number of characters from the edge of the movement range;
[0285] Determine the candidate position closest to each other non-player character as the second target position corresponding to each other non-player character.
[0286] In some embodiments, controlling the target non-player character to move towards the target position includes:
[0287] Control the nearest non-player character to move towards the first target position, and control each other non-player character to move towards the corresponding second target position respectively.
[0288] In some embodiments, based on the first target position and the number of characters, determining candidate positions for the number of characters from the edge of the movement range includes:
[0289] Based on the first target position, determine the starting division position for dividing the edge of the movement range;
[0290] According to the total length of the edge of the movement range and the number of target non-player characters, calculate the interval distance for dividing the edge of the movement range;
[0291] Based on the starting division position and the interval distance, divide the edge of the movement range to obtain candidate positions for the number of characters.
[0292] In some embodiments, after predicting the movement range of the player character in the game scene based on the first position and the movement speed, it further includes:
[0293] In response to the movement of the player character in the game scene, obtain the post-movement position of the player character;
[0294] Based on the post-movement position and the movement speed, predict the changed movement range of the player character in the game scene;
[0295] Based on the second position of non-player characters in the game scene and the movement range, determine the target non-player characters among the non-player characters that need to surround and pursue the player character, including:
[0296] Based on the second position of non-player characters in the game scene and the changed movement range, determine the target non-player characters among the non-player characters that need to surround and pursue the player character.
[0297] In this solution, by obtaining the first position and movement speed of the player character in the game scene, predicting the movement range of the player character in the game scene based on the first position and movement speed, and then, based on the movement range and the second position of non-player characters in the game scene, determining the target non-player characters among the non-player characters that need to surround and pursue the player character; based on the positional relationship between the target non-player characters and the movement range, determining the target positions corresponding to the target non-player characters surrounding and pursuing the player character, and further controlling the target non-player characters to move towards the target positions, so as to achieve the surrounding and pursuit of the player character by multiple non-player characters in the game scene, thereby improving the player's gaming experience.
[0298] For the specific implementation of each of the above operations, reference may be made to the previous embodiments and will not be elaborated herein.
[0299] Among them, the storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.
[0300] Since the computer program stored in the storage medium can execute the steps in any of the non-player character control methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any of the non-player character control methods provided in the embodiments of the present application can be realized. For details, reference may be made to the previous embodiments and will not be elaborated herein.
[0301] The above has introduced in detail a non-player character control method, device, storage medium and computer device provided by the embodiments of the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A control method for non-player characters, characterized in that, Including: Obtain the first position and moving speed of the player character in the game scene of the target game; Predict the moving range of the player character in the game scene based on the first position and the moving speed; Determine the target non-player characters among the non-player characters that need to surround and pursue the player character according to the second position of the non-player characters in the game scene and the moving range; Determine the target position corresponding to the surrounding and pursuit of the player character by the target non-player characters based on the positional relationship between the target non-player characters and the moving range; Control the target non-player characters to move towards the target position; Wherein, there are multiple target non-player characters; The determining the target position corresponding to the surrounding and pursuit of the player character by the target non-player characters based on the positional relationship between the target non-player characters and the moving range includes: Determine the nearest non-player character to the player character from multiple target non-player characters; Determine the position connection line between the nearest non-player character and the player character in the game scene; Determine the first target position corresponding to the nearest non-player character based on the intersection point of the position connection line and the moving range; Determine the number of other non-player characters; Determine the starting division position for dividing the edge of the moving range based on the first target position; Calculate the interval distance for dividing the edge of the moving range according to the total length of the edge of the moving range and the number of target non-player characters; Divide the edge of the moving range based on the starting division position and the interval distance to obtain candidate positions for the number of characters; [[ID= 2. The method according to claim 1, wherein 3. The method according to claim 1, wherein 4. The method according to claim 1, wherein 5. The method according to claim 1, characterized in that, Control the movement of the nearest non-player character towards the first target position, and control the movement of each other non-player character towards the corresponding second target position respectively.
6. The method according to claim 1, characterized in that, After predicting the movement range of the player character in the game scene based on the first position and the movement speed, it further includes: In response to the movement of the player character in the game scene, obtain the post-movement position of the player character; Predict the changed movement range of the player character in the game scene based on the post-movement position and the movement speed; Determining the target non-player characters among the non-player characters that need to surround and pursue the player character according to the second position of the non-player characters in the game scene and the movement range includes: Determine the target non-player characters among the non-player characters that need to surround and pursue the player character according to the second position of the non-player characters in the game scene and the changed movement range.
7. A control device for a non-player character, characterized in that, The device includes: An acquisition unit for acquiring the first position and the movement speed of the player character in the game scene of the target game; A first prediction unit for predicting the movement range of the player character in the game scene based on the first position and the movement speed; A first determination unit for determining the target non-player characters among the non-player characters that need to surround and pursue the player character according to the second position of the non-player characters in the game scene and the movement range; A second determination unit for determining the target position corresponding to the surrounding pursuit of the player character by the target non-player character based on the positional relationship between the target non-player character and the movement range; A control unit for controlling the movement of the target non-player character towards the target position; Wherein, there are multiple target non-player characters; Determining the target position corresponding to the surrounding pursuit of the player character by the target non-player character based on the positional relationship between the target non-player character and the movement range includes: Determine the nearest non-player character closest to the player character from multiple target non-player characters; Determine the position connection line between the nearest non-player character and the player character in the game scene; Based on the intersection point of the position connection line and the movement range, determine the first target position corresponding to the nearest non-player character; Determine the number of other non-player characters; Based on the first target position, determine the starting division position for dividing the edge of the movement range; According to the total length of the edge of the movement range and the number of target non-player characters, calculate the interval distance for dividing the edge of the movement range; Based on the starting division position and the interval distance, divide the edge of the movement range to obtain candidate positions for the number of characters; Determine the candidate position closest to each other non-player character as the second target position corresponding to each other non-player character.
8. A computer device, comprising a memory, a processor, and a computer program stored on the memory and running on the processor, wherein, When the processor executes the program, it implements the control method of non-player characters as described in any one of claims 1 to 6.
9. A storage medium, characterized in that, The storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the control method of the non-player character according to any one of claims 1 to 6.
Citation Information
Patent Citations
Character motion following method and device, computing device and storage medium
CN110292773A
Motion control method and device
CN112451970A