WO2024066993A1 - 非玩家角色的控制方法和装置、存储介质及电子设备 - Google Patents

非玩家角色的控制方法和装置、存储介质及电子设备 Download PDF

Info

Publication number
WO2024066993A1
WO2024066993A1 PCT/CN2023/117303 CN2023117303W WO2024066993A1 WO 2024066993 A1 WO2024066993 A1 WO 2024066993A1 CN 2023117303 W CN2023117303 W CN 2023117303W WO 2024066993 A1 WO2024066993 A1 WO 2024066993A1
Authority
WO
WIPO (PCT)
Prior art keywords
sound
npc
sound intensity
intensity
player character
Prior art date
Application number
PCT/CN2023/117303
Other languages
English (en)
French (fr)
Inventor
王玉龙
杨洋
王亚昌
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2024066993A1 publication Critical patent/WO2024066993A1/zh

Links

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/55Controlling game characters or game objects based on the game progress
    • A63F13/56Computing the motion of game characters with respect to other game characters, game objects or elements of the game scene, e.g. for simulating the behaviour of a group of virtual soldiers or for path finding

Definitions

  • the present invention relates to the field of computer technology, and in particular to a control method and device for a non-player character, a storage medium and an electronic device.
  • NPCs non-player characters
  • the NPC's environmental perception ability is used to enable the NPC to perform specified behavioral operations, thereby achieving interaction between the NPC and the player.
  • the NPC's environmental perception ability mainly relies on visual perception, and is usually simulated based on information such as the distance and angle between the NPC and the player. For example, in a 3D game scene, when the player is within a specified distance and angle range in front of the NPC, the NPC will see the player and interact with the player.
  • the relevant technology does not take into account the impact of 3D game scenes on NPC vision. For example, when the player hides behind obstacles such as rocks, the NPC cannot see the player. Then, when the player walks, runs or sprints in the blind spot of the NPC's field of vision, the NPC will not be able to perceive the player, let alone control the NPC to interact with the player, resulting in a technical problem of being unable to accurately control non-player characters to perform behavioral operations.
  • the embodiments of the present invention provide a method and device for controlling a non-player character, a storage medium, and an electronic device, so as to at least solve the technical problem that a non-player character cannot be accurately controlled to perform behavioral operations.
  • a control method for a non-player character comprising: obtaining a first sound intensity of a first sound and a first propagation distance of the first sound, wherein the first sound is a sound generated by a first player character at a first position, the first sound intensity is a preset sound intensity corresponding to a first motion state of the first player character at the first position, and the first propagation distance is a propagation distance determined according to the first sound intensity; when a first target distance between a non-player character NPC and the first player character is less than the first propagation distance and less than a preset hearing radius of the NPC, determining the sound intensity of the first sound heard by the NPC according to the first sound intensity and the first target distance; when the sound intensity of the first sound heard by the NPC is greater than or equal to a first sound intensity threshold, controlling the NPC to perform a behavioral operation corresponding to the first sound.
  • controlling the NPC to perform a behavioral operation corresponding to the first sound when the sound intensity of the first sound heard by the NPC is greater than or equal to a first sound intensity threshold includes: when the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold and less than a second sound intensity threshold, controlling the NPC to perform a first behavioral operation, wherein the first behavioral operation is a behavioral operation performed when the NPC perceives the sound.
  • controlling the NPC to perform a behavior operation corresponding to the first sound further includes: when the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold, When the sound intensity is greater than or equal to the second sound intensity threshold, the NPC is controlled to perform a second behavior operation, wherein the second behavior operation is a behavior operation performed when the NPC discovers the first player character.
  • controlling the NPC to perform a behavioral operation corresponding to the first sound when the sound intensity of the first sound heard by the NPC is greater than or equal to a first sound intensity threshold includes: controlling the NPC to move to the first position when the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold and less than a second sound intensity threshold; or controlling the NPC to search for the first player character while moving to the first position when the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold and less than the second sound intensity threshold.
  • controlling the NPC to perform a behavioral operation corresponding to the first sound when the sound intensity of the first sound heard by the NPC is greater than or equal to a first sound intensity threshold also includes: controlling the NPC to move in a direction away from the first player character, or controlling the NPC to move in the direction of the first player character when the sound intensity of the first sound heard by the NPC is greater than or equal to a second sound intensity threshold; or controlling the NPC to perform an interactive operation with the first player character when the sound intensity of the first sound heard by the NPC is greater than or equal to the second sound intensity threshold.
  • the above-mentioned determining the sound intensity of the first sound heard by the NPC based on the first sound intensity and the first target distance includes: determining the residual sound intensity when the first sound propagates to the position of the NPC based on the first sound intensity and the first target distance; obtaining the sound intensity of the ambient noise at the position of the NPC; and determining the sound intensity of the first sound heard by the NPC based on the residual sound intensity and the sound intensity of the ambient noise.
  • the above-mentioned acquisition of the sound intensity of the ambient noise at the location where the NPC is located includes: determining a target grid where the NPC is located in a target game scene, wherein the target game scene is pre-divided into a group of grids, a group of grids includes a target grid, each grid in a group of grids is pre-set with a corresponding sound intensity of the ambient noise, and the sound intensity of the ambient noise corresponding to each grid is determined according to the type of virtual terrain in each grid; and determining the sound intensity of the ambient noise at the location where the NPC is located to be equal to the sound intensity of the ambient noise corresponding to the pre-set target grid.
  • the method further includes: performing the following operations on each grid in a group of grids to obtain the sound intensity of the ambient noise corresponding to each grid, wherein when performing the following operations, each of the above grids is the current grid: obtaining the sound intensity of the initial noise corresponding to the current grid, wherein the sound intensity of the initial noise has a preset corresponding relationship with the type of virtual terrain in the current grid; obtaining the sound intensity of the propagated noise received by the current grid, wherein the sound intensity of the propagated noise includes the residual sound intensity when the initial noise corresponding to each grid in a group of grids except the current grid propagates to the current grid; determining the sound intensity of the ambient noise corresponding to the current grid according to the sound intensity of the initial noise and the sound intensity of the propagated noise.
  • the above-mentioned determining the sound intensity of the ambient noise corresponding to the current grid based on the sound intensity of the initial noise and the sound intensity of the propagated noise includes: determining the sound intensity of the ambient noise corresponding to the current grid to be equal to the maximum sound intensity of the sound intensity of the initial noise and the sound intensity of the propagated noise; or determining the sound intensity of the ambient noise corresponding to the current grid to be equal to the sum of the sound intensity of the initial noise and the sound intensity of the propagated noise; or determining the sound intensity of the ambient noise corresponding to the current grid to be equal to the value obtained by weighted summing the sound intensity of the initial noise and the sound intensity of the propagated noise.
  • determining the sound intensity of the first sound heard by the NPC based on the residual sound intensity and the sound intensity of the ambient noise includes: when the residual sound intensity is greater than the sound intensity of the ambient noise, determining the sound intensity of the first sound heard by the NPC to be equal to the difference between the residual sound intensity and the sound intensity of the ambient noise; and/or In a case where the remaining sound intensity is less than or equal to the sound intensity of the ambient noise, the sound intensity of the first sound heard by the NPC is determined to be equal to the sound intensity of the ambient noise or to be zero.
  • the above method also includes: setting a preset hearing radius according to the character type of the NPC, wherein when the character type of the NPC is a character type with sensitive hearing, the preset hearing radius is set to a first value, and when the character type of the NPC is a character type without sensitive hearing, the preset hearing radius is set to a second value, and the first value is greater than the second value; or setting the preset hearing radius according to the current state of the NPC, wherein when the current state of the NPC is a state of not being damaged by an attack, the preset hearing radius is set to a first value, and when the current state of the NPC is a state of being damaged by an attack, the preset hearing radius is set to a second value, and the first value is greater than the second value; or setting the preset hearing radius according to the release state of the NPC's target skill, wherein the target skill is used to increase the NPC's hearing range in a released state, and when the release state of the target skill is a released state, the
  • the above method also includes: in the process of controlling the NPC to perform a behavioral operation corresponding to the first sound, obtaining a second sound intensity of the second sound and a second propagation distance of the second sound, wherein the second sound is the sound generated by the second player character at the second position, the second sound intensity is a preset sound intensity corresponding to the second motion state of the second player character at the second position, and the second propagation distance is a propagation distance determined according to the second sound intensity; when the second target distance between the NPC and the second player character is less than the second propagation distance and less than a preset hearing radius of the NPC, determining the sound intensity of the second sound heard by the NPC according to the second sound intensity and the second target distance; when the sound intensity of the second sound heard by the NPC is greater than or equal to the first sound intensity threshold and greater than the sound intensity of the first sound heard by the NPC, controlling the NPC to stop performing the behavioral operation corresponding to the first sound, and controlling the NPC to perform the behavioral operation corresponding to the second sound,
  • a control device for a non-player character comprising: a first acquisition unit, configured to acquire a first sound intensity of a first sound and a first propagation distance of the first sound, wherein the first sound is a sound generated by the first player character at a first position, the first sound intensity is a preset sound intensity corresponding to a first motion state of the first player character at the first position, and the first propagation distance is a propagation distance determined according to the first sound intensity; a first processing unit, configured to determine the sound intensity of the first sound heard by the NPC according to the first sound intensity and the first target distance when a first target distance between the non-player character NPC and the first player character is less than the first propagation distance and less than a preset hearing radius of the NPC; and a second processing unit, configured to control the NPC to perform a behavioral operation corresponding to the first sound when the sound intensity of the first sound heard by the NPC is greater than or equal to a first sound intensity threshold.
  • a computer-readable storage medium in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned control method for non-player characters when running.
  • a computer program product including a computer program/instruction, which implements the steps of the above method when executed by a processor.
  • an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the control method of the non-player character through the computer program.
  • the NPC when it is determined that the NPC can hear the first sound emitted by the first player character according to the first target distance between the non-player character NPC and the first player character and the preset hearing radius of the NPC, the NPC is controlled by comparing the sound intensity of the first sound heard by the NPC with the first sound intensity threshold. Execute the behavioral operation corresponding to the first sound. In other words, by comparing the sound intensity of the first sound heard by the NPC with the first sound intensity threshold, the NPC can accurately execute the corresponding behavioral operation, thus avoiding the technical problem of being unable to accurately control the NPC to execute the behavioral operation, and achieving the technical effect of improving the accuracy of controlling the NPC to execute the behavioral operation.
  • FIG1 is a schematic diagram of an application scenario of an optional non-player character control method according to an embodiment of the present invention.
  • FIG2 is a flow chart of an optional non-player character control method according to an embodiment of the present invention.
  • FIG3 is a schematic diagram (I) of an optional method of controlling an NPC to perform a behavior operation corresponding to a first sound according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of the sound intensity of a first sound generated by a first player character in different types of virtual terrains and in different motion states according to an optional embodiment of the present invention
  • FIG5 is a schematic diagram of an optional preset hearing radius of an NPC according to an embodiment of the present invention.
  • FIG6 is a schematic diagram (II) of an optional method of controlling an NPC to perform a behavior operation corresponding to a first sound according to an embodiment of the present invention
  • FIG7 is a schematic diagram (III) of an optional method of controlling an NPC to perform a behavior operation corresponding to a first sound according to an embodiment of the present invention
  • FIG8 is a schematic diagram of an optional attenuation process of the sound intensity of a first sound according to an embodiment of the present invention
  • FIG. 9 is a schematic diagram of a group of grids obtained by optionally dividing a target game scene into grids according to an embodiment of the present invention.
  • FIG10 is a schematic diagram of the sound intensity of environmental noise corresponding to different types of virtual terrains according to an optional embodiment of the present invention.
  • FIG11 is a schematic diagram of an optional method for determining the sound intensity of the ambient noise at the location of the NPC according to an embodiment of the present invention.
  • FIG12 is a schematic diagram of another optional method for determining the sound intensity of the ambient noise at the location of the NPC according to an embodiment of the present invention.
  • FIG13 is a schematic diagram of an optional method for setting a preset hearing radius of an NPC according to an embodiment of the present invention.
  • FIG. 14 is a schematic diagram of an optional method of switching a behavior operation corresponding to a first sound performed by an NPC to a behavior operation corresponding to a second sound according to an embodiment of the present invention
  • FIG15 is an overall flow chart of an optional non-player character control method according to an embodiment of the present invention.
  • FIG16 is a schematic diagram of the structure of an optional control device for a non-player character according to an embodiment of the present invention.
  • FIG. 17 is a schematic structural diagram of an optional electronic device according to an embodiment of the present invention.
  • AI A synonym for NPCs with anthropomorphic behaviors in games
  • Hearing range The range in which an AI object can hear sounds, usually a spherical area
  • Auditory Perception Threshold The sound intensity value that causes the AI object to perceive. When hearing a sound greater than this value, the AI object will enter the perception state;
  • Auditory detection threshold The sound intensity value that causes the AI object to detect the player. When hearing a sound greater than this value, the AI object will detect the player and interact with the player.
  • a control method for a non-player character may be, but is not limited to, applied to an application scenario as shown in FIG. 1.
  • the terminal device 102 may, but is not limited to, communicate with the server 106 via the network 104, and the server 106 may, but is not limited to, perform operations on the database 108, such as write data operations or read data operations.
  • the terminal device 102 may, but is not limited to, include a human-computer interaction screen, a processor, and a memory.
  • the human-computer interaction screen may, but is not limited to, be used to display the motion state of the first player character at the first position on the terminal device 102, the interactive behavior between the NPC and the first player character, etc.
  • the processor may, but is not limited to, be used to respond to the human-computer interaction operation, perform a corresponding operation, or generate a corresponding instruction, and send the generated instruction to the server 106.
  • the memory is used to store relevant processing data, such as the first sound intensity of the first sound, the first propagation distance of the first sound, and the preset hearing radius of the NPC, etc.
  • Step S102 obtaining the first sound intensity of the first sound and the first propagation distance of the first sound, wherein the first sound is the sound generated by the first player character at the first position, the first sound intensity is the preset sound intensity corresponding to the first motion state of the first player character at the first position, and the first propagation distance is the propagation distance determined according to the first sound intensity; when the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold, the NPC is controlled to perform the behavior operation corresponding to the first sound.
  • Step S104 when the first target distance between the non-player character NPC and the first player character is less than the first propagation distance and less than the preset hearing radius of the NPC, the sound intensity of the first sound heard by the NPC is determined according to the first sound intensity and the first target distance; Step S106, when the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold, the NPC is controlled to perform the behavior operation corresponding to the first sound.
  • the NPC when it is determined that the NPC can hear the first sound emitted by the first player character based on the first target distance between the non-player character NPC and the first player character and the preset hearing radius of the NPC, the NPC is controlled to perform the behavior operation corresponding to the first sound by comparing the sound intensity of the first sound heard by the NPC with the first sound intensity threshold.
  • the NPC can accurately perform the corresponding behavior operation, avoiding the problem of being unable to accurately control the NPC to perform the behavior.
  • the technical problem of operation is solved, and the technical effect of improving the accuracy of controlling NPC to perform behavioral operations is achieved.
  • FIG2 is a flow chart of the control method for a non-player character according to an embodiment of the present invention.
  • the flow chart includes the following steps:
  • Step S202 obtaining a first sound intensity of a first sound and a first propagation distance of the first sound, wherein the first sound is a sound generated by a first player character at a first position, the first sound intensity is a preset sound intensity corresponding to a first motion state of the first player character at the first position, and the first propagation distance is a propagation distance determined according to the first sound intensity;
  • the first sound intensity and the first propagation distance of the first sound can be obtained from the specified parameter value, which is not limited in the present application.
  • the first sound intensity can be obtained from the specified parameter value based on the first position of the first player character and the first motion state at the first position, or further combined with other information.
  • the first propagation distance can be determined based on the first sound intensity.
  • the first propagation distance can be a virtual distance in a virtual scene.
  • a first sound intensity of the first sound may be determined according to a first motion state of the first player character at the first position.
  • the first sound intensity may be a preset sound intensity corresponding to the type of virtual terrain at the first position and the first motion state of the first player character at the first position, in addition to being related to the first motion state of the first player character at the first position.
  • the sound emitted by the player in the game scene may be, but is not limited to, simulated based on the player's behavior state to generate the sound intensity of different sounds emitted by the player in the game scene. For example, as shown in FIG4 , when the first player is located on different types of virtual terrains and in different motion states, the sound emitted has different intensities.
  • the intensity of the sound emitted by the first player character in the game scene can be simulated to be 10DB; according to the virtual terrain "ground” and the movement state "sneaking" of the first position of the first player character, the intensity of the sound emitted by the first player character in the game scene can be simulated to be 15DB;
  • the intensity of the sound emitted by the first player character in the game scene can be simulated to be 40DB; according to the virtual terrain "mountain” and the movement state “sprinting forward” of the first position where the first player character is located, the intensity of the sound emitted by the first player character in the game scene can be simulated to be 50DB;
  • the intensity of the sound emitted by the first player character in the game scene can be simulated to be 25DB; according to the virtual terrain "bush” and the movement state “walking" of the first position of the first player character, It can simulate that the intensity of the sound made by the first player character in the game scene is 30DB;
  • the intensity of the sound emitted by the first player character in the game scene can be simulated to be 20DB.
  • the method of determining the first sound intensity of the first sound can be but is not limited to querying a pre-created relationship mapping table according to the type of virtual terrain at the first position and/or the first motion state to obtain the value of the first sound intensity.
  • Step S204 when the first target distance between the non-player character NPC and the first player character is less than the first propagation distance and less than the preset hearing radius of the NPC, determining the sound intensity of the first sound heard by the NPC according to the first sound intensity and the first target distance;
  • NPCs have different corresponding hearing abilities. Therefore, in the process of determining the sound intensity of the first sound heard by the NPC, in addition to considering the first target distance between the NPC and the first player character, it is also necessary to consider the NPC's own auditory perception ability, for example, the NPC's preset hearing radius.
  • the propagation distance of the first sound emitted by the first player character (which can also be understood as the first propagation distance of the first sound) is d
  • the target distance between the first player character and NPC1 is d1
  • the target distance between the first player character and NPC2 is d2
  • d2 ⁇ d, and d2 ⁇ r it is determined that NPC2 can hear the first sound with a stronger sound intensity, wherein r is the preset hearing radius of NPC2, and r determines the hearing range of NPC2.
  • the sound intensity of the first sound heard by NPC2 is determined.
  • NPC1 and NPC2 can hear the first sound can also be determined through the following implementation process: when the first player character makes the first sound, first, according to the propagation distance d of the first sound, the NPCs within the propagation distance d are determined, as shown in FIG5 , including NPC1 and NPC2; then, according to whether the sound source of the first sound is within the preset hearing radius of the NPC, it can be determined that only NPC2 can hear the first sound. For NPC1, although it is within the range of the propagation distance d of the first sound, the sound source of the first sound is outside the preset hearing radius of NPC1, so NPC1 cannot hear the first sound.
  • the propagation distance d of the first sound, the preset hearing radius r of NPC2, the target distance between NPC1 and NPC2 and the first player character, etc. are only examples and are not limiting.
  • Step S206 When the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold, the NPC is controlled to perform a behavior operation corresponding to the first sound.
  • step S204 when the sound intensity of the first sound heard by the NPC is determined, the sound intensity of the first sound heard by the NPC is compared with the first sound intensity threshold, for example, the sound intensity of the first sound heard by the NPC is compared with the auditory perception threshold of the NPC.
  • the behavior operation corresponding to the first sound can only be performed when the NPC perceives the first sound. For example, when NPC2 shown in FIG5 can hear the first sound and the sound intensity of the first sound heard by NPC2 is greater than the auditory perception threshold (first sound intensity threshold), the conversation operation shown in FIG3 is performed. Since NPC1 cannot hear the first sound, it will continue to be in a daily state, such as sleeping, patrolling, etc.
  • steps S202 to S206 are all executed on the server side, which improves the data synchronization efficiency and data processing efficiency between different clients and avoids problems such as client cheating and large data synchronization delays.
  • the NPC is controlled to perform the behavior operation corresponding to the first sound by comparing the sound intensity of the first sound heard by the NPC with the first sound intensity threshold.
  • the NPC can accurately perform the corresponding behavior operation, thus avoiding the technical problem of being unable to accurately control the NPC to perform the behavior operation, and achieving the technical effect of improving the accuracy of controlling the NPC to perform the behavior operation.
  • various rules are set according to different parameters to control the NPC to perform behavioral operations corresponding to the first sound, for example, the NPC's preset auditory radius, the first sound intensity threshold, etc.
  • a second sound intensity threshold is also provided in an embodiment of the present application.
  • controlling the NPC to perform a behavior operation corresponding to the first sound includes:
  • the NPC When the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold and less than the second sound intensity threshold, the NPC is controlled to perform a first behavior operation, wherein the first behavior operation is a behavior operation performed when the NPC perceives the sound.
  • the NPC when the NPC can hear the first sound, in order to accurately control the NPC to perform the behavioral operation corresponding to the first sound, the behavioral operations performed when the NPC perceives the first sound but does not find the first player character and when the NPC perceives the first sound and finds the first player character are divided.
  • the following is a detailed description of the first behavioral operation performed when the NPC perceives the first sound but does not find the first player character, combined with specific examples.
  • the NPC performs a behavior operation corresponding to the first sound, including:
  • the NPC When the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold and less than the second sound intensity threshold, the NPC is controlled to search for the first player character in the process of moving to the first position.
  • the NPC perceives the first sound, becomes alert to the first sound, and performs perception behavior, for example, moving toward the first position S1 where the first player character is located.
  • the first behavior operation performed by the NPC can also be to search for the first player character while moving.
  • the NPC moves toward the first position S1 where the first player character is located and searches for the first player character during the movement.
  • the above-mentioned controlling the NPC to perform the behavior operation corresponding to the first sound also includes:
  • the NPC When the sound intensity of the first sound heard by the NPC is greater than or equal to the second sound intensity threshold, the NPC is controlled to perform a second behavior operation, wherein the second behavior operation is a behavior operation performed when the NPC discovers the first player character.
  • the second sound intensity threshold may be, but is not limited to, the auditory detection threshold for the NPC to detect the first player character. That is, when the sound intensity of the first sound heard by the NPC is greater than or equal to the second sound intensity threshold, the NPC will find the first player character and perform a second behavior operation corresponding to the first sound, specifically, including:
  • the NPC When the sound intensity of the first sound heard by the NPC is greater than or equal to the second sound intensity threshold, the NPC is controlled to move in a direction away from the first player character, or the NPC is controlled to move in a direction toward the first player character; or
  • the NPC When the sound intensity of the first sound heard by the NPC is greater than or equal to the second sound intensity threshold, the NPC is controlled to perform an interactive operation with the first player character.
  • the NPC Since the sound intensity of the first sound heard by the NPC is greater than or equal to the second sound intensity threshold, the NPC will directly discover the first player character and trigger the corresponding discovery behavior of the NPC (which can also be understood as the second behavior operation). For example, according to the relationship between the NPC and the first player character, the NPC is controlled to move away from or close to the first player character, or the NPC is controlled to perform an interactive operation with the first player character, etc.
  • the above discovery behavior is described below with reference to specific examples:
  • the NPC when the NPC discovers the first player character, the NPC is controlled to perform interactive operations with the first player character, such as performing a dialogue, or sending a prompt message to the first player character to inform the first player character of the NPC's location or status, etc.
  • controlling the NPC to perform the behavior operation corresponding to the first sound also includes: when the sound intensity of the first sound heard by the NPC is less than the first sound intensity threshold and less than the second sound intensity threshold, since the NPC does not perceive the first sound, the NPC will continue to perform daily behaviors, for example, the NPC continues to patrol, rest or sleep, etc.
  • the NPC is controlled to perform the first behavior operation, the second behavior operation or the daily behavior operation corresponding to the first sound, thereby avoiding the problem in the related technology that when the NPC is in a blind spot of vision, it is impossible to utilize the NPC's visual perception ability to hear the sound in an anthropomorphic way, thereby improving the player's gaming experience.
  • the above-mentioned determining the sound intensity of the first sound heard by the NPC according to the first sound intensity and the first target distance includes:
  • the sound intensity of the first sound heard by the NPC is determined based on the remaining sound intensity and the sound intensity of the ambient noise.
  • NPC1 when the player character emits the first sound while moving, the remaining sound intensity of the first sound received by NPC1 (character level is Lv.7) which is closer to the player character is greater than the remaining sound intensity of the first sound received by NPC2 (character level is Lv.6) which is farther away from the player character.
  • NPC1 can hear the first sound emitted by the player character and come to interact with the player character; while NPC2 is still in the daily state, for example, performing daily behaviors such as resting or sleeping.
  • the sound intensity of the first sound heard by the NPC in addition to considering the attenuation process of the first sound mentioned above, it is also necessary to consider the impact of the sound intensity of the ambient noise on the auditory perception ability of the NPC, and when determining the sound intensity of the ambient noise at the NPC's location, determine the sound intensity of the first sound heard by the NPC based on the remaining sound intensity of the first sound received at the NPC's location and the sound intensity of the ambient noise.
  • the above-mentioned determining the sound intensity of the first sound heard by the NPC according to the residual sound intensity and the sound intensity of the ambient noise includes:
  • the sound intensity of the first sound heard by the NPC is determined to be equal to the sound intensity of the ambient noise or to be zero.
  • the first sound emitted by the player character is the sound that the NPC hopes to receive
  • the ambient noise emitted by the surrounding environment is the sound that interferes with the NPC's hearing of the first sound emitted by the player character
  • the target grid corresponding to the NPC's position as shown in Figure 9 can be quickly located based on the XYZ coordinates of the NPC's position, and then the sound intensity of the ambient noise corresponding to each grid can be queried to conveniently obtain the sound intensity of the ambient noise in the target grid, thereby improving the efficiency of obtaining the sound intensity of the ambient noise at the NPC's position.
  • the sound intensity of the first sound heard by the NPC is equal to the sound intensity of the ambient noise at the NPC's location.
  • the sound intensity of the first sound heard by the NPC is 0, that is, the NPC actually does not hear any sound.
  • the sound intensity of the first sound heard by the NPC can be accurately determined according to the residual sound intensity when the first sound propagates to the position where the NPC is located and the sound intensity of the ambient noise at the position where the NPC is located, thereby improving the This not only ensures the accuracy of the sound intensity of the first sound heard by the NPC, but also helps to accurately control the NPC to perform the behavioral operations corresponding to the first sound.
  • the above-mentioned obtaining the sound intensity of the ambient noise at the location where the NPC is located includes:
  • a target grid where the NPC is located in a target game scene, wherein the target game scene is pre-divided into a group of grids, the group of grids includes the target grid, each grid in the group of grids is pre-set with a sound intensity of a corresponding environmental noise, and the sound intensity of the environmental noise corresponding to each grid is determined according to the type of virtual terrain in each grid;
  • the sound intensity of the ambient noise at the location where the NPC is located is determined to be equal to the sound intensity of the ambient noise corresponding to the preset target grid.
  • the entire game scene Before obtaining the sound intensity of the ambient noise at the location of the NPC, the entire game scene needs to be gridded, for example, the entire game scene is divided into 2D square grids or 3D cube grids according to the actual game screen. In the embodiment of the present application, it is assumed that the entire 3D game screen is divided into a group of 0.5m*0.5m*0.5m cube grids as shown in FIG9 .
  • the specific implementation steps of determining the sound intensity of the ambient noise at the location of the NPC using the above-mentioned gridded game scene include:
  • S1 sets the sound intensity of the ambient noise of each grid in the target game scene
  • the sound intensity of the ambient noise in the forest is greater than that in the grassland, and the sound intensity of the ambient noise around the waterfall is greater than that in the forest. That is, the type of virtual terrain in each grid directly affects the sound intensity of the ambient noise of the grid.
  • a simulation system from virtual terrain to the sound intensity of environmental noise is established, that is, according to the type of virtual terrain in each grid, the sound intensity of the environmental noise corresponding to each grid can be determined.
  • the sound intensity of the corresponding environmental noise is pre-set to 10DB; when the virtual terrain where the NPC is located is a grassland, the sound intensity of the corresponding environmental noise is pre-set to 0DB; when the virtual terrain where the NPC is located is a waterfall, the sound intensity of the corresponding environmental noise is pre-set to 20DB.
  • the query time of the sound intensity of the ambient noise is reduced, the efficiency of determining the sound intensity of the ambient noise corresponding to each grid is improved, and the data processing efficiency of the server is improved.
  • the grid is directly determined as the target grid where the NPC is located; when the NPC's location is within two or more grids, the grid with the largest proportion of NPC locations among the multiple grids is determined as the target grid.
  • noise as a type of sound, can also propagate in a medium and also attenuate.
  • the sound intensity of the ambient noise corresponding to each grid is affected not only by the virtual terrain of the grid itself, but also by the virtual terrain in the surrounding grids. Therefore, in the embodiment of the present application, a linear attenuation simulation form is also used to determine the sound intensity of the ambient noise corresponding to each grid.
  • each grid is a current grid when performing the following operations:
  • the sound intensity of the propagation noise includes the residual sound intensity when the initial noise corresponding to each grid in a group of grids except the current grid propagates to the current grid;
  • the sound intensity of the ambient noise corresponding to the current grid is determined according to the sound intensity of the initial noise and the sound intensity of the propagation noise.
  • the sound intensity of the initial noise of the 1# grid is 10, and the sound intensity of the initial noise of the 2# grid is 20.
  • the noise impact value may be, but is not limited to, the residual sound intensity when the initial noise corresponding to each grid in a group of grids except the current grid propagates to the current grid.
  • the residual sound intensity when the initial noise corresponding to the 1# grid propagates to the 2# grid is 5, and the residual sound intensity when the initial noise corresponding to the 2# grid propagates to the 1# grid is 15, which means that the sound intensity of the propagated noise from the 2# grid received by the 1# grid is 15, and the sound intensity of the propagated noise from the 1# grid received by the 2# grid is 5.
  • the measurement unit of the sound intensity may be, but is not limited to, decibel (DB).
  • the sound intensity of the ambient noise corresponding to grid #2 can also be determined based on the sound intensity of the initial noise corresponding to grid #2 and the sound intensity of the propagation noise received by grid #2.
  • the above-mentioned determining the sound intensity of the ambient noise corresponding to the current grid according to the sound intensity of the initial noise and the sound intensity of the propagation noise includes:
  • the sound intensity of the ambient noise corresponding to the current grid is determined to be equal to a value obtained by weighted summing the sound intensity of the initial noise and the sound intensity of the propagation noise.
  • the sound intensity of the ambient noise corresponding to the current grid is determined to be equal to the maximum sound intensity of the sound intensity of the initial noise and the sound intensity of the propagation noise;
  • the 1# grid is the current grid, assuming that the sound intensity of the initial noise of the 1# grid is 10 and the sound intensity of the propagation noise received by the 1# grid is 15, then the maximum value of 10 and 15 is taken as the 1# grid.
  • the final sound intensity of the ambient noise of the grid that is, the sound intensity of the ambient noise corresponding to the 1# grid is 15.
  • the maximum value of 20 and 5 is taken as the final sound intensity of the ambient noise of the 2# grid, that is, the sound intensity of the ambient noise corresponding to the 2# grid is 20.
  • a group of grids includes 9 grids in total, and the sound intensities of the initial noises corresponding to grids #1 to #9 are V1, V2, ..., V9, respectively, and the current grid is grid #5 as an example for explanation.
  • the residual sound intensity of the initial noise corresponding to the 1# ⁇ 4# grids when propagating to the 5# grid is V'1 ⁇ V'4 respectively
  • the residual sound intensity of the initial noise corresponding to the 6# ⁇ 9# grids when propagating to the 5# grid is V'6 ⁇ V'9 respectively.
  • the above method further includes:
  • a preset hearing radius according to the NPC's character type, wherein when the NPC's character type is a character type with sensitive hearing, the preset hearing radius is set to a first value, and when the NPC's character type is a character type with non-sensitive hearing, the preset hearing radius is set to a second value, and the first value is greater than the second value; or
  • the preset hearing radius is set according to the current state of the NPC, wherein when the current state of the NPC is a state of not being damaged by an attack, the preset hearing radius is set to a first value, and when the current state of the NPC is a state of being damaged by an attack, the preset hearing radius is set to a second value, and the first value is greater than the second value; or
  • a preset hearing radius is set according to the release state of the NPC's target skill, wherein the target skill is used to increase the NPC's hearing range when in a released state.
  • the preset hearing radius is set to a first value.
  • the preset hearing radius is set to a second value. The first value is greater than the second value.
  • the preset hearing radius of the NPC represents the hearing perception ability of the NPC itself. It can also be understood as the hearing range within which the NPC can receive the sound. Therefore, in the process of determining whether the NPC can hear the first sound emitted by the first player character, the setting of the preset hearing radius plays a vital role.
  • the following example describes how to set the preset hearing radius of the NPC.
  • the first one Assume that according to the NPC's role type, the NPC is divided into two different types: sensitive hearing and non-sensitive hearing;
  • the sound intensity of the first sound heard by the NPC with sensitive hearing is greater than the sound intensity of the first sound heard by the NPC with non-sensitive hearing.
  • the NPC with sensitive hearing can hear the first sound emitted by the first player character, but the NPC with non-sensitive hearing cannot hear the first sound, that is, the preset hearing radius of the NPC with sensitive hearing is greater than the preset hearing radius of the NPC with non-sensitive hearing.
  • the second method is to divide NPCs into two different types: attacked and not attacked, based on their status characteristics.
  • the sound intensity of the first sound heard by the attacked NPC is less than the sound intensity of the first sound heard by the unattacked NPC.
  • the unattacked NPC can hear the first sound emitted by the first player character, but the attacked NPC cannot hear the first sound, that is, the preset hearing radius of the unattacked NPC is greater than the preset hearing radius of the attacked NPC.
  • the third type Assume that according to the skill release status of the NPC, the NPC is divided into two different types: skills not released and skills released.
  • the sound intensity of the first sound heard by the NPC whose skill has not been released is greater than the sound intensity of the first sound heard by the NPC whose skill has been released.
  • the NPC whose skill has not been released can hear the first sound emitted by the first player character, but the NPC whose skill has been released cannot hear the first sound, that is, the preset hearing radius of the NPC whose skill has not been released is greater than the preset hearing radius of the NPC whose skill has been released.
  • the preset hearing radius of NPCs in different states of different types is set according to the NPC's character type, the NPC's current state and the release state of the NPC's target skill, which improves the flexibility of setting the preset hearing radius and enhances the authenticity of the preset hearing radius.
  • the NPC can be controlled to perform the first behavior operation and the second behavior operation corresponding to the first sound.
  • the NPC's behavior operation can also be controlled to switch, specifically, including:
  • a second sound intensity of a second sound and a second propagation distance of the second sound are obtained, wherein the second sound is a sound generated by a second player character at a second position, the second sound intensity is a preset sound intensity corresponding to a second motion state of the second player character at the second position, and the second propagation distance is a propagation distance determined according to the second sound intensity;
  • the second target distance between the NPC and the second player character is less than the second propagation distance and less than the NPC's expected
  • the sound intensity of the second sound heard by the NPC is determined according to the second sound intensity and the second target distance
  • the NPC When the sound intensity of the second sound heard by the NPC is greater than or equal to the first sound intensity threshold and greater than the sound intensity of the first sound heard by the NPC, the NPC is controlled to stop performing the behavior operation corresponding to the first sound and to perform the behavior operation corresponding to the second sound.
  • the second sound intensity and the second propagation distance are obtained in a manner similar to the first sound intensity and the first propagation distance, and reference may be made to the above description.
  • the NPC is performing a behavior operation corresponding to a sound emitted by the first player character P1, for example, approaching the first player character P1.
  • the second player character P2 located at the second position S2 emits a second sound, and according to the sound intensity corresponding to the second motion state of the second player character P2 at the second position S2, the second sound intensity V2 corresponding to the second motion state of P2 at S2 is obtained.
  • the specific process can refer to the description of the first sound intensity corresponding to the first motion state of the first player character at the first position in the above embodiment, which will not be repeated here.
  • the second motion state of the second player character P2 at the second position S2 includes but is not limited to sneaking, sprinting, walking and flying as shown in FIG. 4 .
  • the second target distance between the NPC and the second player character is less than the second propagation distance and less than the preset hearing radius of the NPC, it is determined that the NPC can hear the second sound emitted by the second player character.
  • the sound intensity of the second sound heard by the NPC is determined based on the second sound intensity V2 and the second target distance.
  • the sound intensity of the second sound heard by the NPC is greater than or equal to the first sound intensity threshold, and greater than the sound intensity of the first sound heard by the NPC, it means that the NPC has detected the second sound, and the second sound heard by the NPC interferes with the first sound heard by the NPC in advance. Then the NPC will stop approaching the first player character P1 and perform the behavior operation corresponding to the second sound, for example, as shown in FIG14 (b), moving away from the second player character P1.
  • the NPC hears the first sound and the second sound emitted by the first player character and the second player character
  • the sound intensity of the first sound and the second sound are calculated respectively.
  • the behavioral operation performed by the NPC is switched, which improves the flexibility of the behavioral operations performed by the NPC, enriches the gameplay of the game, and enhances the user experience.
  • the target game scene is pre-divided into a group of grids, and the sound intensity of the ambient noise corresponding to each grid is determined according to the type of virtual terrain in each grid in the group of grids.
  • the sound intensity of the ambient noise of each grid can be determined by referring to the description in the above-mentioned embodiment part, which will not be repeated here.
  • the sound intensity of the first sound of the player character can be simulated according to the movement state of the player character at the first position.
  • the relationship between the sound intensity of the first sound and the type of the virtual terrain at the first position and/or the motion state of the player character can be determined by, but is not limited to, querying a pre-created relationship mapping table.
  • the propagation distance d of the first sound shown in FIG5 and the preset auditory semi-perception value of the NPC are used to determine the sound intensity of the first sound.
  • Path to filter NPCs the specific implementation process is as follows:
  • the propagation distance of the first sound emitted by the first player character (which can also be understood as the first propagation distance of the first sound) is d
  • the target distance between the first player character and NPC1 is d1
  • the target distance between the first player character and NPC2 is d2
  • d2 ⁇ d, and d2 ⁇ r it is determined that NPC2 can hear the first sound, where r is the preset hearing radius of NPC2, and r determines the hearing range of NPC2.
  • NPC1 and NPC2 can hear the first sound can also be determined through the following implementation process: when the first player character makes the first sound, first, according to the propagation distance d of the first sound, the NPCs within the propagation distance d are determined, as shown in FIG5 , including NPC1 and NPC2; then, according to whether the sound source of the first sound is within the preset hearing radius of the NPC, it can be determined that only NPC2 can hear the first sound. For NPC1, although it is within the range of the propagation distance d of the first sound, the sound source of the first sound is outside the preset hearing radius of NPC1, so NPC1 cannot hear the first sound.
  • the target distance between the NPC selected in the above manner and the first player character is smaller than the propagation distance of the first sound and smaller than the preset hearing radius of the NPC.
  • subsequent calculations only need to be performed on some NPCs that meet the requirements, wherein the subsequent calculations include but are not limited to calculations of the remaining sound intensity of the first sound received by the NPC, calculations of the sound intensity of the first sound actually heard by the NPC, etc.
  • the total number of NPCs in the virtual scene is 100, and according to the above screening method, it is determined that only 2 NPCs meet the requirements, then, it is only necessary to calculate the residual sound intensity of the first sound received by the two NPCs and the sound intensity of the first sound actually heard, thereby achieving the technical effect of reducing the amount of calculation and improving the efficiency of NPCs in performing behavioral operations.
  • the entire game scene is gridded and divided into a group of grids, and the sound intensity of the corresponding environmental noise is set in advance for each grid in the group of grids. Finally, the sound intensity obtained by the NPC is determined according to the type of virtual terrain in each grid.
  • the sound intensity of the ambient noise at the NPC's location can be directly determined as the sound intensity of the ambient noise corresponding to a preset target grid, or the sound intensity of the ambient noise corresponding to the target grid can be determined based on the initial noise corresponding to the queried target grid and the residual sound intensity of the initial noise generated by the surrounding grids after propagating to the target grid.
  • the specific process can be referred to the description in the above embodiment section.
  • the sound intensity of the first sound heard by the NPC is determined to be equal to the residual sound intensity and the ambient noise. the difference between the sound levels of the noise; or
  • the sound intensity of the first sound heard by the NPC is determined to be equal to the sound intensity of the ambient noise or to be zero.
  • step S1514 comparing the relationship between the sound intensity of the first sound heard by the NPC and the auditory perception threshold and the auditory discovery threshold, and performing a corresponding behavioral operation, as in step S1516;
  • the first behavior operation in the above embodiment is performed, for example, searching for the player.
  • the NPC When the sound intensity of the first sound heard by the NPC is greater than or equal to the auditory detection threshold (second sound intensity threshold), the NPC is controlled to perform a second behavior operation, such as conversation or interaction with the player.
  • a second behavior operation such as conversation or interaction with the player.
  • the NPC when it is determined that the NPC can hear the first sound emitted by the first player character according to the first target distance between the non-player character NPC and the first player character and the preset hearing radius of the NPC, the NPC is controlled to perform the behavior operation corresponding to the first sound by comparing the sound intensity of the first sound heard by the NPC with the first sound intensity threshold.
  • the NPC can accurately perform the corresponding behavior operation, avoiding the technical problem of being unable to accurately control the NPC to perform the behavior operation, and achieving the technical effect of improving the accuracy of controlling the NPC to perform the behavior operation.
  • a control device for a non-player character as shown in FIG. 16 comprising:
  • a first acquisition unit 1602 is configured to acquire a first sound intensity of a first sound and a first propagation distance of the first sound, wherein the first sound is a sound generated by a first player character at a first position, the first sound intensity is a preset sound intensity corresponding to a first motion state of the first player character at the first position, and the first propagation distance is a propagation distance determined according to the first sound intensity;
  • the first processing unit 1604 is configured to determine the sound intensity of the first sound heard by the NPC according to the first sound intensity and the first target distance when the first target distance between the NPC and the first player character is less than the first propagation distance and less than the preset hearing radius of the NPC;
  • the second processing unit 1606 is configured to control the NPC to perform a behavior operation corresponding to the first sound when the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold.
  • the second processing unit 1606 includes:
  • the first processing module is used to control the NPC to perform a first behavior operation when the sound intensity of the first sound heard by the NPC is greater than or equal to a first sound intensity threshold and less than a second sound intensity threshold, wherein the first behavior operation is a behavior operation performed when the NPC perceives the sound.
  • the first processing module further includes:
  • the first processing submodule is used to control the NPC to perform a second behavior operation when the sound intensity of the first sound heard by the NPC is greater than or equal to a second sound intensity threshold, wherein the second behavior operation is a behavior operation performed when the NPC discovers the first player character.
  • the second processing unit 1606 includes:
  • a second processing module is used to control the NPC to move to the first position when the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold and less than the second sound intensity threshold;
  • the NPC When the sound intensity of the first sound heard by the NPC is greater than or equal to the first sound intensity threshold and less than the second sound intensity threshold, the NPC is controlled to search for the first player character in the process of moving to the first position.
  • the second processing module further includes:
  • the second processing submodule is used to control the NPC to move in a direction away from the first player character, or to control the NPC to move in a direction toward the first player character when the sound intensity of the first sound heard by the NPC is greater than or equal to the second sound intensity threshold; or
  • the NPC When the sound intensity of the first sound heard by the NPC is greater than or equal to the second sound intensity threshold, the NPC is controlled to perform an interactive operation with the first player character.
  • the first processing unit 1604 includes:
  • a third processing module is used to determine the remaining sound intensity when the first sound propagates to the location of the NPC according to the first sound intensity and the first target distance;
  • the first acquisition module is used to obtain the sound intensity of the ambient noise at the location where the NPC is located;
  • the fourth processing module is used to determine the sound intensity of the first sound heard by the NPC according to the residual sound intensity and the sound intensity of the ambient noise.
  • the first acquisition module includes:
  • the third processing submodule is used to determine the target grid where the NPC is located in the target game scene, wherein the target game scene is pre-divided into a group of grids, the group of grids includes the target grid, each grid in the group of grids is pre-set with a sound intensity of the corresponding environmental noise, and the sound intensity of the environmental noise corresponding to each grid is determined according to the type of virtual terrain in each grid;
  • the fourth processing submodule is used to determine the sound intensity of the ambient noise at the location where the NPC is located to be equal to the sound intensity of the ambient noise corresponding to the preset target grid.
  • the first acquisition module further includes:
  • the fifth processing submodule is used to perform the following operations on each grid in a group of grids to obtain the sound intensity of the environmental noise corresponding to each grid, wherein each grid is a current grid when performing the following operations:
  • the sound intensity of the propagation noise includes the residual sound intensity when the initial noise corresponding to each grid in a group of grids except the current grid propagates to the current grid;
  • the sound intensity of the ambient noise corresponding to the current grid is determined according to the sound intensity of the initial noise and the sound intensity of the propagation noise.
  • the above device further includes:
  • a sixth processing submodule configured to determine the sound intensity of the ambient noise corresponding to the current grid to be equal to the maximum sound intensity of the sound intensity of the initial noise and the sound intensity of the propagation noise;
  • the sound intensity of the ambient noise corresponding to the current grid is determined to be equal to a value obtained by weighted summing the sound intensity of the initial noise and the sound intensity of the propagation noise.
  • the fourth processing module includes:
  • a seventh processing submodule configured to determine the sound intensity of the first sound heard by the NPC to be equal to the difference between the remaining sound intensity and the sound intensity of the ambient noise when the remaining sound intensity is greater than the sound intensity of the ambient noise;
  • the sound intensity of the first sound heard by the NPC is determined to be equal to the sound intensity of the ambient noise or to be zero.
  • the above device further includes:
  • a third processing unit configured to set a preset hearing radius according to a character type of the NPC, wherein when the character type of the NPC is a character type with sensitive hearing, the preset hearing radius is set to a first value, and when the character type of the NPC is a character type with non-sensitive hearing, the preset hearing radius is set to a second value, and the first value is greater than the second value; or
  • the preset hearing radius is set according to the current state of the NPC, wherein when the current state of the NPC is a state of not being damaged by an attack, the preset hearing radius is set to a first value, and when the current state of the NPC is a state of being damaged by an attack, the preset hearing radius is set to a second value, and the first value is greater than the second value; or
  • a preset hearing radius is set according to the release state of the NPC's target skill, wherein the target skill is used to increase the NPC's hearing range when in a released state.
  • the preset hearing radius is set to a first value.
  • the preset hearing radius is set to a second value. The first value is greater than the second value.
  • the above device further includes:
  • a second acquisition unit for acquiring a second sound intensity of a second sound and a second propagation distance of the second sound during a process of controlling the NPC to perform a behavior operation corresponding to the first sound, wherein the second sound is a sound generated by a second player character at a second position, the second sound intensity is a preset sound intensity corresponding to a second motion state of the second player character at the second position, and the second propagation distance is a propagation distance determined according to the second sound intensity;
  • a fourth processing unit configured to determine the sound intensity of the second sound heard by the NPC according to the second sound intensity and the second target distance when the second target distance between the NPC and the second player character is less than the second propagation distance and less than a preset hearing radius of the NPC;
  • the fifth processing unit is used to control the NPC to stop performing the behavioral operation corresponding to the first sound and control the NPC to perform the behavioral operation corresponding to the second sound when the sound intensity of the second sound heard by the NPC is greater than or equal to the first sound intensity threshold and greater than the sound intensity of the first sound heard by the NPC.
  • the NPC is controlled to perform the behavior operation corresponding to the first sound by comparing the sound intensity of the first sound heard by the NPC with the first sound intensity threshold.
  • the NPC can accurately perform the corresponding behavior operation, thus avoiding the technical problem of being unable to accurately control the NPC to perform the behavior operation, and achieving the technical effect of improving the accuracy of controlling the NPC to perform the behavior operation.
  • control device for the non-player character can refer to the embodiments of the control method for the non-player character described above, which will not be described in detail here.
  • an electronic device for implementing the control method of the non-player character is also provided, and the electronic device may be a terminal device as shown in FIG17.
  • the electronic device may be a terminal device as shown in FIG17.
  • the electronic device includes a memory 1702 and a processor 1704, wherein the memory 1702 stores a computer program, and the processor 1704 is configured to execute any of the above methods through the computer program. Steps in the embodiment.
  • the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
  • the processor may be configured to perform the following steps through a computer program:
  • the first sound is a sound generated by a first player character at a first position
  • the first sound intensity is a preset sound intensity corresponding to a first motion state of the first player character at the first position
  • the first propagation distance is a propagation distance determined according to the first sound intensity
  • FIG. 17 is for illustration only, and the electronic device may also be a target terminal such as a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, and a mobile Internet device (Mobile Internet Devices, MID), PAD, etc.
  • FIG. 17 does not limit the structure of the above-mentioned electronic device.
  • the electronic device may also include more or fewer components (such as a network interface, etc.) than those shown in FIG. 17, or have a configuration different from that shown in FIG. 17.
  • the memory 1702 can be used to store software programs and modules, such as program instructions/modules corresponding to the control method and device of the non-player character in the embodiment of the present application.
  • the processor 1704 executes various functional applications and data processing by running the software programs and modules stored in the memory 1702, that is, the control method of the non-player character described above is realized.
  • the memory 1702 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
  • the memory 1702 may further include a memory remotely arranged relative to the processor 1704, and these remote memories may be connected to the terminal via a network.
  • the above-mentioned network examples include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
  • the memory 1702 may be specifically, but not limited to, used to store the first sound intensity of the first sound, the first target distance between the NPC and the first player character, the preset hearing radius of the NPC, etc.
  • the above-mentioned memory 1702 may include, but is not limited to, the first acquisition unit 1602, the first processing unit 1604, and the second processing unit 1606 in the control device of the non-player character described above.
  • other module units in the control device of the non-player character mentioned above may also be included but not limited to, which will not be described in detail in this example.
  • the transmission device 1706 is used to receive or send data via a network.
  • the above-mentioned network may include a wired network and a wireless network.
  • the transmission device 1706 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network.
  • the transmission device 1706 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
  • RF radio frequency
  • the electronic device further includes: a display 1708 for displaying the direction prompt information of the target sound; and a connection bus 1710 for connecting various module components in the electronic device.
  • the target terminal or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes through network communication.
  • the nodes may form a peer-to-peer (P2P) Any form of computing device, such as servers, terminals and other electronic devices, can become a node in the blockchain system by joining the peer-to-peer network.
  • P2P peer-to-peer
  • a computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium.
  • a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the control method of a non-player character provided in various optional implementations of the above-mentioned server verification processing and other aspects, wherein the computer program is configured to execute the steps of any of the above-mentioned method embodiments when running.
  • the computer-readable storage medium may be configured to store a computer program for performing the following steps:
  • the first sound is a sound generated by a first player character at a first position
  • the first sound intensity is a preset sound intensity corresponding to a first motion state of the first player character at the first position
  • the first propagation distance is a propagation distance determined according to the first sound intensity
  • a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the target terminal through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
  • the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
  • the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium.
  • the technical solution of the present invention, or the part that contributes to the prior art, or all or 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 enabling one or more computer devices (which can be personal computers, servers or network devices, etc.) to execute all or part of the steps of the methods of various embodiments of the present invention.
  • the disclosed client can be implemented in other ways.
  • the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
  • Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
  • Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, i.e., may be located in one place or may be distributed over multiple networks. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Stereophonic System (AREA)
  • Electrophonic Musical Instruments (AREA)

