Ihnatus branch for 2.6 Longturn server/client

Can you help improve your favourite game? Hardcore C mages, talented artists, and players with any level of experience are welcome!
Ignatus
Elite
Posts: 338
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Ihnatus branch for 2.6 Longturn server/client

Postby Ignatus » Sat Nov 30, 2019 6:06 pm

I have started a branch of 2.6 mods some of which may go to the main or Longturn releases. Network compatibility with 2.6 protocol is kept.
Features:
  • Bombardment revealing may be restricted with option "bombardment_reveal":
    "ALL" reveals all participants of bombardment (current behaviour),
    "BEST" reveals only the strongest defender,
    "ATTACKER" reveals the bombarder only,
    "NONE" hides the bombarder if otherwise unseen (in 2.6 that means mostly bombarding from behind city walls).
    Whatever is the option, the bombarding side knows if it has succeeded in reducing at least 1 hp from any unit, and the defender knows nationality and type of the bombarder.
  • Option "cargo_visibility": "NONE" = don't see any non-allied units (default behaviour), "FORTIFY" = see if they are fortifying or fortified, "ACTIVITIES" = see if they do any terrain-related activity (it's just implausible that workers can stay hidden manipulating huge land masses), "ALL" = just see all of them (e.g. transports in your ruleset are horses and bikes).
  • Removed exploits of bouncing units around for terrain change or stack conflicts: they now keep UWT and lose movepoints if they have landed.
  • For the Gtk3.22 client, if you click a tech that may possibly be researched in a moment with you current bulbs, you get a confirmation popup.
  • Different client Lua callbacks are added to help you not lose anything. Callbacks now may send feedback to the C code; so, "event" callback may change the place the message is displayed (output/chat/box/nowhere).
    "unit_remove" (Unit unit) - when unit is going out of sight by any reason (defore processing it).
    "unit_moved" (Unit unit, Tile t_from, Tile t_to) - after we processed a package of unit info about a unit that was on another position just before.
    "unit_captured"(Unit unit, Player gainer) - before we process a package of unit info when we just have seen the unit ID on another side. "unit_remove" and "unit_create" are also called in this case (but if you can't see the captured unit any more, you get only "unit_remove" of all callbacks).
    "unit_create"(Unit unit) - after we have processed an info about a unit not in sight just before (or that belonged to another player).
    "combat_info"(Unit attacker, Unit defender, int att_hp, int def_hp, bool veteranship_achieved) - when a combat was seen. The last parameter requires more testing though.
    "city_create"(City city) - a city newly seen.
    "city_transferred"(City city, Player gainer, Player loser)
    "city_remove"(City city) - we see the tile without the city that was there.
    "event"(string plain_text, Tile ptile, int event, int turn, Player sender, table objects) - an event message received. event is a value from E table. objects is a sequence of links (Unit, City or Tile type) mentioned in the message; your callback may create a key "show" in it: boolean value false means that the message goes hidden, string "Popup" (any case) displays it in a window, string "Messages" puts it into message window, any other string sends it to the console.

Ignatus
Elite
Posts: 338
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Ihnatus branch for 2.6 Longturn server/client

Postby Ignatus » Wed Jun 17, 2020 10:30 pm

A patch adds some new common functionality (I don't keep along with Pneu's branch so some his fun is not here neither automatically mergeable):
  • find.player and find.city now work with string arguments
  • direction.name(dir)
  • effects.player_output_bonus(Player plr, output_type, string eft_name) --output_type may be "Trade" etc. or OUTPUT.TRADE etc.
  • Player.team_number
  • Player.is_male
  • Player,nturns_idle
  • Player:waste_level_at(Tile where, outp_type, Tile govcenter_pos?) -- outp_type see above, calculates corruption for virtual cities using effects.player_output_bonus() and given or current govcenter position to get waste levels, ignores "Output_Waste_Pct" (Courthouse) effect (warning: lies like one breathes in many rulesets, you'd better write a calculator yourself)
  • City.martial_law --number of citizens potentially pacified by troops
  • City.food_stock, .shield_stock, .airlift, .did_buy, .did_sell, .before_change_shields, .caravan_shields, .disbanded_shields, .last_turns_shield_surplus
  • City.supported_count --number of units supported, including free
  • City.production --Unit_Type or Building_Type currently being produced
  • City:waste_level(outp_type = "Shield", int gc_dist?) --waste level for outp_type (see above), 1.0 means all wasted, gc_dist maybe specified instead of actual distance to nearest known govcenter
  • City:happy_count(int citizen = CITIZEN.HAPPY, int level = FEELING.FINAL) --number of citizens with given happiness state at given feeling calculation level, constants CITIZEN.* and FEELING.* may be specified to override default params
  • Tile.owner
  • Tile.continent --number
  • Tile:real_map_distance(Tile other), Tile:map_distance(Tile other) --Real map distance in "airplane steps", diagonal==1, and Manhattan one (diagonal==2)
  • Tile:govcenter_dist(Player p) -- Real distance to nearest govcenter of p, important for corruption
  • Tile:output(output_type, City working_city?, bool celebrating?) -- optionally, how many it gives if worked by some_city, optionally, if it would celebrate.
  • Unit.hp, .fuel, .veteran, .moves_left --all int
  • Unit.activity --string, e.g. "Sentry"
  • Unit.orders_index -- Number of current order in the list starting from 1, nil if no order list. The list will be dealed by upcoming patches.
  • Unit:move_rate()
  • Unit:activity_rate() -- Dimensioned in 1/10 movepoints, sum on a tile to get total rate. Ignores if unit has movepoints to perform an activity now or can do any rate-related activity
  • Unit_Type.move_rate, .fuel, .happy_cost
Last edited by Ignatus on Thu Jul 02, 2020 10:05 pm, edited 2 times in total.

Ignatus
Elite
Posts: 338
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Ihnatus branch for 2.6 Longturn server/client

Postby Ignatus » Sun Jun 21, 2020 9:47 pm

Next patch adds to common API:
  • game object now has subtable terrain_control, its fields are also delegated up to game object:
    • int ocean_reclaim_requirement_pct;
    • int land_channel_requirement_pct;
    • int terrain_thaw_requirement_pct;
    • int terrain_freeze_requirement_pct;
    • int lake_max_size;
    • int min_start_native_area;
    • int move_fragments; /* alias: game.SINGLE_MOVE */
    • int igter_cost; /* alias: game.IGTER_MOVE_COST */
    • bool pythagorean_diagonal
  • Player:dipl_rel(Player other_player, string what) --tests "DiplRel" requirement with range="Local" and name = what
  • City:surplus(otype) /* Final surplus in each category. */
  • City:waste(otype) /* Waste/corruption in each category. */
  • City:unhappy_penalty(otype) /* Penalty from unhappy cities. */
  • City:prod(otype) /* Production is total minus waste and penalty. */
  • City:citizen_base(otype) /* Base production from citizens. */
  • City:usage(otype) /* Amount of each resource being used. */
  • City:nationalities() --table {[Player] = count}, nil if nationalities are off
  • City:specialist(string spec_rule_name) --count of specialists
  • City:is_virtual() --in client, trade partners may be unknown, so you won't know much about them
  • City:traderoutes_number
  • City:trade_routes() -- returns table {[City partner] = int trade}
  • City:trade_routes_iterate() -- just is pairs(City:trade_routes)
  • A change in client code to make the following pair of functions workable: caravan bonus style and trade revenue style options are dumped into C game.server structure. It works only for servers with the same definitions (but it's a LT client, so log2N style works by keyword "LOGARITHMIC").
  • City:trade_with(City) -- (possible) trade between cities, based on known data
  • City:caravan_bonus(City target, bool establish?) -- how much trade and/or science you get if a caravan arrives to target. establish is by default true iff there is no active trade route.
  • City:supported_iterate() -- Iterates by supported units list
  • Unit.activity_target -- extra name or nil
  • Unit:orders() -- if a unit has orders, returns a sequence of tables {{order = ORDER.MOVE etc., activity = activity_name, direction=Direction, target = extra_rule_name}}. Second and third values are boolean: if the orders are repeated and if they are interrupted by spotting an enemy.

Ignatus
Elite
Posts: 338
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Ihnatus branch for 2.6 Longturn server/client

Postby Ignatus » Thu Jul 02, 2020 6:19 pm

Mod for clients:
  • client.player -- it's you
  • client.option, game.server_option -- tables that contain client and known server options, the values are tables, integers or strings depending on option types, may be iterated by pairs()
  • client.state -- "Initial", "Disconnected", "Preparing", "Observing", "Playing" or "Gameover"
  • client.center(Tile tile) -- centers the view at tile

Ignatus
Elite
Posts: 338
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Ihnatus branch for 2.6 Longturn server/client

Postby Ignatus » Fri Jul 03, 2020 1:25 pm

A n example of a script. Function trade_plan(player) prints on the Lua console possible domestic trade routes sorted firstly by trade output (from two cities), then by one-time bonus. Does not check number of trade routes per city, existence of a trade route influences only the bonus.
Attachments
lt-mp.lua.zip
(493 Bytes) Downloaded 1 time