Skip to content
24 changes: 24 additions & 0 deletions C3X.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ struct work_area_improvement {
int work_area_radius_bonus;
};

struct unit_visibility_rule {
int unit_id;
enum UnitTypeClasses unit_class;

int base_visibility;
int terrain_bonus_multiplier;
int fortification_bonus;
bool fortification_bonus_continent_lock;
};

enum retreat_rules {
RR_STANDARD = 0,
RR_NONE,
Expand Down Expand Up @@ -483,6 +493,20 @@ struct c3x_config {
int ai_auto_build_great_wall_strategy;

bool enable_city_work_radii_highlights;

bool enable_alternate_view_distance_logic; //enable the whole system or not
bool terrain_visibility_euclidean; //whether the upper bound should be determined by a euclidean metric than a chebyshev one.
int base_visibility_range; //should default to 1
int terrain_visibility_see_height[14]; //most tiles are 1, mountains+volcanoes are 2
int terrain_visibility_seen_height[14]; //most tiles are 0, forest+jungle+hills are 1, mountains+volcanoes are 2
int terrain_visibility_bonus[14]; //most tiles are 0, hills+mountains+volcanoes are 1
bool terrain_visibility_bonus_can_stack; //whether seeing hills and being on a hill provides double the bonus
bool terrain_visibility_flat_bonus[14]; //water tiles provide height bonus to tiles being seen across them [ie +2] / adjacent tiles always seen
int terrain_visibility_flat_bonus_limit; //maximum size of the flat bonus, in tiles
bool terrain_visibility_flat_bonus_can_stack; //whether flat bonus and regular bonus can both apply at once
struct unit_visibility_rule * unit_visibility_rule_list; //should default to naval unit type has +1 range in fortification with continent lock
int c_unit_visibility_rules;
//tiles blocked by obstructions are visible if *either* intermediate tile is not blocking in height.
};

enum stackable_command {
Expand Down
12 changes: 11 additions & 1 deletion civ_prog_objects.csv
Original file line number Diff line number Diff line change
Expand Up @@ -970,4 +970,14 @@ ignore, 0x4BF660, 0x4C6C10, 0x4BF6F0, "City_draw_citizens", "void (__fastc
ignore, 0x4B9F60, 0x4C15D0, 0x4B9FF0, "City_add_population", "void (__fastcall *) (City * this, int edx, int num, int race_id)"
ignore, 0x670234, 0x68D2E0, 0x670234, "Tile_m27_Check_Shield_Bonus", "bool (__fastcall *) (Tile * this)"
ignore, 0x5f3448, 0x6032DF, 0x5F3378, "CHECK_SHIELD_BONUS_TO_CAN_SPAWN_RES_RETURN", "int"

inlead, 0x5BA010, 0x5C8AD0, 0x5BA090, "Unit_can_see_tile", "bool (__fastcall *) (Unit * this, int edx, int x, int y)"
define, 0x44A8D0, 0x44C870, 0x44A950, "Map_chebyshev_distance", "int (__fastcall *) (Map * this, int edx, int x1, int y1, int x2, int y2)"
define, 0x5BA1F9, 0x5C8CD6, 0x5BA279, "ADDR_UNIT_VISIBILITY_RADIUS_1", "byte *"
define, 0x5BA29B, 0x5C8D76, 0x5BA32B, "ADDR_UNIT_VISIBILITY_RADIUS_2", "byte *"
define, 0x5BA5F4, 0x5C90CD, 0x5BA674, "ADDR_UNIT_VISIBILITY_RADIUS_3", "byte *"
define, 0x5C811A, 0x5D6FF5, 0x5C819A, "ADDR_UNIT_TO_UNIT_VISIBILITY_RADIUS", "byte *"
define, 0x5BB7E6, 0x5CA333, 0x5BB866, "ADDR_CIV_UNIT_VISIBILITY_RADIUS", "byte *"
define, 0x5beb25, 0x5cd745, 0x5beba5, "ADDR_UTC_SEA_CMP_1", "byte *"
define, 0x5c644c, 0x5d529c, 0x5c64cc, "ADDR_UTC_SEA_CMP_2", "byte *"
define, 0x5c65c8, 0x5d5418, 0x5c6648, "ADDR_UTC_SEA_CMP_3", "byte *"
define, 0x5c7e43, 0x5d6d08, 0x5c7ec3, "ADDR_UTC_SEA_CMP_4", "byte *"
36 changes: 36 additions & 0 deletions default.c3x_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,42 @@ override_barbarian_activity_level_for_scenario_maps = none
; types at the start of the game so they behave like normal MGLs spawned during a game.
initialize_preplaced_scenario_leaders_as_mgls = false

[==================]
[=== VISIBILITY ===]
[==================]

; Whether to enable the alternate visibility system. Within this system, the total view distance cannot exceed 7 tiles due to technical limitations. Any visibility beyond this will be clamped.
enable_alternate_view_distance_logic = false

; Whether a euclidean (circular) metric is used instead of the normal chebyshev (square) one
terrain_visibility_euclidean = false

; The base view distance of units
base_visibility_range = 1
; The following settings have an entry for each terrain type, annotated and abbreviated as follows
; [DESRT, PLAIN, GRSLD, TNDRA, FLDPL, HILLS, MNTNS, FORST, JUNGL, MARSH, VLCNO, COAST, SEA, OCEAN]
; The height a unit is considered to be standing at when on this type of tile.
terrain_visibility_see_height = [1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1]
; The hight a tile is considered to be seen from another tile. If this equals or exceed the see height, it will occlude tiles beyond.
terrain_visibility_seen_height = [0, 0, 0, 0, 0, 1, 2, 1, 1, 0, 2, 0, 0, 0]
; The bonus sight range granted by standing on or looking at a given tile
terrain_visibility_bonus = [0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0]
; Whether a unit on a tile with a bonus and seeing a tile with bonus is double rewarded. Otherwise, the large value is used. This may be necessary if you wish to use negative bonuses.
terrain_visibility_bonus_can_stack = false
; Whether tiles of the given type provide bonus view distance for seeing across them. This config only supports 0 and 1.
terrain_visibility_flat_bonus = [false, false, false, false, false, false, false, false, false, false, false, true, true, true]
; The number of times the flat bonus may be applied.
terrain_visibility_flat_bonus_limit = 1
; Whether the flat bonus may stack with the regular, height-based bonus.
terrain_visibility_flat_bonus_can_stack = false

; A list of rules for individual unit types or unit classes (UTC_Land, UTC_Sea, UTC_Air)
; A base visibility can be give, a multiplier to the height based bonus visibility can be give (times_bonus), and a single fortification bonus can be given.
; There are two mutually-exclusive types of fortification bonus: when_fortified and when_fortified_same_continent. The latter only applies to tiles on the same continent.
; The first rule matching a unit is used. Therefore, unit class rules should be at the end.
; The following is an example: [Scout: 1 + 2 times_bonus, "Landmine": 0 + 0 times_bonus, "Army": 2 + 2 when_fortified]
unit_visibility_rules = ["UTC_Sea": 2 when_fortified_same_continent]

[==================]
[=== AESTHETICS ===]
[==================]
Expand Down
Loading