Method, device and electronic equipment for controlling virtual character in game
By monitoring game events and character levels, and dynamically calling subtrees of the behavior tree based on priority, the problem of virtual character behavior not changing with game progress is solved, improving the interactive experience and computational efficiency.
Patent Information
- Application Number
- CN202411975577.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2044-12-30
AI Technical Summary
In existing technologies, when managing virtual character behavior through behavior trees and finite state machines, the behavior of virtual characters cannot change with the player's game progress, which limits the depth of the interactive experience and makes it difficult to dynamically adjust behavior priorities and manage complex states and nodes.
By monitoring game events, the current character level of the virtual character is obtained, and the corresponding behavior tree is invoked according to the level to control the virtual character to perform matching behaviors. The behavior tree includes multiple subtrees divided with different priorities to ensure that the behavior changes with the character level.
It enhances the growth potential and interactive depth of virtual characters, improves their reaction speed and flexibility, and optimizes the use of computing resources.
Smart Images

Figure CN119680196B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a method and device for controlling a virtual character in a game and an electronic device. BACKGROUND
[0002] In modern virtual role-playing games, artificial intelligence (AI) technology is widely used. AI is not only used to enhance the challenge of enemy virtual characters, but also used to support complex virtual character interactions.
[0003] Currently, game AI frameworks mainly use behavior trees and finite state machines to manage virtual character behaviors.
[0004] However, the current way of managing virtual character behaviors through behavior trees and finite state machines does not allow virtual character behaviors to change with the game progress of the player, thereby limiting the depth of the interactive experience. SUMMARY
[0005] The present application provides a method and device for controlling a virtual character in a game and an electronic device, which can improve the depth of the interactive experience. The specific solutions are as follows:
[0006] In a first aspect, the present application provides a method for controlling a virtual character in a game, the method comprising:
[0007] In response to monitoring the occurrence of a game event, obtaining a current character level of a first virtual character, the first virtual character being a virtual character controlled by an agent in a game session, the character level changing with the game progress.
[0008] According to the current character level, calling a first behavior tree, the first behavior tree being a behavior tree corresponding to the current character level among a plurality of behavior trees preset for the agent, the behavior tree including a plurality of behaviors and trigger conditions corresponding to the behaviors.
[0009] In response to determining that the game event meets a trigger condition of a first behavior, controlling the first virtual character to perform the first behavior, the first behavior being a behavior in the plurality of behaviors included in the first behavior tree that matches the game event.
[0010] In a second aspect, the present application provides a behavior tree, the behavior tree including a first behavior subtree, a second behavior subtree, and a third behavior subtree, the first behavior subtree including behaviors with a high execution priority, the second behavior subtree including behaviors without an execution priority, and the third behavior subtree including behaviors with a highest execution priority; wherein the behavior tree corresponds to a preset character level.
[0011] In a third aspect, the embodiments of the present application provide an agent, which comprises a monitoring module, a behavior tree module, a matching module and a control module.
[0012] The monitoring module is configured to monitor a game event.
[0013] The behavior tree module is configured to maintain a plurality of behavior trees, the plurality of behavior trees corresponding to a plurality of character levels, and each behavior tree comprising a plurality of behaviors and trigger conditions corresponding to the behaviors.
[0014] The matching module is configured to acquire a current character level of a first virtual character, the first virtual character being a virtual character controlled by the agent in a game session, and the character level changing along with a game process; and to call a first behavior tree according to the current character level, the first behavior tree being a behavior tree corresponding to the current character level among the plurality of behavior trees; and to call a first behavior matching the game event from the plurality of behaviors included in the first behavior tree according to the game event.
[0015] The control module is configured to control the first virtual character to perform the first behavior.
[0016] In a fourth aspect, the embodiments of the present application provide a control device for a virtual character in a game, which comprises:
[0017] The acquisition unit is configured to acquire a current character level of a first virtual character in response to monitoring occurrence of a game event, the first virtual character being a virtual character controlled by the agent in a game session, and the character level changing along with a game process.
[0018] The calling unit is configured to call a first behavior tree according to the current character level, the first behavior tree being a behavior tree corresponding to the current character level among a plurality of behavior trees preset for the agent, and each behavior tree comprising a plurality of behaviors and trigger conditions corresponding to the behaviors.
[0019] The control unit is configured to control the first virtual character to perform a first behavior in response to determining that the game event meets a trigger condition of the first behavior, the first behavior being a behavior matching the game event among the plurality of behaviors included in the first behavior tree.
[0020] In a fifth aspect, the embodiments of the present application further provide an electronic device, which comprises:
[0021] a processor; and
[0022] a memory configured to store a data processing program, and the electronic device, after being powered on and running the program by the processor, executes the method according to the first aspect.
[0023] In a sixth aspect, the embodiments of the present application further provide a computer readable storage medium, which stores a data processing program, and the program, when being run by a processor, executes the method according to the first aspect.
[0024] The method for controlling a virtual role in a game provided by the embodiments of the present application comprises the following steps: in response to monitoring occurrence of a game event, obtaining a current role level of a first virtual role, the first virtual role being a virtual role controlled by an intelligent agent in a game session, the role level changing along with a game process; according to the current role level, calling a first behavior tree, the first behavior tree being a behavior tree corresponding to the current role level in a plurality of behavior trees preset for the intelligent agent, the behavior tree comprising a plurality of behaviors and trigger conditions corresponding to the behaviors; in response to determining that the game event satisfies a trigger condition of a first behavior, controlling the first virtual role to perform the first behavior, the first behavior being a behavior in the plurality of behaviors included in the first behavior tree and matching the game event. It can be seen that, in the present application, firstly, the current role level of the first virtual role is obtained after monitoring occurrence of the game event, and the role level is limited to change along with the game process, then according to the current role level of the first virtual role, the first behavior tree is called, so that the behavior of the virtual role changes along with the change of the role level, and the growth of the virtual role is enhanced. Therefore, the method for controlling a virtual role in a game provided by the embodiments of the present application can improve the depth of interactive experience and enhance the game experience of users. BRIEF DESCRIPTION OF DRAWINGS
[0025] Figure 1 A flowchart of the method for controlling a virtual role in a game provided by the embodiments of the present application;
[0026] Figure 2 Another flowchart of the method for controlling a virtual role in a game provided by the embodiments of the present application;
[0027] Figure 3 Still another flowchart of the method for controlling a virtual role in a game provided by the embodiments of the present application;
[0028] Figure 4 Still another flowchart of the method for controlling a virtual role in a game provided by the embodiments of the present application;
[0029] Figure 5 A schematic diagram of a behavior tree provided by the embodiments of the present application;
[0030] Figure 6 A structural block diagram of an example of a device for controlling a virtual role in a game provided by the embodiments of the present application;
[0031] Figure 7 A structural block diagram of an example of an electronic device for controlling a virtual role in a game provided by the embodiments of the present application. DETAILED DESCRIPTION
[0032] In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be practiced without the specific details. In other instances, well-known methods have not been described in detail in order not to unnecessarily obscure aspects of the present application.
[0033] It should be noted that the terms "first", "second", "third", and the like in the description and in the claims of the present application are used for distinguishing between similar objects and not necessarily for describing a sequential or chronological order. The use of such terms in the description is therefore not to be construed as implying a specific order or sequence. Also, the terms "comprises", "comprising", "has", "having", "includes", "including", and the like, are to be construed open- ended, i.e., to mean including but not limited to, to indicate the presence of what follows recited members, steps or elements "comprising", "comprising", "has", "having", "includes" and "including" and the like, are to be construed as specifying the presence of stated members, steps or elements, but not to preclude the presence or addition of one or more other members, steps or elements, or groups thereof. Only the transitional phrases "consisting of and "consisting essentially of are to be construed as being closed or limited terms as defined by statute.
[0034] It should be understood that, in the embodiments of the present application, "at least one" means one or more, and "multiple" means two or more than two. "And / or" is only a description of the relationship between the associated objects, which means that there can be three relationships, for example, A and / or B can represent the existence of A alone, the existence of A and B together, and the existence of B alone. The character " / " generally represents an "or" relationship between the associated objects. "Including A, B and / or C" means including any one or any two or three of A, B and C.
[0035] It should be understood that, in the embodiments of the present application, "B corresponding to A", "B corresponding to A", "A corresponding to B" or "B corresponding to A" means that B is associated with A, and B can be determined according to A. Determining B according to A does not mean that B is determined only according to A, but also can be determined according to A and / or other information.
[0036] In modern virtual role-playing games, artificial intelligence technology is widely used. AI is not only used to enhance the challenge of enemy virtual characters, but also to support complex virtual character interactions.
[0037] Currently, game AI framework mainly implements the management of virtual character behavior through behavior tree and finite state machine. Behavior tree organizes character behavior through hierarchical structure, which is intuitive and manageable. Each node represents a decision point or action, and the relationship between nodes determines the execution order of behavior. Finite state machine (FSM) determines the action of the virtual character through state and state transition rules. The virtual character switches between different states to respond to game events. These technical methods usually combine with scripted interaction rules to ensure that the virtual character performs predetermined behavior in a specific situation.
[0038] However, the current behavior tree and FSM perform well in simple AI scenarios, but they are insufficient when dealing with complex and dynamic environments. The behavior of the virtual character does not change with the progress of the player, which limits the depth of the interactive experience. Due to the structural fixity, it is difficult for behavior tree and FSM to dynamically adjust the behavior priority and adapt to the changes in player behavior. At the same time, with the increase of game complexity, the number of states and nodes of behavior tree and FSM increases sharply, which is difficult to manage and maintain efficiently.
[0039] Based on the background technology, in order to improve the depth of interactive experience, the embodiment of the present application provides a method for controlling a virtual character in a game. The method is applied to a computer or a server, or other electronic devices capable of controlling a virtual character in a game. The embodiment of the present application is not specifically limited.
[0040] The technical solutions of the present application will be described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0041] Figure 1 The flowchart of the method for controlling a virtual character in a game provided by the embodiment of the present application is shown in FIG. 1. As shown in FIG. 1, the method can include S101-S103. Figure 1
[0042] S101, in response to monitoring the occurrence of a game event, obtaining the current character level of a first virtual character, the first virtual character being a virtual character controlled by an intelligent agent in a game session, the character level changing with the progress of the game.
[0043] Exemplarily, after the game event is monitored, the agent can obtain the current character level of the first virtual character. The character level changes along with the game progress, for example, the character level can be raised or lowered along with the game progress. The game event can include a change in the environment of the game session and a change in the behavior of the virtual character in the game session. Generally referred to as a specific situation occurring in the game or an activity that the player can participate in, the game event can be any event occurring in the game progress, for example, a game event triggered by the behavior of the player, in a multi-character role-playing game, when the virtual character controlled by the player reaches a certain location, a dialogue or a battle with other virtual characters is triggered, or the life value, the physical value, and / or the hatred value of the virtual character changes, etc. It can also be a game event preset by the game developer in the development stage, for example, the developer will hide special achievements, props or additional story fragments, waiting for the player to trigger. In different game types, the specific meaning represented by the character level is also different. For example, in games of types similar to multi-character role-playing, social interaction, etc., the character level can represent the bond level, which can be used to measure and represent the depth or strength of the relationship between game characters. In games of types similar to battle arena games, fighting games, etc., the character level can represent the fighting power level. In games of types similar to simulation management games, puzzle adventure games, etc., the character level can represent the intelligence level.
[0044] S102, according to the current character level, calling the first behavior tree, the first behavior tree being a behavior tree corresponding to the current character level in a plurality of behavior trees preset for the agent, the behavior tree including a plurality of behaviors and trigger conditions corresponding to the behaviors.
[0045] Exemplarily, the agent can correspond to a plurality of behavior trees, the plurality of behavior trees corresponding to the agent are built in response to the building instruction. The behavior tree is a collection of a plurality of behaviors preset for a virtual character, and the behaviors included in the behavior tree are different for different virtual characters. Exemplarily, the virtual character is a tank character, and the behavior tree corresponding to the tank character can include a taunt behavior, a normal attack behavior, and a charge behavior, etc. The virtual character is a fast double-knife character, and the behavior tree corresponding to the fast double-knife character can include a fast attack behavior, a charge behavior, and a petrification behavior, etc. The behavior tree includes a plurality of behaviors and trigger conditions corresponding to the behaviors. For example, the behavior tree includes a taunt behavior, and the corresponding trigger condition is that the hostile character's hatred target changes. The behavior tree includes a healing behavior, and the corresponding trigger condition is that the life value of the teammate is lower than 50%. The first behavior tree is a behavior tree corresponding to the current character level in the plurality of behavior trees preset for the agent, and different behaviors will be executed for different character levels of the virtual character. For example, the combat behavior executed when the combat power level of the virtual character is high can be a combo behavior, and the combat behavior executed when the combat power level of the virtual character is low can be a single move. Based on this, in the embodiment, the agent corresponds to a plurality of behavior trees, and each behavior tree corresponds to a different level. For example, the agent controlling the first virtual character corresponds to a behavior tree A, a behavior tree B, and a behavior tree C. The behavior tree A corresponds to level 1, the behavior tree B corresponds to level 2, and the behavior tree C corresponds to level 3. When it is monitored that the current character level of the first virtual character is level 2, the behavior tree B is called.
[0046] Exemplarily, after the current character level is obtained, the first behavior tree can be called according to the obtained current character level. When the character level represents a bond level, the bond level can include a high bond level, a medium bond level, and a low bond level. If it is obtained that the current character level belongs to the high bond level, the behavior tree corresponding to the high bond level is the first behavior tree, and the behavior tree corresponding to the high bond level can be called, that is, the first behavior tree is called.
[0047] S103, in response to determining that the game event meets the trigger condition of the first behavior, controlling the first virtual character to execute the first behavior, the first behavior being a behavior in the plurality of behaviors included in the first behavior tree and matching the game event.
[0048] Exemplarily, the game event can be compared with the trigger condition of each behavior in the first behavior sub-tree, and when the game event satisfies the trigger condition of the first behavior, the first virtual role can be controlled to perform the first behavior. For example, the trigger condition of the first behavior is that the role level of the first virtual role is greater than a preset threshold and the distance between the second virtual role and the first virtual role is less than a preset threshold, and when the game event satisfies that the role level of the first virtual role is greater than the preset threshold and the distance between the second virtual role and the first virtual role is less than the preset threshold, the first virtual role can be controlled to perform the first behavior, and the second virtual role is a virtual role in the virtual scene which has a distance less than the preset threshold from the first virtual role.
[0049] Exemplarily, it is assumed that the first behavior tree includes a taunt behavior, a quick attack behavior and a healing behavior, the trigger condition of the taunt behavior is that the hostile role changes the hatred target, the trigger condition of the quick attack behavior is that the distance between the hostile role and the virtual role corresponding to the first behavior tree is less than 50 meters, and the trigger condition of the healing behavior is that the life value of the teammate is less than 50%. It is assumed that the monitored game event is that the distance between the virtual role corresponding to the first behavior tree and the hostile role is 35 meters, and the game event can be compared with the trigger conditions of the taunt behavior, the quick attack behavior and the healing behavior in turn, and it is concluded that the game event satisfies the trigger condition of the quick attack behavior, and the virtual role corresponding to the first behavior tree can be controlled to perform the quick attack behavior.
[0050] The embodiment of the present application can obtain the current role level of the first virtual role in response to monitoring the occurrence of the game event, and limit the change of the role level along with the game process, and then call the first behavior tree according to the current role level, and control the first virtual role to perform the first behavior in response to determining that the game event satisfies the trigger condition of the first behavior. The current role level of the virtual role can be used to call the first behavior tree corresponding to the current role level of the virtual role, so that the behavior of the virtual role changes along with the change of the role level, the growth of the virtual role is enhanced, and the depth of the interactive experience is improved.
[0051] In an optional implementation provided in the embodiment, the role level of the virtual role is not only related to the behavior performed by the virtual role, but also related to the reaction time of the virtual role when performing the behavior. Exemplarily, the higher the bond level of the virtual role is, the shorter the reaction time of the virtual role when performing the behavior is, that is, the interval between performing a task and entering the next task is also shorter. From the perspective of the player, the virtual role fights more energetically.
[0052] Figure 2 Another flowchart of the method for controlling a virtual role in a game provided by the embodiment of the present application is provided. As shown in Figure 2 the method can further include S201-S204.
[0053] S201. Obtain, according to the current character level, a first parameter corresponding to the current character level, the first parameter being used to represent an influence multiple of a reaction duration when the character level influences the first virtual character to perform a behavior.
[0054] S202. Obtain a basic reaction duration preset for the first virtual character and a basic character level of the first virtual character.
[0055] Exemplarily, before the step of controlling the first virtual character to perform the first behavior in response to determining that the game event meets the trigger condition of the first behavior, the embodiment can further include: obtaining, according to the current character level, a first parameter corresponding to the current character level, wherein the first parameter is used to represent an influence multiple of a reaction duration when the character level influences the first virtual character to perform a behavior. The reaction duration can also be understood as a global cooldown (GCD). The basic reaction duration preset for the first virtual character can be understood as a preset default value of the reaction duration of the first virtual character. The basic character level of the first virtual character is the character level when the first virtual character starts to enter a game match. The basic reaction duration of the virtual character and the first parameter can be set through a configuration parameter table (for example, a
DT_CharacterAI
[0056] S203. Determine, according to the first parameter, the basic reaction duration corresponding to the first virtual character, and the basic character level of the first virtual character, a changed reaction duration corresponding to the first virtual character under the current character level.
[0057] S204. Control the first virtual character to perform the first behavior after waiting for the changed reaction duration.
[0058] Exemplarily, after obtaining the first parameter, the basic reaction duration corresponding to the first virtual character, and the basic character level of the first virtual character, the changed reaction duration corresponding to the first virtual character under the current character level can be determined, and then the first virtual character is controlled to perform the first behavior after waiting for the changed reaction duration.
[0059] For example, when the character level represents the bond level, the bond level can include a high bond level, a medium bond level and a low bond level, and the higher the bond level, the shorter the global cooling time. Assuming that the preset basic reaction length of the first virtual character is 30 seconds, the basic character level of the first virtual character is 1, and the basic reaction length corresponding to the first virtual character can be reduced by 5% for each level of the character level, i.e., the first parameter is 5%, when the current character level of the first virtual character is 3, the changed reaction length corresponding to the first virtual character can be determined according to the first parameter, the basic reaction length corresponding to the first virtual character and the basic character level of the first virtual character, which is 27 seconds. Then control the first virtual character to wait for 27 seconds and execute the first behavior.
[0060] The embodiment obtains the first parameter corresponding to the current character level according to the current character level, and obtains the preset basic reaction length of the first virtual character and the basic character level of the first virtual character. According to the first parameter, the basic reaction length corresponding to the first virtual character and the basic character level of the first virtual character, the changed reaction length corresponding to the first virtual character under the current character level is determined. The first virtual character is controlled to wait for the changed reaction length, and then the first behavior is executed. By using the influence of the character level on the reaction length of the virtual character executing the behavior, the promotion degree of the fighting desire of the virtual character with different attack styles can be adjusted.
[0061] In an optional implementation, according to the behavior priority, each behavior tree is divided into a plurality of sub-trees, for example, the first behavior tree is divided into a first behavior sub-tree and a second behavior sub-tree, the first behavior sub-tree includes behaviors with high execution priority, such as rapid attack behaviors, charge behaviors, etc., therefore, the first behavior sub-tree can also be called a priority group, the second behavior sub-tree includes behaviors without execution priority, such as normal attacks, petrification, turning around in place, etc., and the second behavior sub-tree can also be called a general group, and the trigger condition of the behaviors in the second behavior sub-tree is that all game events can trigger. Of course, the first behavior tree can also be divided into a first behavior sub-tree, a second behavior sub-tree, a third behavior sub-tree, …, with more refined priority, so as to refine the performance behaviors of the first virtual character, which will not be described in detail here.
[0062] Figure 3 Another flowchart of the method for controlling a virtual character in a game provided by the embodiment of the present application is shown in FIG. 3. Figure 3 As shown in FIG. 3, before S103, the method can further include S301-S303.
[0063] S301, compare the game event with the trigger condition of each behavior in the first behavior sub-tree.
[0064] S302, if the game event meets the trigger condition of the second behavior, the second behavior is determined as the first behavior, the second behavior is a behavior in the first behavior sub-tree that matches the game event.
[0065] S303, if the game event does not meet the trigger condition of each behavior in the first behavior sub-tree, the third behavior is determined as the first behavior, the third behavior is any behavior in the second behavior sub-tree.
[0066] For example, the game event can be compared with the trigger condition of each behavior in the first behavior sub-tree in turn, if the game event meets the trigger condition of the second behavior, the second behavior is determined as the first behavior. If the game event does not meet the trigger condition of each behavior in the first behavior sub-tree, any behavior in the second behavior sub-tree can be selected as the first behavior. The trigger condition of the behavior in the second behavior sub-tree is that all game events can trigger.
[0067] For example, in a battle game, the behavior tree A corresponding to the agent controlling the virtual character X is called according to the current character level of the virtual character X, the behavior tree A includes a first behavior sub-tree and a second behavior sub-tree. The first behavior sub-tree includes a healing behavior, a taunt behavior and a charge behavior, and the second behavior sub-tree includes a general attack behavior and a petrification behavior. When the game event is that the life value of the teammate of the virtual character X is less than 80%, the trigger condition of the healing behavior in the first behavior sub-tree is that when the life value of the teammate of the virtual character X is less than 80%, the teammate is given continuous healing, and the game event meets the trigger condition of the healing behavior. The healing behavior can be determined as the first behavior. After comparing the game event with the trigger condition of each behavior in the first behavior sub-tree in turn, if the game event does not meet the trigger condition of each behavior in the first behavior sub-tree, the general attack can be selected as the first behavior, or the petrification can be selected as the first behavior.
[0068] The embodiment compares the game event with the trigger condition of each behavior in the first behavior sub-tree, if the game event meets the trigger condition of the second behavior, the second behavior is determined as the first behavior, if the game event does not meet the trigger condition of each behavior in the first behavior sub-tree, the third behavior is determined as the first behavior, and the second behavior is a behavior in the first behavior sub-tree that matches the game event, and the third behavior is any behavior in the second behavior sub-tree, which can ensure that the virtual character has a guaranteed behavior to execute after the game event occurs, thereby ensuring stable operation of the game process.
[0069] In another optional implementation provided in the embodiment, the first behavior tree can further include a third behavior subtree, the third behavior subtree including behaviors with the highest execution priority, such as taunting behaviors, healing behaviors, and quick attack behaviors, and thus the third behavior subtree can also be referred to as a stress group. The behaviors included in the first behavior subtree, the second behavior subtree, and the third behavior subtree can be the same, but the behaviors included in each behavior subtree correspond to different trigger conditions.
[0070] Figure 4 Another flowchart of the method for controlling a virtual character in a game provided in the embodiment is shown in FIG. 4. As shown in FIG. 4, the method can further include S401-S403. Figure 4
[0071] S401, in response to a time of occurrence of a game event being a preset detection time, comparing the game event with trigger conditions of each behavior in a third behavior subtree.
[0072] S402, in response to the game event satisfying a trigger condition of a fourth behavior, controlling the first virtual character to perform the fourth behavior, and after the fourth behavior is performed, performing a first behavior, the fourth behavior being a behavior in the third behavior subtree that matches the game event.
[0073] S403, if the game event does not satisfy the trigger condition of each behavior in the third behavior subtree, controlling the first virtual character to perform the first behavior.
[0074] Exemplarily, the first behavior tree further includes a third behavior subtree, the third behavior subtree including behaviors with the highest execution priority, and the third behavior subtree can also be referred to as a stress group. When it is detected that a game event occurs and a time of occurrence of the game event is a preset detection time, the game event can be compared with trigger conditions of each behavior in the third behavior subtree, and the game event can also be compared with trigger conditions of each behavior in the first behavior subtree. If the game event satisfies a trigger condition of a fourth behavior and a trigger condition of a first behavior at the same time, the first virtual character is controlled to perform the fourth behavior, and after the fourth behavior is performed, the first behavior is performed. If the game event does not satisfy the trigger condition of each behavior in the third behavior subtree and satisfies the trigger condition of the first behavior, the first virtual character is controlled to perform the first behavior. If the game event does not satisfy the trigger condition of each behavior in the third behavior subtree and the trigger condition of each behavior in the first behavior subtree, the first virtual character is controlled to perform a third behavior.
[0075] For example, when the occurrence time of the game event is the preset detection time, the game event is that the bond level of the virtual character X is greater than the preset threshold and the hatred target of the virtual character Y is not the virtual character X, and the virtual character Y is the enemy character of the virtual character X. The game event can be compared with the trigger condition of each behavior in the third behavior sub-tree and the trigger condition of each behavior in the first behavior sub-tree. If the game event meets the trigger condition of behavior A and the trigger condition of behavior B at the same time, the virtual character X is controlled to execute the taunt skill, and after the execution of the taunt skill ends, the charge skill is executed; wherein behavior A is a behavior in the third behavior sub-tree that matches the game event, behavior B is a behavior in the first behavior tree that matches the game event, behavior A triggers the taunt skill, and behavior B is the charge skill. If the game event does not meet the trigger condition of each behavior in the third behavior sub-tree and meets the trigger condition of behavior B, the virtual character X is controlled to execute the charge skill; if the game event does not meet the trigger condition of each behavior in the third behavior sub-tree and the trigger condition of each behavior in the first behavior sub-tree, the virtual character X is controlled to execute behavior C, that is, any one behavior in the second behavior sub-tree is executed.
[0076] In this embodiment, the game event is compared with the trigger condition of each behavior in the third behavior sub-tree in response to the occurrence time of the game event being the preset detection time, and the first virtual character is controlled to execute the fourth behavior in response to the game event meeting the trigger condition of the fourth behavior, and after the execution of the fourth behavior ends, the first behavior is executed. If the game event does not meet the trigger condition of each behavior in the third behavior sub-tree, the first virtual character is controlled to execute the first behavior. The game event can be detected in real time, the first virtual character is immediately controlled to execute the fourth behavior when the game event meets the trigger condition of the fourth behavior, the reaction speed and flexibility of the virtual character are improved, and the user's game experience is further improved.
[0077] In some embodiments, the above method further includes S501-S503.
[0078] S501, in response to the occurrence time of the game event not being the detection time, the first virtual character is controlled to execute the first behavior.
[0079] S502, in response to the game progress reaching the detection time, the game event is compared with the trigger condition of each behavior in the third behavior sub-tree.
[0080] S503, in response to the game event meeting the trigger condition of the fourth behavior, the first virtual character is controlled to stop executing the first behavior, execute the fourth behavior, and continue to execute the first behavior after the execution of the fourth behavior ends.
[0081] Exemplarily, when the occurrence of the game event is monitored and the occurrence time of the game event is not the preset detection time, the game event can be compared with the trigger condition of each behavior in the first behavior sub-tree first, and if the game event meets the trigger condition of the first behavior, the first virtual role is controlled to execute the first behavior. When the game progresses to the preset detection time, the game event is compared with the trigger condition of each behavior in the third behavior sub-tree, and if the game event meets the trigger condition of the fourth behavior, the first virtual role is controlled to stop executing the first behavior, immediately execute the fourth behavior, and continue to execute the first behavior after the execution of the fourth behavior ends.
[0082] Exemplarily, assuming that the occurrence time of the game event is the first time, the preset detection time is the second time, and the first time is a time 30 seconds before the second time. The game event can be compared with the trigger condition of each behavior in the first behavior sub-tree at the occurrence time of the game event, and if the game event meets the trigger condition of the first behavior, the first virtual role is controlled to execute the first behavior. Then, 30 seconds after the game progresses, the game event is compared with the trigger condition of each behavior in the third behavior sub-tree, and if the game event meets the trigger condition of the fourth behavior, the first virtual role is controlled to stop executing the first behavior, execute the fourth behavior, and continue to execute the first behavior after the execution of the fourth behavior ends.
[0083] The embodiment can detect the game event when the game event progresses to the preset detection time by responding to the occurrence time of the game event not being the detection time, controlling the first virtual role to execute the first behavior, responding to the game progressing to the detection time, comparing the game event with the trigger condition of each behavior in the third behavior sub-tree, and responding to the game event meeting the trigger condition of the fourth behavior, controlling the first virtual role to stop executing the first behavior, execute the fourth behavior, and continue to execute the first behavior after the execution of the fourth behavior ends, so as to achieve the purpose of detecting the game event in real time, and further improve the reaction speed and flexibility of the virtual role.
[0084] The above is a specific implementation mode of the control method of the virtual role in the game. In the specific implementation, the virtual role in the game can also be controlled by other feasible modes, and the embodiment of the application is not limited thereto.
[0085] In the exemplary embodiment, the embodiment of the application further provides a behavior tree, the behavior tree including a first behavior sub-tree, a second behavior sub-tree and a third behavior sub-tree, the first behavior sub-tree including behaviors with a high execution priority, the second behavior sub-tree including behaviors without an execution priority, and the third behavior sub-tree including behaviors with a highest execution priority; wherein the behavior tree corresponds to a preset role level.
[0086] Figure 5This is a schematic diagram of a behavior tree provided for an embodiment of this application. Figure 5 As shown, each character level corresponds to a behavior tree, and each behavior tree can include a first behavior subtree, a second behavior subtree, and a third behavior subtree. For example, when the character level represents the bond level, the bond level can include high bond level, medium bond level, and low bond level, and each bond level corresponds to a behavior tree.
[0087] During game operation, the behavior of virtual characters can be controlled according to the behavior tree provided in this application embodiment, which contains various behaviors and corresponding triggering conditions, thereby reducing computational redundancy, optimizing the use of computing resources, and effectively improving the game's operating efficiency.
[0088] In an exemplary embodiment, this application also provides an intelligent agent that can be used to execute the control method for virtual characters in the above-described game. The intelligent agent includes: a monitoring module, a behavior tree module, a matching module, and a control module.
[0089] The monitoring module is used to monitor game events.
[0090] The Behavior Tree module is used to maintain multiple behavior trees, which correspond to multiple role levels. Each behavior tree includes multiple behaviors and their corresponding triggering conditions.
[0091] The matching module is used to obtain the current character level of the first virtual character, which is a virtual character controlled by an intelligent agent in the game, and whose character level changes with the progress of the game; it is also used to call the first behavior tree according to the current character level, which is a behavior tree among multiple behavior trees that corresponds to the behavior of the current character level; it is also used to retrieve the first behavior that matches the game event from among the multiple behaviors included in the first behavior tree according to the game event.
[0092] The control module controls the first virtual character to perform the first action.
[0093] The intelligent agent provided in this application includes: a monitoring module, a behavior tree module, a matching module, and a control module. The intelligent agent can utilize the included modules to execute the control methods of the virtual character in the game, thereby supporting templated configuration, reducing repetitive work, and allowing for the expansion of the behavior tree, thus improving development efficiency and facilitating subsequent maintenance and updates.
[0094] Corresponding to the method for controlling virtual characters in games provided in this application, this application also provides a device for controlling virtual characters in games. Figure 6 A structural block diagram of an example of a control device for a virtual character in a game provided in this application embodiment, such as... Figure 6 As shown, the control device 600 for the virtual character in the game includes:
[0095] The acquisition unit 601 is configured to acquire a current role level of a first virtual role in response to monitoring occurrence of a game event, the first virtual role being a virtual role controlled by an agent in a game session, the role level changing along with game progress.
[0096] The calling unit 602 is configured to call a first behavior tree according to the current role level, the first behavior tree being a behavior tree corresponding to the current role level in a plurality of behavior trees preset for the agent, the behavior tree including a plurality of behaviors and trigger conditions corresponding to the behaviors.
[0097] The control unit 603 is configured to control the first virtual role to perform a first behavior in response to determining that the game event meets a trigger condition of the first behavior, the first behavior being a behavior in the plurality of behaviors included in the first behavior tree and matching the game event.
[0098] Optionally, the acquisition unit 601 is further configured to acquire a first parameter corresponding to the current role level according to the current role level, the first parameter being used to represent an influence multiple of a reaction time length of the role level on performance of the behavior by the first virtual role; and acquire a basic reaction time length preset for the first virtual role and a basic role level of the first virtual role; and the control unit 603 is specifically configured to determine a changed reaction time length of the first virtual role corresponding to the current role level according to the first parameter, the basic reaction time length corresponding to the first virtual role, and the basic role level of the first virtual role; and control the first virtual role to perform the first behavior after waiting for the changed reaction time length.
[0099] Optionally, the first behavior tree includes at least a first behavior sub-tree and a second behavior sub-tree, the first behavior sub-tree including a behavior with a high execution priority, and the second behavior sub-tree including a behavior without an execution priority.
[0100] Optionally, as shown in Figure 6 the control apparatus 600 of the virtual role in the game further includes a comparison unit 604 and a determination unit 605.
[0101] The comparison unit 604 is configured to compare the game event with trigger conditions of each behavior in the first behavior sub-tree.
[0102] The determination unit 605 is configured to determine a second behavior as the first behavior if the game event meets a trigger condition of the second behavior, the second behavior being a behavior in the plurality of behaviors included in the first behavior sub-tree and matching the game event; and determine a third behavior as the first behavior if the game event does not meet the trigger condition of each behavior in the first behavior sub-tree, the third behavior being any behavior in the second behavior sub-tree.
[0103] Optionally, the comparison unit 604 is further configured to compare the game event with the trigger condition of each behavior in the third behavior sub-tree in response to the occurrence time of the game event being the preset detection time. The control unit 603 is specifically configured to: control the first virtual role to perform the fourth behavior in response to the game event satisfying the trigger condition of the fourth behavior, and perform the first behavior after the fourth behavior is performed, the fourth behavior being a behavior in the third behavior tree that matches the game event; and control the first virtual role to perform the first behavior in response to the game event not satisfying the trigger condition of each behavior in the third behavior sub-tree.
[0104] Optionally, the control unit 603 is further configured to: control the first virtual role to perform the first behavior in response to the occurrence time of the game event not being the detection time; compare the game event with the trigger condition of each behavior in the third behavior sub-tree in response to the game progress reaching the detection time; and control the first virtual role to stop performing the first behavior and perform the fourth behavior in response to the game event satisfying the trigger condition of the fourth behavior, and continue to perform the first behavior after the fourth behavior is performed.
[0105] Optionally, the game event includes: a change in an environment of a game session and a change in a behavior of a virtual role in the game session.
[0106] Optionally, as shown in Figure 6 the game virtual role control apparatus 600 further includes a construction unit 606.
[0107] The construction unit 606 is configured to construct, in response to a construction instruction, a plurality of behavior trees corresponding to the agent, the behavior tree including a plurality of behaviors and a trigger condition corresponding to the behavior.
[0108] Corresponding to the game virtual role control method provided in the embodiments of the present application, the embodiments of the present application further provide an electronic device for controlling a game virtual role.
[0109] As shown in Figure 7 , a structure block diagram of an example of the electronic device for controlling a game virtual role provided in the embodiments of the present application. Figure 7
[0110] In the present embodiment, an optional hardware structure of the electronic device 700 can include at least one processor 701, at least one memory 702 and at least one communication bus 705, as shown in Figure 7 the memory 702 contains a program 703 and data 704.
[0111] Bus 705 can be a communication device for transmitting data between components within electronic device 700, such as an internal bus (e.g., CPU-memory bus, where the processor is the central processing unit, or CPU for short) or an external bus (e.g., a universal serial bus port or a peripheral component interconnection fast port).
[0112] Additionally, the electronic device also includes at least one network interface 706 and at least one peripheral interface 707. The network interface 706 provides wired or wireless communication with an external network 708 (e.g., the Internet, intranet, local area network, mobile communication network, etc.). In some embodiments, the network interface 706 may include any number of network interface controllers (NICs), radio frequency (RF) modules, repeaters, transceivers, modems, routers, gateways, any combination of wired network adapters, wireless network adapters, Bluetooth adapters, infrared adapters, near field communication (NFC) adapters, cellular network chips, etc.
[0113] Peripheral interface 707 is used to connect to peripherals, such as peripheral 1 in the figure. Figure 7 709 in the middle), peripheral 2 ( Figure 7 710 in the middle) and peripheral 3 ( Figure 7 (711 in the original text). Peripherals are peripheral devices, which may include, but are not limited to, cursor control devices (such as mice, touchpads, or touchscreens), keyboards, displays (such as cathode ray tube displays, liquid crystal displays), displays or light-emitting diode displays, video input devices (such as cameras or input interfaces coupled to video files), etc.
[0114] The processor 701 may be a CPU, an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0115] The memory 702 may include high-speed RAM (Random Access Memory) memory, and may also include non-volatile memory, such as at least one disk storage device.
[0116] The processor 701 calls the program and data stored in the memory 702 and executes the following steps:
[0117] In response to monitoring occurrence of the game event, a current role level of the first virtual role is acquired, the first virtual role being a virtual role controlled by the agent in the game session, the role level changing along with a game progress;
[0118] According to the current role level, a first behavior tree is invoked, the first behavior tree being a behavior tree corresponding to the current role level in a plurality of behavior trees preset for the agent, the behavior tree including a plurality of behaviors and trigger conditions corresponding to the behaviors;
[0119] In response to determining that the game event satisfies a trigger condition of a first behavior, the first virtual role is controlled to perform the first behavior, the first behavior being a behavior in the plurality of behaviors included in the first behavior tree and matching the game event.
[0120] Corresponding to the method for controlling a virtual role in a game provided in the embodiments of the present application, the embodiments of the present application further provide a computer readable storage medium storing a program of the method for controlling a virtual role in a game, the program being run by a processor to perform the following steps:
[0121] In response to monitoring occurrence of the game event, a current role level of the first virtual role is acquired, the first virtual role being a virtual role controlled by the agent in the game session, the role level changing along with a game progress;
[0122] According to the current role level, a first behavior tree is invoked, the first behavior tree being a behavior tree corresponding to the current role level in a plurality of behavior trees preset for the agent, the behavior tree including a plurality of behaviors and trigger conditions corresponding to the behaviors;
[0123] In response to determining that the game event satisfies a trigger condition of a first behavior, the first virtual role is controlled to perform the first behavior, the first behavior being a behavior in the plurality of behaviors included in the first behavior tree and matching the game event.
[0124] It should be noted that the detailed description of the apparatus, the electronic device and the computer readable storage medium provided in the embodiments of the present application can refer to the related description of the method for controlling a virtual role in a game provided in the embodiments of the present application, which will not be repeated here.
[0125] The present application discloses the above with reference to the preferred embodiments, but it is not intended to limit the present application, any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application, therefore the protection scope of the present application should be limited by the scope defined in the claims of the present application.
[0126] In a typical configuration, a node device in a blockchain includes one or more processors (CPUs), input / output interfaces, network interfaces, and memories.
[0127] Memory can include, without being limited to, non-persistent memory, random access memory (RAM), and / or non-volatile memory, etc., such as read-only memory (ROM), or flash memory (flash RAM), in a computer-readable medium. Memory is an example of computer-readable media.
[0128] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other properties of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage media or any other non-transmission medium that can be used to store information that can be accessed by a computing device. According to the definition herein, computer-readable media does not include non-transitory computer-readable media (transitory media), such as modulated data signals and carriers.
[0129] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as a method, system or computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0130] Although the present application is disclosed as above with preferred embodiments, it is not intended to limit the present application, and any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application, therefore the protection scope of the present application should be limited by the scope defined by the claims of the present application.
Claims
1. A method of controlling a virtual character in a game, characterized by, The game session includes at least one virtual character, and the method comprises: in response to monitoring occurrence of a game event, obtaining a current character level of a first virtual character, the first virtual character being a virtual character controlled by an agent in the game session, the character level changing along with game progress; according to the current character level, calling a first behavior tree, the first behavior tree being a behavior tree corresponding to the current character level in a plurality of behavior trees preset for the agent, the behavior tree comprising a plurality of behaviors and trigger conditions corresponding to the behaviors; in response to determining that the game event satisfies a trigger condition of a first behavior, controlling the first virtual character to perform the first behavior, the first behavior being a behavior in the plurality of behaviors included in the first behavior tree and matching the game event; before the step of controlling the first virtual character to perform the first behavior in response to determining that the game event satisfies a trigger condition of a first behavior, the method further comprises: according to the current character level, obtaining a first parameter corresponding to the current character level, the first parameter being used to represent an influence multiple of a reaction time length of the character level when the first virtual character performs a behavior; obtaining a basic reaction time length preset for the first virtual character and a basic character level of the first virtual character; the step of controlling the first virtual character to perform the first behavior in response to determining that the game event satisfies a trigger condition of a first behavior comprises: determining, according to the first parameter, the basic reaction time length corresponding to the first virtual character and the basic character level of the first virtual character, a changed reaction time length corresponding to the first virtual character under the current character level; controlling the first virtual character to perform the first behavior after waiting for the changed reaction time length.
2. The method of claim 1, wherein, The first behavior tree comprises at least a first behavior subtree and a second behavior subtree, the first behavior subtree comprising behaviors with a high execution priority, and the second behavior subtree comprising behaviors without an execution priority.
3. The method of claim 2, wherein, before the step of controlling the first virtual character to perform the first behavior in response to determining that the game event satisfies a trigger condition of a first behavior, the method further comprises: comparing the game event with trigger conditions of each behavior in the first behavior subtree; if the game event satisfies a trigger condition of a second behavior, determining the second behavior as the first behavior, the second behavior being a behavior in the plurality of behaviors included in the first behavior subtree and matching the game event; if the game event does not satisfy the trigger conditions of each behavior in the first behavior subtree, determining a third behavior as the first behavior, the third behavior being any behavior in the second behavior subtree.
4. The method of claim 3, wherein, The first behavior tree further comprises a third behavior subtree, the third behavior subtree comprising behaviors with a highest execution priority, and the method further comprises: in response to the occurrence time of the game event being a preset detection time, comparing the game event with trigger conditions of each behavior in the third behavior subtree; The control of the first virtual character to perform the first behavior includes: In response to the game event satisfying a trigger condition of a fourth behavior, the first virtual character is controlled to perform the fourth behavior, and after the fourth behavior is performed, the first behavior is performed, the fourth behavior being a behavior in the third behavior sub-tree that matches the game event; If the game event does not satisfy the trigger condition of each behavior in the third behavior sub-tree, the first virtual character is controlled to perform the first behavior.
5. The method of claim 4, wherein, The method further includes: In response to the occurrence time of the game event not being the detection time, the first virtual character is controlled to perform the first behavior; In response to the game process proceeding to the detection time, the game event is compared with the trigger condition of each behavior in the third behavior sub-tree; In response to the game event satisfying a trigger condition of a fourth behavior, the first virtual character is controlled to stop performing the first behavior, perform the fourth behavior, and continue to perform the first behavior after the fourth behavior is performed.
6. The method of claim 1, wherein, The game event includes: Changes in the environment of the game session and changes in the behavior of a virtual character in the game session.
7. The method of claim 1, wherein, The method further includes: In response to a construction instruction, the plurality of behavior trees corresponding to the agent are constructed, the behavior trees including a plurality of behaviors and trigger conditions corresponding to the behaviors.
8. An agent, characterized in that The agent includes a monitoring module, a behavior tree module, a matching module, and a control module. The monitoring module is configured to monitor game events. The behavior tree module is configured to maintain a plurality of behavior trees corresponding to a plurality of character levels, the behavior trees including a plurality of behaviors and trigger conditions corresponding to the behaviors. The matching module is configured to obtain a current character level of a first virtual character, the first virtual character being a virtual character in a game session controlled by the agent, the character level changing as the game progresses; further configured to call a first behavior tree according to the current character level, the first behavior tree being a behavior tree in the plurality of behavior trees corresponding to the current character level; and further configured to call a first behavior matching the game event from a plurality of behaviors included in the first behavior tree according to the game event. The control module controls the first virtual character to perform the first behavior. Before the step of controlling the first virtual character to perform the first behavior in response to determining that the game event satisfies a trigger condition of the first behavior, the matching module is further configured to: According to the current character level, a first parameter corresponding to the current character level is obtained, the first parameter being used to represent an influence multiple of a reaction time of the character level when the first virtual character performs a behavior; A preset basic reaction time for the first virtual character and a basic character level of the first virtual character are obtained. The response to the determination that the game event satisfies the trigger condition of the first behavior includes: determine a changed reaction duration corresponding to the first virtual character under the current character level according to the first parameter, a basic reaction duration corresponding to the first virtual character, and a basic character level of the first virtual character; control the first virtual character to execute the first behavior after waiting for the changed reaction duration.
9. A control apparatus for a virtual character in a game, characterized by comprising: The apparatus comprises: an acquisition unit configured to, in response to monitoring occurrence of a game event, acquire a current character level of a first virtual character, the first virtual character being a virtual character controlled by an intelligent agent in a game session, the character level changing along with game progress; a calling unit configured to call a first behavior tree according to the current character level, the first behavior tree being a behavior tree corresponding to the current character level in a plurality of behavior trees preset for the intelligent agent, the behavior tree comprising a plurality of behaviors and trigger conditions corresponding to the behaviors; a control unit configured to, in response to determining that the game event meets a trigger condition of a first behavior, control the first virtual character to execute the first behavior, the first behavior being a behavior in the plurality of behaviors included in the first behavior tree and matching the game event; Before the step of, in response to determining that the game event meets a trigger condition of a first behavior, controlling the first virtual character to execute the first behavior, the acquisition unit is further configured to: acquire a first parameter corresponding to the current character level according to the current character level, the first parameter being used to represent an influence multiple of the character level on a reaction duration of the first virtual character when executing a behavior; acquire a basic reaction duration preset for the first virtual character and a basic character level of the first virtual character; the step of, in response to determining that the game event meets a trigger condition of a first behavior, controlling the first virtual character to execute the first behavior, comprises: determining a changed reaction duration corresponding to the first virtual character under the current character level according to the first parameter, a basic reaction duration corresponding to the first virtual character, and a basic character level of the first virtual character; controlling the first virtual character to execute the first behavior after waiting for the changed reaction duration.
10. An electronic device, comprising: comprise: a processor; and a memory configured to store a data processing program, after the electronic device is powered on and the program is run by the processor, the method according to any one of claims 1-7 is executed.
11. A computer readable storage medium, characterized in that, a data processing program is stored, the program is run by the processor, and the method according to any one of claims 1-7 is executed.
Citation Information
Patent Citations
Game control method and device and electronic equipment
CN111111193A
Virtual game role control method and device, storage medium and electronic device
CN113926196A