Пример #1
0
////////////////// mission.h
////
void mission::deserialize(JsonIn &jsin)
{
    JsonObject jo = jsin.get_object();

    if (jo.has_member("type_id")) {
        type = &(g->mission_types[jo.get_int("type_id")]);
    }
    jo.read("description", description);
    jo.read("failed", failed);
    jo.read("value", value);
    jo.read("reward", reward);
    jo.read("uid", uid );
    JsonArray ja = jo.get_array("target");
    if (ja.size() == 2) {
        target.x = ja.get_int(0);
        target.y = ja.get_int(1);
    }
    follow_up = mission_id(jo.get_int("follow_up", follow_up));
    item_id = itype_id(jo.get_string("item_id", item_id));
    jo.read("deadline", deadline );
    jo.read("step", step );
    jo.read("count", count );
    jo.read("npc_id", npc_id );
    jo.read("good_fac_id", good_fac_id );
    jo.read("bad_fac_id", bad_fac_id );
}
Пример #2
0
std::string dynamic_line(talk_topic topic, game *g, npc *p)
{
// First, a sanity test for mission stuff
    if (topic >= TALK_MISSION_START && topic <= TALK_MISSION_END) {

        if (topic == TALK_MISSION_START)
            return _("Used TALK_MISSION_START - not meant to be used!");
        if (topic == TALK_MISSION_END)
            return _("Used TALK_MISSION_END - not meant to be used!");

        if (p->chatbin.mission_selected == -1)
            return _("mission_selected = -1; BUG!");
        int id = -1;
        if (topic == TALK_MISSION_INQUIRE || topic == TALK_MISSION_ACCEPTED ||
                topic == TALK_MISSION_SUCCESS || topic == TALK_MISSION_ADVICE ||
                topic == TALK_MISSION_FAILURE || topic == TALK_MISSION_SUCCESS_LIE) {
            if (p->chatbin.mission_selected >= p->chatbin.missions_assigned.size())
                return _("mission_selected is too high; BUG!");
            id = p->chatbin.missions_assigned[ p->chatbin.mission_selected ];
        } else {
            if (p->chatbin.mission_selected >= p->chatbin.missions.size())
                return _("mission_selected is too high; BUG!");
            id = p->chatbin.missions[ p->chatbin.mission_selected ];
        }

// Mission stuff is a special case, so we'll handle it up here
        mission *miss = g->find_mission(id);
        mission_type *type = miss->type;
        std::string ret = mission_dialogue(mission_id(type->id), topic);
        if (topic == TALK_MISSION_SUCCESS && miss->follow_up != MISSION_NULL)
            return ret + _("  And I have more I'd like you to do.");
        return ret;

    }

    switch (topic) {
    case TALK_NONE:
    case TALK_DONE:
        return "";

    case TALK_MISSION_LIST:
        if (p->chatbin.missions.empty()) {
            if (p->chatbin.missions_assigned.empty())
                return _("I don't have any jobs for you.");
            else
                return _("I don't have any more jobs for you.");
        } else if (p->chatbin.missions.size() == 1) {
            if (p->chatbin.missions_assigned.empty())
                return _("I just have one job for you.  Want to hear about it?");
            else
                return _("I have other one job for you.  Want to hear about it?");
        } else if (p->chatbin.missions_assigned.empty())
            return _("I have several jobs for you.  Which should I describe?");
        else
            return _("I have several more jobs for you.  Which should I describe?");

    case TALK_MISSION_LIST_ASSIGNED:
        if (p->chatbin.missions_assigned.empty())
            return _("You're not working on anything for me right now.");
        else if (p->chatbin.missions_assigned.size() == 1)
            return _("What about it?");
        else
            return _("Which job?");

    case TALK_MISSION_REWARD:
        return _("Sure, here you go!");

    case TALK_SHELTER:
        switch (rng(1, 2)) {
        case 1:
            return _("Well, I guess it's just us.");
        case 2:
            return _("At least we've got shelter.");
        }

    case TALK_SHELTER_PLANS:
        return _("I don't know, look for supplies and other survivors I guess.");

    case TALK_SHARE_EQUIPMENT:
        return _("Why should I share my equipment with you?");

    case TALK_GIVE_EQUIPMENT:
        return _("Okay, here you go.");

    case TALK_DENY_EQUIPMENT:
        if (p->op_of_u.anger >= p->hostile_anger_level() - 4)
            return _("<no>, and if you ask again, <ill_kill_you>!");
        else
            return _("<no><punc> <fuck_you>!");

    case TALK_SUGGEST_FOLLOW:
        if (p->has_disease(DI_INFECTION))
            return _("Not until I get some antibiotics...");
        if (p->has_disease(DI_ASKED_TO_FOLLOW))
            return _("You asked me recently; ask again later.");
        return _("Why should I travel with you?");

    case TALK_AGREE_FOLLOW:
        return _("You got it, I'm with you!");

    case TALK_DENY_FOLLOW:
        return _("Yeah... I don't think so.");

    case TALK_FRIEND:
        return _("What is it?");

    case TALK_COMBAT_COMMANDS: {
        std::stringstream status;
        status << _("*is "); // Prepending * makes this an action, not a phrase
        switch (p->combat_rules.engagement) {
        case ENGAGE_NONE:
            status << _("not engaging enemies.");
            break;
        case ENGAGE_CLOSE:
            status << _("engaging nearby enemies.");
            break;
        case ENGAGE_WEAK:
            status << _("engaging weak enemies.");
            break;
        case ENGAGE_HIT:
            status << _("engaging enenmies you attack.");
            break;
        case ENGAGE_ALL:
            status << _("engaging all enemies.");
            break;
        }
        status << " " << (p->male ? _("He") : _("She")) << _(" will ") <<
               (p->combat_rules.use_guns ? "" : _("not ")) << _("use firearms.");
        status << " " << (p->male ? _("He") : _("She")) << _(" will ") <<
               (p->combat_rules.use_grenades ? "" : _("not ")) << _("use grenades.");

        return status.str();
    }

    case TALK_COMBAT_ENGAGEMENT:
        return _("What should I do?");

    case TALK_SIZE_UP: {
        int ability = g->u.per_cur * 3 + g->u.int_cur;
        if (ability <= 10)
            return _("&You can't make anything out.");

        std::stringstream info;
        info << "&";
        int str_range = int(100 / ability);
        int str_min = int(p->str_max / str_range) * str_range;
        info << _("Str ") << str_min << " - " << str_min + str_range;

        if (ability >= 40) {
            int dex_range = int(160 / ability);
            int dex_min = int(p->dex_max / dex_range) * dex_range;
            info << _("  Dex ") << dex_min << " - " << dex_min + dex_range;
        }
        if (ability >= 50) {
            int int_range = int(200 / ability);
            int int_min = int(p->int_max / int_range) * int_range;
            info << _("  Int ") << int_min << " - " << int_min + int_range;
        }
        if (ability >= 60) {
            int per_range = int(240 / ability);
            int per_min = int(p->per_max / per_range) * per_range;
            info << _("  Per ") << per_min << " - " << per_min + per_range;
        }

        return info.str();
    }
    break;

    case TALK_LOOK_AT: {
        std::stringstream look;
        look << "&" << p->short_description();
        return look.str();
    }
    break;

    case TALK_OPINION: {
        std::stringstream opinion;
        opinion << "&" << p->opinion_text();
        return opinion.str();
    }
    break;

    }

    return _("I don't know what to say. (BUG)");
}