[Freeciv-tickets] [freeciv] #44085: custom actions

Back to archive index
OSDN Ticket System norep****@osdn*****
Fri Mar 25 04:53:37 JST 2022


#44085: custom actions

  Open Date: 2022-03-12 13:38
Last Update: 2022-03-24 16:53

URL for this Ticket:
    https://osdn.net//projects/freeciv/ticket/44085
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=44085

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2022-03-24 16:53 Updated by: dark-ether

Comment:

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.

---------------------------------------------------------------------
Ticket Status:

      Reporter: dark-ether
         Owner: (None)
          Type: Feature Requests
        Status: Open
      Priority: 5 - Medium
     MileStone: (None)
     Component: General
      Severity: 5 - Medium
    Resolution: None
---------------------------------------------------------------------

Ticket 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 information of Freeciv project
Freeciv Project is hosted on OSDN

Project URL: https://osdn.net/projects/freeciv/
OSDN: https://osdn.net

URL for this Ticket:
    https://osdn.net/projects/freeciv/ticket/44085
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=44085



More information about the Freeciv-tickets mailing list
Back to archive index