Incidencia #44085

custom actions

Abrir Fecha: 2022-03-13 01:38 Última actualización: 2022-04-17 19:19

Informador:
Propietario:
(Ninguno)
Estado:
Open
Componente:
Hito:
(Ninguno)
Prioridad:
5 - Medium
Gravedad:
5 - Medium
Resolución:
Ninguno
Fichero:
Ninguno

Details

i saw that there wasn't a ticket so i thought i should add one for the people that only browse here at OSDN. the idea is that the ruleset can define actions, those actions can be only a placeholder to call lua events and they would already be immensely useful. to lessen boilerplate lua code we could add a new function signal.action_connect which receives a action name to connect, a sucess callback and optionally a failure callback. in the action section of the ruleset we could also define all other actions settings, like range , target type, ui name, basically all action specific settings would go in this section. ideally all actions would be changed to be in the ruleset, however to start we should create the possibility to add actions in the ruleset, and only after that start unhardcoding actions.

In a issue in hostedredmine there also was a suggestion of multi-actions. the idea of multi-actions is that actions are created based on effects that are composed together. so a ruleset creator could potentially create most of the sane possible actions without lua code. example: a action called Explode Mini Nuke could have a target type of Tile and a success_effect field with
{"type", "value"
"Create Extra","Fallout"
"Kill Units","All"
}
so if this were implemented , actions would be similar to effects, created from a list of possible ones and a value(or multiple)

Another thing that could be done is add a field called formula(or something similar) in which the ruleset creator provides a string in which words have specific meaning to create a formula for the probability, generating a number, with any between 0 and 1 being a probabilty and <0 impossible. and =>1 certain sucess example: A formula like "tanh(10*tcities*ttechs)" would generate a probability that approaches 100% as the cities of the target and their technology count increase. another example:"tanh((aattack+afirepower)/tdefense)" would be a formula for a action with target type unit

Both the formula field and the multi-actions may be unneded as lua could implement them with callback functions, and unlike effects lua code can probably do everything a action created by multi-actions could do, although i may be wrong on this, and i don't know how hard they would be to implement, but if they are easy to implement i will probably personally submit a patch.

basically my long term plan is to unhardcode all current and future actions.

Ticket History (3/14 Histories)

2022-03-13 01:38 Updated by: dark-ether
  • New Ticket "custom actions" created
2022-03-13 01:49 Updated by: dark-ether
  • Details Updated
2022-03-13 02:04 Updated by: cazfi
Comentario

