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

Tacoma Commune: fix caravans splitting #50702

Closed

Conversation

hexagonrecursion
Copy link
Contributor

Summary

Bugfixes "Tacoma Commune: fix caravans splitting"

Purpose of change

By talking to the crop overseer at the Tacoma Commune you can send
followers on a caravan to the refugee center. The caravans are sometimes
attacked by raiders. It is supposed to be possible to send multiple
followers in one caravan to make it better defended. The issue is that
when you recover followers from the caravan the game behaves as if each
follower went on a separate caravan and if one of the caravans is
attacked the rest don't help.

To reproduce:

  1. Load the attached save file caravan.zip
  2. Talk to the overseer and send all 8 followers on one caravan
  3. Debug skip time forward 1 day
  4. Recover the followers

Version:

  • OS: Linux
    • OS Version: LSB Version: :core-4.1-amd64:core-4.1-noarch; Distributor ID: Fedora; Description: Fedora release 33 (Thirty Three); Release: 33; Codename: ThirtyThree;
  • Game Version: cb86201 [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Bionic Professions [package_bionic_professions]
    ]

This code looks suspect:

for( auto &elem : npc_list ) {
if( elem->companion_mission_time == calendar::before_time_starts ) {
//Adds a 10% error in estimated travel time
elem->companion_mission_time = calendar::turn + time * rng_float( -1.1, 1.1 );
}
}

//So we have chosen to return an individual or party who went on the mission
//Everyone who was on the mission will have the same companion_mission_time
//and will simulate the mission and return together
std::vector<npc_ptr> caravan_party;
std::vector<npc_ptr> bandit_party;
std::vector<npc_ptr> npc_list = companion_list( p, id );
const int rand_caravan_size = rng( 1, 3 );
caravan_party.reserve( npc_list.size() + rand_caravan_size );
for( int i = 0; i < rand_caravan_size; i++ ) {
caravan_party.push_back( temp_npc( string_id<npc_template>( "commune_guard" ) ) );
}
for( auto &elem : npc_list ) {
if( elem->companion_mission_time == comp->companion_mission_time ) {
caravan_party.push_back( elem );
}
}

Describe the solution

Randomize the time once per caravan instead of once for each follower

Describe alternatives you've considered

None

Testing

  1. Load the attached save file caravan.zip
  2. Talk to the overseer and send all 8 followers on one caravan
  3. Debug skip time forward 1 day
  4. Recover the followers

Additional context

By talking to the crop overseer at the Tacoma Commune you can send
followers on a caravan to the refugee center. The caravans are sometimes
attacked by raiders. It is supposed to be possible to send multiple
followers in one caravan to make it better defended. The issue is that
when you recover followers from the caravan the game behaves as if each
follower went on a separate caravan and if one of the caravans is
attacked the rest don't help.

To reproduce:
1. Load the attached save file https://github.com/CleverRaven/Cataclysm-DDA/files/6973179/caravan.zip
2. Talk to the overseer and send all 8 followers on one caravan
3. Debug skip time forward 1 day
4. Recover the followers

Version:
- OS: Linux
    - OS Version: LSB Version: :core-4.1-amd64:core-4.1-noarch; Distributor ID: Fedora; Description: Fedora release 33 (Thirty Three); Release: 33; Codename: ThirtyThree;
- Game Version: cb86201 [64-bit]
- Graphics Version: Tiles
- Game Language: English [en]
- Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Bionic Professions [package_bionic_professions]
]

This code looks suspect:

https://github.com/CleverRaven/Cataclysm-DDA/blob/998d767d441192ea67516ce3e7ed668ead25ee84/src/mission_companion.cpp#L763-L768
    for( auto &elem : npc_list ) {
        if( elem->companion_mission_time == calendar::before_time_starts ) {
            //Adds a 10% error in estimated travel time
            elem->companion_mission_time = calendar::turn + time * rng_float( -1.1, 1.1 );
        }
    }

https://github.com/CleverRaven/Cataclysm-DDA/blob/998d767d441192ea67516ce3e7ed668ead25ee84/src/mission_companion.cpp#L792-L807
    //So we have chosen to return an individual or party who went on the mission
    //Everyone who was on the mission will have the same companion_mission_time
    //and will simulate the mission and return together
    std::vector<npc_ptr> caravan_party;
    std::vector<npc_ptr> bandit_party;
    std::vector<npc_ptr> npc_list = companion_list( p, id );
    const int rand_caravan_size = rng( 1, 3 );
    caravan_party.reserve( npc_list.size() + rand_caravan_size );
    for( int i = 0; i < rand_caravan_size; i++ ) {
        caravan_party.push_back( temp_npc( string_id<npc_template>( "commune_guard" ) ) );
    }
    for( auto &elem : npc_list ) {
        if( elem->companion_mission_time == comp->companion_mission_time ) {
            caravan_party.push_back( elem );
        }
    }
@actual-nh actual-nh added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Missions Quests and missions labels Aug 12, 2021
@hexagonrecursion hexagonrecursion marked this pull request as draft August 12, 2021 06:22
@hexagonrecursion
Copy link
Contributor Author

For some reason this patch triggers a debug assertion if the caravan is attacked and some of the followers die:

 DEBUG    : overmapbuffer::remove_npc: NPC (53) not found.

 FUNCTION : shared_ptr_fast<npc> overmapbuffer::remove_npc(const character_id &)
 FILE     : src/overmapbuffer.cpp
 LINE     : 1110
 VERSION  : 0.F-1420-g96497661b9

@I-am-Erk
Copy link
Member

Closing as abandoned, bookmarked for hopeful pickup

@I-am-Erk I-am-Erk closed this Dec 15, 2021
@hexagonrecursion hexagonrecursion deleted the caravan branch December 19, 2021 11:45
@hexagonrecursion
Copy link
Contributor Author

This can be removed from Abandoned but Desired PRs: it was fixed by #55746

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Missions Quests and missions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants