Method and device for controlling virtual character in game and electronic equipment
By monitoring game events and obtaining the current character level of virtual characters, dynamically calling the behavior tree and performing matching behavior, the problem that virtual character behavior in the existing technology cannot change with the progress of the game is solved, and a deeper interactive experience and a better gaming experience are achieved.
Patent Information
- Application Number
- CN202411975577.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-12-30
AI Technical Summary
The existing game AI framework manages virtual character behavior through behavior trees and finite state machines, resulting in behavior being unable to change with the player's game progress, limiting the depth of the interactive experience.
By monitoring game events, obtaining the current character level of the virtual character, and calling the corresponding behavior tree according to the level, performing matching behaviors in response to game events, so that the behavior of the virtual character changes with the change of the character level.
It enhances the growth of virtual characters and the depth of interactive experience, and improves the user's gaming experience.
Smart Images

Figure CN119680196A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, device, and electronic device for controlling a virtual character in a game. Background Art
[0002] In modern virtual role-playing games, artificial intelligence (AI) technology is widely used. AI is not only used to enhance the challenge of hostile virtual characters, but also to support complex virtual character interactions.
[0003] Currently, game AI frameworks mainly manage virtual character behaviors through behavior trees and finite state machines.
[0004] However, the current way of managing virtual character behaviors through behavior trees and finite state machines means that the behavior of virtual characters does not change with the player's game progress, thus limiting the depth of the interactive experience. Summary of the invention
[0005] The present application provides a method, device, and electronic device for controlling a virtual character in a game, which can enhance the depth of the interactive experience. The specific scheme is as follows:
[0006] In a first aspect, an embodiment of 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, a current character level of a first virtual character is obtained, where the first virtual character is a virtual character controlled by an agent in a game match, and the character level changes with the progress of the game.
[0008] According to the current character level, the first behavior tree is called. The first behavior tree is a behavior tree corresponding to the current character level among multiple behavior trees preset for the intelligent agent. The behavior tree includes multiple behaviors and trigger conditions corresponding to the behaviors.
[0009] In response to determining that the game event meets the triggering condition of the first behavior, the first virtual character is controlled to perform the first behavior, where the first behavior is a behavior that matches the game event among the multiple behaviors included in the first behavior tree.
[0010] In a second aspect, an embodiment of the present application provides a behavior tree, wherein the behavior tree includes a first behavior subtree, a second behavior subtree, and a third behavior subtree, wherein the first behavior subtree includes behaviors with high execution priorities, the second behavior subtree includes behaviors with no execution priorities, and the third behavior subtree includes behaviors with the highest execution priority; wherein the behavior tree corresponds to a preset role level.
[0011] In a third aspect, an embodiment of the present application provides an intelligent agent, which includes: a monitoring module, a behavior tree module, a matching module, and a control module.
[0012] Monitoring module, used to monitor game events.
[0013] The behavior tree module is used to maintain multiple behavior trees. Multiple behavior trees correspond to multiple role levels. A behavior tree includes multiple behaviors and the trigger conditions corresponding to the behaviors.
[0014] The matching module is used to obtain the current character level of a first virtual character, the first virtual character is a virtual character controlled by an intelligent agent in a game match, and the character level changes with the progress of the game; it is also used to call a first behavior tree according to the current character level, the first behavior tree is a behavior tree corresponding to the current character level behavior among multiple behavior trees; it is also used to call a first behavior that matches a game event among multiple behaviors included in the first behavior tree according to a game event.
[0015] The control module controls the first virtual character to perform a first behavior.
[0016] In a fourth aspect, an embodiment of the present application provides a control device for a virtual character in a game, the device comprising:
[0017] The acquisition unit is used to acquire the current role level of the first virtual role in response to monitoring the occurrence of a game event. The first virtual role is a virtual role controlled by an intelligent agent in the game, and the role level changes with the progress of the game.
[0018] The calling unit is used to call a first behavior tree according to the current character level, where the first behavior tree is a behavior tree corresponding to the current character level among multiple behavior trees preset for the intelligent agent, and the behavior tree includes multiple behaviors and trigger conditions corresponding to the behaviors.
[0019] The control unit is used to control the first virtual character to perform the first behavior in response to determining that the game event meets the triggering condition of the first behavior, where the first behavior is a behavior that matches the game event among multiple behaviors included in the first behavior tree.
[0020] In a fifth aspect, the present application further provides an electronic device, including:
[0021] Processor; and
[0022] The memory is used to store a data processing program. After the electronic device is powered on and the program is run by the processor, the method described in the first aspect is executed.
[0023] In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium storing a data processing program, which is run by a processor to execute the method described in the first aspect.
[0024] The control method of a virtual character in a game provided by an embodiment of the present application comprises the following steps: in response to monitoring the occurrence of a game event, obtaining the current character level of a first virtual character, the first virtual character is a virtual character controlled by an intelligent agent in a game match, and the character level changes with the progress of the game; according to the current character level, calling a first behavior tree, the first behavior tree is a behavior tree corresponding to the current character level among multiple behavior trees preset for the intelligent agent, and the behavior tree includes multiple behaviors and trigger conditions corresponding to the behaviors; in response to determining that the game event meets the trigger condition of the first behavior, controlling the first virtual character to perform a first behavior, the first behavior is a behavior that matches the game event among multiple behaviors included in the first behavior tree. It can be seen that in the present application, firstly, after monitoring the occurrence of a game event, the current character level of the first virtual character is obtained, and it is defined that the character level changes with the progress of the game, and then according to the current character level of the first virtual character, calling the first behavior tree, so that the behavior of the virtual character changes with the change of the character level, and the growth of the virtual character is enhanced. Therefore, the control method of a virtual character in a game provided by an embodiment of the present application can enhance the depth of the interactive experience and enhance the user's gaming experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A flowchart of a method for controlling a virtual character in a game provided by an embodiment of the present application;
[0026] Figure 2 Another flow chart of the method for controlling a virtual character in a game provided by an embodiment of the present application;
[0027] Figure 3 Another flow chart of a method for controlling a virtual character in a game provided by an embodiment of the present application;
[0028] Figure 4 Another flow chart of a method for controlling a virtual character in a game provided by an embodiment of the present application;
[0029] Figure 5 A schematic diagram of a behavior tree provided in an embodiment of the present disclosure;
[0030] Figure 6 A structural block diagram of an example of a control device for a virtual character in a game provided by an embodiment of the present application;
[0031] Figure 7 A structural block diagram of an example of an electronic device for controlling a virtual character in a game provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0033] It should be noted that the terms "first", "second", "third", etc. in the claims, description and drawings of the present application are used to distinguish similar objects and are not used to describe a specific order or sequence. The data used in this way are interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including", "having" and their variants are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] It should be understood that in the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" is merely a way to describe the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "Including A, B and / or C" means including any one, any two, or any 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 corresponds to B", or "B corresponds 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 determining B only according to A, and B can also 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 hostile virtual characters, but also to support complex virtual character interactions.
[0037] At present, game AI frameworks mainly use behavior trees and finite state machines to manage virtual character behaviors. Behavior trees organize character behaviors through a 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 behaviors. Finite state machines (FSMs) determine the actions of characters through states and state transition rules. Virtual characters switch between different states to respond to game events. These technical methods are usually combined with scripted interaction rules to ensure that virtual characters perform predetermined behaviors in specific situations.
[0038] However, currently behavior trees and FSMs perform well in simple AI scenarios, but they are insufficient when dealing with complex and dynamic environments. The behavior of virtual characters does not change with the player's game progress, which limits the depth of the interactive experience. In addition, due to their structural fixedness, behavior trees and FSMs are difficult to dynamically adjust behavior priorities and cannot adapt to changes in player behavior. At the same time, as the complexity of the game increases, the number of states and nodes of behavior trees and FSMs increases dramatically, making them difficult to manage and maintain efficiently.
[0039] Based on background technical reasons, in order to enhance the depth of interactive experience, an embodiment of the present application provides a method for controlling a virtual character in a game. The method is applied to a computer or server, or other electronic devices capable of controlling a virtual character in a game, and the embodiment of the present application is not specifically limited.
[0040] The technical solution of the present application is 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 This is a flow chart of a method for controlling a virtual character in a game provided by an embodiment of the present application. Figure 1 As shown, the method may include S101-S103.
[0042] S101. In response to monitoring the occurrence of a game event, a current character level of a first virtual character is obtained, where the first virtual character is a virtual character controlled by an intelligent agent in a game match, and the character level changes with the progress of the game.
[0043] Exemplarily, after the agent detects the occurrence of a game event, the current character level of the first virtual character can be obtained. The character level changes with the progress of the game, for example, the character level can increase or decrease with the progress of the game. Game events may include: changes in the environment of the game match and changes in the behavior of the virtual character in the game match. Usually refers to a specific situation that occurs in the game or an activity that the player can participate in. The game event can be any event that occurs in the game process, for example, a game event triggered by the player's behavior. In a multi-role-playing game, when the virtual character controlled by the player reaches a certain location, it triggers a dialogue or battle with other virtual characters, or the life value, physical value, and / or hatred value of the virtual character changes. It can also be a game event preset by the game developer during 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 of the character level is also different. For example, in games such as multi-role-playing and social interaction, the character level can represent the bond level, and the bond level can be used to measure and represent the depth or strength of the relationship between game characters. In games such as battle arena games and fighting games, the character level can represent the combat effectiveness level. In games like business simulation games and puzzle adventure games, character level can represent intelligence level.
[0044] S102. Call a first behavior tree according to the current character level. The first behavior tree is a behavior tree corresponding to the current character level among a plurality of behavior trees preset for the agent. The behavior tree includes a plurality of behaviors and trigger conditions corresponding to the behaviors.
[0045] Exemplarily, an agent may correspond to multiple behavior trees, and the multiple behavior trees corresponding to the agent are constructed in response to the construction instruction. A behavior tree is a set of multiple behaviors preset for a virtual character. Different virtual characters have different behaviors included in the behavior tree. For example, if the virtual character is a tank character, its corresponding behavior tree may include taunting behavior, normal attack behavior, and charge behavior, etc., and if the virtual character is a fast double-blade character, its corresponding behavior tree may include fast attack behavior, charge behavior, and petrification behavior, etc. A behavior tree includes multiple behaviors and trigger conditions corresponding to the behaviors. For example, the behavior included in the behavior tree is a taunting behavior, and the corresponding trigger condition is that the target of hatred of the hostile character changes; the behavior included in the behavior tree is a healing behavior, and the corresponding trigger condition is that the health value of the teammate is less than 50%. The first behavior tree is a behavior tree corresponding to the current character level among the multiple behavior trees preset for the agent. Different virtual characters will execute different behaviors when their role levels are different. For example, when the combat power level of the virtual character is high, the combat behavior executed may be a combo behavior, and when the combat power level of the virtual character is low, the combat behavior executed may be a single move. Based on this, in this embodiment, the agent corresponds to multiple behavior trees, and each behavior tree corresponds to a different level. For example, the agent controlling the first virtual character corresponds to behavior tree A, behavior tree B, and behavior tree C. Behavior tree A corresponds to level 1, behavior tree B corresponds to level 2, and behavior tree C corresponds to level 3. When it is detected that the current role level of the first virtual character is level 2, behavior tree B is called.
[0046] For example, after obtaining the current character level, the first behavior tree can be called according to the obtained current character level. 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. If the current character level is obtained to be a 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 triggering condition of the first behavior, control the first virtual character to execute the first behavior, where the first behavior is a behavior that matches the game event among multiple behaviors included in the first behavior tree.
[0048] Exemplarily, the game event can be compared with the triggering condition of each behavior in the first behavior subtree, and when the game event meets the triggering condition of the first behavior, the first virtual character can be controlled to perform the first behavior. For example, the triggering condition of the first behavior is that the character level of the first virtual character is greater than a preset threshold and the distance between the second virtual character and the first virtual character is less than a preset threshold. When the game event meets the condition that the character level of the first virtual character is greater than the preset threshold and the distance between the second virtual character and the first virtual character is less than the preset threshold, the first virtual character can be controlled to perform the first behavior, and the second virtual character is a virtual character whose distance from the first virtual character in the virtual scene is less than the preset threshold.
[0049] For example, assuming that the first behavior tree includes taunting behavior, quick attack behavior and healing behavior, the triggering condition of taunting behavior is that the hostile character's target of hatred changes, the triggering condition of quick attack behavior is that the distance between the hostile character and the virtual character corresponding to the first behavior tree is less than 50 meters, and the triggering condition of healing behavior is that the teammate's health value is less than 50%. Assuming that the monitored game event is that the distance between the virtual character corresponding to the first behavior tree and the hostile character is 35 meters, the game event can be compared with the triggering conditions of taunting behavior, quick attack behavior and healing behavior in turn, and it is concluded that the game event meets the triggering condition of quick attack behavior, and the virtual character corresponding to the first behavior tree can be controlled to perform quick attack behavior.
[0050] The embodiment of the present application obtains the current character level of the first virtual character in response to monitoring the occurrence of a game event, and limits the character level to change with the game process, then calls the first behavior tree according to the current character level, and controls the first virtual character to perform the first behavior in response to determining that the game event satisfies the triggering condition of the first behavior. The first behavior tree corresponding to the current character level of the virtual character can be called according to the current character level of the virtual character, so that the behavior of the virtual character changes with the change of the character level, thereby enhancing the growth of the virtual character and improving the depth of the interactive experience.
[0051] In an optional implementation provided in this embodiment, the role level of the virtual character is not only related to the behavior performed by the virtual character, but also to the reaction time of the virtual character when performing the behavior. For example, the higher the bond level of the virtual character, the shorter the reaction time of the virtual character when performing the behavior, that is, the shorter the interval between performing a task and entering the next task. From the perspective of player perception, the virtual character fights harder.
[0052] Figure 2 Another flow chart of the method for controlling a virtual character in a game provided by an embodiment of the present application. Figure 2 As shown, the method may also include S201-S204.
[0053] S201. According to the current character level, obtain a first parameter corresponding to the current character level, where the first parameter is used to represent the influence ratio of the character level on the reaction time of the first virtual character when performing an action.
[0054] S202: Obtain a preset basic reaction time for the first virtual character and a basic character level of the first virtual character.
[0055] Exemplarily, before the above step: in response to determining that the game event satisfies the triggering condition of the first behavior, controlling the first virtual character to perform the first behavior, the present embodiment may further include: obtaining a first parameter corresponding to the current character level according to the current character level, wherein the first parameter is used to characterize the influence multiplier of the character level on the reaction time when the first virtual character performs the behavior. The reaction time can also be understood as the global cooldown (GCD). The basic reaction time preset for the first virtual character can be understood as the preset default value of the reaction time 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 the game. The basic reaction time and the first parameter of the virtual character can be set by configuring a parameter table (e.g., [DT_CharacterAI] table). After determining the current character level of the first virtual character, the first parameter corresponding to the current character level and the basic reaction time of the first virtual character can be obtained in the above parameter table according to the current character level of the first virtual character.
[0056] S203: Determine, according to the first parameter, the basic reaction time corresponding to the first virtual character and the basic character level of the first virtual character, the change reaction time corresponding to the first virtual character at the current character level.
[0057] S204: Control the first virtual character to execute a first behavior after waiting for the change reaction time.
[0058] Exemplarily, after obtaining the first parameter, the basic reaction time corresponding to the first virtual character and the basic character level of the first virtual character, the change reaction time corresponding to the first virtual character at the current character level can be determined, and then the first virtual character is controlled to wait for the change reaction time before executing the first behavior.
[0059] For example, when the character level represents the bond level, the bond level may include a high bond level, a medium bond level, and a low bond level. The higher the bond level, the shorter the global cooling time. Assuming that the preset basic reaction time for the first virtual character is 30 seconds, the basic character level of the first virtual character is 1, and each level of the character level can reduce the basic reaction time corresponding to the first virtual character by 5%, that is, the first parameter is 5%. When the current character level of the first virtual character is 3, the first parameter, the basic reaction time corresponding to the first virtual character, and the basic character level of the first virtual character can be used to determine that the change reaction time corresponding to the first virtual character is 27 seconds. Then control the first virtual character to wait for 27 seconds and then execute the first behavior.
[0060] This embodiment obtains a first parameter corresponding to the current character level according to the current character level, and obtains a basic reaction time preset for the first virtual character and a basic character level of the first virtual character; determines a change reaction time corresponding to the first virtual character under the current character level according to the first parameter, the basic reaction time corresponding to the first virtual character, and the basic character level of the first virtual character; controls the first virtual character to execute a first behavior after waiting for the change reaction time, and utilizes the influence of the character level on the reaction time when the virtual character executes the behavior to adjust the degree of improvement in the fighting desire of virtual characters with different attack styles.
[0061] In an optional implementation, each behavior tree is divided into multiple subtrees according to the behavior priority. For example, the first behavior tree is divided into the first behavior subtree and the second behavior subtree. The execution priority of the behaviors included in the first behavior subtree is high priority, such as fast attack behavior, charge behavior, etc. Therefore, the first behavior subtree can also be called a priority group. The behaviors included in the second behavior subtree have no execution priority, such as ordinary attack, petrification, and spinning in place. The second behavior subtree can also be called a general group. The triggering conditions of the behaviors in the second behavior subtree are that all game events can be triggered. Of course, the first behavior tree can also be divided into the first behavior subtree, the second behavior subtree, the third behavior subtree, etc. with more refined priorities to refine the performance behavior of the first virtual character, which will not be explained in detail here.
[0062] Figure 3 This is another flow chart of a method for controlling a virtual character in a game provided by an embodiment of the present application. Figure 3 As shown, before the above S103, the method may further include S301-S303.
[0063] S301, comparing the game event with the triggering condition of each behavior in the first behavior subtree.
[0064] S302: If the game event meets the triggering condition of the second behavior, the second behavior is determined as the first behavior, and the second behavior is a behavior that matches the game event among the multiple behaviors included in the first behavior subtree.
[0065] S303: If the game event does not satisfy the triggering condition of each behavior in the first behavior subtree, the third behavior is determined as the first behavior, and the third behavior is any behavior in the second behavior subtree.
[0066] For example, the game event can be compared with the triggering conditions of each behavior in the first behavior subtree in turn. If the game event meets the triggering conditions of the second behavior, the second behavior is determined as the first behavior. If the game event does not meet the triggering conditions of each behavior in the first behavior subtree, any behavior in the second behavior subtree can be selected as the first behavior. The triggering conditions of the behaviors in the second behavior subtree are that all game events can be triggered.
[0067] For example, in a battle game, behavior tree A corresponding to the intelligent agent controlling virtual character X is called according to the current character level of virtual character X, and behavior tree A includes a first behavior subtree and a second behavior subtree. The first behavior subtree includes healing behavior, taunting behavior, and charging behavior, and the second behavior subtree includes general attack behavior and petrification behavior. When the game event is that the health value of a teammate of virtual character X is less than 80%, the triggering condition of the healing behavior in the first behavior subtree is that when the health value of a teammate of virtual character X is less than 80%, the teammate is given continuous healing. Then, the game event meets the triggering condition of the healing behavior, and the healing behavior can be determined as the first behavior. After comparing the game event with the triggering condition of each behavior in the first behavior subtree in turn, if the game event does not meet the triggering condition of each behavior in the first behavior subtree, a general attack can be selected as the first behavior, or petrification can be selected as the first behavior.
[0068] This embodiment compares the game event with the triggering condition of each behavior in the first behavior subtree; if the game event meets the triggering condition of the second behavior, the second behavior is determined as the first behavior; if the game event does not meet the triggering condition of each behavior in the first behavior subtree, the third behavior is determined as the first behavior, and it is defined that the second behavior is a behavior that matches the game event among the multiple behaviors included in the first behavior subtree, and the third behavior is any behavior in the second behavior subtree. This can ensure that the virtual character has a guaranteed behavior to execute after the game event occurs, thereby ensuring the stable operation of the game process.
[0069] In another optional implementation provided by this embodiment, the first behavior tree may further include a third behavior subtree, and the execution priority of the behaviors included in the third behavior subtree is the highest priority, such as taunting behavior, healing behavior, and rapid attack behavior, so the third behavior subtree may also be called a stress group. The behaviors included in the first behavior subtree, the second behavior subtree, and the third behavior subtree may be the same, but the trigger conditions corresponding to the behaviors included in each behavior subtree are different.
[0070] Figure 4 This is another flow chart of a method for controlling a virtual character in a game provided by an embodiment of the present application. Figure 4 As shown, the method may also include S401-S403.
[0071] S401: In response to the occurrence time of the game event being a preset detection time, the game event is compared with the triggering condition of each behavior in the third behavior subtree.
[0072] S402, in response to the game event satisfying the triggering condition of the fourth behavior, controlling the first virtual character to execute the fourth behavior, and after the fourth behavior is executed, executing the first behavior, the fourth behavior is a behavior that matches the game event among the multiple behaviors included in the third behavior subtree.
[0073] S403: If the game event does not satisfy the triggering condition of each behavior in the third behavior subtree, control the first virtual character to execute the first behavior.
[0074] Exemplarily, the first behavior tree also includes a third behavior subtree, and the execution priority of the behavior included in the third behavior subtree is the highest priority. The third behavior subtree can also be called a stress group. When the occurrence of a game event is monitored and the occurrence time of the game event is a preset detection time, the game event can be compared with the triggering condition of each behavior in the third behavior subtree, and the game event can be compared with the triggering condition of each behavior in the first behavior subtree. If the game event satisfies the triggering condition of the fourth behavior and the triggering condition of the first behavior at the same time, the first virtual character is controlled to execute the fourth behavior, and after the fourth behavior is executed, the first behavior is executed; if the game event does not meet the triggering condition of each behavior in the third behavior subtree, and meets the triggering condition of the first behavior, the first virtual character is controlled to execute the first behavior; if the game event does not meet the triggering condition of each behavior in the third behavior subtree and the triggering condition of each behavior in the first behavior subtree, the first virtual character is controlled to execute the third behavior.
[0075] For example, when the occurrence time of the game event is monitored to be the preset detection time, the game event is that the bond level of virtual character X is greater than the preset threshold and the target of hatred of virtual character Y is not virtual character X, and virtual character Y is the enemy of virtual character X. The game event can be compared with the triggering conditions of each behavior in the third behavior subtree and the triggering conditions of each behavior in the first behavior subtree. If the game event satisfies both the triggering conditions of behavior A and the triggering conditions of behavior B, the virtual character X is controlled to execute the taunt skill, and after the execution of the taunt skill is completed, the charge skill is executed; wherein behavior A is a behavior that matches the above game event among the multiple behaviors included in the third behavior subtree, and behavior B is a behavior that matches the above game event among the multiple behaviors included in the first behavior tree, behavior A triggers the taunt skill, and behavior B is the charge skill. If the game event does not meet the triggering conditions of each behavior in the third behavior subtree, but meets the triggering conditions of behavior B, the virtual character X is controlled to perform the charge skill; if the game event does not meet the triggering conditions of each behavior in the third behavior subtree and the triggering conditions of each behavior in the first behavior subtree, the virtual character X is controlled to perform behavior C, that is, the virtual character X is controlled to perform any behavior in the second behavior subtree.
[0076] This embodiment responds to the occurrence time of the game event as a preset detection time, compares the game event with the triggering conditions of each behavior in the third behavior subtree; in response to the game event satisfying the triggering condition of the fourth behavior, controls the first virtual character to execute the fourth behavior, and executes the first behavior after the fourth behavior is executed; if the game event does not satisfy the triggering conditions of each behavior in the third behavior subtree, controls the first virtual character to execute the first behavior, wherein the fourth behavior is a behavior that matches the game event among the multiple behaviors included in the third behavior tree, and can detect the game event in real time, and when the game event satisfies the triggering condition of the fourth behavior, controls the first virtual character to immediately execute the fourth behavior, thereby improving the reaction speed and flexibility of the virtual character and further enhancing the user's gaming experience.
[0077] In some embodiments, the above method also includes S501-S503.
[0078] S501: In response to the occurrence time of the game event not being the detection time, control the first virtual character to execute a first behavior.
[0079] S502: In response to the game process reaching the detection moment, the game event is compared with the triggering condition of each behavior in the third behavior subtree.
[0080] S503: In response to the game event satisfying the triggering 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 is completed.
[0081] For example, when the occurrence of a game event is monitored and the occurrence time of the game event is not a preset detection time, the game event can be compared with the triggering conditions of each behavior in the first behavior subtree. If the game event meets the triggering conditions of the first behavior, the first virtual character is controlled to perform the first behavior. When the game process reaches the preset detection time, the game event is compared with the triggering conditions of each behavior in the third behavior subtree. If the game event meets the triggering conditions of the fourth behavior, the first virtual character is controlled to stop performing the first behavior, immediately perform the fourth behavior, and continue to perform the first behavior after the fourth behavior is completed.
[0082] For example, assuming that the occurrence time of the game event is the first moment, the preset detection time is the second moment, and the first moment is 30 seconds before the second moment. At the time of the game event, the game event can be compared with the triggering conditions of each behavior in the first behavior subtree. If the game event meets the triggering conditions of the first behavior, the first virtual character is controlled to perform the first behavior. Then, after 30 seconds of the game process, the game event is compared with the triggering conditions of each behavior in the third behavior subtree. If the game event meets the triggering conditions of the 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 completed.
[0083] In response to the occurrence moment of the game event being not the detection moment, this embodiment controls the first virtual character to execute the first behavior; in response to the game process reaching the detection moment, compares the game event with the triggering condition of each behavior in the third behavior subtree; in response to the game event satisfying the triggering condition of the fourth behavior, controls the first virtual character to stop executing the first behavior, execute the fourth behavior, and continue executing the first behavior after the fourth behavior is executed. The game event can be detected when the game event reaches the preset detection moment, thereby achieving the purpose of real-time detection of game events and further improving the reaction speed and flexibility of the virtual character.
[0084] The above is a specific implementation of a method for controlling a virtual character in a game. In specific implementation, the control of the virtual character in the game can also be performed in other feasible ways, and the embodiments of the present application are not limited thereto.
[0085] In an exemplary embodiment, the embodiment of the present application further provides a behavior tree, the behavior tree includes a first behavior subtree, a second behavior subtree and a third behavior subtree, the first behavior subtree includes behaviors with high execution priority, the second behavior subtree includes behaviors with no execution priority, and the third behavior subtree includes behaviors with the highest execution priority; wherein the behavior tree corresponds to a preset role level.
[0086] Figure 5A schematic diagram of a behavior tree provided in an embodiment of the present 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 a high bond level, a medium bond level, and a low bond level, and each bond level corresponds to a behavior tree.
[0087] During game operation, the behaviors performed by the virtual character can be controlled according to the various behaviors contained in the behavior tree provided in the embodiment of the present application and the trigger conditions corresponding to the behaviors, thereby reducing computational redundancy, optimizing the use of computing resources, and effectively improving the operation efficiency of the game.
[0088] In an exemplary embodiment, the present application also provides an intelligent agent, which can be used to execute the control method of the virtual character in the above game. The intelligent agent includes: a monitoring module, a behavior tree module, a matching module, and a control module.
[0089] Monitoring module, used to monitor game events.
[0090] The behavior tree module is used to maintain multiple behavior trees. Multiple behavior trees correspond to multiple role levels. A behavior tree includes multiple behaviors and the trigger conditions corresponding to the behaviors.
[0091] The matching module is used to obtain the current character level of a first virtual character, the first virtual character is a virtual character controlled by an intelligent agent in a game match, and the character level changes with the progress of the game; it is also used to call a first behavior tree according to the current character level, the first behavior tree is a behavior tree corresponding to the current character level behavior among multiple behavior trees; it is also used to call a first behavior that matches a game event among multiple behaviors included in the first behavior tree according to a game event.
[0092] The control module controls the first virtual character to perform a first behavior.
[0093] The intelligent agent provided in the embodiment of the present application includes: a monitoring module, a behavior tree module, a matching module, and a control module. The intelligent agent can use the modules contained therein to execute the control method of the virtual character in the game, thereby supporting templated configuration, reducing repetitive work, and expanding the behavior tree, thereby improving development efficiency and facilitating subsequent maintenance and updates.
[0094] Corresponding to the method for controlling a virtual character in a game provided by the embodiment of the present application, the embodiment of the present application also provides a device for controlling a virtual character in a game. Figure 6 This is a structural block diagram of an example of a control device for a virtual character in a game provided by an embodiment of the present application, such as Figure 6 As shown, the control device 600 of the virtual character in the game includes:
[0095] The acquisition unit 601 is used to acquire the current role level of the first virtual character in response to monitoring the occurrence of a game event. The first virtual character is a virtual character controlled by an intelligent agent in the game, and the role level changes with the progress of the game.
[0096] The calling unit 602 is used to call a first behavior tree according to the current character level. The first behavior tree is a behavior tree corresponding to the current character level among multiple behavior trees preset for the intelligent agent. The behavior tree includes multiple behaviors and trigger conditions corresponding to the behaviors.
[0097] The control unit 603 is used to control the first virtual character to perform the first behavior in response to determining that the game event meets the triggering condition of the first behavior, where the first behavior is a behavior that matches the game event among the multiple behaviors included in the first behavior tree.
[0098] Optionally, the acquisition unit 601 is further used to obtain a first parameter corresponding to the current character level according to the current character level, the first parameter being used to characterize the influence multiplier of the character level on the reaction time of the first virtual character when performing a behavior; obtaining a basic reaction time preset for the first virtual character and a basic character level of the first virtual character; the control unit 603 is specifically used to: determine the change reaction time corresponding to the first virtual character at the current character level according to the first parameter, the basic reaction time corresponding to the first virtual character and the basic character level of the first virtual character; and control the first virtual character to wait for the change reaction time before performing the first behavior.
[0099] Optionally, the first behavior tree includes at least a first behavior subtree and a second behavior subtree, the first behavior subtree includes behaviors with high execution priorities, and the second behavior subtree includes behaviors with no execution priorities.
[0100] Alternatively, if Figure 6 As shown, the control device 600 for the virtual character in the game further includes: a comparison unit 604 and a determination unit 605 .
[0101] The comparison unit 604 is used to compare the game event with the triggering condition of each behavior in the first behavior subtree.
[0102] Determination unit 605 is used to determine the second behavior as the first behavior if the game event meets the triggering condition of the second behavior, and the second behavior is a behavior that matches the game event among the multiple behaviors included in the first behavior subtree; if the game event does not meet the triggering condition of each behavior in the first behavior subtree, then determine the third behavior as the first behavior, and the third behavior is any behavior in the second behavior subtree.
[0103] Optionally, the comparison unit 604 is further used to compare the game event with the triggering condition of each behavior in the third behavior subtree in response to the occurrence time of the game event being the preset detection time. The control unit 603 is specifically used to: in response to the game event meeting the triggering condition of the fourth behavior, control the first virtual character to perform the fourth behavior, and after the fourth behavior is executed, perform the first behavior, the fourth behavior being a behavior that matches the game event among the multiple behaviors included in the third behavior tree; if the game event does not meet the triggering condition of each behavior in the third behavior subtree, control the first virtual character to perform the first behavior.
[0104] Optionally, the control unit 603 is also used to control the first virtual character to perform the first behavior in response to the occurrence time of the game event being not the detection time; in response to the game process reaching the detection time, compare the game event with the triggering condition of each behavior in the third behavior subtree; in response to the game event satisfying the triggering condition of the fourth behavior, control the first virtual character to stop executing the first behavior, execute the fourth behavior, and continue executing the first behavior after the fourth behavior is completed.
[0105] Optionally, the game event includes: a change in the environment of the game game and a change in the behavior of a virtual character in the game game.
[0106] Alternatively, if Figure 6 As shown, the control device 600 for the virtual character in the game further includes: a construction unit 606 .
[0107] The construction unit 606 is used to construct multiple behavior trees corresponding to the agent in response to the construction instruction, and the behavior trees include multiple behaviors and trigger conditions corresponding to the behaviors.
[0108] Corresponding to the method for controlling a virtual character in a game provided in the embodiment of the present application, the embodiment of the present application also provides an electronic device for controlling a virtual character in a game.
[0109] like Figure 7 As shown, Figure 7 A structural block diagram of an example of an electronic device for controlling a virtual character in a game provided in an embodiment of the present application.
[0110] In this embodiment, an optional hardware structure of the electronic device 700 can be as follows: Figure 7 As shown, it includes: at least one processor 701, at least one memory 702 and at least one communication bus 705; the memory 702 contains a program 703 and data 704.
[0111] The bus 705 may be a communication device for transmitting data between components inside the electronic device 700, such as an internal bus (e.g., a CPU-memory bus, where the processor is a central processing unit, CPU for short), an external bus (e.g., a universal serial bus port, a peripheral component interconnect express port), etc.
[0112] In addition, the electronic device also includes: at least one network interface 706, at least one peripheral interface 707. The network interface 706 provides wired or wireless communication related to an external network 708 (for example, the Internet, an intranet, a local area network, a 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] The peripheral interface 707 is used to connect to the peripheral device, and the peripheral device can be the peripheral device 1 ( Figure 7 709 in), peripheral 2 ( Figure 7 710) and peripheral 3 ( Figure 7 711 in the figure). Peripherals are peripheral devices, which may include but are not limited to cursor control devices (such as mice, touch pads or touch screens), keyboards, displays (such as cathode ray tube displays, liquid crystal displays). Displays or light emitting diode displays, video input devices (such as cameras or communication interfaces coupled to video files), etc.
[0114] The processor 701 may be a CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application.
[0115] The memory 702 may include a high-speed RAM (full name: Random Access Memory) memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0116] The processor 701 calls the program and data stored in the memory 702 to perform the following steps:
[0117] In response to detecting the occurrence of a game event, obtaining a current character level of a first virtual character, where the first virtual character is a virtual character controlled by an agent in a game match, and the character level changes with the progress of the game;
[0118] According to the current character level, calling a first behavior tree, the first behavior tree is a behavior tree corresponding to the current character level among multiple behavior trees preset for the agent, and the behavior tree includes multiple behaviors and trigger conditions corresponding to the behaviors;
[0119] In response to determining that the game event meets the triggering condition of the first behavior, the first virtual character is controlled to perform the first behavior, where the first behavior is a behavior that matches the game event among the multiple behaviors included in the first behavior tree.
[0120] Corresponding to the method for controlling a virtual character in a game provided in the embodiment of the present application, the embodiment of the present application further provides a computer-readable storage medium storing a program for the method for controlling a virtual character in a game, the program being executed by a processor to perform the following steps:
[0121] In response to detecting the occurrence of a game event, obtaining a current character level of a first virtual character, where the first virtual character is a virtual character controlled by an agent in a game match, and the character level changes with the progress of the game;
[0122] According to the current character level, calling a first behavior tree, the first behavior tree is a behavior tree corresponding to the current character level among multiple behavior trees preset for the agent, and the behavior tree includes multiple behaviors and trigger conditions corresponding to the behaviors;
[0123] In response to determining that the game event meets the triggering condition of the first behavior, the first virtual character is controlled to perform the first behavior, where the first behavior is a behavior that matches the game event among the multiple behaviors included in the first behavior tree.
[0124] It should be noted that for the detailed description of the device, electronic device and computer-readable storage medium provided in the embodiments of the present application, reference can be made to the relevant description of the method for controlling a virtual character in a game provided in the embodiments of the present application, which will not be repeated here.
[0125] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
[0126] In a typical configuration, a node device in a blockchain includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0127] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0128] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. 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), random access memory (RAM) of other attributes, read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage media or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.
[0129] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. 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 in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
Claims
1. A method for controlling a virtual character in a game, characterized in that: The game game includes at least one virtual character, and the method includes: In response to monitoring the occurrence of a game event, obtaining a current character level of a first virtual character, where the first virtual character is a virtual character controlled by an agent in a game match, and the character level changes with the progress of the game; 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; In response to determining that the game event satisfies a trigger condition of a first behavior, the first virtual character is controlled to execute the first behavior, where the first behavior is a behavior that matches the game event among a plurality of behaviors included in the first behavior tree.
2. The method according to claim 1, characterized in that Before the step of controlling the first virtual character to perform the first behavior in response to determining that the game event satisfies the triggering condition of the first behavior, the method further includes: According to the current character level, obtaining a first parameter corresponding to the current character level, the first parameter being used to characterize the influence ratio of the character level on the reaction time of the first virtual character when performing an action; Obtaining a preset basic reaction time for the first virtual character and a basic character level of the first virtual character; In response to determining that the game event satisfies a triggering condition of a first behavior, controlling the first virtual character to perform the first behavior includes: Determining, according to the first parameter, a basic reaction time corresponding to the first virtual character and a basic character level of the first virtual character, a change reaction time corresponding to the first virtual character at the current character level; After controlling the first virtual character to wait for the change reaction time, the first behavior is executed.
3. The method according to claim 1, characterized in that The first behavior tree includes at least a first behavior subtree and a second behavior subtree. The first behavior subtree includes behaviors with high execution priorities, and the second behavior subtree includes behaviors with no execution priorities.
4. The method according to claim 3, characterized in that Before the step of controlling the first virtual character to perform the first behavior in response to determining that the game event satisfies the triggering condition of the first behavior, the method further includes: Comparing the game event with the triggering condition of each behavior in the first behavior subtree; If the game event meets the triggering condition of the second behavior, the second behavior is determined as the first behavior, and the second behavior is a behavior that matches the game event among the multiple behaviors included in the first behavior subtree; If the game event does not satisfy the triggering condition of each behavior in the first behavior subtree, a third behavior is determined as the first behavior, and the third behavior is any behavior in the second behavior subtree.
5. The method according to claim 4, characterized in that The first behavior tree further includes a third behavior subtree, the third behavior subtree includes a behavior with a highest execution priority, and the method further includes: In response to the occurrence time of the game event being a preset detection time, comparing the game event with the triggering condition of each behavior in the third behavior subtree; The controlling the first virtual character to perform the first behavior includes: In response to the game event satisfying a trigger condition of a fourth behavior, controlling the first virtual character to execute the fourth behavior, and after the fourth behavior is executed, executing the first behavior, wherein the fourth behavior is a behavior that matches the game event among a plurality of behaviors included in the third behavior tree; If the game event does not satisfy the triggering condition of each behavior in the third behavior subtree, the first virtual character is controlled to execute the first behavior.
6. The method according to claim 5, characterized in that The method further comprises: In response to the occurrence time of the game event not being the detection time, controlling the first virtual character to perform the first behavior; In response to the game process reaching the detection moment, comparing the game event with the triggering condition of each behavior in the third behavior subtree; In response to the game event satisfying the triggering 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 is completed.
7. The method according to claim 1, characterized in that The game events include: The environment of the game game changes and the behavior of the virtual character in the game game changes.
8. The method according to claim 1, characterized in that The method further comprises: In response to the construction instruction, the multiple behavior trees corresponding to the agent are constructed, and the behavior trees include multiple behaviors and trigger conditions corresponding to the behaviors.
9. A behavior tree, characterized in that: The behavior tree includes a first behavior subtree, a second behavior subtree and a third behavior subtree, the first behavior subtree includes behaviors with a high execution priority, the second behavior subtree includes behaviors with no execution priority, and the third behavior subtree includes behaviors with a highest execution priority; wherein the behavior tree corresponds to a preset role level.
10. An intelligent agent, characterized in that: The intelligent agent includes: a monitoring module, a behavior tree module, a matching module, and a control module; The monitoring module is used to monitor game events; The behavior tree module is used to maintain multiple behavior trees, the multiple behavior trees correspond to multiple character levels, and the behavior trees include multiple behaviors and trigger conditions corresponding to the behaviors; The matching module is used to obtain a current character level of a first virtual character, the first virtual character being a virtual character controlled by the agent in a game match, and the character level changes with the progress of the game; further used to call a first behavior tree according to the current character level, the first behavior tree being a behavior tree corresponding to the behavior of the current character level among the multiple behavior trees; further used to call a first behavior that matches the game event among the multiple 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.
11. A control device for a virtual character in a game, characterized in that: The device comprises: an acquisition unit, configured to acquire a current character level of a first virtual character in response to monitoring the occurrence of a game event, wherein the first virtual character is a virtual character controlled by an agent in a game match, and the character level changes with the progress of the game; a calling unit, configured to call a first behavior tree according to the current character level, wherein the first behavior tree is a behavior tree corresponding to the current character level among a plurality of behavior trees preset for the agent, and the behavior tree includes a plurality of behaviors and trigger conditions corresponding to the behaviors; The control unit is used to control the first virtual character to perform the first behavior in response to determining that the game event meets the triggering condition of the first behavior, where the first behavior is a behavior that matches the game event among the multiple behaviors included in the first behavior tree.
12. An electronic device, characterized in that: include: processor; as well as The memory is used 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 to 8 is executed.
13. A computer-readable storage medium, characterized in that: A data processing program is stored, and the program is run by a processor to execute the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Content operation control method and device
CN110324712A
Game control method and device and electronic equipment
CN111111193A
Virtual game role control method and device, storage medium and electronic device
CN113926196A
Method, device and equipment for controlling agent to match, and storage medium
CN116747521A
Non-user role control method and device based on behavior tree, equipment and medium
CN117180750A