Custom actions

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Post Reply
eldritch_cookie
Posts: 22
Joined: Sat Mar 05, 2022 6:41 pm

Custom actions

Post by eldritch_cookie »

The idea is really simple, allow action enablers to define any string as an action. the custom action by itself happens and then does nothing, what is useful about this is that the action would call the appropriate lua event with the proper argument. My particular use case is that in the ruleset i am creating there are worker-like units that aren't workers and workers are available to some civilizations with their default actions so i can't just repurpose those, so one use case would be to create variants of already existing actions without changing the original. Another way more interesting use case would be to add entirely new actions to the game.
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: Custom actions

Post by cazfi »

Freeciv-3.1 has three "user action" slots.
eldritch_cookie
Posts: 22
Joined: Sat Mar 05, 2022 6:41 pm

Re: Custom actions

Post by eldritch_cookie »

cazfi wrote:Freeciv-3.1 has three "user action" slots.
that is amazing to know but i am probably going to need more than that even assuming i use some tricks to reuse actions, but how would i set so that for different conditions it shows different actions name even though it is the "same" action? if i am not mistaken the irrigate and change to grassland are the same action so can i do that or is it hardcoded?
Lachu
Elite
Posts: 472
Joined: Sat May 04, 2013 2:19 pm

Re: Custom actions

Post by Lachu »

I am developing counters currently. Counters can enable effects, when checkpoint value were met. Allowing custom actions to increase/decrease counter of target or actor could be great.

For example:
Player could sell captured workers as an slave in city (actor: unit with some reqs; target: our city). When sold, increasing counter of happiness of city by 1. When this counter met 1 value, extra happiness could be added to city. I think is good idea to use counter as multiplier of effects.
eldritch_cookie
Posts: 22
Joined: Sat Mar 05, 2022 6:41 pm

Re: Custom actions

Post by eldritch_cookie »

i find myself considering implementing this feature myself, as i really want this, i am making a list of what would need to be changed for this to work and planning the feature, i also i am reading the source code to familiarize myself with it.so i would like to have a discussion about the details of this, so obviously there should be in the game.ruleset a new type of section [action_*].
it obviously should have a name field, but what else should it have? i think it should also have the other actions specific configuration in there so this adds ui name , whether the actor is always consumed, the target kind and its maximum and minimum range, but i am unsure if with this the list is exhaustive so if i forgot something i would like to know.
also i think players would benefit if actions help text was automatically generated, and if there was a possibility of adding help text to action/action enablers.so i probably need to also change that, can anyone say which files do i need to change to make all this possible?i know that to submit a patch i need to go to a specific site , do i also need to create a issue there?
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: Custom actions

Post by cazfi »

Too bad Sveinung is on a long break. He is the one who has been main developer and designer of action enablers & generic actions that are supposed to come after them. Also, he does not have a habit of sharing much of his plans before posting actual patches to review. So it's kind a hard to tell what work would conflict with his long term plans, and what would go toward them.

In any case, don't start implementing single huge patch. We want one logical change / patch, for reasons like being able to review and test each step individually.

See the wiki for development resources, in the beginning especially http://www.freeciv.org/wiki/How_to_Contribute
eldritch_cookie
Posts: 22
Joined: Sat Mar 05, 2022 6:41 pm

Re: Custom actions

Post by eldritch_cookie »

cazfi wrote:Too bad Sveinung is on a long break. He is the one who has been main developer and designer of action enablers & generic actions that are supposed to come after them. Also, he does not have a habit of sharing much of his plans before posting actual patches to review. So it's kind a hard to tell what work would conflict with his long term plans, and what would go toward them.

In any case, don't start implementing single huge patch. We want one logical change / patch, for reasons like being able to review and test each step individually.

See the wiki for development resources, in the beginning especially http://www.freeciv.org/wiki/How_to_Contribute
ok i read the wiki and the hacking document in the doc directory, but i am left with a question, how big should a patch be, around 100 lines , or around 1000 lines? i believe 10000 is too big and 10 is too small i have one with 66 line alterations is that too small? or should i submit it? if it is too small i could add other changes like actually creating a action list from speclist.h and adding a action list field in the game struct, i think i will submit the patch and if it is too small... i don't know but probably the worst that could happen is that the patch is rejected
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: Custom actions

Post by cazfi »

Number of lines rarely is a good metric of how "big" a patch is. Yes, it's hard to review 10000 line patch that does many kind of changes (but it's actually not that bad if it's doing similar change to a lot of places, like changing some variable name where ever it's used). Single line changes often have huge impact (like changing important feature from "disabled" to "enabled"), and 1000 lines can be mostly cosmetic.
Post Reply