Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Synergy Bonuses and New TotalCapacity Formulas to terrain.cfg #3710

Merged
merged 13 commits into from
Nov 26, 2024
29 changes: 28 additions & 1 deletion config/fxdata/terrain.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,22 @@ Messages = 0 0 0
; Sound sample playing in a loop when hovering over it on screen.
AmbientSndSample = 0
; Algorithm used to compute room capacity:
; slabs_all_only, slabs_all_wth_effcncy, slabs_div2_wth_effcncy, gold_slabs_wth_effcncy, gold_slabs_full, none.
; slabs_all_only - One capacity per slab
; slabs_all_wth_effcncy - Capacity is reduced when the room is less effecient
; slabs_no_min_wth_effcncy - Same as above, but without a minimum capacity of 1.
; slabs_div2_wth_effcncy - Capacity is reduced by room effeciency, then divided by two.
; slabs_div2_nomin_effcncy - Same as above, but without a minimum capacity of 1.
; slabs_mul2_wth_effcncy - Capacity is reduced by room effeciency, then multiplied by two.
; slabs_pow2_wth_effcncy - Capacity is reduced by the square of room effeciency, ie 50% efficient means 25% capacity.
; gold_slabs_wth_effcncy - Capacity is reduced by room effeciency, then multiplied by gold hoard types (5)
; gold_slabs_full - One capacity per slab, then multiplied by gold hoard types
; none - No capacity
TotalCapacity = none
; Algorithm used to used storage space and used worker space:
; count_gold_hoardes_in_room, count_books_in_room, count_workers_in_room, count_crates_in_room, count_bodies_in_room, count_food_in_room, count_lair_occupants, none.
UsedCapacity = none none
; Slab that it also receives full efficiency bonus from.
SlabSynergy = none
walt253 marked this conversation as resolved.
Show resolved Hide resolved
; Height in cubes at which storage is created. Negative values for any.
StorageHeight = 0
; Sprite icon of the room, large size and medium size.
Expand All @@ -1113,6 +1124,7 @@ Messages = 0 0 0
AmbientSndSample = 0
TotalCapacity = slabs_all_only
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 0
SymbolSprites = 0 0
PointerSprites = 0
Expand All @@ -1131,6 +1143,7 @@ Messages = 39 24 35
AmbientSndSample = 0
TotalCapacity = gold_slabs_wth_effcncy
UsedCapacity = gold_hoardes_in_room none
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 29 57
PointerSprites = 25
Expand All @@ -1149,6 +1162,7 @@ Messages = 0 25 0
AmbientSndSample = 0
TotalCapacity = slabs_div2_wth_effcncy
UsedCapacity = books_in_room workers_in_room
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 33 61
PointerSprites = 27
Expand All @@ -1168,6 +1182,7 @@ Messages = 0 26 0
AmbientSndSample = 0
TotalCapacity = slabs_all_wth_effcncy
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 37 65
PointerSprites = 29
Expand All @@ -1187,6 +1202,7 @@ Messages = 0 27 0
AmbientSndSample = 0
TotalCapacity = slabs_div2_wth_effcncy
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 35 63
PointerSprites = 28
Expand All @@ -1205,6 +1221,7 @@ Messages = 0 28 0
AmbientSndSample = 85
TotalCapacity = slabs_div2_wth_effcncy
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 39 67
PointerSprites = 30
Expand All @@ -1222,6 +1239,7 @@ Properties = CANNOT_BE_CLAIMED CANNOT_BE_SOLD CANNOT_VANDALIZE HAS_NO_ENSIGN
AmbientSndSample = 0
TotalCapacity = none
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 2
SymbolSprites = 0 0
PointerSprites = 0
Expand All @@ -1240,6 +1258,7 @@ Messages = 0 29 0
AmbientSndSample = 86
TotalCapacity = slabs_div2_wth_effcncy
UsedCapacity = crates_in_room workers_in_room
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 47 75
PointerSprites = 34
Expand All @@ -1258,6 +1277,7 @@ Messages = 0 30 0
AmbientSndSample = 156
TotalCapacity = slabs_div2_wth_effcncy
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 49 77
PointerSprites = 35
Expand All @@ -1276,6 +1296,7 @@ Messages = 0 31 0
AmbientSndSample = 155
TotalCapacity = slabs_div2_wth_effcncy
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 2
SymbolSprites = 45 73
PointerSprites = 33
Expand All @@ -1295,6 +1316,7 @@ Messages = 0 32 0
AmbientSndSample = 45
TotalCapacity = slabs_all_only
UsedCapacity = bodies_in_room none
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 43 71
PointerSprites = 32
Expand All @@ -1313,6 +1335,7 @@ Messages = 0 33 0
AmbientSndSample = 0
TotalCapacity = slabs_div2_wth_effcncy
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 2
SymbolSprites = 41 69
PointerSprites = 31
Expand All @@ -1331,6 +1354,7 @@ Messages = 41 22 34
AmbientSndSample = 0
TotalCapacity = slabs_all_wth_effcncy
UsedCapacity = food_in_room none
SlabSynergy = none
StorageHeight = 0
SymbolSprites = 31 59
PointerSprites = 26
Expand All @@ -1349,6 +1373,7 @@ Messages = 40 23 36
AmbientSndSample = 0
TotalCapacity = slabs_all_wth_effcncy
UsedCapacity = lair_occupants none
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 51 79
PointerSprites = 36
Expand All @@ -1367,6 +1392,7 @@ Messages = 0 0 0
AmbientSndSample = 0
TotalCapacity = none
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 1
SymbolSprites = 53 81
PointerSprites = 37
Expand All @@ -1385,6 +1411,7 @@ Messages = 0 0 0
AmbientSndSample = 0
TotalCapacity = slabs_all_only
UsedCapacity = none none
SlabSynergy = none
StorageHeight = 2
SymbolSprites = 55 83
PointerSprites = 38
Expand Down
1 change: 1 addition & 0 deletions keeperfx_vs2010.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
<ClCompile Include="src\room_library.c" />
<ClCompile Include="src\room_list.c" />
<ClCompile Include="src\room_scavenge.c" />
<ClCompile Include="src\room_treasure.c" />
<ClCompile Include="src\room_util.c" />
<ClCompile Include="src\room_workshop.c" />
<ClCompile Include="src\scrcapt.c" />
Expand Down
3 changes: 3 additions & 0 deletions keeperfx_vs2010.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@
<ClCompile Include="src\spritesheet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\room_treasure.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\actionpt.h">
Expand Down
54 changes: 44 additions & 10 deletions src/config_terrain.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ const struct NamedCommand terrain_room_commands[] = {
{"PANELTABINDEX", 12},
{"TOTALCAPACITY", 13},
{"USEDCAPACITY", 14},
{"AMBIENTSNDSAMPLE", 15},
{"ROLES", 16},
{"STORAGEHEIGHT", 17},
{"SLABSYNERGY", 15},
{"AMBIENTSNDSAMPLE", 16},
{"ROLES", 17},
{"STORAGEHEIGHT", 18},
{NULL, 0},
};

