A method and system for skill realization
The callback function of the skill is registered in the game through the event dispatcher, the triggering event is distributed, and the triggering effect of the skill is determined based on the callback function, which solves the problems of complex skill implementation process and code coupling in the existing technology, and realizes skill-related code decoupling and simplification.
Patent Information
- Application Number
- CN202110127368.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-29
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-01-29
AI Technical Summary
The skill implementation process in the existing technology is too complex and the codes are tightly coupled, making it difficult to call.
Register the callback function of the skill in the trigger event through the event dispatcher, distribute the trigger event, determine the trigger effect of the skill based on the callback function, and decouple the skill-related code and the trigger event code.
It simplifies the skill implementation process, decouples code, and improves the convenience and callability of skill implementation.
Smart Images

Figure CN112827178B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of game development and design, and in particular to a method and system for realizing skills. Background Art
[0002] Skills are a common game mechanism in role-playing games and multiplayer online tactical competitive games. Different games have different skill implementation methods based on their own game mechanisms.
[0003] In related technologies, the mechanism for implementing skills is generally simple, and usually a hard-coded method is used to trigger the skills. However, in this process, the code that triggers the skill event and the skill-related code are closely coupled, and there are many connections between the two, making it inconvenient to call. In addition, it also makes the skill implementation process too complicated.
[0004] Currently, no effective solution has been proposed to address the problem that the process of skill realization in related technologies is too complicated. Summary of the invention
[0005] The embodiments of the present application provide a method, apparatus, system, computer device, and computer-readable storage medium for realizing a skill, so as to at least solve the problem that the process of realizing the skill in the related art is too complicated.
[0006] In a first aspect, an embodiment of the present application provides a method for realizing a skill, the method comprising:
[0007] Acquire resource information of a game object, and create a distributor for the game object based on the resource information, wherein the resource information includes: a first skill, a second skill, and a trigger event;
[0008] registering the callback function of the first skill in the trigger event through the distributor, and distributing the trigger event when the trigger condition is met;
[0009] When the receiving end of the second skill receives the trigger event, the virtual character executes the instruction corresponding to the second skill;
[0010] The distributor calls the callback function and determines the triggering effect of the first skill according to the callback function.
[0011] In some embodiments, after creating a distributor for the resource information and before registering a callback function of the first skill in the trigger event through the distributor, the method further includes:
[0012] Determine whether there is any association information between the first skill and the triggering event;
[0013] In the case where the association information exists, the distributor registers the callback function of the first skill in the trigger event;
[0014] In the case where the association information does not exist, the distributor does not register the callback function of the first skill in the trigger event.
[0015] In some embodiments, after instructing the virtual character to execute the instruction corresponding to the second skill, the method further includes:
[0016] The distributor searches for a callback function of the first skill;
[0017] If the callback function of the first skill is not found, the client does not issue an instruction to the virtual character to execute the first skill.
[0018] In some embodiments, the distributor calls the callback function and determines the triggering effect of the first skill according to the callback function, including:
[0019] In a case where the callback function includes the trigger information of the first skill, instructing the virtual character to execute an instruction corresponding to the first skill;
[0020] If the callback function does not include the trigger information of the first skill, the first skill is not triggered.
[0021] In some embodiments, after creating a distributor for resource information, the method further includes:
[0022] After registering the calling object in the trigger event through the distributor, the trigger event is distributed when the trigger condition is met;
[0023] After the receiving end of the second skill receives the trigger event and releases it, the calling object is called through the distributor.
[0024] In some embodiments, after determining the triggering effect of the first skill according to the callback function, the method further includes:
[0025] The configuration requirement is accepted through a configuration interface, and the distributor is instructed to cancel the registration of the callback function and the calling object of the triggering event according to the configuration requirement.
[0026] In a second aspect, an embodiment of the present application provides a system for realizing skills, the system comprising: an acquisition creation module, a distribution module and a receiving module;
[0027] The acquisition creation module is used to acquire resource information of the game object and create a distributor for the game object based on the resource information, wherein the resource information includes: a first skill, a second skill and a trigger event;
[0028] The distribution module is used to register the callback function of the first skill in the trigger event through the distributor, and distribute the trigger event when the trigger condition is met, or,
[0029] Used to call the callback function through the distributor and determine the triggering effect of the first skill according to the callback function;
[0030] The receiving module is used to instruct the virtual character to execute the instruction corresponding to the second skill when the trigger event is received at the receiving end of the second skill.
[0031] In some embodiments, the acquisition creation module is also used to determine whether there is association information between the first skill and the trigger event after creating a distributor for the resource information and before registering the callback function of the first skill in the trigger event through the distributor; if the association information exists, the distributor registers the callback function of the first skill in the trigger event; if the association information does not exist, the distributor does not register the callback function of the first skill in the trigger event.
[0032] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, a skill realization method as described in the first aspect above is implemented.
[0033] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a skill realization method as described in the first aspect above.
[0034] Compared with the related art, the method for realizing a skill provided by the embodiment of the present application decouples the skill-related code and the trigger event code through event distribution; specifically, the method includes: registering the callback function of the first skill in the trigger event through the distributor, distributing the trigger event; when the receiving end of the second skill receives the trigger event, instructing the virtual character to execute the instruction corresponding to the second skill; at the same time, the distributor calls the callback function and determines the trigger effect of the first skill according to the callback function. The problem that the process of realizing skills in the related art is too complicated and difficult to call is solved, and the skill-related code is decoupled from the trigger event code, simplifying the process of realizing skills. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0036] Figure 1 is a schematic diagram of an application environment of a skill realization method according to an embodiment of the present application;
[0037] Figure 2 is a flow chart of a skill realization method according to an embodiment of the present application;
[0038] Figure 3 is a structural block diagram of a skill realization system according to an embodiment of the present application;
[0039] Figure 4 It is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0041] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.
[0042] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0043] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0044] The method for realizing a skill provided by the present application can be applied to Figure 1 In the application environment shown, Figure 1 is a schematic diagram of an application environment of a skill realization method according to an embodiment of the present application, such as Figure 1 As shown, the terminal 10 communicates with the server 11 through the network, and the terminal 10 uploads the data generated by the game client to the server 11. At the same time, the server 11 obtains data from other terminals 10; in addition, the terminal 10 is installed with an application for skill realization that runs this embodiment. Users can interact with virtual game characters in the application through external devices such as touch screens, physical buttons, keyboards and mice on the terminal 10, such as releasing skills, releasing secrets, and moving physical characters. Through this embodiment, the skill code part and the trigger event code part in the skill realization process can be decoupled, thereby simplifying the skill realization process. Furthermore, the terminal 10 can be a smart phone, a tablet computer, a desktop computer, a laptop computer, and a smart wearable device. The server 11 can be an independent server or a server cluster composed of multiple servers.
[0045] This application provides a method for skill realization. Figure 2 is a flow chart of a skill realization method according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0046] Step S201, obtain resource information of the game object, and create a distributor for the game object based on the resource information, wherein the resource information includes: a first skill, a second skill and a trigger event; wherein the first skill and the second skill can be obtained by directly reading from the local memory, or through the network. The first skill and the second skill are a series of game events executed by the game system. Under certain prerequisites, the game event can instruct the game character to trigger a specific effect in the game scene. This effect can be a combination of one or more effects such as displacement, control and gain of the game character. Further, the trigger event can be one of the prerequisites; it can be understood that during the running of the game program, when the receiving end of a skill receives the corresponding trigger event, the skill is triggered or released, and a specific effect is triggered at the same time. Further, when this specific effect is triggered, the skill is released;
[0047] Step S202, after registering the callback function of the first skill in the trigger event through the distributor, the trigger event is distributed; in this embodiment, the distributor is defined according to actual needs, and its specific implementation steps have no core impact on this embodiment, so the comparison is not repeated; it should be noted that before executing this step, it is first necessary to determine whether there is association information between the first skill and the trigger event; further, if the association information exists, the distributor registers the callback function of the first skill in the trigger event; if the association information does not exist, the distributor does not register the callback function of the first skill in the trigger event;
[0048] Step S203, when the receiving end of the second skill receives a trigger event, instruct the virtual character to execute the instruction corresponding to the second skill; optionally, both the first skill and the second skill include independent code parts, wherein the receiving end is used to receive information such as the trigger event; further, after receiving the trigger event and the second skill is released, the virtual character is instructed to execute the instruction included in the second skill, for example, the skill description of the second skill is to move a preset distance in the virtual map or to increase the moving speed and perform an enhanced version of a normal attack, and correspondingly, the virtual character presents a corresponding action state in the game scene;
[0049] In step S204, the distributor calls the callback function and determines the triggering effect of the first skill according to the callback function; it should be noted that in step S201, it is described that the callback function of the first skill is determined by searching for associated information to determine whether to register the triggering event. Correspondingly, here, the callback function is called and the first skill is determined according to the callback function. It can be understood that if the callback function can be found, the first skill is triggered; if the callback function is not found, that is, if the callback function of the first skill is not registered for the triggering event in step S201, the first skill is not triggered.
[0050] Through the above steps S201 to S204, compared with the method of implementing skills by hard coding in the related art, this embodiment registers a callback function for the trigger event of the first skill through a distributor. In the game, when the trigger conditions are met, the trigger event is distributed through the distributor, and the second skill is released after receiving the trigger event. Finally, the trigger effect of the first skill is judged by the callback function. The problem that the skill code and the trigger event code are coupled with each other in the related art, resulting in an overly complicated skill implementation process, is solved. For example, in the related art, the trigger event of the first skill needs to trigger another skill held by the player character, namely the second skill. In this case, the first skill must first obtain the player character object, and then trigger the second skill through the player character. Then there is coupling between the first skill, the second skill and the trigger event, resulting in a more complicated skill implementation process. In this embodiment, the trigger event and the specific skill are decoupled by the distributor. In the skill triggering process, it is not necessary to know the specific skill. As long as the trigger event is distributed through the distributor, whether it is triggered is determined according to the callback function registered to the first skill.
[0051] In one embodiment, after the resource information creates a distributor, before the distributor registers the callback function of the first skill in the trigger event, it is determined whether there is associated information between the first skill and the trigger event; if the associated information exists, the distributor registers the callback function of the first skill in the trigger event; if the associated information does not exist, the distributor does not register the callback function of the first skill in the trigger event.
[0052] In one embodiment, after instructing the virtual character to execute the instruction corresponding to the second skill, it can be determined whether to trigger the first skill based on whether the callback function of the first skill can be found. The distributor searches for the callback function of the first skill; if the callback function of the first skill is not found, the distributor does not send information to the client to trigger the first skill.
[0053] In one embodiment, it is also possible to determine whether to trigger the first skill based on the specific content of the callback function. The distributor calls the callback function and determines the triggering effect of the first skill based on the callback function, including: when the callback function includes the triggering information of the first skill, the client instructs the virtual character to execute the instruction corresponding to the first skill; when the callback function does not include the triggering information of the first skill, the first skill is not triggered.
[0054] In one embodiment, after creating a distributor for resource information, the distributor can also register a call object in the trigger event and distribute the trigger event; after the receiving end of the second skill receives the trigger event and releases it, the distributor calls the call object. Optionally, the client accepts the configuration requirement through the configuration interface and instructs the distributor to cancel the registration of the callback function and the call object of the trigger event according to the configuration requirement.
[0055] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0056] This embodiment also provides a skill realization system, which is used to realize the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. As used below, the terms "module", "unit", "subunit", etc. can be a combination of software and / or hardware that realizes a predetermined function. Although the devices described in the following embodiments are preferably realized by software, the realization by hardware, or a combination of software and hardware, is also possible and conceivable.
[0057] Figure 3 is a structural block diagram of a skill realization system according to an embodiment of the present application, such as Figure 3 As shown, the system includes an acquisition creation module 31, a distribution module 32 and a receiving module 33;
[0058] The acquisition creation module 31 is used to acquire resource information of the game object and create a distributor for the game object based on the resource information, wherein the resource information includes: a first skill, a second skill and a trigger event;
[0059] The distribution module 32 is used to register the callback function of the first skill in the trigger event through the distributor, and distribute the trigger event when the trigger condition is met, or,
[0060] Used to call the callback function through the distributor and determine the triggering effect of the first skill according to the callback function;
[0061] The receiving module 33 is used to instruct the virtual character to execute the instruction corresponding to the second skill when the receiving end of the second skill receives a trigger event.
[0062] In one embodiment, the acquisition creation module 31 is also used to determine whether there is associated information between the first skill and the trigger event after creating a distributor for resource information and before registering the callback function of the first skill in the trigger event through the distributor; if the associated information exists, the distributor registers the callback function of the first skill in the trigger event; if the associated information does not exist, the distributor does not register the callback function of the first skill in the trigger event.
[0063] In one embodiment, a computer device is provided, which may be a terminal. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for realizing a skill is implemented. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or a key, trackball, or touchpad provided on the housing of the computer device, or an external keyboard, touchpad, or mouse, etc.
[0064] In one embodiment, Figure 4 is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application, such as Figure 4 As shown, an electronic device is provided, which may be a server, and its internal structure diagram may be as shown in Figure 4 As shown. The electronic device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the electronic device is used to store data. The network interface of the electronic device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for realizing a skill is implemented.
[0065] Those skilled in the art will understand that Figure 4The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0066] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0067] Those skilled in the art should understand that the technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0068] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for realizing a skill, characterized in that: The method comprises: Acquire resource information of a game object, and create a distributor for the game object based on the resource information, wherein the resource information includes: a first skill, a second skill, and a trigger event; Determine whether there is any association information between the first skill and the triggering event; In the case where the association information exists, the distributor registers a callback function of the first skill in the trigger event; In the case where the association information does not exist, the distributor does not register the callback function of the first skill in the trigger event; registering the callback function of the first skill in the trigger event through the distributor, and distributing the trigger event when the trigger condition is met; When the receiving end of the second skill receives the trigger event, the virtual character executes the instruction corresponding to the second skill; The distributor calls the callback function and determines the triggering effect of the first skill according to the callback function, wherein the distributor decouples the triggering event from the specific skill, and during the skill triggering process, it is not necessary to know the specific associated skills.
2. The method according to claim 1, characterized in that After instructing the virtual character to execute the instruction corresponding to the second skill, the method further includes: The distributor searches for a callback function of the first skill; If the callback function of the first skill is not found, the client does not issue an instruction to the virtual character to execute the first skill.
3. The method according to claim 1, characterized in that The distributor calling the callback function and determining the triggering effect of the first skill according to the callback function includes: In a case where the callback function includes the trigger information of the first skill, instructing the virtual character to execute an instruction corresponding to the first skill; If the callback function does not include the trigger information of the first skill, the first skill is not triggered.
4. The method according to claim 1, characterized in that After creating a distributor for resource information, the method further includes: After registering the calling object in the trigger event through the distributor, the trigger event is distributed when the trigger condition is met; After the receiving end of the second skill receives the trigger event and releases it, the calling object is called through the distributor.
5. The method according to claim 4, characterized in that After determining the triggering effect of the first skill according to the callback function, the method further includes: The configuration requirement is accepted through a configuration interface, and the distributor is instructed to cancel the registration of the callback function and the calling object of the triggering event according to the configuration requirement.
6. A system for skill realization, characterized in that: The system comprises: an acquisition creation module, a distribution module and a receiving module; The acquisition creation module is used to acquire resource information of the game object and create a distributor for the game object based on the resource information, wherein the resource information includes: a first skill, a second skill and a trigger event; Determine whether there is any association information between the first skill and the triggering event; In the case where the association information exists, the distributor registers a callback function of the first skill in the trigger event; In the case where the association information does not exist, the distributor does not register the callback function of the first skill in the trigger event; The distribution module is used to register the callback function of the first skill in the trigger event through the distributor, and distribute the trigger event when the trigger condition is met, or, for calling the callback function through the distributor and determining the triggering effect of the first skill according to the callback function, wherein the distributor decouples the triggering event from the specific skill, and in the skill triggering process, it is not necessary to know the specific associated skills; The receiving module is used to instruct the virtual character to execute the instruction corresponding to the second skill when the trigger event is received at the receiving end of the second skill.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, a skill realization method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, a skill realization method as claimed in any one of claims 1 to 5 is implemented.