Note that we already have "User Actions" that are to be implemented in lua. You should probably be extending/refactoring their functionality, e.g., by first rearranging their ruleset representation (section of their own for each of them), then maybe by increasing their number (this is something I just had a brief look about, for the future plans, when I added just one slot for S3_1: #44079)

2022-03-13 08:10 Updated by: dark-ether
Comentario

Reply To cazfi

Note that we already have "User Actions" that are to be implemented in lua. You should probably be extending/refactoring their functionality, e.g., by first rearranging their ruleset representation (section of their own for each of them), then maybe by increasing their number (this is something I just had a brief look about, for the future plans, when I added just one slot for S3_1: #44079)

yeah i know about user actions, but personally i think adding more user actions is a fool's errand someone will always need more and most rulesets won't need them , so we will not only waste memory for most rulesets but we also won't attend the needs of some people.

in my opinion what should be done is to allow a arbitrary number of user actions, to do that i plan to split the actions in two types hardcoded ones and custom, the custom action list will be a speclist on action structs.they may need to be altered to accommodate. and then action_iterate should be changed to also iterate over this list. Should i add a new macro for only the hardcoded ones in case someone may need to iterate over all actions when the ruleset isn't loaded? i can't imagine a situation it would be useful for. the lua api probably will also need to be changed, i just i am not sure in what way as i haven't looked too much in common/scriptcore and server/scripting.

i agree with you that actions and action enablers may need a new file for them.

also only somewhat related to the discussion but is there any way to separate the files for the lua code? i don't know of one, and if for instance someone uses user action one for a different action for each unit creating a massive switch block, is there a way of putting some of the functions the switch calls in files other than default.lua?

(Edited, 2022-03-13 08:51 Updated by: dark-ether)
2022-03-13 08:21 Updated by: cazfi
Comentario

Reply To dark-ether

... i think adding more user actions is a fool's errand ... ... in my opinion what should be done is to allow a arbitrary number of user actions ...

Naturally part of the plan is to support arbitrary number of user actions, added to the same list after the internal ones.

2022-03-14 00:14 Updated by: dark-ether
Comentario

what is your opinion for multi-actions and formulas, if we unhardcode actions what probably would be done is splitting each action in subcomponents and storing each subcomponent in the action, that would probably help immensely in allowing multi-actions, formulas would probably need their own parser to evaluate the formula.

2022-03-20 12:10 Updated by: cazfi
Comentario

As the very first preparatory step, you should now implement #44103, which should be quite trivial. It's also a dependency to several other things currently boiling (that's why it's needed also for S3_1 while your user actions will take place in master only).

Then we should take a look at setting up new actions.ruleset. If we are going to introduce new ruleset sections/fields related to actions now, I definitely want them in the new ruleset from the beginning. That will save us a ton of work later (no need to do the migration for them, possibly with ruleset compatibility code to handle the update between versions that have the information in different files). We have some tickets about this already - I'll check and adjust them for the User Actions improvements plan.

2022-03-23 13:40 Updated by: cazfi
  • Componente Update from Rulesets to General
2022-03-25 04:53 Updated by: dark-ether
Comentario

Reply To cazfi

As the very first preparatory step, you should now implement #44103, which should be quite trivial. It's also a dependency to several other things currently boiling (that's why it's needed also for S3_1 while your user actions will take place in master only). Then we should take a look at setting up new actions.ruleset. If we are going to introduce new ruleset sections/fields related to actions now, I definitely want them in the new ruleset from the beginning. That will save us a ton of work later (no need to do the migration for them, possibly with ruleset compatibility code to handle the update between versions that have the information in different files). We have some tickets about this already - I'll check and adjust them for the User Actions improvements plan.

when you mentioned this i was already working on a patch, i did what you asked but i also have other changes and want to send my patch when it is final(not exactly as i won't be implementing ruleset defined actions in this one), to do that, i need to remove all instances of NUM_ACTIONS and MAX_NUM_ACTIONS ,as i have changed the internal representation of actions, the mentions i found with ripgrep were mostly arrays and a few iterating loops, for the arrays i want to substitute them for something that can have a variable size,but i don't want to create speclists for gen_action enums and action_id, ideally it would be something already in the project that can handle multiple ints and needs only to change the declaration line and add a destruction statement ,is there a data structure which we are including which does that ? if not how should i store a variable number of ints? i know that with pointers there is realloc, so worst case scenario i create a dynamic array struct from scratch and associated functions. for the loops i will need to include game.h in each file which wants to iterate over all actions , will that be a problem? or should i change it from actions being in the single game global object to at least 2 global objects, the actions global object and the game global object. about separating the actions section in their own section, i probably would do that when i start working on the ruleset, this patch i am making now is for changing the internal representation of actions(from a array to a speclist) to accommodate future changes.

2022-03-28 04:40 Updated by: cazfi
Comentario

Reply To dark-ether

when you mentioned this i was already working on a patch, i did what you asked but i also have other changes and want to send my patch when it is final

The very first thing I said when you told that you're starting to work on this was: "In any case, don't start implementing single huge patch."

E.g. we need #44103 separately also for the reason that it's going to both master and S3_1, unlike the rest of your work that is expected for master only. As for the rest - if you do it as a one patch at first, it's very likely that you need to split it up afterwards, which can be much harder to do than doing it one step at a time from the beginning.

2022-03-28 19:55 Updated by: dark-ether
  • Componente Update from General to Rulesets
Comentario

ok i will have to agree with you, as it stands now my code compiles and doesn't seem to introduce bugs so i may as well submit it, but my work is dependent on #44084, do i edit that ticket to a new scope or do i add a new ticket and reference the other one in that one? and if so do i reinclude the needed patches? like, i have 9 commits , 2 are already submitted on the mentioned ticket, in the new ticket i add, only the 7 new commits or do i add all 9? also, unrelated but i added a patch to #44103 you may want to check if it is adequate.

2022-03-30 18:37 Updated by: cazfi
Comentario

Could e.g. alienvalkyrie check this work in a more timely manner than I? If not, I will get to it, eventually.

2022-03-30 22:45 Updated by: alienvalkyrie
Comentario

Reply To cazfi

Could e.g. alienvalkyrie check this work in a more timely manner than I? If not, I will get to it, eventually.

I'll see if I can take a look

2022-04-17 19:19 Updated by: cazfi
Comentario

Sorry for being ignorant here, but I've really had no time to follow how the overall situation progressed. I promised earlier to create some kind of roadmap / meta-ticket for the actions.ruleset creation. Is that urgently needed?

Attachment File List

No attachments

Editar

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Entrar