Abstract

本发明公开了一种非玩家角色的控制方法和装置、存储介质及电子设备。其中,该方法包括:获取第一声音的第一声音强度以及第一声音的第一传播距离,其中,第一声音强度是预设的与第一玩家角色在第一位置上的第一运动状态对应的声音强度;在非玩家角色NPC与第一玩家角色之间的第一目标距离小于第一传播距离、且小于NPC的预设听觉半径的情况下,根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度;在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作。本发明解决了相关技术中无法准确地控制非玩家角色执行行为操作的技术问题。

Description

非玩家角色的控制方法和装置、存储介质及电子设备
本申请要求于2022年09月26日提交中国专利局、申请号为202211174826.0、申请名称为“非玩家角色的控制方法和装置、存储介质及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及计算机技术领域,具体而言,涉及一种非玩家角色的控制方法和装置、存储介质及电子设备。
背景技术
在虚拟游戏场景中,通常会设置多个不同类型的非玩家角色NPC,并并且为了增加游戏的趣味性,会通过NPC的环境感知能力,使得NPC执行指定行为操作,从而实现NPC与玩家之间的交互。
相关技术中,NPC的环境感知能力主要依赖于视觉感知,通常基于NPC和玩家的距离、角度等信息模拟NPC的视觉感知能力,例如,在3D游戏场景中,当玩家位于NPC前方指定距离、指定角度范围内时,NPC会看到玩家,并和玩家进行交互。
然而,相关技术中并未考虑到3D游戏场景对NPC视觉的影响,例如,玩家躲在岩石等障碍物后面时,NPC无法看到玩家,那么当玩家在NPC视野盲区内行走、跑动或冲刺时,NPC将无法感知到玩家,更加无法控制NPC与玩家进行交互,从而造成了无法准确地控制非玩家角色执行行为操作的技术问题。
针对上述的问题,目前尚未提出有效的解决方案。
发明内容
本发明实施例提供了一种非玩家角色的控制方法和装置、存储介质及电子设备,以至少解决无法准确地控制非玩家角色执行行为操作的技术问题。
根据本发明实施例的一个方面,提供了一种非玩家角色的控制方法,包括:获取第一声音的第一声音强度以及第一声音的第一传播距离,其中,第一声音是第一玩家角色在第一位置上产生的声音,第一声音强度是预设的与第一玩家角色在第一位置上的第一运动状态对应的声音强度,第一传播距离是根据第一声音强度确定的传播距离;在非玩家角色NPC与第一玩家角色之间的第一目标距离小于第一传播距离、且小于NPC的预设听觉半径的情况下,根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度;在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作。
可选地,上述在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作,包括:在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,控制NPC执行第一行为操作,其中,第一行为操作是在NPC察觉到有声音时所执行的行为操作。
可选地,上述在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作,还包括:在NPC听到的第一声音的 声音强度大于或等于第二声音强度阈值的情况下,控制NPC执行第二行为操作,其中,第二行为操作是在NPC发现第一玩家角色时所执行的行为操作。
可选地,上述在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作,包括:在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,控制NPC向第一位置移动;或者在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,控制NPC在向第一位置移动的过程中寻找第一玩家角色。
可选地,上述在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作,还包括:在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值的情况下,控制NPC朝着远离第一玩家角色的方向移动,或者,控制NPC朝着第一玩家角色的方向移动;或者在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值的情况下,控制NPC与第一玩家角色执行交互操作。
可选地,上述根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度,包括:根据第一声音强度以及第一目标距离,确定第一声音传播到NPC所在的位置时的剩余声音强度;获取NPC所在的位置上的环境噪声的声音强度;根据剩余声音强度和环境噪声的声音强度,确定NPC听到的第一声音的声音强度。
可选地,上述获取NPC所在的位置上的环境噪声的声音强度,包括:确定目标游戏场景中NPC所在的目标网格,其中,目标游戏场景预先被划分成一组网格,一组网格包括目标网格,一组网格中的每个网格预先设置了对应的环境噪声的声音强度,每个网格对应的环境噪声的声音强度是根据每个网格中的虚拟地形的类型确定得到的声音强度;将NPC所在的位置上的环境噪声的声音强度确定为等于预先设置的目标网格对应的环境噪声的声音强度。
可选地,上述方法还包括:对一组网格中的每个网格执行以下操作,得到每个网格对应的环境噪声的声音强度,其中,在执行以下操作时,上述每个网格为当前网格:获取当前网格对应的初始噪声的声音强度,其中,初始噪声的声音强度与当前网格中的虚拟地形的类型具有预设的对应关系;获取当前网格收到的传播噪声的声音强度,其中,传播噪声的声音强度包括一组网格中除当前网格之外的每个网格对应的初始噪声传播到当前网格时的剩余声音强度;根据初始噪声的声音强度和传播噪声的声音强度,确定当前网格对应的环境噪声的声音强度。
可选地,上述根据初始噪声的声音强度和传播噪声的声音强度,确定当前网格对应的环境噪声的声音强度,包括:将当前网格对应的环境噪声的声音强度确定为等于初始噪声的声音强度和传播噪声的声音强度中的最大声音强度;或者将当前网格对应的环境噪声的声音强度确定为等于初始噪声的声音强度和传播噪声的声音强度之和;或者将当前网格对应的环境噪声的声音强度确定为等于对初始噪声的声音强度和传播噪声的声音强度进行加权求和所得到的值。
可选地,上述根据剩余声音强度和环境噪声的声音强度,确定NPC听到的第一声音的声音强度,包括:在剩余声音强度大于环境噪声的声音强度的情况下,将NPC听到的第一声音的声音强度确定为等于剩余声音强度与环境噪声的声音强度之间的差值;和/或 在剩余声音强度小于或等于环境噪声的声音强度的情况下,将NPC听到的第一声音的声音强度确定为等于环境噪声的声音强度或者为0。
可选地,上述方法还包括:根据NPC的角色类型设置预设听觉半径,其中,当NPC的角色类型为听力灵敏的角色类型时,预设听觉半径被设置为第一值,当NPC的角色类型为非听力灵敏的角色类型时,预设听觉半径被设置为第二值,第一值大于第二值;或者根据NPC的当前状态设置预设听觉半径,其中,当NPC的当前状态为未受到攻击伤害的状态时,预设听觉半径被设置为第一值,当NPC的当前状态为受到攻击伤害的状态时,预设听觉半径被设置为第二值,第一值大于第二值;或者根据NPC的目标技能的释放状态设置预设听觉半径,其中,目标技能用于在被释放的状态下增加NPC的听觉范围,当目标技能的释放状态为已释放状态时,预设听觉半径被设置为第一值,当目标技能的释放状态为未释放状态时,预设听觉半径被设置为第二值,第一值大于第二值。
可选地,上述方法还包括:在控制NPC执行与第一声音对应的行为操作的过程中,获取第二声音的第二声音强度以及第二声音的第二传播距离,其中,第二声音是第二玩家角色在第二位置上产生的声音,第二声音强度是预设的与第二玩家角色在第二位置上的第二运动状态对应的声音强度,第二传播距离是根据第二声音强度确定的传播距离;在NPC与第二玩家角色之间的第二目标距离小于第二传播距离、且小于NPC的预设听觉半径的情况下,根据第二声音强度以及第二目标距离确定NPC听到的第二声音的声音强度;在NPC听到的第二声音的声音强度大于或等于第一声音强度阈值、且大于NPC听到的第一声音的声音强度的情况下,控制NPC停止执行与第一声音对应的行为操作,并控制NPC执行与第二声音对应的行为操作。
根据本发明实施例的另一方面,还提供了一种非玩家角色的控制装置,包括:第一获取单元,用于获取第一声音的第一声音强度以及第一声音的第一传播距离,其中,第一声音是第一玩家角色在第一位置上产生的声音,第一声音强度是预设的与第一玩家角色在第一位置上的第一运动状态对应的声音强度,第一传播距离是根据第一声音强度确定的传播距离;第一处理单元,用于在非玩家角色NPC与第一玩家角色之间的第一目标距离小于第一传播距离、且小于NPC的预设听觉半径的情况下,根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度;第二处理单元,用于在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作。
根据本发明实施例的又一方面,还提供了一种计算机可读的存储介质,该计算机可读的存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述非玩家角色的控制方法。
根据本发明实施例的又一方面,还提供了一种计算机程序产品,包括计算机程序/指令,该计算机程序/指令被处理器执行时实现上述方法的步骤。
根据本发明实施例的又一方面,还提供了一种电子设备,包括存储器和处理器,上述存储器中存储有计算机程序,上述处理器被设置为通过计算机程序执行上述非玩家角色的控制方法。
通过本申请提供的上述实施例,在根据非玩家角色NPC与第一玩家角色之间的第一目标距离以及NPC的预设听觉半径,确定NPC能够听到第一玩家角色发出的第一声音的情况下,通过比较NPC听到的第一声音的声音强度与第一声音强度阈值,控制NPC 执行与第一声音对应的行为操作。换言之,通过比较NPC听到的第一声音的声音强度和第一声音强度阈值,使得NPC能够准确地执行相应的行为操作,避免了无法准确地控制NPC执行行为操作的技术问题,实现了提高控制NPC执行行为操作的准确性的技术效果。
附图说明
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:
图1是根据本发明实施例的一种可选的非玩家角色的控制方法的应用场景的示意图;
图2是根据本发明实施例的一种可选的非玩家角色的控制方法的流程图;
图3是根据本发明实施例的一种可选的控制NPC执行与第一声音对应的行为操作的示意图(一);
图4是根据本发明实施例的一种可选的第一玩家角色处于不同类型的虚拟地形和不同运动状态下产生的第一声音的声音强度的示意图;
图5是根据本发明实施例的一种可选的NPC的预设听觉半径的示意图;
图6是根据本发明实施例的一种可选的控制NPC执行与第一声音对应的行为操作的示意图(二);
图7是根据本发明实施例的一种可选的控制NPC执行与第一声音对应的行为操作的示意图(三);
图8是根据本发明实施例的一种可选的第一声音的声音强度的衰减过程的示意图;
图9是根据本发明实施例的一种可选的对目标游戏场景进行网格化划分后得到的一组网格的示意图;
图10是根据本发明实施例的一种可选的不同类型的虚拟地形所对应的环境噪声的声音强度的示意图;
图11是根据本发明实施例的一种可选的确定NPC所在位置上的环境噪声的声音强度的示意图;
图12是根据本发明实施例的另一种可选的确定NPC所在位置上的环境噪声的声音强度的示意图;
图13是根据本发明实施例的一种可选的NPC的预设听觉半径的设置方法的示意图;
图14是根据本发明实施例的一种可选的将NPC执行的与第一声音对应的行为操作切换为与第二声音对应的行为操作的示意图;
图15是根据本发明实施例的一种可选的非玩家角色控制方法的整体流程图;
图16是根据本发明实施例的一种可选的非玩家角色的控制装置的结构示意图;
图17是根据本发明实施例的一种可选的电子设备的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。
首先,对本发明实施例中使用或相关的术语进行如下描述,可以理解的是以下描述是术语的一种解释而不是唯一解释:
AI:游戏中具有拟人化行为的NPC的代称;
听觉范围:AI对象可以听到声音的范围,一般为球形区域;
听觉察觉阈值:引起AI对象察觉的声音强度值,听到大于该值的声音时,AI对象会进入察觉状态;
听觉发现阈值:引起AI对象发现玩家的声音强度值,听到大于该值的声音时,AI对象会发现玩家,和玩家进行交互。
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
根据本发明实施例的一个方面,提供了一种非玩家角色的控制方法。作为一种可选的实施方式,上述非玩家角色的控制方法可以但不限于应用于如图1所示的应用场景。在如图1所示的应用场景中,终端设备102可以但不限于通过网络104与服务器106进行通信,服务器106可以但不限于对数据库108执行操作,例如,写数据操作或读数据操作。上述终端设备102可以但不限包括人机交互屏幕、处理器及存储器。上述人机交互屏幕可以但不限于用于显示在终端设备102上的第一玩家角色在第一位置上的运动状态、NPC与第一玩家角色之间的交互行为等。上述处理器可以但不限于用于响应上述人机交互操作,执行对应的操作,或者,生成对应的指令,并将生成的指令发送给服务器106。上述存储器用于存储相关处理数据,如第一声音的第一声音强度、第一声音的第一传播距离及NPC的预设听觉半径等。
作为一种可选的方式,可以在服务器106上执行非玩家角色的控制方法中的以下步骤:步骤S102,获取第一声音的第一声音强度以及第一声音的第一传播距离,其中,第一声音是第一玩家角色在第一位置上产生的声音,第一声音强度是预设的与第一玩家角色在第一位置上的第一运动状态对应的声音强度,第一传播距离是根据第一声音强度确定的传播距离;在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作。步骤S104,在非玩家角色NPC与第一玩家角色之间的第一目标距离小于第一传播距离、且小于NPC的预设听觉半径的情况下,根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度;步骤S106,在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作。
采用上述方式,在根据非玩家角色NPC与第一玩家角色之间的第一目标距离以及NPC的预设听觉半径,确定NPC能够听到第一玩家角色发出的第一声音的情况下,通过比较NPC听到的第一声音的声音强度与第一声音强度阈值,控制NPC执行与第一声音对应的行为操作。换言之,通过比较NPC听到的第一声音的声音强度和第一声音强度阈值,使得NPC能够准确地执行相应的行为操作,避免了无法准确地控制NPC执行行为 操作的技术问题,实现了提高控制NPC执行行为操作的准确性的技术效果。
为了解决上述无法准确地控制NPC执行行为操作的技术问题,本发明实施例提供了一种非玩家角色的控制方法,图2是根据本发明实施例的非玩家角色的控制方法的流程图,该流程包括如下步骤:
步骤S202,获取第一声音的第一声音强度以及第一声音的第一传播距离,其中,第一声音是第一玩家角色在第一位置上产生的声音,第一声音强度是预设的与第一玩家角色在第一位置上的第一运动状态对应的声音强度,第一传播距离是根据第一声音强度确定的传播距离;
示例性的,可以从指定参数值中获取第一声音强度和第一声音的第一传播距离,本申请对此不做限定。例如,可以根据第一玩家角色所处的第一位置,以及在第一位置上的第一运动状态,或者进一步结合其他信息从指定参数值中获取第一声音强度。进一步的,根据第一声音强度可以确定第一传播距离。这里,该第一传播距离可以是虚拟场景中的虚拟距离。
如图3所示,假设第一玩家角色在第一位置上产生第一声音,那么根据第一玩家角色在第一位置上的第一运动状态,即可确定第一声音的第一声音强度。
作为一种可选的示例,如图4所示,当第一玩家角色在第一位置上的运动状态为“行走”时,根据第一玩家角色的运动状态,模拟出在游戏场景中第一玩家角色发出的声音的强度为25DB;当第一玩家角色在第一位置上的运动状态为“潜行”时,根据第一玩家角色的运动状态,模拟出在游戏场景中第一玩家角色发出的声音的强度为10DB;当第一玩家角色在第一位置上的运动状态为“冲刺”时,根据第一玩家角色的运动状态,模拟出在游戏场景中第一玩家角色发出的声音的强度为40DB;当第一玩家角色在第一位置上的运动状态为“飞行”时,根据第一玩家角色的运动状态,模拟出在游戏场景中第一玩家角色发出的声音的强度为20DB。
作为另一种可选的示例,第一声音强度除了与上述第一玩家角色在第一位置上的第一运动状态有关之外,还可以是预设的与第一位置所处的虚拟地形的类型和第一玩家角色在第一位置上的第一运动状态对应的声音强度。其中,对于游戏场景中玩家发出的声音,可以但不限于以玩家的行为状态为基础,模拟出玩家在游戏场景中发出的不同声音的声音强度,例如,如图4所示,当第一玩家位于不同类型的虚拟地形上、且处于不同运动状态的情况下,发出的声音强弱不同。
举例来说,(1)当第一玩家角色在草丛中潜行时,根据第一玩家角色所处的第一位置的虚拟地形“草丛”和运动状态“潜行”,可以模拟出在游戏场景中第一玩家角色发出的声音的强度为10DB;根据第一玩家角色所处的第一位置的虚拟地形“地面”和运动状态“潜行”,可以模拟出在游戏场景中第一玩家角色发出的声音的强度为15DB;
当第一玩家角色在草丛中冲刺前进时,根据第一玩家角色所处的第一位置的虚拟地形“草丛”和运动状态“冲刺前进”,可以模拟出在游戏场景中第一玩家角色发出的声音的强度为40DB;根据第一玩家角色所处的第一位置的虚拟地形“山地”和运动状态“冲刺前进”,可以模拟出在游戏场景中第一玩家角色发出的声音的强度为50DB;
当第一玩家角色在地面上正常行走时,根据第一玩家角色所处的第一位置的虚拟地形“地面”和运动状态“行走”,可以模拟出在游戏场景中第一玩家角色发出的声音的强度为25DB;根据第一玩家角色所处的第一位置的虚拟地形“草丛”和运动状态“行走”, 可以模拟出在游戏场景中第一玩家角色发出的声音的强度为30DB;
(4)当第一玩家角色在空中飞行时,根据第一玩家角色所处的第一位置的虚拟地形“天空”和运动状态“飞行”,可以模拟出在游戏场景中第一玩家角色发出的声音的强度为20DB。
结合上述分析可知,确定第一声音的第一声音强度的方式可以但不限于根据第一位置的虚拟地形的类型和/或第一运动状态,查询预先创建的关系映射表,即可得到第一声音强度的数值。
步骤S204,在非玩家角色NPC与第一玩家角色之间的第一目标距离小于第一传播距离、且小于NPC的预设听觉半径的情况下,根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度;
容易理解的是,不同类型的NPC,对应的听觉能力也不同,因此,在确定NPC听到的第一声音的声音强度的过程中,除了考虑NPC与第一玩家角色之间的第一目标距离之外,还需要考虑NPC自身的听觉感知能力,例如,NPC的预设听觉半径。
例如,如图5所示,假设第一玩家角色发出的第一声音的传播距离(又可以被理解为第一声音的第一传播距离)为d,第一玩家角色与NPC1之间的目标距离为d1,由于d1>d,NPC1距离第一玩家角色较远,NPC1无法听到第一声音;而第一玩家角色与NPC2之间的目标距离为d2,由于d2<d,且d2<r,确定NPC2可以听到第一声音的声音强度较强,其中,r为NPC2的预设听觉半径,r决定了NPC2的听力范围。进一步地,根据第一声音的第一声音强度及第一目标距离,确定NPC2听到的第一声音的声音强度。
另外,对于NPC1和NPC2是否能够听到第一声音,还可以通过下述实现过程来确定:在第一玩家角色发出第一声音时,首先会根据第一声音的传播距离d,确定处于传播距离d范围内的NPC,如图5所示,包括NPC1和NPC2;然后根据第一声音的声源是否位于NPC的预设听觉半径内,可以确定出仅有NPC2能够听到第一声音。对于NPC1来说,虽然处于第一声音的传播距离d的范围内,但第一声音的声源位于NPC1的预设听觉半径之外,所以NPC1无法听到第一声音。
需要说明的是,上述第一声音的传播距离d、NPC2的预设听觉半径r、NPC1和NPC2与第一玩家角色之间的目标距离等仅为一种示例,并不对其进行限定。
步骤S206,在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作。
通过执行步骤S204,确定NPC听到的第一声音的声音强度的情况下,比较NPC听到的第一声音的声音强度与第一声音强度阈值,例如,比较NPC听到的第一声音的声音强度与NPC的听觉察觉阈值。
显然,容易理解的是,仅在NPC察觉到第一声音的情况下,才可能执行与第一声音对应的行为操作。例如,在图5中所示的NPC2能够听到第一声音,且NPC2听到的第一声音的声音强度大于听觉察觉阈值(第一声音强度阈值)的情况下,执行如图3所示的会话操作。而由于NPC1无法听到第一声音,因此将继续处于日常状态,例如,睡眠、巡逻等。
需要说明的是,上述步骤S202~S206均在服务器侧执行,提高了不同客户端之间数据的同步效率和数据处理效率,避免了客户端作弊、数据同步延迟大等问题。
通过本申请提供的上述实施例,在根据非玩家角色NPC与第一玩家角色之间的第一 目标距离以及NPC的预设听觉半径,确定NPC能够听到第一玩家角色发出的第一声音的情况下,通过比较NPC听到的第一声音的声音强度与第一声音强度阈值,控制NPC执行与第一声音对应的行为操作。换言之,通过比较NPC听到的第一声音的声音强度和第一声音强度阈值,使得NPC能够准确地执行相应的行为操作,避免了无法准确地控制NPC执行行为操作的技术问题,实现了提高控制NPC执行行为操作的准确性的技术效果。
为了确保NPC听觉感知的真实性,使得NPC具有拟人化的听觉感知能力,在本申请实施例中,依据不同参数设置各项规则,来控制NPC执行与第一声音对应的行为操作,例如,NPC的预设听觉半径、第一声音强度阈值等,除此之外,本申请实施例中还提供了第二声音强度阈值。
作为一种可选的示例,上述在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作,包括:
在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,控制NPC执行第一行为操作,其中,第一行为操作是在NPC察觉到有声音时所执行的行为操作。
在本申请实施例中,在NPC能够听到第一声音的情况下,为了准确控制NPC执行与第一声音对应的行为操作,根据NPC察觉到第一声音、但并未发现第一玩家角色,以及NPC察觉到第一声音、且发现第一玩家角色对执行的行为操作进行划分,下面结合具体的示例,先对NPC察觉到第一声音、但并未发现第一玩家角色的情况下,所执行的第一行为操作进行详细描述。
作为一种可选的示例,上述在NPC察觉到第一声音、但并未发现第一玩家角色的情况下,NPC执行与第一声音对应的行为操作,包括:
在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,控制NPC向第一位置移动;或者
在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,控制NPC在向第一位置移动的过程中寻找第一玩家角色。
举例来说,如图6中(a)所示,在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,NPC察觉到了第一声音,并对第一声音引起警觉,并执行察觉行为,例如,向第一玩家角色所在的第一位置S1方向移动。
显然,由于NPC听到的第一声音的声音强度小于第二声音强度阈值,也就意味着NPC只是听到了第一声音,但并未发现第一玩家角色,因此,NPC执行的第一行为操作除了仅向第一位置S1方向移动之外,还可以是边移动边寻找第一玩家角色。
具体地,如图6中(b)所示,在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,NPC向第一玩家角色所在的第一位置S1方向移动,并在移动的过程中寻找第一玩家角色。
作为另一种可选的示例,在NPC察觉到第一声音、且发现第一玩家角色的情况下,上述控制NPC执行与第一声音对应的行为操作,还包括:
在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值的情况下,控制NPC执行第二行为操作,其中,第二行为操作是在NPC发现第一玩家角色时所执行的行为操作。
其中,第二声音强度阈值可以但不限于NPC发现第一玩家角色的听觉发现阈值,也 即,在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值时,NPC将发现第一玩家角色,并执行与第一声音对应的第二行为操作,具体地,包括:
在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值的情况下,控制NPC朝着远离第一玩家角色的方向移动,或者,控制NPC朝着第一玩家角色的方向移动;或者
在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值的情况下,控制NPC与第一玩家角色执行交互操作。
由于在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值的情况下,NPC会直接发现第一玩家角色,并触发NPC对应的发现行为(又可以被理解为第二行为操作)。例如,根据NPC与第一玩家角色之间的关系,控制NPC向远离或靠近第一玩家角色的方向移动,或者控制NPC执行与第一玩家角色之间的交互操作等,下面结合具体的示例对上述发现行为进行描述:
(1)如图7中(a)所示,在NPC发现第一玩家角色的情况下,假设NPC与第一玩家角色处于不同的阵营,或者NPC会对第一玩家角色产生伤害的情况下,则控制NPC远离第一玩家角色;
(2)如图7中(b)所示,在NPC发现第一玩家角色的情况下,假设NPC与第一玩家角色处于同一阵营,或者NPC不会对第一玩家角色产生伤害的情况下,则控制NPC靠近第一玩家角色;
(3)如图7中(c)所示,在NPC发现第一玩家角色的情况下,控制NPC与第一玩家角色执行交互操作,例如,执行对话,或者向第一玩家角色发出提示信息,以告知第一玩家角色NPC的位置或状态等。
通过上述规则,控制NPC执行与第一声音对应的行为操作除了上述第一行为操作和第二行为操作之外,还包括:在NPC听到的所述第一声音的声音强度小于第一声音强度阈值、且小于第二声音强度阈值的情况下,由于NPC并未察觉到第一声音,因此NPC将继续执行日常行为,例如,NPC继续巡逻、休息或睡觉等,具体可参考如图7中(d)所示的示意图。
基于上述各实施例的分析可知,根据上述NPC听到的第一声音的声音强度、第一声音强度阈值和第二声音强度阈值等多个参数,控制NPC执行与第一声音对应的第一行为操作、第二行为操作或日常行为操作等,避免了相关技术中当NPC处于视野盲区时,无法利用NPC的视觉感知能力,拟人化地听到声音的问题,提高了玩家的游戏体验感。
作为一种可选的示例,上述根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度,包括:
根据第一声音强度以及第一目标距离,确定第一声音传播到NPC所在的位置时的剩余声音强度;
获取NPC所在的位置上的环境噪声的声音强度;
根据剩余声音强度和环境噪声的声音强度,确定NPC听到的第一声音的声音强度。
为了确保声源模拟的真实性,需要充分考虑当声音在介质中传播时,声音的强度会随着距离的增加而不断衰减,并且声音的衰减情况与衰减公式和距离、介质特征等因素相关。例如,如图8中(a)所示,从声源处发出的第一声音的声音强度会随着传播距离的增大逐渐衰减至0。
示例性地,假设在本申请实施例中,按照线性衰减公式来模拟声音衰减的具体过程,例如,y=a/x,其中,y为NPC接收到的第一声音的剩余声音强度,x为第一玩家角色与NPC之间的第一目标距离,a为第一玩家角色在第一位置发出的第一声音的第一声音强度,通过公式可知,随着第一玩家角色与NPC之间的第一目标距离逐渐增大,NPC接收到的第一声音的剩余声音强度逐渐减小,具体地,可参考如图8中(b)所示的示意图。
举例来说,如果8中(c)所示,按照上述线性衰减公式,在玩家角色移动时发出第一声音的情况下,距离玩家角色较近的NPC1(角色等级为Lv.7)接收到的第一声音的剩余声音强度大于距离玩家角色较远的NPC2(角色等级为Lv.6)接收到的第一声音的剩余声音强度,例如,NPC1可以听到玩家角色发出的第一声音,并前来与玩家角色进行交互;而NPC2则仍处于日常状态,例如,执行休息或睡觉等日常行为等。
通过利用上述线性衰减公式,充分考虑了声音传播过程中声音强度跟随传播距离而变化的过程,较为真实地还原了3D虚拟游戏场景中声音的产生、传播等情况。
显然,容易理解的是,上述线性衰减公式仅为一种示例,并不对其进行限定,例如,还可以是其他非线性的衰减公式。
在确定NPC听到的第一声音的声音强度时,除了考虑上述第一声音的衰减过程,还需要考虑环境噪声的声音强度对NPC的听觉感知能力的影响,并在确定NPC所在的位置上的环境噪声的声音强度的情况下,根据NPC所在位置上接收到的第一声音的剩余声音强度和环境噪声的声音强度,确定NPC听到的第一声音的声音强度。
作为一种可选的实现方式,上述根据剩余声音强度和环境噪声的声音强度,确定NPC听到的第一声音的声音强度,包括:
在剩余声音强度大于环境噪声的声音强度的情况下,将NPC听到的第一声音的声音强度确定为等于剩余声音强度与环境噪声的声音强度之间的差值;和/或
在剩余声音强度小于或等于环境噪声的声音强度的情况下,将NPC听到的第一声音的声音强度确定为等于环境噪声的声音强度或者为0。
由于玩家角色发出的第一声音是NPC希望接收到的声音,而周围环境发出的环境噪声则是干扰到NPC听到玩家角色发出的第一声音的声音,因此,在剩余声音强度大于环境噪声的声音强度的情况下,将剩余声音强度与环境噪声的声音强度之间的差值确定为NPC听到的第一声音的声音强度。
需要说明的是,在第一玩家角色发出第一声音,且NPC接收到第一声音的情况下,根据NPC所处位置的XYZ坐标,可以快速定位到NPC所处位置对应如图9所示的目标网格,然后通过查询每个网格对应的环境噪声的声音强度,可以便捷地获取目标网格中的环境噪声的声音强度,提高了获取NPC所处位置的环境噪声的声音强度的效率。
在剩余声音强度小于NPC所处位置的环境噪声的声音强度的情况下,由于NPC接收到的第一声音被NPC所处位置的环境噪声所掩盖,因此,NPC听到的第一声音的声音强度等于NPC所处位置的环境噪声的声音强度。
在剩余声音强度等于NPC所处位置的环境噪声的声音强度的情况下,按照上述剩余声音强度与环境噪声的声音强度之间的差值计算方法可知,NPC听到的第一声音的声音强度为0,也即,NPC实际上并未听到声音。
采用上述方式,根据第一声音传播到NPC所在的位置时的剩余声音强度和NPC所处位置的环境噪声的声音强度,可以准确地确定NPC听到的第一声音的声音强度,提高 了NPC听到的第一声音的声音强度的准确性,同时也有助于准确地控制NPC执行与第一声音对应的行为操作。
作为一种可选的示例,上述获取NPC所在的位置上的环境噪声的声音强度,包括:
确定目标游戏场景中NPC所在的目标网格,其中,目标游戏场景预先被划分成一组网格,一组网格包括目标网格,一组网格中的每个网格预先设置了对应的环境噪声的声音强度,每个网格对应的环境噪声的声音强度是根据每个网格中的虚拟地形的类型确定得到的声音强度;
将NPC所在的位置上的环境噪声的声音强度确定为等于预先设置的目标网格对应的环境噪声的声音强度。
在获取NPC所在的位置上的环境噪声的声音强度之前,需要对整个游戏场景进行网格化划分,例如,根据实际的游戏画面,将整个游戏场景划分为2D的正方形网格,或者划分为3D的正方体网格。在本申请实施例中,假设将整个3D游戏画面划分为如图9所示的一组0.5m*0.5m*0.5m的正方体网格。
利用上述网格化划分后的游戏场景,确定NPC所在的位置上的环境噪声的声音强度的具体实现步骤,包括:
S1,设置目标游戏场景中每个网格的环境噪声的声音强度;
显然,容易理解的是,在实际生活场景中,身处森林时的环境噪声的声音强度大于身处草地时的环境噪声的声音强度,而处于瀑布周围的环境噪声的声音强度又大于身处森林时的环境噪声的声音强度。也即,每个网格中的虚拟地形的类型直接影响着该网格的环境噪声的声音强度。
因此,在本申请实施例中,建立了一套从虚拟地形到环境噪声的声音强度的模拟系统,即,根据每个网格中的虚拟地形的类型,可以确定每个网格对应的环境噪声的声音强度。
如图10所示,当NPC所处的虚拟地形为森林时,对应的环境噪声的声音强度预先设置为10DB;当NPC所处的虚拟地形为草地时,对应的环境噪声的声音强度预先设置为0DB;当NPC所处的虚拟地形为瀑布时,对应的环境噪声的声音强度预先设置为20DB。
在本申请实施例中,通过预先计算出这个游戏场景中各个网格的环境噪声的声音强度,减少了环境噪声的声音强度的查询时间,提高了确定每个网格对应的环境噪声的声音强度的效率,提升了服务器的数据处理效率。
S2,确定目标游戏场景中NPC所在的目标网格;
例如,当NPC所在的位置完全处于1个网格中的情况下,直接将该网格确定为NPC所在的目标网格;当NPC所在的位置处于2个或2个以上网格中的情况下,将多个网格中NPC位置占比最大的网格确定为目标网格。
S3,将预先设置的目标网格对应的环境噪声的声音强度确定为NPC所在位置上的环境噪声的声音强度。
如上所述,噪声作为声音的一种,也可以在介质中传播,并且也存在衰减的情形。对于每个网格对应的环境噪声的声音强度,除了受到该网格自身虚拟地形的影响之外,还受到周围网格中的虚拟地形的影响。因此,在本申请实施例中,也采用线性衰减的模拟形式,确定每个网格对应的环境噪声的声音强度。
作为一种可选的示例,在考虑周围网格中的虚拟地形的情况下,确定每个网格对应 的环境噪声的声音强度的实现方式如下:
对一组网格中的每个网格执行以下操作,得到每个网格对应的环境噪声的声音强度,其中,在执行以下操作时,每个网格为当前网格:
获取当前网格对应的初始噪声的声音强度,其中,初始噪声的声音强度与当前网格中的虚拟地形的类型具有预设的对应关系;
获取当前网格收到的传播噪声的声音强度,其中,传播噪声的声音强度包括一组网格中除当前网格之外的每个网格对应的初始噪声传播到当前网格时的剩余声音强度;
根据初始噪声的声音强度和传播噪声的声音强度,确定当前网格对应的环境噪声的声音强度。
如图11所示,假设一组网格中共包括2个网格,假设1#网格为当前网格,那么,确定当前网格对应的环境噪声的声音强度的具体步骤如下:
S11,首先根据每个网格中的虚拟地形模拟出每个网格对应的初始噪声的声音强度;
例如,1#网格的初始噪声的声音强度为10、2#网格的初始噪声的声音强度为20。
S12,计算每个网格对应的初始噪声在传播过程中对周围网格的噪声影响值;
其中,噪声影响值可以但不限于一组网格中除当前网格之外的每个网格对应的初始噪声传播到当前网格时的剩余声音强度。例如,1#网格对应的初始噪声传播到2#网格时的剩余声音强度为5,2#网格对应的初始噪声传播到1#网格时的剩余声音强度为15,也就意味着,1#网格收到2#网格的传播噪声的声音强度为15,2#网格收到1#网格的传播噪声的声音强度为5。其中,在上述各个步骤中,声音强度的计量单位可以但不限于分贝(DB)
需要说明的是,在1#网格对应的初始噪声向2#网格传播的过程中,或者2#网格对应的初始噪声向1#网格传播的过程中,均存在声音强度的衰减。
S13,根据1#网格对应的初始噪声的声音强度和1#网格收到的传播噪声的声音强度,确定1#网格对应的环境噪声的声音强度。
采用与上述步骤S11~S13相同的方法,在将2#网格确定为当前网格的情况下,也可以根据2#网格对应的初始噪声的声音强度和2#网格收到的传播噪声的声音强度,确定2#网格对应的环境噪声的声音强度。
作为一种可选的示例,上述根据初始噪声的声音强度和传播噪声的声音强度,确定当前网格对应的环境噪声的声音强度,包括:
将当前网格对应的环境噪声的声音强度确定为等于初始噪声的声音强度和传播噪声的声音强度中的最大声音强度;或者
将当前网格对应的环境噪声的声音强度确定为等于初始噪声的声音强度和传播噪声的声音强度之和;或者
将当前网格对应的环境噪声的声音强度确定为等于对初始噪声的声音强度和传播噪声的声音强度进行加权求和所得到的值。
下面结合具体的示例,对上述当前网格对应的环境噪声的声音强度的具体实现方法进行介绍。
(一)对于当前网格对应的环境噪声的声音强度确定为等于初始噪声的声音强度和传播噪声的声音强度中的最大声音强度的情况;
如图11所示,在1#网格为当前网格的情况下,假设1#网格的初始噪声的声音强度为10、1#网格收到的传播噪声的声音强度为15,那么取10和15中的最大值,作为1# 网格最终的环境噪声的声音强度,也即,1#网格对应的环境噪声的声音强度为15。
在2#网格为当前网格的情况下,假设2#网格的初始噪声的声音强度为20、2#网格收到的传播噪声的声音强度为5,那么取20和5中的最大值,作为2#网格最终的环境噪声的声音强度,也即,2#网格对应的环境噪声的声音强度为20。
(二)对于将当前网格对应的环境噪声的声音强度确定为等于初始噪声的声音强度和传播噪声的声音强度之和的情况;
如图12所示,假设一组网格中共包括9个网格,且1#~9#网格对应的初始噪声的声音强度分别为V1、V2...V9,以当前网格为5#网格为例进行说明。
由于5#网格周围包括1#~4#、6#~9#网格,假设1#~4#网格各自对应的初始噪声传播到5#网格时的剩余声音强度分别为V'1~V'4,6#~9#网格各自对应的初始噪声传播到5#网格时的剩余声音强度分别为V'6~V'9。那么,5#网格对应的环境噪声的声音强度为V=V5+V'1...V'4+V'6+V'9。
需要说明的是,采用上述线性衰减的模拟形式,在上述1#~4#、6#~9#网格对应的初始噪声传播到5#网格时,各个初始噪声的声音强度可能衰减至0。也即,5#网格收到的传播噪声的声音强度V'1~V'4、V'6~V'9中可能部分取值为0。
(三)对于将当前网格对应的环境噪声的声音强度确定为等于对初始噪声的声音强度和传播噪声的声音强度进行加权求和所得到的值的情况;
仍以图12为例,根据1#~4#、6#~9#网格对应的初始噪声的类型,或者1#~4#、6#~9#网格与5#网格之间的距离远近,对5#网格收到的传播噪声的声音强度分别设置不同的权重。例如,距离5#网格较近的周围网格的传播噪声的声音强度所占的权重较大,距离5#网格较远的周围网格的传播噪声的声音强度所占的权重较小。
对5#网格的初始噪声的声音强度V5和传播噪声的声音强度V'1~V'4、V'6~V'9进行加权求和,得到5#网格对应的环境噪声的声音强度为V=W1V5+W2V'1...W5V'4+W6V'6...W9V'9。
通过上述方式,在考虑NPC所在位置的虚拟地形的前提下,通过引入NPC所在的目标网格对应的初始噪声的声音强度及目标网格接收到的传播噪声的声音强度,充分考虑了环境噪声的衰减和周围网格的环境噪声对目标网格对应的环境噪声的声音强度的影响,提高了环境噪声的真实性。
作为一种可选的示例,上述方法还包括:
根据NPC的角色类型设置预设听觉半径,其中,当NPC的角色类型为听力灵敏的角色类型时,预设听觉半径被设置为第一值,当NPC的角色类型为非听力灵敏的角色类型时,预设听觉半径被设置为第二值,第一值大于第二值;或者
根据NPC的当前状态设置预设听觉半径,其中,当NPC的当前状态为未受到攻击伤害的状态时,预设听觉半径被设置为第一值,当NPC的当前状态为受到攻击伤害的状态时,预设听觉半径被设置为第二值,第一值大于第二值;或者
根据NPC的目标技能的释放状态设置预设听觉半径,其中,目标技能用于在被释放的状态下增加NPC的听觉范围,当目标技能的释放状态为已释放状态时,预设听觉半径被设置为第一值,当目标技能的释放状态为未释放状态时,预设听觉半径被设置为第二值,第一值大于第二值。
结合上述实施例的描述可知,NPC的预设听觉半径表示NPC自身的听觉感知能力, 也可以被理解为NPC可以接收到声音的听力范围。因此,在判断NPC能否能到第一玩家角色发出的第一声音的过程中,预设听觉半径的设置起着至关重要的作用,下面结合的示例对如何设置NPC的预设听觉半径进行描述。
第一种:假设根据NPC的角色类型,将NPC划分为听力灵敏和非听力灵敏两种不同的类型;
在与第一玩家角色之间的距离相同情况下,听力灵敏的NPC听到的第一声音的声音强度大于非听力灵敏的NPC听到的第一声音的声音强度。或者,听力灵敏的NPC能够听到第一玩家角色发出的第一声音,但非听力灵敏的NPC不能听到第一声音,也即,听力灵敏的NPC的预设听觉半径大于非听力灵敏的NPC的预设听觉半径。
如图13中(a)所示,在将听力灵敏的NPC的预设听觉半径设置为第一值r1、将非听力灵敏的NPC的预设听觉半径设置为第二值r2时,r1>r2。
第二种:假设根据NPC的状态特征,将NPC划分为受到攻击和未受到攻击两种不同的类型;
显然,容易理解的是,在与第一玩家角色之间的距离相同情况下,受到攻击的NPC听到的第一声音的声音强度小于未受到攻击的NPC听到的第一声音的声音强度。或者,未受到攻击的NPC能够听到第一玩家角色发出的第一声音,但受到攻击的NPC不能听到第一声音,也即,未受到攻击的NPC的预设听觉半径大于受到攻击的NPC的预设听觉半径。
如图13中(b)所示,在将未受到攻击的NPC的预设听觉半径设置为第一值r3、将受到攻击的NPC的预设听觉半径设置为第二值r4时,r3>r4。
第三种:假设根据NPC的技能释放状态,将NPC划分为技能未释放和技能已释放两种不同的类型。
在与第一玩家角色之间的距离相同情况下,技能未释放的NPC听到的第一声音的声音强度大于技能已释放的NPC听到的第一声音的声音强度。或者,技能未释放的NPC能够听到第一玩家角色发出的第一声音,但技能已释放的NPC不能听到第一声音,也即,技能未释放的NPC的预设听觉半径大于技能已释放的NPC的预设听觉半径。
如图13中(c)所示,在将技能未释放的NPC的预设听觉半径设置为第一值r5、将技能已释放的NPC的预设听觉半径设置为第二值r6时,r5>r6。
通过上述方式,根据NPC的角色类型、NPC的当前状态及NPC的目标技能的释放状态,设置不同类型后处于不同状态下的NPC的预设听觉半径,提高了设置预设听觉半径的灵活性,提升了预设听觉半径的真实性。
作为一种可选的示例,根据上述NPC的预设听觉半径、第一声音强度阈值和第二声音强度阈值等参数,可以控制NPC执行与第一声音对应的第一行为操作、第二行为操作。除此之外,通过第一声音强度阈值和第二声音强度阈值,还可以控制NPC的行为操作进行切换,具体地,包括:
在控制NPC执行与第一声音对应的行为操作的过程中,获取第二声音的第二声音强度以及第二声音的第二传播距离,其中,第二声音是第二玩家角色在第二位置上产生的声音,第二声音强度是预设的与第二玩家角色在第二位置上的第二运动状态对应的声音强度,第二传播距离是根据第二声音强度确定的传播距离;
在NPC与第二玩家角色之间的第二目标距离小于第二传播距离、且小于NPC的预 设听觉半径的情况下,根据第二声音强度以及第二目标距离确定NPC听到的第二声音的声音强度;
在NPC听到的第二声音的声音强度大于或等于第一声音强度阈值、且大于NPC听到的第一声音的声音强度的情况下,控制NPC停止执行与第一声音对应的行为操作,并控制NPC执行与第二声音对应的行为操作。
其中,第二声音强度与第二传播距离的获取方式与第一声音强度以及第一传播距离类似,可以参考上文中的描述。
如图14中(a)所示,假设NPC正在执行与第一玩家角色P1发出的一声音对应的行为操作,例如,靠近第一玩家角色P1。位于第二位置S2上的第二玩家角色P2发出第二声音,根据第二玩家角色P2在第二位置S2上的第二运动状态对应的声音强度,获取P2在S2上的第二运动状态对应的第二声音强度V2。具体过程可以参考上述实施例中对第一玩家角色在第一位置上的第一运动状态对应的第一声音强度部分的描述,此处不再赘述。
其中,第二玩家角色P2在第二位置S2上的第二运动状态包括但不限于如图4所示的潜行、冲刺、行走和飞行等。
在NPC与第二玩家角色之间的第二目标距离小于第二传播距离、且小于NPC的预设听觉半径的情况下,确定NPC能够听到第二玩家角色发出的第二声音,此时,根据第二声音强度V2以及第二目标距离,确定NPC听到的第二声音的声音强度。
如果NPC听到的第二声音的声音强度大于或等于第一声音强度阈值、且大于NPC听到的第一声音的声音强度,也就意味着,NPC已经察觉到了第二声音,并且NPC听到的第二声音干扰到了NPC预先听到的第一声音。那么NPC将停止靠近第一玩家角色P1,并执行与第二声音对应的行为操作,例如,如图14中(b)所示的远离第二玩家角色P1。
可见,在NPC听到第一玩家角色和第二玩家角色发出的第一声音和第二声音的情况下,分别计算第一声音和第二声音的声音强度,在确定NPC听到的第二声音的声音强度大于NPC听到的第一声音的声音强度的情况下,切换NPC执行的行为操作,提高了NPC所执行的行为操作灵活性,丰富了游戏的玩法,提升了用户体验感。
为了更加清晰地理解上述非玩家角色的控制方法,下面结合如图15所示的整体流程图对其进行进一步描述,具体地,包括:
S1502,计算环境噪声的声音强度;
例如,通过如图9~图12所示的示意图,将目标游戏场景预先划分成一组网格,并根据一组网格中的每个网格中的虚拟地形的类型确定每个网格对应的环境噪声的声音强度,确定每个网格的环境噪声的声音强度可以参考上述实施例部分的描述,此处不再赘述。
S1504,模拟玩家角色发出的第一声音的声音强度;
假设玩家角色在游戏场景中的第一位置上产生第一声音,那么根据玩家角色在第一位置上的运动状态,即可模拟出玩家角色的第一声音的声音强度。
其中,第一声音的声音强度与第一位置所处的虚拟地形的类型和/或玩家角色的运动状态之间的关系,可以但不限于通过查询预先创建的关系映射表来确定。
S1506,通过第一声音的传播距离和NPC的预设听觉半径,筛选出NPC;
作为一种可选的示例,通过图5所示的第一声音的传播距离d和NPC的预设听觉半 径来筛选NPC,具体实现过程如下:
如图5所示,假设第一玩家角色发出的第一声音的传播距离(又可以被理解为第一声音的第一传播距离)为d,第一玩家角色与NPC1之间的目标距离为d1,由于d1>d,NPC1距离第一玩家角色较远,NPC1无法听到第一声音;而第一玩家角色与NPC2之间的目标距离为d2,由于d2<d,且d2<r,确定NPC2可以听到第一声音,其中,r为NPC2的预设听觉半径,r决定了NPC2的听力范围。
另外,对于NPC1和NPC2是否能够听到第一声音,还可以通过下述实现过程来确定:在第一玩家角色发出第一声音时,首先会根据第一声音的传播距离d,确定处于传播距离d范围内的NPC,如图5所示,包括NPC1和NPC2;然后根据第一声音的声源是否位于NPC的预设听觉半径内,可以确定出仅有NPC2能够听到第一声音。对于NPC1来说,虽然处于第一声音的传播距离d的范围内,但第一声音的声源位于NPC1的预设听觉半径之外,所以NPC1无法听到第一声音。
通过上述方式筛选出的NPC与第一玩家角色之间的目标距离小于第一声音的传播距离、且小于NPC的预设听觉半径。
进一步地,通过采用上述方式对NPC进行筛选,仅需要对满足要求的部分NPC执行后续的计算,其中,后续的计算包括但不限于NPC收到的第一声音的剩余声音强度的计算、NPC实际听到的第一声音的声音强度的计算等。
例如,假设虚拟场景中NPC的总数量为100个,按照上述筛选方法,确定只有2个NPC满足要求,那么,只需要计算2个NPC收到的第一声音的剩余声音强度和实际听到的第一声音的声音强度,实现了减少计算量、提高NPC执行行为操作的效率的技术效果。
S1508,计算第一声音传播至第一位置时,NPC收到的第一声音的剩余声音强度;
为了确保声源模拟的真实性,需要充分考虑当声音在介质中传播时,声音的强度会随着距离的增加而不断衰减,并且声音的衰减情况与衰减公式和距离、介质特征等因素相关。例如,如图8中(a)所示,从声源处发出的第一声音的声音强度会随着传播距离的增大逐渐衰减至0。
其中,在本申请实施例中,可以但不限于按照线性衰减公式来模拟声音衰减的具体过程,例如,y=a/x,其中,y为NPC接收到的第一声音的剩余声音强度,x为第一玩家角色与NPC之间的第一目标距离,a为第一玩家角色在第一位置发出的第一声音的第一声音强度。
S1510,查询环境噪声的声音强度;
首先对整个游戏场景进行网格化划分为一组网格,并预先为一组网格中的每个网格设置对应的环境噪声的声音强度,最后根据每个网格中的虚拟地形的类型确定NPC得到的声音强度。
做为一种可选的示例,可以直接将NPC所在位置上的环境噪声的声音强度直接确定为预先设置的目标网格对应的环境噪声的声音强度,或者根据查询到的目标网格对应的初始噪声和周围网格产生的初始噪声传播至目标网格后的剩余声音强度,确定目标网格对应的环境噪声的声音强度,具体过程可以参考上述实施例部分的描述。
S1512,计算NPC实际听到的第一声音的声音强度;
示例性地,在第一声音传播到NPC所在位置时的剩余声音强度大于环境噪声的声音强度的情况下,将NPC听到的所述第一声音的声音强度确定为等于剩余声音强度与环境 噪声的声音强度之间的差值;或者
在剩余声音强度小于或等于环境噪声的声音强度的情况下,将NPC听到的第一声音的声音强度确定为等于环境噪声的声音强度或者为0。
S1514,比较NPC听到的第一声音的声音强度与听觉察觉阈值、听觉发现阈值之间的关系,并执行响应的行为操作,如步骤S1516;
例如,在NPC听到的第一声音的声音强度大于或等于听觉察觉阈值(第一声音强度阈值)的情况下,执行上述实施例中的第一行为操作,例如,寻找玩家。
在NPC听到的第一声音的声音强度大于或等于听觉发现阈值(第二声音强度阈值)的情况下,控制所述NPC执行第二行为操作,例如,会话或与玩家互动。
S1516,控制NPC执行与第一声音对应的行为操作。
通过本申请提供的上述实施例,在根据非玩家角色NPC与第一玩家角色之间的第一目标距离以及NPC的预设听觉半径,确定NPC能够听到第一玩家角色发出的第一声音的情况下,通过比较NPC听到的第一声音的声音强度与第一声音强度阈值,控制NPC执行与第一声音对应的行为操作。换言之,通过比较NPC听到的第一声音的声音强度和第一声音强度阈值,使得NPC能够准确地执行相应的行为操作,避免了无法准确地控制NPC执行行为操作的技术问题,实现了提高控制NPC执行行为操作的准确性的技术效果。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。
根据本发明实施例的另一个方面,还提供了如图16所示的一种非玩家角色的控制装置,该装置包括:
第一获取单元1602,用于获取第一声音的第一声音强度以及第一声音的第一传播距离,其中,第一声音是第一玩家角色在第一位置上产生的声音,第一声音强度是预设的与第一玩家角色在第一位置上的第一运动状态对应的声音强度,第一传播距离是根据第一声音强度确定的传播距离;
第一处理单元1604,用于在非玩家角色NPC与第一玩家角色之间的第一目标距离小于第一传播距离、且小于NPC的预设听觉半径的情况下,根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度;
第二处理单元1606,用于在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作。
可选地,上述第二处理单元1606,包括:
第一处理模块,用于在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,控制NPC执行第一行为操作,其中,第一行为操作是在NPC察觉到有声音时所执行的行为操作。
可选地,上述第一处理模块,还包括:
第一处理子模块,用于在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值的情况下,控制NPC执行第二行为操作,其中,第二行为操作是在NPC发现第一玩家角色时所执行的行为操作。
可选地,第二处理单元1606,包括:
第二处理模块,用于在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,控制NPC向第一位置移动;或者
在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值、且小于第二声音强度阈值的情况下,控制NPC在向第一位置移动的过程中寻找第一玩家角色。
可选地,上述第二处理模块,还包括:
第二处理子模块,用于在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值的情况下,控制NPC朝着远离第一玩家角色的方向移动,或者,控制NPC朝着第一玩家角色的方向移动;或者
在NPC听到的第一声音的声音强度大于或等于第二声音强度阈值的情况下,控制NPC与第一玩家角色执行交互操作。
可选地,上述第一处理单元1604,包括:
第三处理模块,用于根据第一声音强度以及第一目标距离,确定第一声音传播到NPC所在的位置时的剩余声音强度;
第一获取模块,用于获取NPC所在的位置上的环境噪声的声音强度;
第四处理模块,用于根据剩余声音强度和环境噪声的声音强度,确定NPC听到的第一声音的声音强度。
可选地,上述第一获取模块,包括:
第三处理子模块,用于确定目标游戏场景中NPC所在的目标网格,其中,目标游戏场景预先被划分成一组网格,一组网格包括目标网格,一组网格中的每个网格预先设置了对应的环境噪声的声音强度,每个网格对应的环境噪声的声音强度是根据每个网格中的虚拟地形的类型确定得到的声音强度;
第四处理子模块,用于将NPC所在的位置上的环境噪声的声音强度确定为等于预先设置的目标网格对应的环境噪声的声音强度。
可选地,上述第一获取模块,还包括:
第五处理子模块,用于对一组网格中的每个网格执行以下操作,得到每个网格对应的环境噪声的声音强度,其中,在执行以下操作时,每个网格为当前网格:
获取当前网格对应的初始噪声的声音强度,其中,初始噪声的声音强度与当前网格中的虚拟地形的类型具有预设的对应关系;
获取当前网格收到的传播噪声的声音强度,其中,传播噪声的声音强度包括一组网格中除当前网格之外的每个网格对应的初始噪声传播到当前网格时的剩余声音强度;
根据初始噪声的声音强度和传播噪声的声音强度,确定当前网格对应的环境噪声的声音强度。
可选地,上述装置还包括:
第六处理子模块,用于将当前网格对应的环境噪声的声音强度确定为等于初始噪声的声音强度和传播噪声的声音强度中的最大声音强度;或者
将当前网格对应的环境噪声的声音强度确定为等于初始噪声的声音强度和传播噪声的声音强度之和;或者
将当前网格对应的环境噪声的声音强度确定为等于对初始噪声的声音强度和传播噪声的声音强度进行加权求和所得到的值。
可选地,上述第四处理模块,包括:
第七处理子模块,用于在剩余声音强度大于环境噪声的声音强度的情况下,将NPC听到的第一声音的声音强度确定为等于剩余声音强度与环境噪声的声音强度之间的差值;和/或
在剩余声音强度小于或等于环境噪声的声音强度的情况下,将NPC听到的第一声音的声音强度确定为等于环境噪声的声音强度或者为0。
可选地,上述装置还包括:
第三处理单元,用于根据NPC的角色类型设置预设听觉半径,其中,当NPC的角色类型为听力灵敏的角色类型时,预设听觉半径被设置为第一值,当NPC的角色类型为非听力灵敏的角色类型时,预设听觉半径被设置为第二值,第一值大于第二值;或者
根据NPC的当前状态设置预设听觉半径,其中,当NPC的当前状态为未受到攻击伤害的状态时,预设听觉半径被设置为第一值,当NPC的当前状态为受到攻击伤害的状态时,预设听觉半径被设置为第二值,第一值大于第二值;或者
根据NPC的目标技能的释放状态设置预设听觉半径,其中,目标技能用于在被释放的状态下增加NPC的听觉范围,当目标技能的释放状态为已释放状态时,预设听觉半径被设置为第一值,当目标技能的释放状态为未释放状态时,预设听觉半径被设置为第二值,第一值大于第二值。
可选地,上述装置还包括:
第二获取单元,用于在控制NPC执行与第一声音对应的行为操作的过程中,获取第二声音的第二声音强度以及第二声音的第二传播距离,其中,第二声音是第二玩家角色在第二位置上产生的声音,第二声音强度是预设的与第二玩家角色在第二位置上的第二运动状态对应的声音强度,第二传播距离是根据第二声音强度确定的传播距离;
第四处理单元,用于在NPC与第二玩家角色之间的第二目标距离小于第二传播距离、且小于NPC的预设听觉半径的情况下,根据第二声音强度以及第二目标距离确定NPC听到的第二声音的声音强度;
第五处理单元,用于在NPC听到的第二声音的声音强度大于或等于第一声音强度阈值、且大于NPC听到的第一声音的声音强度的情况下,控制NPC停止执行与第一声音对应的行为操作,并控制NPC执行与第二声音对应的行为操作。
通过将上述装置应用于在根据非玩家角色NPC与第一玩家角色之间的第一目标距离以及NPC的预设听觉半径,确定NPC能够听到第一玩家角色发出的第一声音的情况下,通过比较NPC听到的第一声音的声音强度与第一声音强度阈值,控制NPC执行与第一声音对应的行为操作。换言之,通过比较NPC听到的第一声音的声音强度和第一声音强度阈值,使得NPC能够准确地执行相应的行为操作,避免了无法准确地控制NPC执行行为操作的技术问题,实现了提高控制NPC执行行为操作的准确性的技术效果。
需要说明的是,这里的非玩家角色的控制装置的实施例可以参考上述非玩家角色的控制方法的实施例,这里不再赘述。
根据本申请实施例的又一个方面,还提供了一种用于实施上述非玩家角色的控制方法的电子设备,该电子设备可以是图17所示的终端设备。本实施例以该电子设备为后台设备为例来说明。如图17所示,该电子设备包括存储器1702和处理器1704,该存储器1702中存储有计算机程序,该处理器1704被设置为通过计算机程序执行上述任一项方法 实施例中的步骤。
可选地,在本实施例中,上述电子设备可以位于计算机网络的多个网络设备中的至少一个网络设备。
可选地,在本实施例中,上述处理器可以被设置为通过计算机程序执行以下步骤:
S1,获取第一声音的第一声音强度以及第一声音的第一传播距离,其中,第一声音是第一玩家角色在第一位置上产生的声音,第一声音强度是预设的与第一玩家角色在第一位置上的第一运动状态对应的声音强度,第一传播距离是根据第一声音强度确定的传播距离;
S2,在非玩家角色NPC与第一玩家角色之间的第一目标距离小于第一传播距离、且小于NPC的预设听觉半径的情况下,根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度;
S3,在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作。
可选地,本领域普通技术人员可以理解,图17所示的结构仅为示意,电子装置电子设备也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌上电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等目标终端。图17其并不对上述电子装置电子设备的结构造成限定。例如,电子装置电子设备还可包括比图17中所示更多或者更少的组件(如网络接口等),或者具有与图17所示不同的配置。
其中,存储器1702可用于存储软件程序以及模块,如本申请实施例中的非玩家角色的控制方法和装置对应的程序指令/模块,处理器1704通过运行存储在存储器1702内的软件程序以及模块,从而执行各种功能应用以及数据处理,即实现上述的非玩家角色的控制方法。存储器1702可包括高速随机存储器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器1702可进一步包括相对于处理器1704远程设置的存储器,这些远程存储器可以通过网络连接至终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。其中,存储器1702具体可以但不限于用于存储第一声音的第一声音强度、NPC与第一玩家角色之间的第一目标距离、NPC的预设听觉半径等。作为一种示例,如图17所示,上述存储器1702中可以但不限于包括上述非玩家角色的控制装置中的第一获取单元1602、第一处理单元1604和第二处理单元1606。此外,还可以包括但不限于上述非玩家角色的控制装置中的其他模块单元,本示例中不再赘述。
可选地,上述的传输装置1706用于经由一个网络接收或者发送数据。上述的网络具体实例可包括有线网络及无线网络。在一个实例中,传输装置1706包括一个网络适配器(Network Interface Controller,NIC),其可通过网线与其他网络设备与路由器相连从而可与互联网或局域网进行通讯。在一个实例中,传输装置1706为射频(Radio Frequency,RF)模块,其用于通过无线方式与互联网进行通讯。
此外,上述电子设备还包括:显示器1708,用于显示上述目标声音的方位提示信息;和连接总线1710,用于连接上述电子设备中的各个模块部件。
在其他实施例中,上述目标终端或者服务器可以是一个分布式系统中的一个节点,其中,该分布式系统可以为区块链系统,该区块链系统可以是由该多个节点通过网络通信的形式连接形成的分布式系统。其中,节点之间可以组成点对点(P2P,Peer To Peer) 网络,任意形式的计算设备,比如服务器、终端等电子设备都可以通过加入该点对点网络而成为该区块链系统中的一个节点。
根据本申请的一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述服务器校验处理等方面各种可选实现方式中提供的非玩家角色的控制方法,其中,该计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。
可选地,在本实施例中,上述计算机可读的存储介质可以被设置为存储用于执行以下步骤的计算机程序:
S1,获取第一声音的第一声音强度以及第一声音的第一传播距离,其中,第一声音是第一玩家角色在第一位置上产生的声音,第一声音强度是预设的与第一玩家角色在第一位置上的第一运动状态对应的声音强度,第一传播距离是根据第一声音强度确定的传播距离;
S2,在非玩家角色NPC与第一玩家角色之间的第一目标距离小于第一传播距离、且小于NPC的预设听觉半径的情况下,根据第一声音强度以及第一目标距离确定NPC听到的第一声音的声音强度;
S3,在NPC听到的第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制NPC执行与第一声音对应的行为操作。
可选地,在本实施例中,本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令目标终端相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、只读存储器(Read-Only Memory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
上述实施例中的集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在上述计算机可读取的存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在存储介质中,包括若干指令用以使得一台或多台计算机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例方法的全部或部分步骤。
在本发明的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本申请所提供的几个实施例中,应该理解到,所揭露的客户端,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络 单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
以上仅是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。

Claims (16)

  1. 一种非玩家角色的控制方法,其特征在于,包括:
    获取第一声音的第一声音强度以及所述第一声音的第一传播距离,其中,所述第一声音是第一玩家角色在第一位置上产生的声音,所述第一声音强度是预设的与所述第一玩家角色在所述第一位置上的第一运动状态对应的声音强度,所述第一传播距离是根据所述第一声音强度确定的传播距离;
    在非玩家角色NPC与所述第一玩家角色之间的第一目标距离小于所述第一传播距离、且小于所述NPC的预设听觉半径的情况下,根据所述第一声音强度以及所述第一目标距离确定所述NPC听到的所述第一声音的声音强度;
    在所述NPC听到的所述第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制所述NPC执行与所述第一声音对应的行为操作。
  2. 根据权利要求1所述的方法,其特征在于,所述在所述NPC听到的所述第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制所述NPC执行与所述第一声音对应的行为操作,包括:
    在所述NPC听到的所述第一声音的声音强度大于或等于所述第一声音强度阈值、且小于第二声音强度阈值的情况下,控制所述NPC执行第一行为操作,其中,所述第一行为操作是在所述NPC察觉到有声音时所执行的行为操作。
  3. 根据权利要求2所述的方法,其特征在于,所述在所述NPC听到的所述第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制所述NPC执行与所述第一声音对应的行为操作,还包括:
    在所述NPC听到的所述第一声音的声音强度大于或等于所述第二声音强度阈值的情况下,控制所述NPC执行第二行为操作,其中,所述第二行为操作是在所述NPC发现所述第一玩家角色时所执行的行为操作。
  4. 根据权利要求1所述的方法,其特征在于,所述在所述NPC听到的所述第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制所述NPC执行与所述第一声音对应的行为操作,包括:
    在所述NPC听到的所述第一声音的声音强度大于或等于所述第一声音强度阈值、且小于第二声音强度阈值的情况下,控制所述NPC向所述第一位置移动;或者
    在所述NPC听到的所述第一声音的声音强度大于或等于所述第一声音强度阈值、且小于第二声音强度阈值的情况下,控制所述NPC在向所述第一位置移动的过程中寻找所述第一玩家角色。
  5. 根据权利要求4所述的方法,其特征在于,所述在所述NPC听到的所述第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制所述NPC执行与所述第一声音对应的行为操作,还包括:
    在所述NPC听到的所述第一声音的声音强度大于或等于所述第二声音强度阈值的情况下,控制所述NPC朝着远离所述第一玩家角色的方向移动,或者,控制所述NPC朝着所述第一玩家角色的方向移动;或者
    在所述NPC听到的所述第一声音的声音强度大于或等于所述第二声音强度阈值的情况下,控制所述NPC与所述第一玩家角色执行交互操作。
  6. 根据权利要求1至5中任一项所述的方法,其特征在于,所述根据所述第一声音 强度以及所述第一目标距离确定所述NPC听到的所述第一声音的声音强度,包括:
    根据所述第一声音强度以及所述第一目标距离,确定所述第一声音传播到所述NPC所在的位置时的剩余声音强度;
    获取所述NPC所在的位置上的环境噪声的声音强度;
    根据所述剩余声音强度和所述环境噪声的声音强度,确定所述NPC听到的所述第一声音的声音强度。
  7. 根据权利要求6所述的方法,其特征在于,所述获取所述NPC所在的位置上的环境噪声的声音强度,包括:
    确定目标游戏场景中所述NPC所在的目标网格,其中,所述目标游戏场景预先被划分成一组网格,所述一组网格包括所述目标网格,所述一组网格中的每个网格预先设置了对应的环境噪声的声音强度,所述每个网格对应的环境噪声的声音强度是根据所述每个网格中的虚拟地形的类型确定得到的声音强度;
    将所述NPC所在的位置上的环境噪声的声音强度确定为等于预先设置的所述目标网格对应的环境噪声的声音强度。
  8. 根据权利要求7所述的方法,其特征在于,所述方法还包括:
    对所述一组网格中的每个网格执行以下操作,得到所述每个网格对应的环境噪声的声音强度,其中,在执行以下操作时,所述每个网格为当前网格:
    获取所述当前网格对应的初始噪声的声音强度,其中,所述初始噪声的声音强度与所述当前网格中的虚拟地形的类型具有预设的对应关系;
    获取所述当前网格收到的传播噪声的声音强度,其中,所述传播噪声的声音强度包括所述一组网格中除所述当前网格之外的每个网格对应的初始噪声传播到所述当前网格时的剩余声音强度;
    根据所述初始噪声的声音强度和所述传播噪声的声音强度,确定所述当前网格对应的环境噪声的声音强度。
  9. 根据权利要求8所述的方法,其特征在于,所述根据所述初始噪声的声音强度和所述传播噪声的声音强度,确定所述当前网格对应的环境噪声的声音强度,包括:
    将所述当前网格对应的环境噪声的声音强度确定为等于所述初始噪声的声音强度和所述传播噪声的声音强度中的最大声音强度;或者
    将所述当前网格对应的环境噪声的声音强度确定为等于所述初始噪声的声音强度和所述传播噪声的声音强度之和;或者
    将所述当前网格对应的环境噪声的声音强度确定为等于对所述初始噪声的声音强度和所述传播噪声的声音强度进行加权求和所得到的值。
  10. 根据权利要求6-9任一项所述的方法,其特征在于,所述根据所述剩余声音强度和所述环境噪声的声音强度,确定所述NPC听到的所述第一声音的声音强度,包括:
    在所述剩余声音强度大于所述环境噪声的声音强度的情况下,将所述NPC听到的所述第一声音的声音强度确定为等于所述剩余声音强度与所述环境噪声的声音强度之间的差值;和/或
    在所述剩余声音强度小于或等于所述环境噪声的声音强度的情况下,将所述NPC听到的所述第一声音的声音强度确定为等于所述环境噪声的声音强度或者为0。
  11. 根据权利要求1至10中任一项所述的方法,其特征在于,所述方法还包括:
    根据所述NPC的角色类型设置所述预设听觉半径,其中,当所述NPC的角色类型为听力灵敏的角色类型时,所述预设听觉半径被设置为第一值,当所述NPC的角色类型为非听力灵敏的角色类型时,所述预设听觉半径被设置为第二值,所述第一值大于所述第二值;或者
    根据所述NPC的当前状态设置所述预设听觉半径,其中,当所述NPC的当前状态为未受到攻击伤害的状态时,所述预设听觉半径被设置为所述第一值,当所述NPC的当前状态为受到攻击伤害的状态时,所述预设听觉半径被设置为所述第二值,所述第一值大于所述第二值;或者
    根据所述NPC的目标技能的释放状态设置所述预设听觉半径,其中,所述目标技能用于在被释放的状态下增加所述NPC的听觉范围,当所述目标技能的释放状态为已释放状态时,所述预设听觉半径被设置为所述第一值,当所述目标技能的释放状态为未释放状态时,所述预设听觉半径被设置为所述第二值,所述第一值大于所述第二值。
  12. 根据权利要求1至11中任一项所述的方法,其特征在于,所述方法还包括:
    在控制所述NPC执行与所述第一声音对应的行为操作的过程中,获取第二声音的第二声音强度以及所述第二声音的第二传播距离,其中,所述第二声音是第二玩家角色在第二位置上产生的声音,所述第二声音强度是预设的与所述第二玩家角色在所述第二位置上的第二运动状态对应的声音强度,所述第二传播距离是根据所述第二声音强度确定的传播距离;
    在所述NPC与所述第二玩家角色之间的第二目标距离小于所述第二传播距离、且小于所述NPC的所述预设听觉半径的情况下,根据所述第二声音强度以及所述第二目标距离确定所述NPC听到的所述第二声音的声音强度;
    在所述NPC听到的所述第二声音的声音强度大于或等于所述第一声音强度阈值、且大于所述NPC听到的所述第一声音的声音强度的情况下,控制所述NPC停止执行与所述第一声音对应的行为操作,并控制所述NPC执行与所述第二声音对应的行为操作。
  13. 一种非玩家角色的控制装置,其特征在于,包括:
    第一获取单元,用于获取第一声音的第一声音强度以及所述第一声音的第一传播距离,其中,所述第一声音是第一玩家角色在第一位置上产生的声音,所述第一声音强度是预设的与所述第一玩家角色在所述第一位置上的第一运动状态对应的声音强度,所述第一传播距离是根据所述第一声音强度确定的传播距离;
    第一处理单元,用于在非玩家角色NPC与所述第一玩家角色之间的第一目标距离小于所述第一传播距离、且小于所述NPC的预设听觉半径的情况下,根据所述第一声音强度以及所述第一目标距离确定所述NPC听到的所述第一声音的声音强度;
    第二处理单元,用于在所述NPC听到的所述第一声音的声音强度大于或等于第一声音强度阈值的情况下,控制所述NPC执行与所述第一声音对应的行为操作。
  14. 一种计算机可读的存储介质,其特征在于,所述计算机可读的存储介质包括存储的程序,其中,所述程序可被终端设备或计算机运行时执行所述权利要求1至12任一项中所述的方法。
  15. 一种计算机程序产品,包括计算机程序/指令,其特征在于,该计算机程序/指令被处理器执行时实现权利要求1至12任一项中所述方法的步骤。
  16. 一种电子设备,包括存储器和处理器,其特征在于,所述存储器中存储有计算机 程序,所述处理器被设置为通过所述计算机程序执行所述权利要求1至12任一项中所述的方法。
PCT/CN2023/117303 2022-09-26 2023-09-06 非玩家角色的控制方法和装置、存储介质及电子设备 WO2024066993A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211174826.0A CN117797479A (zh) 2022-09-26 2022-09-26 非玩家角色的控制方法和装置、存储介质及电子设备
CN202211174826.0 2022-09-26

Publications (1)

Publication Number Publication Date
WO2024066993A1 true WO2024066993A1 (zh) 2024-04-04

Family

ID=90427414

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/117303 WO2024066993A1 (zh) 2022-09-26 2023-09-06 非玩家角色的控制方法和装置、存储介质及电子设备

Country Status (2)

Country Link
CN (1) CN117797479A (zh)
WO (1) WO2024066993A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111760294A (zh) * 2020-07-07 2020-10-13 网易(杭州)网络有限公司 控制游戏中非玩家游戏角色的方法及装置
CN113398590A (zh) * 2021-07-14 2021-09-17 网易(杭州)网络有限公司 声音处理方法、装置、计算机设备及存储介质
CN113440839A (zh) * 2021-07-19 2021-09-28 网易(杭州)网络有限公司 非玩家游戏角色的控制方法、装置、设备及存储介质
CN113559517A (zh) * 2021-07-30 2021-10-29 腾讯科技(深圳)有限公司 非玩家虚拟角色的控制方法和装置、存储介质及电子设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111760294A (zh) * 2020-07-07 2020-10-13 网易(杭州)网络有限公司 控制游戏中非玩家游戏角色的方法及装置
CN113398590A (zh) * 2021-07-14 2021-09-17 网易(杭州)网络有限公司 声音处理方法、装置、计算机设备及存储介质
CN113440839A (zh) * 2021-07-19 2021-09-28 网易(杭州)网络有限公司 非玩家游戏角色的控制方法、装置、设备及存储介质
CN113559517A (zh) * 2021-07-30 2021-10-29 腾讯科技(深圳)有限公司 非玩家虚拟角色的控制方法和装置、存储介质及电子设备

Also Published As

Publication number Publication date
CN117797479A (zh) 2024-04-02

Similar Documents

Publication Publication Date Title
US10864441B2 (en) Information processing method, terminal, and computer storage medium
US11266913B2 (en) Method and apparatus for synchronously displaying game content and storage medium
US20230241504A1 (en) Object control method and device, storage medium, and electronic device
US11259136B2 (en) Sound reproduction method and apparatus, storage medium, and electronic apparatus
CN111182355B (zh) 一种互动方法、特效展示方法和相关装置
CN105704166B (zh) 机器人系统及其实现方法、客户端、服务器以及游戏系统
CN111298430A (zh) 虚拟道具控制方法和装置、存储介质及电子装置
US10874937B2 (en) Intelligent hardware interaction method and system
KR20200127213A (ko) 음원을 결정하기 위한 방법 및 디바이스, 저장 매체, 및 전자 디바이스
US20220274021A1 (en) Display method and apparatus for virtual scene, storage medium, and electronic device
CN114344892B (zh) 一种数据处理方法和相关装置
CN113082709A (zh) 游戏中信息提示方法、装置、存储介质及计算机设备
CN112569599A (zh) 虚拟场景中虚拟对象的控制方法、装置及电子设备
JP2024507595A (ja) 仮想リソースの投入制御方法、装置、コンピュータ機器及び記憶媒体
CN107678804B (zh) 行为执行方法和装置、存储介质及电子装置
WO2024066993A1 (zh) 非玩家角色的控制方法和装置、存储介质及电子设备
CN110102047B (zh) 游戏操作处理方法和装置、游戏效果展示方法和装置
CN111443838B (zh) 虚拟操作对象的控制方法和装置、存储介质及电子装置
CN113886208B (zh) 一种数据处理方法、装置、设备及存储介质
CN114307157A (zh) 虚拟场景中的声音处理方法、装置、设备及存储介质
JP2024519375A (ja) 音声再生方法及び音声伝送方法、装置、電子機器及びプログラム
JP2024506920A (ja) 仮想対象の制御方法、装置、機器、及びプログラム
JP2023548922A (ja) 仮想対象の制御方法、装置、電子機器、及びコンピュータプログラム
CN115531863A (zh) 虚拟场景中虚拟事件的提示方法、装置、存储介质和电子装置
CN113332724A (zh) 虚拟角色的控制方法、装置、终端和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23870232

Country of ref document: EP

Kind code of ref document: A1