Expand Down Expand Up @@ -129,25 +130,37 @@ const struct NamedCommand room_roles_desc[] = {

extern void count_slabs_all_only(struct Room *room);
extern void count_slabs_all_wth_effcncy(struct Room *room);
extern void count_slabs_no_min_wth_effcncy(struct Room *room);
extern void count_slabs_div2_wth_effcncy(struct Room *room);
extern void count_slabs_div2_nomin_effcncy(struct Room *room);
extern void count_slabs_mul2_wth_effcncy(struct Room *room);
extern void count_slabs_pow2_wth_effcncy(struct Room *room);
extern void count_gold_slabs_wth_effcncy(struct Room *room);
extern void count_gold_slabs_full(struct Room *room);

const struct NamedCommand terrain_room_total_capacity_func_type[] = {
{"slabs_all_only", 1},
{"slabs_all_wth_effcncy", 2},
{"slabs_div2_wth_effcncy", 3},
{"gold_slabs_wth_effcncy", 4},
{"gold_slabs_full", 5},
{"none", 6},
{"slabs_no_min_wth_effcncy",3},
{"slabs_div2_wth_effcncy", 4},
{"slabs_div2_nomin_effcncy",5},
{"slabs_mul2_wth_effcncy", 6},
{"slabs_pow2_wth_effcncy", 7},
{"gold_slabs_wth_effcncy", 8},
{"gold_slabs_full", 9},
{"none", 10},
{NULL, 0},
};

Room_Update_Func terrain_room_total_capacity_func_list[] = {
NULL,
count_slabs_all_only,
count_slabs_all_wth_effcncy,
count_slabs_no_min_wth_effcncy,
count_slabs_div2_wth_effcncy,
count_slabs_div2_nomin_effcncy,
count_slabs_mul2_wth_effcncy,
count_slabs_pow2_wth_effcncy,
count_gold_slabs_wth_effcncy,
count_gold_slabs_full,
NULL,
Expand Down Expand Up @@ -1083,7 +1096,27 @@ TbBool parse_terrain_room_blocks(char *buf, long len, const char *config_textnam
COMMAND_TEXT(cmd_num),block_buf,config_textname);
}
break;
case 15: // AMBIENTSNDSAMPLE
case 15: // SLABSYNERGY
if (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0)
{
if ((strcasecmp(word_buf, "none") == 0)) {
roomst->synergy_slab = -2;
n++;
}
k = get_id(slab_desc, word_buf);
if (k >= 0)
{
roomst->synergy_slab = k;
n++;
}
}
if (n < 1)
{
CONFWRNLOG("Incorrect value of \"%s\" parameter in [%s] block of %s file.",
COMMAND_TEXT(cmd_num),block_buf,config_textname);
}
break;
case 16: // AMBIENTSNDSAMPLE
if (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0)
{
k = atoi(word_buf);
Expand All @@ -1095,11 +1128,12 @@ TbBool parse_terrain_room_blocks(char *buf, long len, const char *config_textnam
}
if (n < 1)
{
roomst->synergy_slab = -3;
CONFWRNLOG("Incorrect value of \"%s\" parameter in [%s] block of %s file.",
COMMAND_TEXT(cmd_num),block_buf,config_textname);
}
break;
case 16: // ROLES
case 17: // ROLES
roomst->roles = RoRoF_None;
while (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0)
{
Expand All @@ -1113,7 +1147,7 @@ TbBool parse_terrain_room_blocks(char *buf, long len, const char *config_textnam
}
}
break;
case 17: // STORAGEHEIGHT
case 18: // STORAGEHEIGHT
walt253 marked this conversation as resolved.
Show resolved Hide resolved
if (get_conf_parameter_single(buf, &pos, len, word_buf, sizeof(word_buf)) > 0)
{
k = atoi(word_buf);
Expand Down
3 changes: 2 additions & 1 deletion src/config_terrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ struct RoomConfigStats {
TextStringId tooltip_stridx;
long creature_creation_model;
SlabKind assigned_slab;
SlabKind synergy_slab;
char storage_height;
unsigned long flags;
RoomRole roles;
Expand Down Expand Up @@ -177,7 +178,7 @@ extern const struct NamedCommand terrain_room_properties_commands[];
extern const struct NamedCommand room_roles_desc[];
extern const struct NamedCommand terrain_room_total_capacity_func_type[];
extern const struct NamedCommand terrain_room_used_capacity_func_type[];
extern Room_Update_Func terrain_room_total_capacity_func_list[8];
extern Room_Update_Func terrain_room_total_capacity_func_list[12];
extern Room_Update_Func terrain_room_used_capacity_func_list[10];

/******************************************************************************/
Expand Down
5 changes: 4 additions & 1 deletion src/lvl_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,10 @@ static void set_room_configuration_process(struct ScriptContext *context)
roomst->update_workers_in_room = terrain_room_used_capacity_func_list[value2];
reinitialise_rooms_of_kind(room_type);
break;
case 16: // StorageHeight
case 16: // SlabSynergy
roomst->synergy_slab = value;
break;
walt253 marked this conversation as resolved.
Show resolved Hide resolved
case 17: // StorageHeight
roomst->storage_height = value;
break;
default:
Expand Down
43 changes: 42 additions & 1 deletion src/room_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ extern "C" {
/******************************************************************************/
void count_slabs_all_only(struct Room *room);
void count_slabs_all_wth_effcncy(struct Room *room);
void count_slabs_no_min_wth_effcncy(struct Room *room);
void count_slabs_div2_wth_effcncy(struct Room *room);
void count_slabs_div2_nomin_effcncy(struct Room *room);
void count_slabs_mul2_wth_effcncy(struct Room *room);
void count_slabs_pow2_wth_effcncy(struct Room *room);
void count_workers_in_room(struct Room *room);
long find_random_valid_position_for_item_in_different_room_avoiding_object(struct Thing* thing, struct Room* skip_room, struct Coord3d* pos);
/******************************************************************************/
Expand Down Expand Up @@ -469,6 +473,15 @@ void count_slabs_all_wth_effcncy(struct Room *room)
room->total_capacity = count;
}

void count_slabs_no_min_wth_effcncy(struct Room *room)
{
unsigned long count = room->slabs_count * ((long)room->efficiency);
count = (count/ROOM_EFFICIENCY_MAX);
if (count < 1)
count = 0;
walt253 marked this conversation as resolved.
Show resolved Hide resolved
room->total_capacity = count;
}

void count_slabs_div2_wth_effcncy(struct Room *room)
{
unsigned long count = room->slabs_count * ((long)room->efficiency);
Expand All @@ -478,6 +491,33 @@ void count_slabs_div2_wth_effcncy(struct Room *room)
room->total_capacity = count;
}

void count_slabs_div2_nomin_effcncy(struct Room *room)
{
unsigned long count = room->slabs_count * ((long)room->efficiency);
count = ((count/ROOM_EFFICIENCY_MAX) >> 1);
if (count < 1)
count = 0;
room->total_capacity = count;
}

void count_slabs_mul2_wth_effcncy(struct Room *room)
{
unsigned long count = room->slabs_count * ((long)room->efficiency);
count = ((count/ROOM_EFFICIENCY_MAX) << 1);
if (count <= 1)
count = 1;
room->total_capacity = count;
}

void count_slabs_pow2_wth_effcncy(struct Room *room)
{
unsigned long count = room->slabs_count * ((long)room->efficiency) * ((long)room->efficiency);
count = (count/ROOM_EFFICIENCY_MAX/ROOM_EFFICIENCY_MAX);
if (count <= 1)
count = 1;
walt253 marked this conversation as resolved.
Show resolved Hide resolved
room->total_capacity = count;
}

void delete_room_structure(struct Room *room)
{
if (room_is_invalid(room))
Expand Down Expand Up @@ -912,6 +952,7 @@ struct Room *prepare_new_room(PlayerNumber owner, RoomKind rkind, MapSubtlCoord
struct Room* room = allocate_free_room_structure();
room->owner = owner;
room->kind = rkind;
room->synergy = get_room_kind_stats(rkind)->synergy_slab;
add_room_to_global_list(room);
add_room_to_players_list(room, owner);
MapSlabCoord slb_x = subtile_slab(stl_x);
Expand Down Expand Up @@ -1127,7 +1168,7 @@ long calculate_cummulative_room_slabs_effeciency(const struct Room *room)
while (i != 0)
{
// Per room tile code
score += calculate_effeciency_score_for_room_slab(i, room->owner);
score += calculate_effeciency_score_for_room_slab(i, room->owner, room->synergy);
// Per room tile code ends
i = get_next_slab_number_in_room(i); // It would be better to have this before per-tile block, but we need old value
k++;
Expand Down
1 change: 1 addition & 0 deletions src/room_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct Room {
MapSubtlCoord central_stl_x;
MapSubtlCoord central_stl_y;
RoomKind kind;
RoomKind synergy;
HitPoints health;
unsigned short total_capacity;
unsigned short used_capacity;
Expand Down
Loading