[Freeciv-tickets] [freeciv] #42659: Unhardcode autoupgrade

アーカイブの一覧に戻る
OSDN Ticket System norep****@osdn*****
Sat Feb 12 02:35:08 JST 2022


#42659: Unhardcode autoupgrade

  Open Date: 2021-07-23 02:19
Last Update: 2022-02-11 20:35

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

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

Last Changes/Comment on this Ticket:
2022-02-11 20:35 Updated by: ihnatus

Comment:

Reply To cazfi
Reply To alienvalkyrie
 I'm not sure I like the idea of a special, named user effect that's given different treatment by the AI, without actually being different in any material way.

That's what I'm thinking too. The effect should still be handled by the C-code. Any ruleset that wants to handle upgrade via lua-script just should leave the effect value to zero.
Actually, I based my solution on existing "Inspire_Partisans" effect that is also for long handled only by Lua callback, helptext and AI. You can in theory handle the effect in any other way or call the API function from any other callback but it's up to you to keep the necessary semantics. And currently we have no tools to give ideas to the AI when and how much an effect is desired unless some hardcoded values are given to it; also, why not to supply an autohelp that most commonly is true and in other cases may be turned off.
"Upgrade_Unit", "Inspire_Partisans" and some other effects don't modify how something happens in the game (as e.g. "Combat_Rounds" do), they are event bonuses that just at certain events bring something else. They naturally may be realized in a signal-callback mechanism and in fact they are in C code, moving the callback to Lua just gives much bigger variability to the behaviour and puts that event into a common way of processing.

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

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

Ticket details:

Autoupgrade (Leonardo effect) is a gimmick bonus, like hut findings, but it is now hardcoded. The result is, we can't have any good way for adding flexibility to it (e.g., upgrade only units in domestic borders, or have wonders that upgrade different classes separately). So, the logical solution is: write autoupgrade code into a Lua callback in default.lua, and the effect "Upgrade_Unit" will just be used by AI and autohelp as it is, and the default callback looks at it but some other one might not. To do it, we must develop in separate tickets:
"phase_end" signal (called in srv_main.c when we now deal with this effect, after do_tech_parasite_effect() and before  player_restore_units() from which we cut do_upgrade_effects());
API to do the things do_upgrade_effects() does:
void (Unit):transform(Unit_Type to_what, bool dont_lose_veteranship) -- maybe the second parameter may be unhardcoded further?
an API for unit_upgrade_test(punit, TRUE). Suggestion:
string (Unit):transform_blocker(Unit_Type tf_to) -- possible values: nil, "cargo", "transport", "tile"; maybe numeric results and constants table for less garbage
Unit_Type (Unit_Type):upgrade_type(Player owner) --for can_upgrade_unittype(), maybe also a shortcut Unit_Type (Unit):upgrade_type(); nil if can't yet upgrade
maybe as more low-level control of the previous: Unit_Type (Unit_Type).obsoleted_by and bool (Player):can_build_direct(Unit_Type utype).

-- 
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/42659
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=42659



More information about the Freeciv-tickets mailing list
アーカイブの一覧に戻る