Game skill processing method and device, equipment and medium
Through multi-threaded scheduling, the problem of poor fluency in game skills processing caused by traditional single-threaded processing is solved, and efficient concurrent release of skills is achieved, improving the fluency and interactivity of the game.
Patent Information
- Application Number
- CN202411470386.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-03-25
AI Technical Summary
The traditional game skills processing mechanism relies on a single main thread, resulting in poor fluency when processing a large number of game skills, prone to lag and delay, and it is difficult to meet the needs of large-scale interactive games.
By obtaining pending skills, determining skill entities and binding them to skill data, forming an array of skill entities, and then using multi-threaded scheduling to release skills concurrently.
It significantly improves the efficiency of game skills release processing, reduces the probability of lag and delay, improves the response speed of skills and the balance of processing, and improves the fluency and interactivity of the game.
Smart Images

Figure CN119680185A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic game technology, and in particular to a game skill processing method, device, equipment and medium. Background Art
[0002] With the rise of the electronic game industry and the popularization of the Internet, multiplayer online games have become an important form of mass entertainment. In multiplayer online games, players can release their skills by triggering different operations, which greatly enhances the fun and sense of participation of the game.
[0003] However, most traditional game skill processing mechanisms rely on the main thread, which has limited processing capacity and is prone to lag when the load is too large, seriously affecting the player's gaming experience. Specifically, the number of unit entities such as characters and non-player characters (NPCs) controlled by players in traditional games is generally small, and the number of skills processed at the same time is also limited, mostly not exceeding 10. When the number of participants in the game increases and players need to release skills frequently, the processing of a single main thread in the existing technology often cannot meet the frame rate requirements, resulting in game screen lag and player operation delays, which seriously affects the smoothness and interactivity of the game and is difficult to meet the needs of large-scale interactive games. Summary of the invention
[0004] The main purpose of the present invention is to provide a game skill processing method, device, equipment and medium, aiming to solve the technical problem that the existing game skill processing method has poor fluency when processing a large number of game skills.
[0005] A first aspect of the present invention provides a game skill processing method, the game skill processing method comprising:
[0006] Get at least one pending skill;
[0007] Determine a skill entity based on the skill to be processed, and bind the skill entity with the corresponding skill data of the skill to be processed to obtain a skill entity array, wherein the skill data is obtained by reading a skill data snapshot;
[0008] Multi-threaded scheduling is performed on the skill entity array to concurrently release the skills to be processed.
[0009] Optionally, in a first implementation of the first aspect of the present invention, the performing multi-threaded scheduling processing on the skill entity array to concurrently release the skills to be processed includes:
[0010] If the quotient of the number S of the skill entities in the skill entity array divided by the preset number of threads N is M, and the remainder is 0, then M skill entities are allocated to each of the N threads to perform the multi-thread scheduling process;
[0011] If the quotient of the number S of the skill entities in the skill entity array divided by the preset number of threads N is M, and the remainder is not 0, then M of the skill entities are allocated to each of the N-1 threads, and S-(N-1)×M of the skill entities are allocated to another thread to perform the multi-thread scheduling processing.
[0012] Optionally, in a second implementation of the first aspect of the present invention, the multi-threaded scheduling processing of the skill entity array to concurrently release the skills to be processed further includes:
[0013] Obtaining the maximum traversal number K of the current thread, and determining the current calculation amount T of the current thread, wherein the current calculation amount T is the number of the skill entities divided into the current thread;
[0014] If the quotient of the current calculation amount T divided by the maximum traversal number K is T1, and the remainder is 0, the current thread executes T1 thread processing;
[0015] If the quotient of the current calculation amount T divided by the maximum traversal number K is T1, and the remainder is not 0, the current thread executes T1+1 thread processing.
[0016] Optionally, in a third implementation of the first aspect of the present invention, after performing multi-threaded scheduling processing on the skill entity array to concurrently release the skills to be processed, the method further includes:
[0017] Obtain target skill data corresponding to the target skill entity from the skill entity array through the index number;
[0018] In response to receiving a modification instruction for the target skill data, data of a corresponding portion of the target skill data in the skill data snapshot is modified.
[0019] Optionally, in a fourth implementation of the first aspect of the present invention, after performing multi-threaded scheduling processing on the skill entity array to concurrently release the skills to be processed, the method further includes:
[0020] Acquire skill result data generated by releasing the skill to be processed;
[0021] Adding the skill result data to a skill result queue;
[0022] In response to the received skill settlement instruction, the skill result data is taken out from the skill result queue, and the skill result data is reported to the main thread to perform skill settlement.
[0023] Optionally, in a fifth implementation of the first aspect of the present invention, the skill to be processed includes the skill entity, the skill entity identifier, the skill identifier, the player user name, the entity identifier of the skill releasing entity, and the skill duration data;
[0024] The skill data includes a releaser identifier, the skill entity identifier, performed time data, the skill duration data and skill configuration data;
[0025] The skill result data includes the releaser identifier, the skill identifier, the skill entity identifier, a target entity identifier, and a target entity index.
[0026] Optionally, in a sixth implementation of the first aspect of the present invention, the acquiring at least one skill to be processed includes:
[0027] Obtain at least one skill release operation instruction, and add the skill operation instructions to a skill to-be-processed queue in order;
[0028] The skill release operation instructions in the skill to-be-processed queue are structured to obtain the to-be-processed skills.
[0029] A second aspect of the present invention further provides a game skill processing device, the game skill processing device comprising:
[0030] An acquisition module, used for acquiring at least one skill to be processed;
[0031] A binding module, used for generating a skill entity based on each of the skills to be processed, and binding the skill entity with the corresponding skill data of the skill to be processed to obtain a skill entity array, wherein the skill data is obtained by reading a skill data snapshot;
[0032] The processing module is used to perform multi-threaded scheduling processing on the skill entity array to concurrently release the skills to be processed.
[0033] The third aspect of the present invention also provides a computer device, which includes: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the computer device executes the game skill processing method as described above.
[0034] A fourth aspect of the present invention further provides a computer-readable storage medium, on which instructions are stored, and when the instructions are executed by a processor, the game skill processing method as described above is implemented.
[0035] The embodiments of the present invention provide a method, device, equipment and storage medium for processing game skills. First, at least one skill to be processed is obtained, then a skill entity is determined based on the skill to be processed, and the skill entity is bound to the skill data of the corresponding skill to be processed to obtain a skill entity array. Finally, the skill entity array is multi-threaded and scheduled to concurrently release the skills to be processed. This method realizes the concurrent processing of game skills by multi-threaded scheduling, can process a large number of game skills at the same time, significantly improves the efficiency of game skill release processing, reduces the probability of freezes and delays, improves the response speed of skills and the balance of processing, is conducive to improving the fluency and interactivity of game skill release, and meets the application requirements of large-scale interactive games. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A flowchart of an embodiment of a method for processing game skills in an embodiment of the present invention;
[0037] Figure 2 For the present invention Figure 1 Embodiment 101 is a flow chart of an embodiment;
[0038] Figure 3 For the present invention Figure 1 Embodiment 103 is a schematic diagram of a process flow of an embodiment;
[0039] Figure 4 For the present invention Figure 1 Embodiment 103 is a flow chart of another embodiment;
[0040] Figure 5 For the present invention Figure 1 A schematic diagram of a process flow of an embodiment following Embodiment 103;
[0041] Figure 6 For the present invention Figure 1 A schematic flow chart of another embodiment following Embodiment 103;
[0042] Figure 7 This is a functional module diagram of an embodiment of a game skill processing device according to an embodiment of the present invention;
[0043] Figure 8 The figure is a functional module diagram of an embodiment of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0044] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0045] For ease of understanding, the specific process of the game skill processing method in the embodiment of the present invention is described below. The game skill processing method of this embodiment is applied to electronic devices, which can be terminals, such as smart phones, laptops, tablet computers, desktop computers, etc., or development boards, chip systems, etc. Please refer to Figure 1 , Figure 1 This is a flow chart of a first embodiment of a method for processing game skills in an embodiment of the present invention. In this embodiment, the method for processing game skills includes:
[0046] 101. Obtain at least one pending skill;
[0047] In this embodiment, pending skills refer to skill operations that have not yet been processed. These skill operations can be generated by player input, clicks, drags, etc., or automatically generated by game logic, such as skill mechanisms triggered by human-machine characters that automatically operate based on preset programs or algorithm models, passive skill mechanisms of player characters and human-machine characters, mechanisms for skill interruption or blocking, and skill gains or losses generated during the game. The skills to be processed are usually selected as skills generated in the same time period or skills selected in the order of generation.
[0048] In this embodiment, the skill to be processed is specifically a structured data object, including a skill entity, a skill entity identifier, a player user name, an entity identifier for releasing the skill, and skill duration data. Among them, the skill entity is an abstract representation used to describe the attributes and behaviors of the skill, the skill entity identifier is used to uniquely identify each skill entity, the skill identifier is used to distinguish different skill types, the player user name is used to identify the skill releaser, the entity identifier for releasing the skill is used to identify the specific role or unit that releases the skill, and the skill duration data represents the duration of the skill. In the game development based on the Unity platform, the skills to be processed can be specifically configured and generated in advance or in real time in the Mono layer, the ECS (Entity Component System) layer or the preset configuration table and other structures. The data of these skills to be processed can be obtained through event monitoring, callback functions, polling mechanisms or active detection, so as to release and process these skills to be processed later.
[0049] In an alternative embodiment, see Figure 2 , obtaining at least one pending skill includes:
[0050] 1011. Obtain at least one skill release operation instruction, and add the skill operation instructions to the skill processing queue in order;
[0051] 1012. Perform structured processing on the skill release operation instructions in the skill pending processing queue to obtain pending skills.
[0052] In this optional embodiment, the skill release operation instruction is an instruction used to describe the player or the in-game character to release a skill. The skill release operation instruction can be triggered by the player operating the corresponding control or connecting the corresponding interface, or can be triggered by the human-machine skill release mechanism, passive skill mechanism, blocking and interruption mechanism, and gain / loss mechanism pre-configured in the game. The skill pending queue is a data structure for temporarily storing skill release operation instructions, which can ensure that the skill release operation instructions are processed in a certain order. For example, the skill pending queue can be a first-in-first-out (FIFO) structure to ensure that the skill operation release instructions are processed in the order in which they are received.
[0053] In this optional embodiment, the instructions in the skill pending queue are structured, which means converting the skill release operation instructions into structured data objects, i.e., the skills to be processed. The structured processing can be implemented by parsing the relevant information in the instructions, such as skill type, target object, and skill parameters, and filling these information into a predefined structured data template. Through this optional embodiment, the data required for the skills to be processed in the instructions are extracted and stored and processed in a unified format, so that the skills to be processed can be obtained effectively and reliably, and then processed later.
[0054] 102. Determine a skill entity based on the skill to be processed, and bind the skill entity to the skill data of the corresponding skill to be processed to obtain a skill entity array, wherein the skill data is obtained by reading a skill data snapshot;
[0055] In this embodiment, the skill data snapshot is a thread-safe encapsulated dictionary. The skill data snapshot is usually set in the main thread and supports multi-threaded reading and writing. The skill data snapshot contains the current skill data of all skill entities. By reading the skill data snapshot, the skill data corresponding to each skill entity can be quickly obtained, ensuring the accuracy and real-time performance of the skill entity array.
[0056] In this embodiment, the skill data of the skill to be processed includes a releaser identifier, a skill entity identifier, elapsed time data, skill duration data, and skill configuration data, wherein the releaser identifier is used to identify the role or unit that releases the skill, the skill entity identifier is used to uniquely identify the business entity skill of each skill entity, and corresponds to the skill entity identifier of the data to be processed, the elapsed time data indicates the time that has passed since the skill was released, the skill duration data indicates the duration of the skill, and the skill configuration data includes various parameters and attributes of the skill, such as damage value, cooling time, and range, etc. By binding these data to the skill entity, it can be ensured that each skill entity can correctly perform its behavior during the game.
[0057] In this embodiment, each skill entity is bound to the skill data of the corresponding skill to be processed to obtain a skill entity array. Through binding, subsequent scheduling only needs to consider the skill entity, and the corresponding skill data can be called and processed accordingly, so that the state and behavior of each skill entity can be quickly and accurately accessed and processed.
[0058] This embodiment can effectively improve the efficiency of data search and selection in the subsequent processing process and improve the response speed and execution efficiency of skills by determining the skill entity and binding the skill entity with the skill data of the skill to be processed. At the same time, since the skill data is obtained based on a thread-safe skill data snapshot, the consistency and real-time nature of the data are ensured, and game anomalies caused by data access conflicts or inconsistencies are avoided. When certain skill data needs to be modified later, it is only necessary to adjust the correspondence between the skill data snapshot and the skill entity, without the need for large-scale modifications to the entire game. It has strong compatibility and can effectively improve the efficiency and accuracy of subsequent processing.
[0059] 103. Perform multi-threaded scheduling on the skill entity array to concurrently release the skills to be processed.
[0060] In this embodiment, multi-threaded scheduling processing utilizes multi-threading technology, and allocates and schedules CPU (Central Processing Unit) resources through the operating system, so that each skill entity in the skill entity array can be processed concurrently, and each thread can independently perform its task to achieve the rapid release of skills. Specifically, the multi-threaded processing method can be a scheduling strategy based on task allocation, by assigning each skill entity in the skill entity array to different threads for processing, each thread is responsible for executing the skill release operation corresponding to the skill entity it is assigned to, thereby concurrently releasing the skills to be processed. In addition, the multi-threaded processing method can also be based on a priority scheduling strategy to sort the skill entities according to the urgency and importance of the skills, and can also be implemented based on a scheduling strategy based on resource consumption, giving priority to those skill entities with lower resource consumption to ensure the smoothness of the game operation.
[0061] In this embodiment, optionally, in the multi-threaded scheduling process, in order to ensure thread safety and data consistency, a lock mechanism can be used to control access to shared resources. For example, a read-write lock (ReadWriteLock) can be used to allow multiple threads to read skill data snapshots at the same time, but exclusive access rights are required when modifying skill data. This can effectively reduce competition between threads and improve the efficiency of concurrent processing. At the same time, in order to further optimize performance, a thread pool (ThreadPool) technology can be used to manage the creation and destruction of threads. The thread pool can create a certain number of threads in advance and keep them in an idle state. When a task needs to be executed, a thread is directly taken out of the thread pool to execute. After the task is completed, the thread returns to the thread pool to wait for the next task. This can avoid the overhead caused by frequent creation and destruction of threads, and can also control the number of concurrent threads to prevent resource competition and system overload caused by too many threads.
[0062] In this embodiment, the multi-thread scheduling process can also adjust and optimize the multi-thread scheduling strategy according to the specific needs of the game and the hardware environment. For example, an adaptive scheduling algorithm can be used in the multi-thread scheduling strategy to dynamically adjust the number of threads and the task allocation strategy according to the current system load. When the system load is low, the number of threads can be increased to make full use of CPU resources and improve the efficiency of skill release; when the system load is high, the number of threads can be reduced to avoid resource competition and system overload, ensuring the stability of the game. At the same time, in order to further improve the response speed and accuracy of skill release, an event-driven mechanism can be introduced. In the event-driven mechanism, each skill entity in the skill entity array can register a corresponding event handler. When a specific event occurs, such as the skill release condition is met or the skill cooldown time ends, the event handler will be triggered to perform the corresponding skill release operation. Through the event-driven mechanism, unnecessary polling and waiting can be reduced, and the response speed and resource utilization of the system can be improved. In addition, the introduction of an asynchronous programming model can also be considered in the multi-thread scheduling process. The asynchronous programming model allows the skill release operation to be asynchronously executed in the background thread, while the main thread can continue to process other tasks, such as user input and interface rendering. This can avoid interface freezes and reduced user experience caused by delays in skill release operations.
[0063] After the above-mentioned multi-threaded scheduling process, this embodiment can realize efficient concurrent release of skills, which can effectively improve the response speed and execution efficiency of skill release, making the game more fluent and interactive. In existing games, single-threaded game skill processing can usually only realize simultaneous processing and release of less than 10 game skills, and the game skill processing of simple skills can reach the existing situation of simultaneous processing and release of more than 10 game skills. The game skill processing method of this embodiment can realize the simultaneous processing and release of hundreds or thousands of game skills on the basis of ensuring thread safety and the certainty of skill release. By continuously optimizing processor performance and adopting more core multi-threaded processors, it can also continuously improve the order of magnitude of game skills processed and released in real time, realize efficient concurrent release of skills, improve the fluency and interactivity of the game, and provide game players with a smoother and more immersive game experience.
[0064] In an alternative embodiment, see Figure 3 , multi-threaded scheduling is performed on the skill entity array to concurrently release the skills to be processed, including:
[0065] 1031. If the quotient of the number of skill entities S in the skill entity array divided by the preset number of threads N is M, and the remainder is 0, M skill entities are allocated to each of the N threads to perform multi-thread scheduling processing;
[0066] 1032. If the quotient of the number of skill entities S in the skill entity array divided by the preset number of threads N is M, and the remainder is not 0, then M skill entities are allocated to each of the N-1 threads, and S-(N-1)×M skill entities are allocated to another thread to perform multi-thread scheduling processing.
[0067] In this optional embodiment, the preset number of threads is a value set based on the actual situation of hardware resources and the actual needs of skill processing. For example, based on a 16-thread processor, the preset number of threads can be 16, or it can be a smaller value. For example, when calling 8 threads can better meet the requirement of the maximum number of skills released simultaneously, the preset number of threads can be set to 8 or a slightly larger value can be used if the hardware resources support it, so as to fully utilize the parallel computing capabilities of multi-threading.
[0068] In this optional embodiment, when the quotient of the number of skill entities S in the skill entity array divided by the preset number of threads N is M and the remainder is 0, the same number of skill entities can be allocated to each thread. For example, if the number of skill entities is 1000 and the preset number of threads is 10, it can be ensured that each thread is allocated to 100 skill entities in the skill entity array for processing, thereby realizing load-balanced multi-threaded processing. When the quotient of the number of skill entities S in the skill entity array divided by the preset number of threads N is M and the remainder is not 0, in order to ensure load balancing between threads, it is necessary to reasonably allocate the remainder. For example, if the number of skill entities is 1003 and the preset number of threads is 10, 100 skill entities can be allocated to 9 of the 10 threads, and the remaining 103 skill entities can be allocated to the 10th thread. In this way, it can be ensured that the load of each thread is relatively balanced when processing skill entities, avoiding performance bottlenecks caused by excessive tasks of some threads.
[0069] In this optional embodiment, it can be understood that when the quotient of the number of skill entities S in the skill entity array divided by the preset number of threads N is M and the remainder is not 0, the skill entities can also be distributed in a manner of allocating M+1 skill entities to each thread in N-1 threads and S-(N-1)×(M+1) skill entities to another thread. For example, 101 skill entities are allocated to 9 of 10 threads, and the remaining 94 skill entities are allocated to the 10th thread. This can also achieve relatively balanced load multi-thread scheduling processing, ensure that the load of each thread when processing skill entities is as balanced as possible, avoid performance bottlenecks caused by too many tasks in some threads, and improve the stability and reliability of game skill processing.
[0070] In an alternative embodiment, see Figure 4 , multi-threaded scheduling processing is performed on the skill entity array to concurrently release the skills to be processed, and also includes:
[0071] 1033. Obtain the maximum traversal number K of the current thread, and determine the current calculation amount T of the current thread, where the current calculation amount T is the number of skill entities allocated to the current thread;
[0072] 1034. If the quotient of the current calculation amount T divided by the maximum traversal number K is T1, and the remainder is 0, the current thread executes T1 thread processing;
[0073] 1035. If the quotient of the current calculation amount T divided by the maximum traversal number K is T1, and the remainder is not 0, the current thread executes T1+1 thread processing.
[0074] In this optional embodiment, the maximum number of traversals is set based on the upper limit of the thread processing capability. For example, if the maximum number of skill entities that a thread can effectively process under a certain hardware environment is 100, then the maximum number of traversals can be set to 100, so that the thread can effectively process a maximum of 100 game skills through one traversal. The current amount of calculation is based on the number of skill entities divided into the current thread in the aforementioned step 1031 or step 1032. By determining the maximum number of traversals K and the current amount of calculation T, data support can be provided for subsequent calculations, ensuring that when processing skill entities, the thread will not waste resources or cause performance bottlenecks due to excessive or insufficient traversal processing times.
[0075] In this optional embodiment, when the quotient of the current calculation amount T divided by the maximum traversal number K is T1 and the remainder is 0, the current thread will perform T1 thread processing. This means that each thread will be processed evenly according to the number of skill entities assigned to it, ensuring the load balancing of each thread. For example, if the number of skill entities assigned to the current thread is 100 and the maximum traversal number is 100, the current thread will perform 1 thread processing to process all assigned skill entities. When the quotient of the current calculation amount T divided by the maximum traversal number K is T1 and the remainder is not 0, the current thread will perform T1+1 thread processing. In this case, in order to process the remaining skill entities, the thread needs to perform an additional processing. For example, if the number of skill entities assigned to the current thread is 151 and the maximum traversal number is 100, the current thread will perform 1 thread processing to process the first 100 skill entities, and then perform the second thread processing to process the remaining 51 skill entities.
[0076] This optional embodiment can ensure that the load of each thread is as balanced as possible when processing skill entities by determining the number of thread processing times based on the maximum number of traversals of the current thread and the current amount of calculation, thereby avoiding performance bottlenecks caused by too many tasks of certain threads. In addition, by reasonably setting the maximum number of traversals, the number of thread processing times can be effectively controlled to avoid waste of resources caused by too many traversals, while ensuring that no performance bottleneck will occur when the thread processes skill entities, thus achieving efficient and balanced multi-threaded skill processing, which not only improves the response speed and execution efficiency of game skill processing, but also ensures the smoothness and interactivity of the game, providing game players with a smoother and more immersive gaming experience.
[0077] In an alternative embodiment, see Figure 5 , after multi-threaded scheduling of the skill entity array to concurrently release the skills to be processed, it also includes:
[0078] 1041. Obtain target skill data corresponding to the target skill entity from the skill entity array through the index number;
[0079] 1042. In response to receiving an instruction to modify the target skill data, modify data of a corresponding portion of the target skill data in the skill data snapshot.
[0080] In this embodiment, the index number is a unique identifier for identifying a specific skill entity in the skill entity array. The target skill entity can be quickly located through the index number, thereby obtaining its corresponding target skill data. This index mechanism makes the access and modification of skill data more efficient, especially in a multi-threaded environment, which can reduce the competition and waiting time between threads, avoid traversing the entire array, and improve the efficiency of data processing.
[0081] In this embodiment, after receiving the modification instruction for the target skill data, the data of the corresponding part in the skill data snapshot is also modified to ensure the consistency and integrity of the data and to meet the modification requirements for the skill. The modification instruction for the target skill data can be initiated by the player or triggered by the game system. It can be an automatic modification determined by preset mechanisms such as game upgrades and monster fighting, or it can be an active modification by the developer to the appearance, triggering method, cooling time and other mechanisms of the skill.
[0082] In this embodiment, the modification is specifically performed in the skill data snapshot, and since the skill data snapshot is a temporary storage structure used to save the state of the skill entity at a certain moment, the modification of the skill data snapshot will not affect the skill entity data being processed. In this way, even in a concurrent environment, it can be ensured that the modification operation of the skill data will not cause data conflicts or inconsistencies, and it can be ensured that each thread will not interfere with each other when modifying the data, thereby ensuring the correctness and stability of the data, and then synchronizing it to the skill mechanism of the game when the subsequent thread is idle, ensuring that all threads can access the latest data when processing the skill entity, avoiding errors and exceptions caused by data asynchrony.
[0083] In an alternative embodiment, see Figure 6 , after multi-threaded scheduling of the skill entity array to concurrently release the skills to be processed, it also includes:
[0084] 1051. Obtain skill result data generated by releasing the pending skill;
[0085] 1052. Add the skill result data to the skill result queue;
[0086] 1053. In response to the received skill settlement instruction, the skill result data is taken out from the skill result queue, and the skill result data is reported to the main thread for skill settlement.
[0087] In this optional embodiment, the skill result data refers to the result information generated after the concurrent release of the pending skills, and the skill result data includes a releaser identifier, a skill identifier, a skill entity identifier, a target entity identifier, and a target entity index, etc., wherein the releaser identifier is used to identify the entity that releases the skill, the skill identifier is used to identify the type of skill being released, the skill entity identifier is used to identify the entity corresponding to the released skill, the target entity identifier is used to identify the target entity of the skill, and the target entity index is used to identify the position, state, or position of the target entity in the game world in a specific data form. Through this information, the process and result of a skill release can be fully described.
[0088] In this optional embodiment, after the skill result data is generated, it will be added to the skill result queue. The skill result queue is a thread-safe temporary storage structure for temporarily storing skill result data, which can support multi-threaded writing and ensure that the skill result data can be processed in an orderly manner in a multi-threaded environment. By using a queue as a data structure, it can be ensured that the processing order of the skill result data is consistent with the order of skill release, avoiding data confusion caused by concurrent processing. After the skill result queue obtains all the skill result data of a single thread, it can be synchronized to the main thread in order according to timing, priority and resource occupancy, and corresponding settlement processing can be performed.
[0089] In this optional embodiment, when a skill settlement instruction is received, the corresponding skill result data will be taken out from the skill result queue and reported to the main thread for settlement processing. Among them, the skill settlement instruction can be triggered by the game system at a fixed time, or it can be caused by player operation or other game events. The skill settlement process includes the final confirmation of the skill effect, the calculation of resource consumption, and the update of the target state, etc., to ensure that the skill release behavior in the game world can get correct feedback and processing. Ensure the accuracy and consistency of the settlement process to avoid data conflicts and inconsistencies caused by concurrent processing.
[0090] The settlement method based on skill result data described above in this optional embodiment effectively separates the processing and settlement of skill result data, ensuring the efficiency and stability of multi-threaded scheduling. At the same time, the main thread can obtain the results of skill execution in a timely manner, ensuring the correctness of the game logic and the fluency of the player experience. In addition, the design of the skill result queue can also cope with the data processing requirements in high-concurrency scenarios, avoiding the performance bottleneck caused by the main thread processing a large amount of skill result data, and can process a large number of game skills at the same time, significantly improving the efficiency of game skill release processing, reducing the probability of freezes and delays, and improving the response speed of skills and the balance of processing, which is conducive to improving the fluency and interactivity of game skill release and meeting the application requirements of large-scale interactive games.
[0091] In order to execute the corresponding steps in the above method embodiment and each possible implementation method, the following provides an implementation method of a game skill processing device. Figure 7 , Figure 7 This is a functional module diagram of an embodiment of a game skill processing device in an embodiment of the present invention. In this embodiment, the game skill processing device is applied to an electronic device, and the game skill processing device includes:
[0092] An acquisition module 201 is used to acquire at least one skill to be processed;
[0093] A binding module 202 is used to determine a skill entity based on the skill to be processed, and bind the skill entity with the skill data of the corresponding skill to be processed to obtain a skill entity array, wherein the skill data is obtained by reading a skill data snapshot;
[0094] The processing module 203 is used to perform multi-threaded scheduling processing on the skill entity array to concurrently release the skills to be processed.
[0095] Optionally, in one embodiment, the acquisition module 201 is further specifically used to: acquire at least one skill release operation instruction, and add the skill operation instruction to the skill pending processing queue in sequence; perform structured processing on the skill release operation instruction in the skill pending processing queue to obtain the pending skills.
[0096] Optionally, in one embodiment, the processing module 203 is further configured to: if the quotient of the number of skill entities S in the skill entity array divided by the preset number of threads N is M, and the remainder is 0, then M skill entities are allocated to each thread in the N threads to perform multi-thread scheduling processing; if the quotient of the number of skill entities S in the skill entity array divided by the preset number of threads N is M, and the remainder is not 0, then M skill entities are allocated to each thread in the N-1 threads, and S-(N-1)×M skill entities are allocated to another thread to perform multi-thread scheduling processing;
[0097] Optionally, in one embodiment, the processing module 203 is specifically used to: obtain the maximum traversal number K of the current thread, and determine the current calculation amount T of the current thread, wherein the current calculation amount T is the number of skill entities allocated to the current thread; if the quotient of the current calculation amount T divided by the maximum traversal number K is T1, and the remainder is 0, then the current thread executes T1 thread processing; if the quotient of the current calculation amount T divided by the maximum traversal number K is T1, and the remainder is not 0, then the current thread executes T1+1 thread processing.
[0098] Optionally, in one embodiment, the processing module 203 is further specifically used to: obtain target skill data corresponding to the target skill entity from the skill entity array through the index number; in response to receiving an instruction to modify the target skill data, modify the data of the corresponding part of the target skill data in the skill data snapshot.
[0099] Optionally, in one embodiment, the processing module 203 is specifically used to: obtain the skill result data generated by releasing the skill to be processed; add the skill result data to the skill result queue; in response to the received skill settlement instruction, take the skill result data out of the skill result queue, and report the skill result data to the main thread for skill settlement.
[0100] Optionally, in the game skill processing device, the skill to be processed includes a skill entity, a skill entity identifier, a skill identifier, a player user name, an entity identifier that releases the skill, and skill duration data; the skill data includes a releaser identifier, a skill entity identifier, elapsed time data, skill duration data, and skill configuration data; the skill result data includes a releaser identifier, a skill identifier, a skill entity identifier, a target entity identifier, and a target entity index.
[0101] Since the embodiments of the device part correspond to the embodiments of the above-mentioned method, please refer to the above-mentioned method embodiments for the introduction of the game skill processing device provided by the embodiments of the present invention. The embodiments of the present invention will not be repeated here, and it has the same beneficial effects as the above-mentioned game skill processing method.
[0102] The present invention also provides a computer device, which includes a memory and a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor executes the game skill processing method as described above. Figure 8 3 is a functional module diagram of a computer device provided by an embodiment of the present invention. The computer device 300 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 310 (for example, one or more processors) and a memory 320, and one or more storage media 330 (for example, one or more mass storage devices) storing application programs 333 or data 332. Among them, the memory 320 and the storage medium 330 may be temporary storage or permanent storage. The program stored in the storage medium 330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the computer device 300. Furthermore, the processor 310 may be configured to communicate with the storage medium 330 to execute a series of instruction operations in the storage medium 330 on the computer device 300.
[0103] The computer device 300 may also include one or more power supplies 340, one or more wired or wireless network interfaces 350, one or more input and output interfaces 360, and / or one or more operating systems 331, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Figure 8 The illustrated computer device structure does not constitute a limitation on the computer device, and may include more or fewer components than illustrated, or combine certain components, or arrange the components differently.
[0104] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the game skill processing method as described above.
[0105] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. If the integrated module or unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0106] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for processing game skills, characterized in that: include: Get at least one pending skill; Determine a skill entity based on the skill to be processed, and bind the skill entity with the corresponding skill data of the skill to be processed to obtain a skill entity array, wherein the skill data is obtained by reading a skill data snapshot; Multi-threaded scheduling is performed on the skill entity array to concurrently release the skills to be processed.
2. The game skill processing method according to claim 1, characterized in that: The multi-threaded scheduling process is performed on the skill entity array to concurrently release the skills to be processed, including: If the quotient of the number S of the skill entities in the skill entity array divided by the preset number of threads N is M, and the remainder is 0, then M skill entities are allocated to each of the N threads to perform the multi-thread scheduling process; If the quotient of the number S of the skill entities in the skill entity array divided by the preset number of threads N is M, and the remainder is not 0, then M of the skill entities are allocated to each of the N-1 threads, and S-(N-1)×M of the skill entities are allocated to another thread to perform the multi-thread scheduling processing.
3. The game skill processing method according to claim 2, characterized in that: The multi-threaded scheduling process is performed on the skill entity array to concurrently release the skills to be processed, and further includes: Obtaining the maximum traversal number K of the current thread, and determining the current calculation amount T of the current thread, wherein the current calculation amount T is the number of the skill entities divided into the current thread; If the quotient of the current calculation amount T divided by the maximum traversal number K is T1, and the remainder is 0, the current thread executes T1 thread processing; If the quotient of the current calculation amount T divided by the maximum traversal number K is T1, and the remainder is not 0, the current thread executes T1+1 thread processing.
4. The game skill processing method according to claim 3, characterized in that: After performing multi-thread scheduling processing on the skill entity array to concurrently release the skills to be processed, the method further includes: Obtain target skill data corresponding to the target skill entity from the skill entity array through the index number; In response to receiving a modification instruction for the target skill data, data of a corresponding portion of the target skill data in the skill data snapshot is modified.
5. The game skill processing method according to claim 1, characterized in that: After performing multi-thread scheduling processing on the skill entity array to concurrently release the skills to be processed, the method further includes: Acquire skill result data generated by releasing the skill to be processed; Adding the skill result data to a skill result queue; In response to the received skill settlement instruction, the skill result data is taken out from the skill result queue, and the skill result data is reported to the main thread to perform skill settlement.
6. The game skill processing method according to claim 5, characterized in that: The skill to be processed includes the skill entity, skill entity identifier, skill identifier, player username, entity identifier of the skill releasing entity and skill duration data; The skill data includes a releaser identifier, the skill entity identifier, performed time data, the skill duration data and skill configuration data; The skill result data includes the releaser identifier, the skill identifier, the skill entity identifier, a target entity identifier, and a target entity index.
7. The game skill processing method according to any one of claims 1 to 6, characterized in that: The acquiring of at least one skill to be processed comprises: Obtain at least one skill release operation instruction, and add the skill operation instructions to a skill to-be-processed queue in order; The skill release operation instructions in the skill to-be-processed queue are structured to obtain the to-be-processed skills.
8. A game skill processing device, characterized in that: The game skill processing device comprises: An acquisition module, used for acquiring at least one skill to be processed; A binding module, used for generating a skill entity based on each of the skills to be processed, and binding the skill entity with the corresponding skill data of the skill to be processed to obtain a skill entity array, wherein the skill data is obtained by reading a skill data snapshot; The processing module is used to perform multi-threaded scheduling processing on the skill entity array to concurrently release the skills to be processed.
9. A computer device, characterized in that: The computer device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory to enable the computer device to execute the game skill processing method according to any one of claims 1-7.
10. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed by the processor, the game skill processing method as described in any one of claims 1-7 is implemented.