Ejemplo n.º 1
0
void npc::load_info(std::string data)
{
 std::stringstream dump;
 dump << data;
// Standard player stuff
 dump >> id >> posx >> posy >> str_cur >> str_max >> dex_cur >> dex_max >>
         int_cur >> int_max >> per_cur >> per_max >> hunger >> thirst >>
         fatigue >> stim >> pain >> pkill >> radiation >> cash >> recoil >>
         scent >> moves >> underwater >> can_dodge >> oxygen;

 for (int i = 0; i < PF_MAX2; i++)
  dump >> my_traits[i];

 for (int i = 0; i < num_hp_parts; i++)
  dump >> hp_cur[i] >> hp_max[i];
 for (int i = 0; i < num_skill_types; i++)
  dump >> sklevel[i] >> skexercise[i];

 int numill;
 int typetmp;
 disease illtmp;
 dump >> numill;
 for (int i = 0; i < numill; i++) {
  dump >> typetmp >> illtmp.duration;
  illtmp.type = dis_type(typetmp);
  illness.push_back(illtmp);
 }
 int numadd;
 addiction addtmp;
 dump >> numadd;
 for (int i = 0; i < numadd; i++) {
  dump >> typetmp >> addtmp.intensity >> addtmp.sated;
  addtmp.type = add_type(typetmp);
  addictions.push_back(addtmp);
 }
 int numbio;
 bionic biotmp;
 dump >> numbio;
 for (int i = 0; i < numbio; i++) {
  dump >> typetmp >> biotmp.invlet >> biotmp.powered >> biotmp.charge;
  biotmp.id = bionic_id(typetmp);
  my_bionics.push_back(biotmp);
 }
// Special NPC stuff
 int misstmp, flagstmp, agg, bra, col, alt, tru, val, fea;
 dump >> agg >> bra >> col >> alt >> wandx >> wandy >> wandf >> omx >> omy >>
         omz >> mapx >> mapy >> plx >> ply >> goalx >> goaly >> misstmp >>
         tru >> val >> fea >> flagstmp >> fac_id;
 personality.aggression = agg;
 personality.bravery = bra;
 personality.collector = col;
 personality.altruism = alt;
 op_of_u.trust = tru;
 op_of_u.value = val;
 op_of_u.fear = fea;
 mission = npc_mission(misstmp);
 flags = flagstmp;
}
Ejemplo n.º 2
0
/*
 * load npc
 */
void npc::deserialize(JsonIn &jsin)
{
    JsonObject data = jsin.get_object();

    json_load_common_variables(data);

    int misstmp, classtmp, flagstmp, atttmp, tmpid;

    data.read("id",tmpid);  setID(tmpid);
    data.read("name",name);
    data.read("marked_for_death", marked_for_death);
    data.read("dead", dead);
    if ( data.read( "myclass", classtmp) ) {
        myclass = npc_class( classtmp );
    }

    data.read("personality", personality);

    data.read("wandx",wandx);
    data.read("wandy",wandy);
    data.read("wandf",wandf);
    data.read("omx",omx);
    data.read("omy",omy);
    data.read("omz",omz);

    data.read("mapx",mapx);
    data.read("mapy",mapy);

    data.read("plx",plx);
    data.read("ply",ply);

    data.read("goalx",goal.x);
    data.read("goaly",goal.y);
    data.read("goalz",goal.z);

    if ( data.read("mission",misstmp) ) {
        mission = npc_mission( misstmp );
    }

    if ( data.read( "flags", flagstmp) ) {
        flags = flagstmp;
    }
    if ( data.read( "attitude", atttmp) ) {
        attitude = npc_attitude(atttmp);
    }

    inv.clear();
    if ( data.has_member("inv") ) {
        JsonIn *invin = data.get_raw("inv");
        inv.json_load_items( *invin );
    }

    worn.clear();
    data.read("worn",worn);

    weapon.contents.clear();
    data.read("weapon",weapon);

    data.read("op_of_u",op_of_u);
    data.read("chatbin",chatbin);
    data.read("combat_rules",combat_rules);
}