Reference behavior structure editing method and behavior control method for non-player characters
By editing and combining basic conditions and behaviors, a reusable reference behavior structure is formed, which solves the problem that NPC behavior structure cannot be flexibly adjusted in the prior art, and realizes the adaptive control of NPC behavior and the reuse rate of effect.
Patent Information
- Application Number
- CN202111638086.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2041-12-29
AI Technical Summary
The prior art is difficult to flexibly adjust the behavior structure of non-player characters (NPCs) according to game application scenarios, resulting in the inability to achieve adaptive control of NPC behavior.
By editing basic conditions and basic behaviors, combining them into preset conditions and preset behaviors, and setting default consumption values and execution effects, users can associate target conditions, available behaviors and target execution effects according to specific needs to form a flexible reference behavior structure.
It realizes the flexibility of adjusting the NPC behavior structure according to actual needs and application scenarios, improves the reuse rate of target conditions, available behaviors and target execution effects, and enhances the adaptability of NPC behavior.
Smart Images

Figure CN114404982B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a reference behavior structure editing method and a behavior control method for non-player characters. Background Art
[0002] The behavior logic of non-player characters (NPCs) in games has always been an important part of the game. Excellent behavior logic can greatly enhance the gaming experience. At present, the implementation of NPC behavior logic has gone through the iteration of state machines, behavior trees, goal-oriented action planning (GOAP), and machine learning technologies.
[0003] The state machine controls the NPC's behavior by breaking the NPC's behavior into multiple states and then setting direct switching conditions for each state. The state machine can conveniently and clearly describe the logical relationship when describing simple NPC behaviors, but when dealing with complex behaviors, there will be problems such as unintuitive structure, difficult maintenance and modification. The behavior tree is a way to control the NPC's behavior by classifying the NPC's behavior into selection nodes, conditional nodes, and behavior nodes, and then combining different nodes. However, the logic of the behavior tree is relatively fixed, the node reuse rate is low, and it is not very convenient to change the NPC's behavior strategy in response to environmental changes. The simulation training process in machine learning is long and requires powerful computing power.
[0004] Therefore, the existing technology has a technical problem that it is impossible to flexibly adjust the behavior structure of the NPC according to the specific application scenarios in the game to achieve adaptive control of the NPC behavior. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a reference behavior structure editing method and a behavior control method for non-player characters, and the specific scheme is as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for editing a reference behavior structure of a non-player character, the method comprising:
[0007] Edit the basic conditions of the first type and the basic behaviors of the second type;
[0008] Combining different basic conditions into multiple preset conditions, and combining different basic behaviors into multiple preset behaviors;
[0009] Setting a default consumption value for each of the preset behaviors and a preset execution effect corresponding to each of the preset behaviors, wherein the default consumption value corresponds to a first type of attribute value of the non-player character, the first type of attribute value includes a physical strength value, and the execution effect includes reducing a second type of attribute value of an operable target, the second type of attribute value includes a health value;
[0010] Acquire a target execution effect that matches the logical condition input by the user from all the preset execution effects, determine each preset behavior corresponding to the target execution effect as an available behavior, and select a target condition associated with the available behavior from all the preset conditions according to the first association relationship input by the user;
[0011] The target condition, each of the available behaviors and the target execution effect are respectively associated with the non-player character to obtain a reference behavior structure of the non-player character.
[0012] According to a specific implementation method disclosed in the present application, the reference behavior structure editing method of the non-player character further includes:
[0013] Each of the basic conditions, each of the preset behaviors and each of the preset execution effects are stored in a preset storage space in a preset data exchange format, wherein the preset data exchange format includes JavaScript object notation.
[0014] According to a specific implementation method disclosed in the present application, the step of associating the target condition, each of the available behaviors and the target execution effect with the non-player character respectively includes:
[0015] Each of the basic conditions is marked with a different first-category number, each of the preset behaviors is marked with a different second-category number, and each of the preset execution effects is marked with a different third-category number;
[0016] According to the user input, the corresponding first category number, second category number and third category number are associated to obtain a second association relationship;
[0017] Based on the second association relationship, all the basic conditions, the available behaviors and the target execution effects included in each corresponding target condition are associated with the non-player character.
[0018] According to a specific implementation method disclosed in the present application, after the step of obtaining the reference behavior structure of the non-player character, the method for editing the reference behavior structure of the non-player character further includes:
[0019] According to the target type of the non-player character input by the user, selecting a target behavior with the highest matching degree with the target type from all the available behaviors;
[0020] Determining whether the default consumption value of the target behavior is greater than a preset consumption value;
[0021] If the default consumption value of the target behavior is greater than the preset consumption value, the default consumption value corresponding to the target behavior in the reference behavior structure is updated to the preset consumption value to obtain the target behavior structure of the target type.
[0022] According to a specific embodiment disclosed in the present application, the first type includes that an operable target exists within a first distance centered on the non-player character and the real-time distance between the operable target and the non-player character does not exceed a preset distance;
[0023] The second type includes movement behaviors and action behaviors, wherein the movement behaviors include any one of approaching, moving away, and random, and the action behaviors include any one of using skills and using props.
[0024] In a second aspect, an embodiment of the present application provides a behavior control method for a non-player character, the behavior control method for a non-player character comprising:
[0025] Determine whether the current game environment conditions meet the preset conditions in the reference behavior structure corresponding to the non-player character;
[0026] When the current game environment condition satisfies the preset condition in the reference behavior structure corresponding to the non-player character, determining whether the number of the available behaviors in the reference behavior structure is unique;
[0027] If the number of the available behaviors in the reference behavior structure is unique, execute the available behaviors, wherein if the available behaviors act on operability targets, trigger corresponding target execution effects;
[0028] If the number of the available behaviors in the reference behavior structure is not unique, executing the available behavior with the smallest priority, wherein the priority of the available behavior is negatively correlated with the corresponding default consumption value;
[0029] The reference behavior structure is obtained according to the method for editing a reference behavior structure of a non-player character described in any one of the first aspects.
[0030] In a third aspect, an embodiment of the present application provides a device for editing a reference behavior structure of a non-player character, the device for editing a reference behavior structure of a non-player character comprising:
[0031] An editing module, used for editing the first type of basic conditions and the second type of basic behaviors;
[0032] A combination module, used for combining different basic conditions into multiple preset conditions, and combining different basic behaviors into multiple preset behaviors;
[0033] A setting module, used to set a default consumption value of each of the preset behaviors and a preset execution effect corresponding to each of the preset behaviors, wherein the default consumption value corresponds to a first type of attribute value of the non-player character, the first type of attribute value includes a physical strength value, and the execution effect includes reducing a second type of attribute value of an operable target, the second type of attribute value includes a health value;
[0034] a selection module, configured to obtain a target execution effect matching a logical condition input by a user from all the preset execution effects, determine each preset behavior corresponding to the target execution effect as an available behavior, and select a target condition associated with the available behavior from all the preset conditions according to a first association relationship input by the user;
[0035] The association module is used to associate the target condition, each of the available behaviors and the target execution effect with the non-player character respectively to obtain a reference behavior structure of the non-player character.
[0036] In a fourth aspect, an embodiment of the present application provides a behavior control device for a non-player character, the behavior control device for a non-player character comprising:
[0037] A first judgment module is used to judge whether the current game environment conditions meet the preset conditions in the reference behavior structure corresponding to the non-player character;
[0038] A second judgment module is used to judge whether the number of available behaviors in the reference behavior structure is unique when the current game environment condition meets the preset condition in the reference behavior structure corresponding to the non-player character;
[0039] A first execution module, configured to execute the available behaviors if the number of the available behaviors in the reference behavior structure is unique, wherein if the available behaviors act on operability targets, trigger corresponding target execution effects;
[0040] A second execution module, configured to execute the available behavior with the lowest priority if the number of the available behaviors in the reference behavior structure is not unique, wherein the priority of the available behavior is negatively correlated with the corresponding default consumption value;
[0041] The reference behavior structure is obtained according to the method for editing a reference behavior structure of a non-player character described in any one of the first aspects.
[0042] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed on the processor, the method for editing a reference behavior structure of a non-player character as described in any one of the embodiments of the first aspect and the method for controlling a behavior of a non-player character as described in any one of the embodiments of the second aspect are implemented.
[0043] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed on a processor, the method for editing a reference behavior structure of a non-player character as described in any one of the embodiments in the first aspect and the method for controlling a behavior of a non-player character as described in any one of the embodiments in the second aspect are implemented.
[0044] Compared with the prior art, this application has the following beneficial effects:
[0045] The present application provides a reference behavior structure associated with target conditions, available behaviors, and target execution effects, so that users can determine and associate different target conditions, available behaviors, and target execution effects according to actual usage requirements and specific application scenarios, obtain different reference behavior structures, and improve the reuse rate of target conditions, available behaviors, and target execution effects. Among them, different reference behavior structures are manifested in the game as non-player characters that can execute different behaviors. Moreover, by adjusting the default consumption value of each available behavior in the reference behavior structure, the user can flexibly adjust the type of non-player characters in the same reference behavior structure. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection of the present invention. In each of the drawings, similar components are numbered similarly.
[0047] Figure 1 A schematic diagram of a flow chart of a method for editing a reference behavior structure of a non-player character provided in an embodiment of the present application;
[0048] Figure 2 A flowchart of a behavior control method for a non-player character provided in an embodiment of the present application;
[0049] Figure 3 A module block diagram of a reference behavior structure editing device for a non-player character provided in an embodiment of the present application;
[0050] Figure 4 A module block diagram of a behavior control device for a non-player character provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0052] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0053] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.
[0054] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0055] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.
[0056] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0057] See also Figure 1 , Figure 1 A flowchart of a method for editing a reference behavior structure of a non-player character provided in an embodiment of the present application. Figure 1 As shown, the reference behavior structure editing method of the non-player character mainly includes:
[0058] Step S101, editing the first type of basic conditions and the second type of basic behaviors.
[0059] Although the prior art can realize the behavior logic of NPCs with a certain degree of complexity, the corresponding behavior structure is fixed, and the reuse rate of each sub-unit or node in the behavior structure is low, and the behavior structure of the NPC cannot be flexibly changed according to environmental changes. Therefore, the present application provides pre-editable reusable sub-units, namely the basic conditions and basic behaviors mentioned above, so that the behavior structure of non-player characters composed of these reusable sub-units can be flexibly adjusted.
[0060] Specifically, the first type includes the existence of an operable target within a first distance centered on the non-player character and the real-time distance between the operable target and the non-player character does not exceed a preset distance. Among them, the operable target can be any other non-player character other than the NPC to be edited in the current game environment where the NPC is located, or it can be any player character, or it can be any operable element in the game scene. The "operation" in the operable target can be any pre-set action, including but not limited to attack, dialogue, and collection. The elements include but are not limited to buildings, trees, city walls, and roads. For example, if an NPC is a lumberjack, one of the basic conditions that can be edited is: there are trees that can be cut down within a 10-meter range centered on the lumberjack. In specific implementation, the specific range of the first type can be customized according to the user's specific usage needs and application scenarios, and is not specifically limited here.
[0061] The second type includes movement behaviors and action behaviors, wherein the movement behaviors include any one of approaching, moving away, and random, and the action behaviors include any one of using skills and using props. In specific implementation, the corresponding distance values and directions of approaching, moving away, and random in the movement behaviors may also be set. The specific form of the skills and the specific type of props in the action behaviors may also be set. For example, long-range attack, medium-range attack, and melee attack.
[0062] Step S102: combining different basic conditions into a plurality of preset conditions, and combining different basic behaviors into a plurality of preset behaviors.
[0063] During specific implementation, any number of different basic conditions can be combined into preset conditions according to the user's input instructions, and any number of different basic behaviors can also be combined into preset behaviors. Among them, the preset condition refers to a set of basic conditions set by the user in a specific game scene to trigger a certain NPC to perform a preset behavior. Of course, the preset condition can only include one basic condition. For example, for the NPC "Dreadlock Man", the prerequisite for executing a preset behavior, that is, the "preset condition", can be set according to the user's input to: the dreadlock man does not hold a big sword, and there is an attackable target within a 2-meter range centered on the dreadlock man. The preset behavior can be a set of basic behaviors that the NPC can perform after the specific game environment meets a preset condition. Of course, the preset behavior can also include only one basic behavior. For example, a preset behavior can be set to backward movement + long-range attack, or left and right around the enemy + long-range attack, etc.
[0064] Step S103, setting a default consumption value for each of the preset behaviors and a preset execution effect corresponding to each of the preset behaviors, wherein the default consumption value corresponds to a first type of attribute value of the non-player character, the first type of attribute value includes physical strength, and the execution effect includes reducing a second type of attribute value of the operable target, the second type of attribute value includes health value.
[0065] The default consumption value corresponds to the first-category attribute value of the NPC. The first-category attribute value includes but is not limited to physical strength and gold coins. The execution of any preset behavior will cause a first-category attribute value of the NPC to decrease by a certain value, which is the default consumption value. The preset execution effect refers to the game effect that can be achieved after the NPC executes a preset behavior. It is usually manifested as the object of the preset behavior, that is, the operable target will change its state. Specifically, the second-category attribute value of the operable target will decrease, and the second-category attribute value includes but is not limited to health value. For example, when the NPC lumberjack performs the preset behavior of "cutting down" or "attacking" the trees within the preset range, the health value of the corresponding tree will decrease. If the health value of the tree is reduced to 0, it will be manifested as "being cut down".
[0066] It should be noted that the preset execution effect is the game effect that can be achieved by executing a preset behavior under an ideal state set by the user, but the actual execution effect will change according to the attribute settings of the corresponding operable target. For example, the preset execution effect corresponding to the preset behavior "backward movement + long-range attack" of the dreadlock man mentioned above can be "reduce the health of the operable target by 10 units", but if the corresponding operation target is a player character with a large defense attribute, then after the preset behavior acts on the player character, the player character's health may be less than 10 units, or even be blocked by the player character's skills or avoided due to the player character's movement.
[0067] In specific implementation, in addition to being expressed as specific data as described above, the preset execution effect can also be a non-numerical goal, such as "reduce the health of the operable object." The record or expression of the preset execution effect can be customized according to the user's specific usage needs and application scenarios, and is not further limited here.
[0068] Step S104, obtaining the target execution effect that matches the logical condition input by the user from all the preset execution effects, determining each preset behavior corresponding to the target execution effect as an available behavior, and selecting the target condition associated with the available behavior from all the preset conditions according to the first association relationship input by the user.
[0069] Logical conditions refer to the purpose that the user wants the NPC to achieve through a certain action or a series of actions, such as "reduce target health value". The target execution effect that matches the logical condition input by the user can be obtained from all preset execution effects. Specifically, the method of judging whether the preset execution effect matches the logical condition includes but is not limited to "keyword matching". For example, if the "reduce-health value" in the logical condition matches the "reduce-health value" in a preset execution effect "reduce the health value of the operable object", the preset execution effect "reduce the health value of the operable object" can be determined as the target execution effect corresponding to the logical condition "reduce target health value".
[0070] During specific implementation, there may be more than one corresponding preset behavior for the same preset execution effect. For example, for the NPC dreadlock man, the preset execution effect "reduce the health of the operable object" corresponds to multiple preset behaviors "backward movement + long-range attack" and "circle the enemy left and right + long-range attack", etc. If the preset execution effect is determined as the target execution effect, all corresponding preset behaviors can be determined as available behaviors. In addition, it is also necessary to determine the preset conditions that can trigger the execution of these available behaviors, and such preset conditions can be defined as target conditions. Specifically, the target condition associated with the available behavior can be selected from all preset conditions according to the first association relationship input by the user. The first association relationship can be a combination of any set of preset conditions input by the user and each available behavior, for example: "Preset condition A, available behaviors B, C and D" is a set of first association relationships.
[0071] Step S105 , associating the target condition, each of the available behaviors and the target execution effect with the non-player character respectively, to obtain a reference behavior structure of the non-player character.
[0072] After determining the target conditions, available behaviors, and target execution effects, the target conditions, available behaviors, and target execution effects can be associated with the NPC to obtain a reference behavior structure for the NPC. For example, for the NPC dreadlock man, a corresponding reference behavior structure can be:
[0073] Target conditions: The man with dreadlocks does not hold a great sword, and there is an attackable target within a 2-meter range centered on the man with dreadlocks;
[0074] Target execution effect: Reduce target health;
[0075] Available behaviors: "Backward movement + ranged attack" and "Circle the enemy left and right + ranged attack".
[0076] In specific implementation, each basic condition, each preset behavior and each preset execution effect can be stored in a preset storage space in the form of a preset data exchange format, wherein the preset data exchange format includes but is not limited to JavaScript object notation, that is, JSON structure.
[0077] Each JSON structure can be marked with a different number. Specifically, each basic condition can be marked with a first-class number, each preset behavior can be marked with a different second-class number, and each preset execution effect can be marked with a different third-class number. The corresponding first-class number, second-class number, and third-class number are associated according to the user input to obtain a second association relationship. Based on the second association relationship, all basic conditions, available behaviors, and target execution effects included in each corresponding target condition are associated with non-player characters. For example, in the reference behavior structure in the previous example, the first number corresponding to the target condition is 101, the second-class number of the target execution effect is 201, and the third-class numbers of the available behaviors are 301 and 302, respectively. Then, the reference behavior structure can be obtained by associating the JSON structures corresponding to 101, 201, 301, and 302.
[0078] Each basic condition, each preset behavior and each preset execution effect is stored in a preset data exchange format represented by a JSON structure, and each JSON structure is marked with a number, so that users can flexibly adjust the reference behavior of the NPC by associating different JSON structures, which can greatly improve the reuse rate of target conditions, available behaviors and target execution effects.
[0079] In specific implementation, after the step of obtaining the reference behavior structure of the non-player character, the target behavior with the highest matching degree with the target type can be selected from all available behaviors according to the target type of the non-player character input by the user. It is determined whether the default consumption value of the target behavior is greater than the preset consumption value. If the default consumption value of the target behavior is greater than the preset consumption value, the default consumption value corresponding to the target behavior in the reference behavior structure is updated to the preset consumption value, and the target behavior structure of the target type is obtained.
[0080] The reference behavior structure described above may include multiple available behaviors. For example, under target conditions, the available behaviors that an NPC can perform include "logging" and "hunting". According to the target type of the non-player character input by the user, such as "carpentry" and "hunter", the target behavior with the highest matching degree with the target type can be selected from all available behaviors. For example, if the target type input at this time is "carpentry", the target behavior is "logging". The preset consumption value can be customized according to the user's specific usage needs and application scenarios, such as 1 unit. If the default consumption value corresponding to "logging" in the current NPC's reference behavior structure exceeds 1 unit, the default consumption value corresponding to the target behavior can be updated to the preset consumption value to obtain the target behavior structure of the target type, that is, in the modified NPC's reference behavior structure, the default consumption value of the available behavior "logging" is smaller, making the corresponding NPC more suitable for executing the target behavior of "logging".
[0081] The reference behavior structure editing method of non-player characters provided by the present application stores each basic condition, each preset behavior and each preset execution effect in a preset data exchange format represented by a JSON structure, and marks each JSON structure by number, so that the user can flexibly adjust the reference behavior of the NPC by associating different JSON structures. Through the target type of the NPC input by the user, the default consumption value of the corresponding target behavior in the reference behavior structure can be adjusted, and the type of non-player characters in the same reference behavior structure can be flexibly adjusted, which can greatly improve the reuse rate of target conditions, available behaviors and target execution effects.
[0082] Corresponding to the above-mentioned method for editing the reference behavior structure of a non-player character, the present invention also provides a method for controlling the behavior of a non-player character. The reference behavior structure is obtained according to any one of the embodiments of the above-mentioned method for editing the reference behavior structure of a non-player character. Figure 2 , Figure 2 A flowchart of a method for controlling the behavior of a non-player character provided in an embodiment of the present application is provided. The method for controlling the behavior of a non-player character includes:
[0083] Step S201, determining whether the current game environment conditions meet the preset conditions in the reference behavior structure corresponding to the non-player character.
[0084] Step S202, when the current game environment condition meets the preset condition in the reference behavior structure corresponding to the non-player character, it is determined whether the number of the available behaviors in the reference behavior structure is unique.
[0085] Step S203: If the number of the available behaviors in the reference behavior structure is unique, the available behaviors are executed, wherein if the available behaviors act on operability targets, corresponding target execution effects are triggered.
[0086] Step S204: If the number of the available behaviors in the reference behavior structure is not unique, execute the available behavior with the lowest priority, wherein the priority of the available behavior is negatively correlated with the corresponding default consumption value.
[0087] In specific implementation, since the number of available behaviors in a reference behavior structure of an NPC may be more than one, it is necessary to first determine whether the number of available behaviors in the reference behavior structure is unique. If the number of available behaviors in the reference behavior structure is unique, the available behaviors are executed to trigger the corresponding target execution effect. If the number of available behaviors in the reference behavior structure is not unique, the available behaviors to be executed can be determined based on the priority order corresponding to each available behavior.
[0088] The priority of the available behaviors is negatively correlated with the corresponding default consumption value. If the number of available behaviors in the reference behavior structure is unique, the available behavior with the lowest priority can be executed. It is also possible to execute each available behavior in order of priority, from large to small. In addition, the available behaviors in the reference behavior structure can be combined into different behavior chains in a preset order, such as abc and def. The size relationship of the default consumption value of the first available behavior in each behavior chain can be compared, and all available behaviors in the behavior chain corresponding to the smallest default consumption value can be executed.
[0089] Corresponding to the above method embodiment, see Figure 3 The present invention also provides a reference behavior structure editing device 300 for a non-player character, the reference behavior structure editing device 300 for a non-player character comprising:
[0090] An editing module 301, used for editing the first type of basic conditions and the second type of basic behaviors;
[0091] A combining module 302, used to combine different basic conditions into a plurality of preset conditions, and to combine different basic behaviors into a plurality of preset behaviors;
[0092] A setting module 303 is used to set a default consumption value of each of the preset behaviors and a preset execution effect corresponding to each of the preset behaviors, wherein the default consumption value corresponds to a first type of attribute value of the non-player character, the first type of attribute value includes a physical strength value, and the execution effect includes reducing a second type of attribute value of an operable target, the second type of attribute value includes a health value;
[0093] A selection module 304 is used to obtain a target execution effect that matches the logical condition input by the user from all the preset execution effects, determine each preset behavior corresponding to the target execution effect as an available behavior, and select a target condition associated with the available behavior from all the preset conditions according to the first association relationship input by the user;
[0094] The association module 305 is used to associate the target condition, each of the available behaviors and the target execution effect with the non-player character to obtain a reference behavior structure of the non-player character.
[0095] Corresponding to the above method embodiment, see Figure 4 The present invention also provides a non-player character behavior control device 400, the non-player character behavior control device 400 comprising:
[0096] The first judgment module 401 is used to judge whether the current game environment conditions meet the preset conditions in the reference behavior structure corresponding to the non-player character;
[0097] The second judgment module 402 is used to judge whether the number of available behaviors in the reference behavior structure is unique when the current game environment condition meets the preset condition in the reference behavior structure corresponding to the non-player character;
[0098] A first execution module 403 is configured to execute the available behaviors if the number of the available behaviors in the reference behavior structure is unique, wherein if the available behaviors act on operability targets, trigger corresponding target execution effects;
[0099] A second execution module 404 is configured to execute the available behavior with the lowest priority if the number of the available behaviors in the reference behavior structure is not unique, wherein the priority of the available behavior is negatively correlated with the corresponding default consumption value;
[0100] The reference behavior structure is obtained according to any one of the embodiments of the method for editing the reference behavior structure of a non-player character described above.
[0101] In addition, a computer device is also provided, which includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed on the processor, the reference behavior structure editing method of the non-player character and the behavior control method of the non-player character are implemented.
[0102] In addition, a computer-readable storage medium is also provided, which stores a computer program. When the computer program is executed on a processor, it implements the above-mentioned reference behavior structure editing method of non-player characters and behavior control method of non-player characters.
[0103] The specific implementation process of the reference behavior structure editing device for non-player characters, the behavior control device for non-player characters, the computer device and the computer-readable storage medium provided in the present application can refer to the specific implementation process of the reference behavior structure editing method for non-player characters or the behavior control method for non-player characters provided in the above embodiments, which will not be repeated here.
[0104] The present application provides a reference behavior structure editing device for non-player characters, a behavior control device for non-player characters, a computer device and a computer-readable storage medium. The default consumption value of the corresponding target behavior in the reference behavior structure can be adjusted according to the target type of the NPC input by the user, and the type of non-player characters in the same reference behavior structure can be flexibly adjusted, which can greatly improve the reuse rate of target conditions, available behaviors and target execution effects.
[0105] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow chart, and the combination of boxes in the structure diagram and / or the flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0106] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0107] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0108] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A method for editing a reference behavior structure of a non-player character, characterized in that: The reference behavior structure editing method of the non-player character comprises: Edit the basic conditions of the first type and the basic behaviors of the second type; Combining different basic conditions into multiple preset conditions, and combining different basic behaviors into multiple preset behaviors; Setting a default consumption value for each of the preset behaviors and a preset execution effect corresponding to each of the preset behaviors, wherein the default consumption value corresponds to a first type of attribute value of the non-player character, the first type of attribute value includes a physical strength value, and the execution effect includes reducing a second type of attribute value of an operable target, the second type of attribute value includes a health value; Acquire a target execution effect that matches the logical condition input by the user from all the preset execution effects, determine each preset behavior corresponding to the target execution effect as an available behavior, and select a target condition associated with the available behavior from all the preset conditions according to the first association relationship input by the user; The target condition, each of the available behaviors and the target execution effect are respectively associated with the non-player character to obtain a reference behavior structure of the non-player character.
2. The method for editing a reference behavior structure of a non-player character according to claim 1, characterized in that: The reference behavior structure editing method of the non-player character also includes: Each of the basic conditions, each of the preset behaviors and each of the preset execution effects are stored in a preset storage space in a preset data exchange format, wherein the preset data exchange format includes JavaScript object notation.
3. The method for editing a reference behavior structure of a non-player character according to claim 1, characterized in that: The step of associating the target condition, each of the available behaviors and the target execution effect with the non-player character respectively comprises: Each of the basic conditions is marked with a different first-category number, each of the preset behaviors is marked with a different second-category number, and each of the preset execution effects is marked with a different third-category number; According to the user input, the corresponding first category number, second category number and third category number are associated to obtain a second association relationship; Based on the second association relationship, all the basic conditions, the available behaviors and the target execution effects included in each corresponding target condition are associated with the non-player character.
4. The method for editing a reference behavior structure of a non-player character according to claim 1, characterized in that: After the step of obtaining the reference behavior structure of the non-player character, the method for editing the reference behavior structure of the non-player character further includes: According to the target type of the non-player character input by the user, selecting a target behavior with the highest matching degree with the target type from all the available behaviors; Determining whether the default consumption value of the target behavior is greater than a preset consumption value; If the default consumption value of the target behavior is greater than the preset consumption value, the default consumption value corresponding to the target behavior in the reference behavior structure is updated to the preset consumption value to obtain the target behavior structure of the target type.
5. The method for editing a reference behavior structure of a non-player character according to claim 1, characterized in that: The first type includes that an operable target exists within a first distance centered on the non-player character and a real-time distance between the operable target and the non-player character does not exceed a preset distance; The second type includes movement behaviors and action behaviors, wherein the movement behaviors include any one of approaching, moving away, and random, and the action behaviors include any one of using skills and using props.
6. A method for controlling the behavior of a non-player character, characterized in that: The behavior control method of the non-player character includes: Determine whether the current game environment conditions meet the preset conditions in the reference behavior structure corresponding to the non-player character; When the current game environment condition satisfies the preset condition in the reference behavior structure corresponding to the non-player character, determining whether the number of the available behaviors in the reference behavior structure is unique; If the number of the available behaviors in the reference behavior structure is unique, execute the available behaviors, wherein if the available behaviors act on operability targets, trigger corresponding target execution effects; If the number of the available behaviors in the reference behavior structure is not unique, executing the available behavior with the smallest priority, wherein the priority of the available behavior is negatively correlated with the corresponding default consumption value; Wherein, the reference behavior structure is obtained according to the reference behavior structure editing method for a non-player character according to any one of claims 1 to 5.
7. A reference behavior structure editing device for a non-player character, characterized in that: The reference behavior structure editing device of the non-player character comprises: An editing module, used for editing the first type of basic conditions and the second type of basic behaviors; A combination module, used for combining different basic conditions into multiple preset conditions, and combining different basic behaviors into multiple preset behaviors; A setting module, used to set a default consumption value of each of the preset behaviors and a preset execution effect corresponding to each of the preset behaviors, wherein the default consumption value corresponds to a first type of attribute value of the non-player character, the first type of attribute value includes a physical strength value, and the execution effect includes reducing a second type of attribute value of an operable target, the second type of attribute value includes a health value; a selection module, configured to obtain a target execution effect matching a logical condition input by a user from all the preset execution effects, determine each preset behavior corresponding to the target execution effect as an available behavior, and select a target condition associated with the available behavior from all the preset conditions according to a first association relationship input by the user; The association module is used to associate the target condition, each of the available behaviors and the target execution effect with the non-player character to obtain a reference behavior structure of the non-player character.
8. A behavior control device for a non-player character, characterized in that: The behavior control device of the non-player character comprises: A first judgment module is used to judge whether the current game environment conditions meet the preset conditions in the reference behavior structure corresponding to the non-player character; A second judgment module is used to judge whether the number of available behaviors in the reference behavior structure is unique when the current game environment condition meets the preset condition in the reference behavior structure corresponding to the non-player character; A first execution module, configured to execute the available behaviors if the number of the available behaviors in the reference behavior structure is unique, wherein if the available behaviors act on operability targets, trigger corresponding target execution effects; A second execution module, configured to execute the available behavior with the lowest priority if the number of the available behaviors in the reference behavior structure is not unique, wherein the priority of the available behavior is negatively correlated with the corresponding default consumption value; Wherein, the reference behavior structure is obtained according to the reference behavior structure editing method for a non-player character according to any one of claims 1 to 5.
9. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed on the processor, the reference behavior structure editing method of a non-player character described in any one of claims 1 to 5 and the behavior control method of a non-player character described in claim 6 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed on a processor, implements the reference behavior structure editing method for a non-player character according to any one of claims 1 to 5 and the behavior control method for a non-player character according to claim 6.
Citation Information
Patent Citations
Method for editing non-player-controlled character
CN102810061A
Method for generating behavior sequence of non-player character and device thereof
CN113648660A