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

missions: autoset monster_kill_goal for KILL_TYPE and KILL_SPEC #27050

Merged
merged 1 commit into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion data/json/npcs/missiondef.json
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@
"monster_kill_goal": 100,
"difficulty": 5,
"value": 250000,
"start": "kill_100_z",
"start": "join",
"end": "leave",
"origins": [ "ORIGIN_SECONDARY" ],
"followup": "MISSION_KILL_HORDE_MASTER",
Expand Down Expand Up @@ -647,6 +647,7 @@
"difficulty": 5,
"value": 250000,
"start": "kill_20_nightmares",
"monster_type": "mon_charred_nightmare",
"monster_kill_goal": 20,
"origins": [ "ORIGIN_SECONDARY" ],
"dialogue": {
Expand Down
10 changes: 8 additions & 2 deletions src/mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mission mission_type::create( const int npc_id ) const
ret.value = value;
ret.follow_up = follow_up;
ret.monster_species = monster_species;
ret.monster_type = monster_type;
ret.monster_kill_goal = monster_kill_goal;

if( deadline_low != 0 || deadline_high != 0 ) {
Expand Down Expand Up @@ -186,6 +187,11 @@ void mission::assign( player &u )
player_id = u.getID();
u.on_mission_assignment( *this );
if( status == mission_status::yet_to_start ) {
if( type->goal == MGOAL_KILL_MONSTER_TYPE && monster_type != mtype_id::NULL_ID() ) {
kill_count_to_reach = g->kill_count( monster_type ) + monster_kill_goal;
} else if( type->goal == MGOAL_KILL_MONSTER_SPEC ) {
kill_count_to_reach = g->kill_count( monster_species ) + monster_kill_goal;
}
type->start( this );
status = mission_status::in_progress;
}
Expand Down Expand Up @@ -325,7 +331,7 @@ bool mission::is_complete( const int _npc_id ) const
return step >= 1;

case MGOAL_KILL_MONSTER_TYPE:
return g->kill_count( mtype_id( monster_type ) ) >= kill_count_to_reach;
return g->kill_count( monster_type ) >= kill_count_to_reach;

case MGOAL_KILL_MONSTER_SPEC:
return g->kill_count( monster_species ) >= kill_count_to_reach;
Expand Down Expand Up @@ -544,7 +550,7 @@ mission::mission()
target_id = string_id<oter_type_t>::NULL_ID();
recruit_class = NC_NONE;
target_npc_id = -1;
monster_type = "mon_null";
monster_type = mtype_id::NULL_ID();
monster_kill_goal = -1;
npc_id = -1;
good_fac_id = -1;
Expand Down
10 changes: 4 additions & 6 deletions src/mission.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ class JsonOut;
struct mission_type;
struct oter_type_t;
struct species_type;
struct mtype;

enum npc_mission : int;

using npc_class_id = string_id<npc_class>;
using mission_type_id = string_id<mission_type>;
using species_id = string_id<species_type>;
using mtype_id = string_id<mtype>;

namespace debug_menu
{
Expand Down Expand Up @@ -77,9 +79,6 @@ struct mission_place {

/* mission_start functions are first run when a mission is accepted; this
* initializes the mission's key values, like the target and description.
* These functions are also run once a turn for each active mission, to check
* if the current goal has been reached. At that point they either start the
* goal, or run the appropriate mission_end function.
*/
struct mission_start {
static void standard( mission * ); // Standard for its goal type
Expand All @@ -96,7 +95,6 @@ struct mission_start {
static void place_grabber( mission * ); // For Old Guard mission
static void place_bandit_camp( mission * ); // For Old Guard mission
static void place_jabberwock( mission * ); // Put a jabberwok in the woods nearby
static void kill_100_z( mission * ); // Kill 100 more regular zombies
static void kill_20_nightmares( mission * ); // Kill 20 more regular nightmares
static void kill_horde_master( mission * ); // Kill the master zombie at the center of the horde
static void place_npc_software( mission * ); // Put NPC-type-dependent software
Expand Down Expand Up @@ -187,7 +185,7 @@ struct mission_type {
int item_count = 1;
npc_class_id recruit_class = npc_class_id( "NC_NONE" ); // The type of NPC you are to recruit
int target_npc_id = -1;
std::string monster_type = "mon_null";
mtype_id monster_type = mtype_id::NULL_ID();
species_id monster_species;
int monster_kill_goal = -1;
string_id<oter_type_t> target_id;
Expand Down Expand Up @@ -265,7 +263,7 @@ class mission
string_id<oter_type_t> target_id; // Destination type to be reached
npc_class_id recruit_class;// The type of NPC you are to recruit
int target_npc_id; // The ID of a specific NPC to interact with
std::string monster_type; // Monster ID that are to be killed
mtype_id monster_type; // Monster ID that are to be killed
species_id monster_species; // Monster species that are to be killed
int monster_kill_goal; // The number of monsters you need to kill
int kill_count_to_reach; // The kill count you need to reach to complete mission
Expand Down
11 changes: 0 additions & 11 deletions src/mission_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,20 +395,9 @@ void mission_start::place_jabberwock( mission *miss )
grove.save();
}

void mission_start::kill_100_z( mission *miss )
{
npc *p = g->find_npc( miss->npc_id );
p->set_attitude( NPCATT_FOLLOW );//npc joins you
//kill count of the monsters from a given species you need to reach
miss->kill_count_to_reach = g->kill_count( miss->monster_species ) + miss->monster_kill_goal;
}

void mission_start::kill_20_nightmares( mission *miss )
{
target_om_ter( "necropolis_c_44", 3, miss, false, -2 );
miss->monster_type = mon_charred_nightmare.str();
//kill count of the monster type you need to reach
miss->kill_count_to_reach = g->kill_count( mon_charred_nightmare ) + miss->monster_kill_goal;
}

void mission_start::kill_horde_master( mission *miss )
Expand Down
4 changes: 3 additions & 1 deletion src/missiondef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static const std::map<std::string, std::function<void( mission * )>> mission_fun
{ "place_grabber", mission_start::place_grabber },
{ "place_bandit_camp", mission_start::place_bandit_camp },
{ "place_jabberwock", mission_start::place_jabberwock },
{ "kill_100_z", mission_start::kill_100_z },
{ "kill_20_nightmares", mission_start::kill_20_nightmares },
{ "kill_horde_master", mission_start::kill_horde_master },
{ "place_npc_software", mission_start::place_npc_software },
Expand Down Expand Up @@ -314,6 +313,9 @@ void mission_type::load( JsonObject &jo, const std::string &src )
if( jo.has_member( "monster_species" ) ) {
monster_species = species_id( jo.get_string( "monster_species" ) );
}
if( jo.has_member( "monster_type" ) ) {
monster_type = mtype_id( jo.get_string( "monster_type" ) );
}

if( jo.has_member( "monster_kill_goal" ) ) {
monster_kill_goal = jo.get_int( "monster_kill_goal" );
Expand Down