bool Shop::ShopItem::valid_item() const { int i=-1; switch (itemclass_) { case WEAPON: i = getweapontype(itemtypename_); break; case CLIP: i = getcliptype(itemtypename_); break; case ARMOR: i = getarmortype(itemtypename_); break; case LOOT: i = getloottype(itemtypename_); break; } return (i != -1); }
void Shop::ShopItem::choose(squadst& customers, int& buyer) const { if (is_available()) { ledger.subtract_funds(adjusted_price(), EXPENSE_SHOPPING); switch (itemclass_) { case WEAPON: { Weapon* i = new Weapon(*weapontype[getweapontype(itemtypename_)]); customers.squad[buyer]->give_weapon(*i, &location[customers.squad[0]->base]->loot); if (i->empty()) delete i; else location[customers.squad[0]->base]->loot.push_back(i); break; } case CLIP: { Clip* i = new Clip(*cliptype[getcliptype(itemtypename_)]); customers.squad[buyer]->take_clips(*i, 1); if (i->empty()) delete i; else location[customers.squad[0]->base]->loot.push_back(i); break; } case ARMOR: { Armor* i = new Armor(*armortype[getarmortype(itemtypename_)]); customers.squad[buyer]->give_armor(*i, &location[customers.squad[0]->base]->loot); if (i->empty()) delete i; else location[customers.squad[0]->base]->loot.push_back(i); break; } case LOOT: { Loot* i = new Loot(*loottype[getloottype(itemtypename_)]); location[customers.squad[0]->base]->loot.push_back(i); break; } } } }
const std::string& Shop::ShopItem::get_description() const { if (description_defined_) { return description_; } else { switch (itemclass_) { default: return description_; // Will be "UNDEFINED" case WEAPON: return weapontype[getweapontype(itemtypename_)]->get_name(); case CLIP : return cliptype [getcliptype (itemtypename_)]->get_name(); case ARMOR : return armortype [getarmortype (itemtypename_)]->get_name(); case LOOT : return loottype [getloottype (itemtypename_)]->get_name(); } } }
/* loads the game from save.dat */ char load(const string& filename) { //LOAD FILE int loadversion; int l; bool dummy_b; int dummy; long dummy_l; FILE *h; h=LCSOpenFile(filename.c_str(), "rb", LCSIO_PRE_HOME); if(h!=NULL) { fread(&loadversion,sizeof(int),1,h); //NUKE INVALID SAVE GAMES if(loadversion<lowestloadversion) { LCSCloseFile(h); reset(); return 0; } fread(seed,sizeof(unsigned long),RNG_SIZE,h); fread(&mode,sizeof(short),1,h); fread(&wincondition,sizeof(short),1,h); fread(&fieldskillrate,sizeof(short),1,h); fread(&day,sizeof(int),1,h); fread(&month,sizeof(int),1,h); fread(&year,sizeof(int),1,h); fread(&execterm,sizeof(short),1,h); fread(&presparty,sizeof(short),1,h); fread(&amendnum,sizeof(int),1,h); fread(&multipleCityMode,sizeof(bool),1,h); fread(&termlimits,sizeof(bool),1,h); fread(&deagle,sizeof(bool),1,h); fread(&m249,sizeof(bool),1,h); fread(¬ermlimit,sizeof(bool),1,h); fread(&nocourtpurge,sizeof(bool),1,h); fread(&stalinmode,sizeof(bool),1,h); fread(&stat_recruits,sizeof(int),1,h); fread(&stat_dead,sizeof(int),1,h); fread(&stat_kills,sizeof(int),1,h); fread(&stat_kidnappings,sizeof(int),1,h); fread(&stat_buys,sizeof(int),1,h); fread(&stat_burns,sizeof(int),1,h); fread(&endgamestate,sizeof(char),1,h); fread(&ccsexposure,sizeof(char),1,h); fread(&ccs_kills,sizeof(char),1,h); fread(&Vehicle::curcarid,sizeof(long),1,h); fread(&curcreatureid,sizeof(long),1,h); fread(&cursquadid,sizeof(long),1,h); fread(&police_heat,sizeof(int),1,h); fread(&offended_corps,sizeof(short),1,h); fread(&offended_cia,sizeof(short),1,h); fread(&offended_amradio,sizeof(short),1,h); fread(&offended_cablenews,sizeof(short),1,h); fread(&offended_firemen,sizeof(short),1,h); fread(attorneyseed,sizeof(unsigned long),RNG_SIZE,h); //fread(&selectedsiege,sizeof(long),1,h); fread(lcityname,sizeof(char),CITY_NAMELEN,h); fread(&newscherrybusted,sizeof(char),1,h); fread(slogan,sizeof(char),SLOGAN_LEN,h); fread(&ledger,sizeof(class Ledger),1,h); fread(&party_status,sizeof(short),1,h); fread(attitude,sizeof(short),VIEWNUM,h); fread(law,sizeof(short),LAWNUM,h); fread(house,sizeof(short),HOUSENUM,h); fread(senate,sizeof(short),SENATENUM,h); fread(court,sizeof(short),COURTNUM,h); fread(courtname,sizeof(char)*POLITICIAN_NAMELEN,COURTNUM,h); fread(exec,sizeof(char),EXECNUM,h); fread(execname,sizeof(char)*POLITICIAN_NAMELEN,EXECNUM,h); fread(oldPresidentName,sizeof(char),POLITICIAN_NAMELEN,h); //LOCATIONS fread(&dummy,sizeof(int),1,h); location.resize(dummy); for(l=0;l<len(location);l++) { location[l]=new Location; fread(&dummy,sizeof(int),1,h); location[l]->loot.resize(dummy); for(int l2=0;l2<len(location[l]->loot);l2++) { int itemLen; fread(&itemLen, sizeof(int), 1, h); vector<char> vec = vector<char>(itemLen + 1); fread(&vec[0], itemLen, 1, h); vec[itemLen] = '\0'; Item* it = create_item(&vec[0]); if(it!=NULL) location[l]->loot[l2] = it; } //Remove items of unknown type. for(int l2=len(location[l]->loot)-1; l2>=0; l2--) { bool del = false; if(location[l]->loot[l2]->is_loot()) del = (getloottype(location[l]->loot[l2]->get_itemtypename()) == -1); else if(location[l]->loot[l2]->is_clip()) del = (getcliptype(location[l]->loot[l2]->get_itemtypename()) == -1); else if(location[l]->loot[l2]->is_weapon()) del = (getweapontype(location[l]->loot[l2]->get_itemtypename()) == -1); else if(location[l]->loot[l2]->is_armor()) del = (getarmortype(location[l]->loot[l2]->get_itemtypename()) == -1); if(del) { addstr("Item type "); addstr(location[l]->loot[l2]->get_itemtypename()); addstr(" does not exist. Deleting item."); delete_and_remove(location[l]->loot,l2); } } consolidateloot(location[l]->loot); // consolidate loot after loading fread(&dummy,sizeof(int),1,h); location[l]->changes.resize(dummy); for(int l2=0;l2<len(location[l]->changes);l2++) fread(&location[l]->changes[l2],sizeof(sitechangest),1,h); fread(location[l]->name,sizeof(char),LOCATION_NAMELEN,h); fread(location[l]->shortname,sizeof(char),LOCATION_SHORTNAMELEN,h); fread(&location[l]->type,sizeof(char),1,h); fread(&location[l]->city,sizeof(int),1,h); fread(&location[l]->area,sizeof(int),1,h); fread(&location[l]->parent,sizeof(int),1,h); fread(&location[l]->id,sizeof(int),1,h); fread(&location[l]->renting,sizeof(int),1,h); fread(&location[l]->newrental,sizeof(char),1,h); fread(&location[l]->needcar,sizeof(char),1,h); fread(&location[l]->closed,sizeof(int),1,h); fread(&location[l]->hidden,sizeof(bool),1,h); fread(&location[l]->mapped,sizeof(bool),1,h); fread(&location[l]->upgradable,sizeof(bool),1,h); fread(&location[l]->highsecurity,sizeof(int),1,h); fread(&location[l]->siege,sizeof(siegest),1,h); fread(&location[l]->heat,sizeof(int),1,h); fread(&location[l]->heat_protection,sizeof(int),1,h); fread(&location[l]->compound_walls,sizeof(int),1,h); fread(&location[l]->compound_stores,sizeof(int),1,h); fread(&location[l]->front_business,sizeof(char),1,h); fread(location[l]->front_name,sizeof(char),LOCATION_NAMELEN,h); fread(location[l]->front_shortname,sizeof(char),LOCATION_SHORTNAMELEN,h); fread(&location[l]->haveflag,sizeof(bool),1,h); fread(location[l]->mapseed,sizeof(unsigned long),RNG_SIZE,h); } //VEHICLES fread(&dummy,sizeof(int),1,h); vehicle.resize(dummy); for(l=0;l<len(vehicle);l++) { int vehicleLen; fread (&vehicleLen, sizeof(int), 1, h); vector<char> vec = vector<char> (vehicleLen + 1); fread (&vec[0], vehicleLen, 1, h); vec[vehicleLen] = '\0'; vehicle[l] = new Vehicle (&vec[0]); } //POOL fread(&dummy,sizeof(int),1,h); pool.resize(dummy); for(int pl=0;pl<len(pool);pl++) { int creatureLen; fread (&creatureLen, sizeof(int), 1, h); vector<char> vec = vector<char> (creatureLen + 1); fread (&vec[0], creatureLen, 1, h); vec[creatureLen] = '\0'; pool[pl] = new Creature(&vec[0]); //pool[pl]=new Creature; //fread(pool[pl],sizeof(Creature),1,h); //read extra interrogation data if applicable if(pool[pl]->align==-1 && pool[pl]->alive) { interrogation* &intr = pool[pl]->activity.intr(); intr = new interrogation; fread(intr->techniques,sizeof(bool[6]),1,h); fread(&intr->druguse,sizeof(int),1,h); intr->rapport.clear(); int size; fread(&size,sizeof(int),1,h); for(int i=0;i<size;i++) { long id; float_zero value; fread(&id,sizeof(long),1,h); fread(&value,sizeof(float_zero),1,h); intr->rapport[id]=value; } } /* //read equipment vector<Item*> dump; //Used to catch invalid pointers from creature so they aren't deleted. pool[pl]->drop_weapon(&dump); pool[pl]->strip(&dump); pool[pl]->clips = deque<Clip*>(); pool[pl]->extra_throwing_weapons = deque<Weapon*>(); int itemLen; fread(&itemLen, sizeof(int), 1, h); if(itemLen != 0) { vector<char> vec = vector<char>(itemLen + 1); fread(&vec[0], itemLen, 1, h); vec[itemLen] = '\0'; Weapon w(&vec[0]); if(getweapontype(w.get_itemtypename())!=-1) //Check it is a valid weapon type. pool[pl]->give_weapon(w,&dump); } //pool[pl]->clips.clear(); fread(&dummy,sizeof(int),1,h); for(int nc=0; nc<dummy; nc++) { fread(&itemLen, sizeof(itemLen), 1, h); vector<char> vec = vector<char>(itemLen + 1); fread(&vec[0], itemLen, 1, h); vec[itemLen] = '\0'; Clip c(&vec[0]); if(getcliptype(c.get_itemtypename())!=-1) //Check it is a valid clip type. pool[pl]->take_clips(c,len(c)); } //pool[pl]->extra_throwing_weapons.clear(); fread(&dummy,sizeof(int),1,h); for(int ne=0; ne<dummy; ne++) { fread(&itemLen, sizeof(itemLen), 1, h); vector<char> vec = vector<char>(itemLen + 1); fread(&vec[0], itemLen, 1, h); vec[itemLen] = '\0'; Weapon w(&vec[0]); if(getweapontype(w.get_itemtypename())!=-1) //Check it is a valid weapon type. pool[pl]->give_weapon(w,NULL); } fread(&itemLen, sizeof(itemLen), 1, h); if(itemLen != 0) { vector<char> vec = vector<char>(itemLen + 1); fread(&vec[0], itemLen, 1, h); vec[itemLen] = '\0'; Armor a(&vec[0]); if(getarmortype(a.get_itemtypename())!=-1) //Check it is a valid armor type. pool[pl]->give_armor(a,&dump); }*/ } //Unique Creatures { int uniquecreaturesLen; fread (&uniquecreaturesLen, sizeof(int), 1, h); vector<char> vec = vector<char> (uniquecreaturesLen + 1); fread (&vec[0], uniquecreaturesLen, 1, h); vec[uniquecreaturesLen] = '\0'; uniqueCreatures = UniqueCreatures(&vec[0]); //fread(&uniqueCreatures,sizeof(UniqueCreatures),1,h); } //SQUADS fread(&dummy,sizeof(int),1,h); squad.resize(dummy); for(int sq=0;sq<len(squad);sq++) { squad[sq]=new squadst; fread(squad[sq]->name,sizeof(char),SQUAD_NAMELEN,h); fread(&squad[sq]->activity,sizeof(activityst),1,h); fread(&squad[sq]->id,sizeof(int),1,h); for(int pos=0;pos<6;pos++) { //REBUILD SQUAD FROM POOL squad[sq]->squad[pos]=NULL; fread(&dummy_b,sizeof(bool),1,h); if(dummy_b) { int dummy_i; fread(&dummy_i,sizeof(int),1,h); for(int pl=0;pl<len(pool);pl++) if(pool[pl]->id==dummy_i) squad[sq]->squad[pos]=pool[pl]; } } fread(&dummy,sizeof(int),1,h); squad[sq]->loot.resize(dummy); for(int l2=0;l2<len(squad[sq]->loot);l2++) { int itemLen; fread(&itemLen, sizeof(int), 1, h); vector<char> vec = vector<char>(itemLen + 1); fread(&vec[0], itemLen, 1, h); vec[itemLen] = '\0'; Item* it = create_item(&vec[0]); //if(it!=NULL) //Assume save file is correct? -XML squad[sq]->loot[l2] = it; /*else squad[sq]->loot.erase(loot.begin()+l2--);*/ } //Remove items of unknown type. for(int l2=len(squad[sq]->loot)-1; l2>=0; l2--) { bool del = false; if(squad[sq]->loot[l2]->is_loot()) del = (getloottype(squad[sq]->loot[l2]->get_itemtypename()) == -1); else if(squad[sq]->loot[l2]->is_clip()) del = (getcliptype(squad[sq]->loot[l2]->get_itemtypename()) == -1); else if(squad[sq]->loot[l2]->is_weapon()) del = (getweapontype(squad[sq]->loot[l2]->get_itemtypename()) == -1); else if(squad[sq]->loot[l2]->is_armor()) del = (getarmortype(squad[sq]->loot[l2]->get_itemtypename()) == -1); if(del) { addstr("Item type "); addstr(squad[sq]->loot[l2]->get_itemtypename()); addstr(" does not exist. Deleting item."); delete_and_remove(squad[sq]->loot,l2); } } consolidateloot(squad[sq]->loot); // consolidate loot after loading } activesquad=NULL; fread(&dummy_b,sizeof(bool),1,h); if(dummy_b) { int dummy_i; fread(&dummy_i,sizeof(int),1,h); for(int sq=0;sq<len(squad);sq++) if(squad[sq]->id==dummy_i) { activesquad=squad[sq]; break; } } //DATES fread(&dummy,sizeof(int),1,h); date.resize(dummy); for(int dt=0;dt<len(date);dt++) { date[dt]=new datest; fread(&date[dt]->mac_id,sizeof(long),1,h); fread(&date[dt]->timeleft,sizeof(short),1,h); fread(&date[dt]->city,sizeof(int),1,h); fread(&dummy,sizeof(int),1,h); date[dt]->date.resize(dummy); for(int dt2=0;dt2<len(date[dt]->date);dt2++) { int creatureLen; fread (&creatureLen, sizeof(int), 1, h); vector<char> vec = vector<char> (creatureLen + 1); fread (&vec[0], creatureLen, 1, h); vec[creatureLen] = '\0'; date[dt]->date[dt2] = new Creature(&vec[0]); //date[dt]->date[dt2]=new Creature; //fread(date[dt]->date[dt2],sizeof(Creature),1,h); } } //RECRUITS fread(&dummy,sizeof(int),1,h); recruit.resize(dummy); for(int rt=0;rt<len(recruit);rt++) { recruit[rt]=new recruitst; fread(&recruit[rt]->recruiter_id,sizeof(long),1,h); fread(&recruit[rt]->timeleft,sizeof(short),1,h); fread(&recruit[rt]->level,sizeof(char),1,h); fread(&recruit[rt]->eagerness1,sizeof(char),1,h); fread(&recruit[rt]->task,sizeof(char),1,h); int creatureLen; fread (&creatureLen, sizeof(int), 1, h); vector<char> vec = vector<char> (creatureLen + 1); fread (&vec[0], creatureLen, 1, h); vec[creatureLen] = '\0'; recruit[rt]->recruit = new Creature(&vec[0]); //recruit[rt]->recruit = new Creature; //fread(recruit[rt]->recruit,sizeof(Creature),1,h); } //NEWS STORIES fread(&dummy,sizeof(int),1,h); newsstory.resize(dummy); for(int ns=0;ns<len(newsstory);ns++) { newsstory[ns]=new newsstoryst; fread(&newsstory[ns]->type,sizeof(short),1,h); fread(&newsstory[ns]->view,sizeof(short),1,h); fread(&newsstory[ns]->loc,sizeof(long),1,h); fread(&newsstory[ns]->priority,sizeof(long),1,h); fread(&newsstory[ns]->page,sizeof(long),1,h); fread(&newsstory[ns]->positive,sizeof(char),1,h); fread(&newsstory[ns]->siegetype,sizeof(short),1,h); newsstory[ns]->cr=NULL; fread(&dummy_b,sizeof(bool),1,h); if(dummy_b) { fread(&dummy_l,sizeof(long),1,h); for(int pl=0;pl<len(pool);pl++) if(pool[pl]->id==dummy_l) { newsstory[ns]->cr=pool[pl]; break; } } fread(&dummy,sizeof(int),1,h); newsstory[ns]->crime.resize(dummy); for(int dt2=0;dt2<len(newsstory[ns]->crime);dt2++) fread(&newsstory[ns]->crime[dt2],sizeof(int),1,h); } // Liberal Media fread(public_interest,sizeof(public_interest),1,h); fread(background_liberal_influence,sizeof(background_liberal_influence),1,h); // Site mode options fread(&encounterwarnings,sizeof(bool),1,h); bool musicenabled; fread(&musicenabled,sizeof(bool),1,h); music.enableIf(musicenabled); LCSCloseFile(h); // Check that vehicles are of existing types. for(int v=0;v<len(vehicle);v++) { if(getvehicletype(vehicle[v]->vtypeidname())==-1) { //Remove vehicle of non-existing type. addstr("Vehicle type "+vehicle[v]->vtypeidname()+" does not exist. Deleting vehicle."); delete_and_remove(vehicle,v--); } } return 1; } gamelog.log("Could not load"); return 0; }
/********************************* ** ** SLEEPERS STEALING THINGS ** **********************************/ void sleeper_steal(Creature &cr,char &clearformess,char canseethings,int (&libpower)[VIEWNUM]) { if(LCSrandom(100) > 100*cr.infiltration) { cr.juice-=1; if(cr.juice<-2) { erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has been arrested while stealing things.", gamelog); gamelog.nextMessage(); getkey(); cr.crimes_suspected[LAWFLAG_THEFT]++; removesquadinfo(cr); cr.location=find_police_station(cr); cr.drop_weapons_and_clips(NULL); cr.activity.type=ACTIVITY_NONE; cr.flag&=~CREATUREFLAG_SLEEPER; } return; } // Improves juice, as confidence improves if(cr.juice<100) { cr.juice += 10; if(cr.juice>100)cr.juice=100; } cr.infiltration-=LCSrandom(10)*0.01f-0.02f; //No effectiveness drop before? -Niel //Item *item; string item; Location *shelter=location[find_homeless_shelter(cr)]; int number_of_items = LCSrandom(10)+1; int itemindex = -1; // have to check case item not found to avoid brave modders segfaults. int numberofxmlfails = 0; // Tell them how many fails while(number_of_items--) { switch(location[cr.location]->type) //Temporary (transitionally) solution until sites are done. -XML { case SITE_RESIDENTIAL_TENEMENT: if(!LCSrandom(3))item="LOOT_KIDART"; else if(!LCSrandom(2))item="LOOT_DIRTYSOCK"; else item="LOOT_FAMILYPHOTO"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_RESIDENTIAL_APARTMENT: if(!LCSrandom(5))item="LOOT_CELLPHONE"; else if(!LCSrandom(4))item="LOOT_SILVERWARE"; else if(!LCSrandom(3))item="LOOT_TRINKET"; else if(!LCSrandom(2))item="LOOT_CHEAPJEWELERY"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_RESIDENTIAL_APARTMENT_UPSCALE: if(!LCSrandom(10))item="LOOT_EXPENSIVEJEWELERY"; else if(!LCSrandom(5))item="LOOT_CELLPHONE"; else if(!LCSrandom(4))item="LOOT_SILVERWARE"; else if(!LCSrandom(3))item="LOOT_PDA"; else if(!LCSrandom(2))item="LOOT_CHEAPJEWELERY"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_LABORATORY_COSMETICS: case SITE_INDUSTRY_NUCLEAR: case SITE_LABORATORY_GENETIC: if(!LCSrandom(5))item="LOOT_RESEARCHFILES"; else if(!LCSrandom(2))item="LOOT_LABEQUIPMENT"; else if(!LCSrandom(2))item="LOOT_COMPUTER"; else if(!LCSrandom(5))item="LOOT_PDA"; else if(!LCSrandom(5))item="LOOT_CHEMICAL"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_GOVERNMENT_COURTHOUSE: if(!LCSrandom(5))item="LOOT_JUDGEFILES"; else if(!LCSrandom(3))item="LOOT_CELLPHONE"; else if(!LCSrandom(2))item="LOOT_PDA"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_GOVERNMENT_PRISON: item="WEAPON_SHANK"; itemindex = getweapontype(item); if(itemindex > -1) {shelter->loot.push_back(new Weapon(*weapontype[itemindex]));} else {numberofxmlfails++;} break; case SITE_BUSINESS_BANK: case SITE_GOVERNMENT_FIRESTATION: if(LCSrandom(2))item="LOOT_TRINKET"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_INDUSTRY_SWEATSHOP: item="LOOT_FINECLOTH"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_INDUSTRY_POLLUTER: item="LOOT_CHEMICAL"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_CORPORATE_HEADQUARTERS: if(!LCSrandom(5))item="LOOT_CORPFILES"; else if(!LCSrandom(3))item="LOOT_CELLPHONE"; else if(!LCSrandom(2))item="LOOT_PDA"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_CORPORATE_HOUSE: if(!LCSrandom(8))item="LOOT_TRINKET"; else if(!LCSrandom(7))item="LOOT_WATCH"; else if(!LCSrandom(6))item="LOOT_PDA"; else if(!LCSrandom(5))item="LOOT_CELLPHONE"; else if(!LCSrandom(4))item="LOOT_SILVERWARE"; else if(!LCSrandom(3))item="LOOT_CHEAPJEWELERY"; else if(!LCSrandom(2))item="LOOT_FAMILYPHOTO"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_MEDIA_AMRADIO: if(!LCSrandom(5))item="LOOT_AMRADIOFILES"; else if(!LCSrandom(4))item="LOOT_MICROPHONE"; else if(!LCSrandom(3))item="LOOT_PDA"; else if(!LCSrandom(2))item="LOOT_CELLPHONE"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_MEDIA_CABLENEWS: if(!LCSrandom(5))item="LOOT_CABLENEWSFILES"; else if(!LCSrandom(4))item="LOOT_MICROPHONE"; else if(!LCSrandom(3))item="LOOT_PDA"; else if(!LCSrandom(2))item="LOOT_CELLPHONE"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} break; case SITE_GOVERNMENT_POLICESTATION: if(!LCSrandom(3)) { if(!LCSrandom(4))item="WEAPON_SMG_MP5"; else if(!LCSrandom(3))item="WEAPON_SEMIPISTOL_45"; else if(!LCSrandom(2))item="WEAPON_SHOTGUN_PUMP"; else item="WEAPON_SEMIRIFLE_AR15"; itemindex = getweapontype(item); if(itemindex > -1) {shelter->loot.push_back(new Weapon(*weapontype[itemindex]));} else {numberofxmlfails++;} } else if(!LCSrandom(2)) { if(law[LAW_POLICEBEHAVIOR]==-2 && law[LAW_DEATHPENALTY]==-2 && !LCSrandom(4))item="ARMOR_DEATHSQUADUNIFORM"; else if(!LCSrandom(3))item="ARMOR_POLICEUNIFORM"; else if(!LCSrandom(2))item="ARMOR_SWATARMOR"; else item="ARMOR_POLICEARMOR"; itemindex = getarmortype(item); if(itemindex > -1) {shelter->loot.push_back(new Armor(*armortype[itemindex]));} else {numberofxmlfails++;} } else { if(!LCSrandom(5))item="LOOT_POLICERECORDS"; else if(!LCSrandom(3))item="LOOT_CELLPHONE"; else if(!LCSrandom(2))item="LOOT_PDA"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} } break; case SITE_GOVERNMENT_ARMYBASE: if(!LCSrandom(3)) { if(LCSrandom(3))item="WEAPON_AUTORIFLE_M16"; else item="WEAPON_CARBINE_M4"; itemindex = getweapontype(item); if(itemindex > -1) {shelter->loot.push_back(new Weapon(*weapontype[itemindex]));} else {numberofxmlfails++;} } else if(!LCSrandom(2)) { item="ARMOR_ARMYARMOR"; itemindex = getarmortype(item); if(itemindex > -1) {shelter->loot.push_back(new Armor(*armortype[itemindex]));} else {numberofxmlfails++;} } else { if(!LCSrandom(5))item="LOOT_SECRETDOCUMENTS"; else if(!LCSrandom(3))item="LOOT_CELLPHONE"; else if(!LCSrandom(2))item="LOOT_CHEMICAL"; else item="LOOT_SILVERWARE"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} } break; case SITE_GOVERNMENT_WHITE_HOUSE: case SITE_GOVERNMENT_INTELLIGENCEHQ: if(!LCSrandom(3)) { if(!LCSrandom(4))item="WEAPON_SMG_MP5"; else if(!LCSrandom(3))item="WEAPON_AUTORIFLE_M16"; else if(!LCSrandom(2))item="WEAPON_SHOTGUN_PUMP"; else item="WEAPON_CARBINE_M4"; itemindex = getweapontype(item); if(itemindex > -1) {shelter->loot.push_back(new Weapon(*weapontype[itemindex]));} else {numberofxmlfails++;} } else if(!LCSrandom(2)) { item="ARMOR_BLACKSUIT"; itemindex = getarmortype(item); if(itemindex > -1) {shelter->loot.push_back(new Armor(*armortype[itemindex]));} else {numberofxmlfails++;} } else { if(!LCSrandom(5))item="LOOT_SECRETDOCUMENTS"; else if(!LCSrandom(3))item="LOOT_CELLPHONE"; else if(!LCSrandom(2))item="LOOT_PDA"; else item="LOOT_COMPUTER"; itemindex = getloottype(item); if(itemindex > -1) {shelter->loot.push_back(new Loot(*loottype[itemindex]));} else {numberofxmlfails++;} } break; } } erase(); set_color(COLOR_WHITE,COLOR_BLACK,0); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has dropped a package off at the homeless shelter.", gamelog); gamelog.nextMessage(); if(numberofxmlfails > 0) { move(8,1); set_color(COLOR_RED,COLOR_BLUE,1); addstr("Items not found in XML files led to ",xmllog); move(9,1); addstr(numberofxmlfails,xmllog); addstr(" lost stolen items! ",xmllog); move(11,1); set_color(COLOR_RED,COLOR_GREEN,1); addstr("Contact the mod author (or DevTeam if playing the vanilla game) at once!",xmllog); xmllog.nextMessage(); } getkey(); }
/********************************* ** ** SLEEPERS SNOOPING AROUND ** **********************************/ void sleeper_spy(Creature &cr,char &clearformess,char canseethings,int (&libpower)[VIEWNUM]) { int homes=find_homeless_shelter(cr); if(LCSrandom(100) > 100*cr.infiltration) { cr.juice-=1; if(cr.juice<-2) { erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has been caught snooping around.", gamelog); gamelog.newline(); move(8,1); addstr("The Liberal is now homeless and jobless...", gamelog); gamelog.nextMessage(); getkey(); removesquadinfo(cr); cr.location=homes; cr.base=homes; cr.drop_weapons_and_clips(NULL); cr.activity.type=ACTIVITY_NONE; cr.flag&=~CREATUREFLAG_SLEEPER; } return; } // Improves juice, as confidence improves if(cr.juice<100) { cr.juice += 10; if(cr.juice>100) cr.juice=100; } location[cr.base]->mapped = 1; bool pause=false; switch(cr.type) { case CREATURE_SECRET_SERVICE: case CREATURE_AGENT: case CREATURE_POLITICIAN: // Agents can leak intelligence files to you if(!location[homes]->siege.siege&&canseethings) { if(LCSrandom(law[LAW_PRIVACY] + 3)) break; Item *it=new Loot(*loottype[getloottype("LOOT_SECRETDOCUMENTS")]); location[homes]->loot.push_back(it); erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has leaked secret intelligence files.", gamelog); gamelog.newline(); move(7,1); addstr("They are stashed at the homeless shelter.", gamelog); gamelog.nextMessage(); pause=true; } break; case CREATURE_DEATHSQUAD: case CREATURE_SWAT: case CREATURE_COP: case CREATURE_GANGUNIT: // Cops can leak police files to you if(!location[homes]->siege.siege&&canseethings) { if(LCSrandom(law[LAW_POLICEBEHAVIOR] + 3)) break; Item *it=new Loot(*loottype[getloottype("LOOT_POLICERECORDS")]); location[homes]->loot.push_back(it); erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has leaked secret police records.", gamelog); gamelog.newline(); move(7,1); addstr("They are stashed at the homeless shelter.", gamelog); gamelog.nextMessage(); pause=true; } break; case CREATURE_CORPORATE_MANAGER: case CREATURE_CORPORATE_CEO: // Can leak corporate files to you if(!location[homes]->siege.siege&&canseethings) { if(LCSrandom(law[LAW_CORPORATE] + 3) && cr.type!=CREATURE_CORPORATE_CEO) break; Item *it=new Loot(*loottype[getloottype("LOOT_CORPFILES")]); location[homes]->loot.push_back(it); erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has leaked secret corporate documents.", gamelog); gamelog.newline(); move(7,1); addstr("They are stashed at the homeless shelter.", gamelog); gamelog.nextMessage(); pause=true; } break; case CREATURE_EDUCATOR: case CREATURE_PRISONGUARD: if(!location[homes]->siege.siege&&canseethings) { if(LCSrandom(law[LAW_POLICEBEHAVIOR] + 3)) break; Item *it=new Loot(*loottype[getloottype("LOOT_PRISONFILES")]); location[homes]->loot.push_back(it); erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has leaked internal prison records.", gamelog); gamelog.newline(); move(7,1); addstr("They are stashed at the homeless shelter.", gamelog); gamelog.nextMessage(); pause=true; } break; case CREATURE_NEWSANCHOR: if(!location[homes]->siege.siege&&canseethings) { // More likely to leak these documents the more restrictive // free speech is -- because the more free the society, the // less any particular action the media takes seems scandalous if(LCSrandom(law[LAW_FREESPEECH] + 3)) break; Item *it=new Loot(*loottype[getloottype("LOOT_CABLENEWSFILES")]); location[homes]->loot.push_back(it); erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has leaked proof of systemic Cable News bias.", gamelog); gamelog.newline(); move(7,1); addstr("The papers are stashed at the homeless shelter.", gamelog); gamelog.nextMessage(); pause=true; } break; case CREATURE_RADIOPERSONALITY: if(!location[homes]->siege.siege&&canseethings) { // More likely to leak these documents the more restrictive // free speech is -- because the more free the society, the // less any particular action the media takes seems scandalous if(LCSrandom(law[LAW_FREESPEECH] + 3)) break; Item *it=new Loot(*loottype[getloottype("LOOT_AMRADIOFILES")]); location[homes]->loot.push_back(it); erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has leaked proof of systemic AM Radio bias.", gamelog); gamelog.newline(); move(7,1); addstr("The papers are stashed at the homeless shelter.", gamelog); gamelog.nextMessage(); pause=true; } break; case CREATURE_SCIENTIST_LABTECH: case CREATURE_SCIENTIST_EMINENT: if(!location[homes]->siege.siege&&canseethings) { if(LCSrandom(law[LAW_ANIMALRESEARCH] + 3)) break; Item *it=new Loot(*loottype[getloottype("LOOT_RESEARCHFILES")]); location[homes]->loot.push_back(it); erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has leaked internal animal research reports.", gamelog); gamelog.newline(); move(7,1); addstr("They are stashed at the homeless shelter.", gamelog); gamelog.nextMessage(); pause=true; } break; case CREATURE_JUDGE_CONSERVATIVE: if(!location[homes]->siege.siege&&canseethings) { if(LCSrandom(5)) break; Item *it=new Loot(*loottype[getloottype("LOOT_JUDGEFILES")]); location[homes]->loot.push_back(it); erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has leaked proof of corruption in the judiciary.", gamelog); gamelog.newline(); move(7,1); addstr("The papers are stashed at the homeless shelter.", gamelog); gamelog.nextMessage(); pause=true; } break; case CREATURE_CCS_ARCHCONSERVATIVE: if(!location[homes]->siege.siege&&canseethings) { if(ccsexposure>=CCSEXPOSURE_LCSGOTDATA) break; Item *it=new Loot(*loottype[getloottype("LOOT_CCS_BACKERLIST")]); location[homes]->loot.push_back(it); erase(); move(6,1); addstr("Sleeper ", gamelog); addstr(cr.name, gamelog); addstr(" has leaked a list of the CCS's government backers.", gamelog); gamelog.newline(); move(7,1); addstr("The disk is stashed at the homeless shelter.", gamelog); gamelog.nextMessage(); pause=true; ccsexposure=CCSEXPOSURE_LCSGOTDATA; } break; } if(pause) getkey(); }
/* monthly - lets the player choose a special edition for the guardian */ int choosespecialedition(char &clearformess) { //Temporary, maybe put special edition definition into an xml file. -XML static const string document_types[] = { // This list MUST be in alphabetical order for binary_search() to work right "LOOT_AMRADIOFILES", "LOOT_CABLENEWSFILES", "LOOT_CCS_BACKERLIST", "LOOT_CEOLOVELETTERS", "LOOT_CEOPHOTOS", "LOOT_CEOTAXPAPERS", "LOOT_CORPFILES", "LOOT_INTHQDISK", "LOOT_JUDGEFILES", "LOOT_POLICERECORDS", "LOOT_PRISONFILES", "LOOT_RESEARCHFILES", "LOOT_SECRETDOCUMENTS" }; static const vector<string> dox(document_types,document_types+len(document_types)); int page=0; //char havetype[LOOTNUM]; //for(int l=0;l<LOOTNUM;l++)havetype[l]=0; vector<bool> havetype(len(loottype),false); vector<int> loottypeindex; //FIND ALL LOOT TYPES for(int loc=0;loc<len(location);loc++) { if(location[loc]->renting==RENTING_NOCONTROL) continue; consolidateloot(location[loc]->loot); for(int l=0;l<len(location[loc]->loot);l++) { if(!location[loc]->loot[l]->is_loot()) continue; if(!binary_search(dox.begin(),dox.end(),location[loc]->loot[l]->get_itemtypename())) continue; if(!havetype[getloottype(location[loc]->loot[l]->get_itemtypename())]) { loottypeindex.push_back(getloottype(location[loc]->loot[l]->get_itemtypename())); havetype[getloottype(location[loc]->loot[l]->get_itemtypename())]=true; } } } for(int sq=0;sq<len(squad);sq++) { consolidateloot(squad[sq]->loot); for(int l=0;l<len(squad[sq]->loot);l++) { if(!squad[sq]->loot[l]->is_loot()) continue; if(!binary_search(dox.begin(),dox.end(),squad[sq]->loot[l]->get_itemtypename())) continue; if(!havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())]) { loottypeindex.push_back(getloottype(squad[sq]->loot[l]->get_itemtypename())); havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())]=true; } } } if(!len(loottypeindex)) return -1; clearformess=1; //PICK ONE while(true) { music.play(MUSIC_NEWSPAPER); erase(); set_color(COLOR_WHITE,COLOR_BLACK,0); move(0,0); addstr("Do you want to run a special edition?"); int x=1,y=10; char str[200]; for(int l=page*18;l<len(loottypeindex)&&l<page*18+18;l++) { str[0]=l-page*18+'A'; str[1]='\x0'; strcat(str," - "); strcat(str,loottype[loottypeindex[l]]->get_name()); move(y,x); addstr(str); x+=26; if(x>53) x=1,y++; } //PAGE UP if(page>0) { move(17,1); addprevpagestr(); } //PAGE DOWN if((page+1)*18<len(loottype)) { move(17,53); addnextpagestr(); } move(24,1); addstr("Enter - Not in this month's Liberal Guardian"); int c=getkey(); if(c>='a'&&c<='r') { int slot=c-'a'+page*18; if(slot>=0&&slot<len(loottypeindex)) { //DELETE THE ITEM for(int loc=0;loc<len(location);loc++) { if(location[loc]->renting==RENTING_NOCONTROL) continue; for(int l=0;l<len(location[loc]->loot);l++) { if(!location[loc]->loot[l]->is_loot()) continue; if(getloottype(location[loc]->loot[l]->get_itemtypename())==loottypeindex[slot]) { location[loc]->loot[l]->decrease_number(1); if(location[loc]->loot[l]->empty()) delete_and_remove(location[loc]->loot,l); return loottypeindex[slot]; } } } for(int sq=0;sq<len(squad);sq++) { for(int l=0;l<len(squad[sq]->loot);l++) { if(!squad[sq]->loot[l]->is_loot()) continue; if(getloottype(squad[sq]->loot[l]->get_itemtypename())==loottypeindex[slot]) { squad[sq]->loot[l]->decrease_number(1); if(squad[sq]->loot[l]->empty()) delete_and_remove(squad[sq]->loot,l); return loottypeindex[slot]; } } } //WHOOPS! return loottypeindex[slot]; } } if(c=='x'||c==ENTER||c==ESC||c==SPACEBAR) return -1; //PAGE UP if((c==interface_pgup||c==KEY_UP||c==KEY_LEFT)&&page>0) page--; //PAGE DOWN if((c==interface_pgdn||c==KEY_DOWN||c==KEY_RIGHT)&&(page+1)*18<len(loottype)) page++; } return -1; }
/* monthly - lets the player choose a special edition for the guardian */ int choosespecialedition(char &clearformess) { int page=0; //char havetype[LOOTNUM]; //for(int l=0;l<LOOTNUM;l++)havetype[l]=0; vector<bool> havetype(loottype.size(),false); vector<int> loottypeindex; //FIND ALL LOOT TYPES for(int loc=0;loc<location.size();loc++) { if(location[loc]->renting==RENTING_NOCONTROL)continue; for(int l=0;l<location[loc]->loot.size();l++) { if(!location[loc]->loot[l]->is_loot())continue; //Temporary, maybe put special edition definition into an xml file. -XML if(location[loc]->loot[l]->get_itemtypename()!="LOOT_CEOPHOTOS"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_CEOLOVELETTERS"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_CEOTAXPAPERS"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_INTHQDISK"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_CORPFILES"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_JUDGEFILES"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_RESEARCHFILES"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_PRISONFILES"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_CABLENEWSFILES"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_AMRADIOFILES"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_SECRETDOCUMENTS"&& location[loc]->loot[l]->get_itemtypename()!="LOOT_POLICERECORDS")continue; if(!havetype[getloottype(location[loc]->loot[l]->get_itemtypename())]) { loottypeindex.push_back(getloottype(location[loc]->loot[l]->get_itemtypename())); havetype[getloottype(location[loc]->loot[l]->get_itemtypename())]=true; } } } for(int sq=0;sq<squad.size();sq++) { for(int l=0;l<squad[sq]->loot.size();l++) { if(!squad[sq]->loot[l]->is_loot())continue; if(squad[sq]->loot[l]->get_itemtypename()!="LOOT_CEOPHOTOS"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_CEOLOVELETTERS"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_CEOTAXPAPERS"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_INTHQDISK"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_CORPFILES"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_JUDGEFILES"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_RESEARCHFILES"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_PRISONFILES"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_CABLENEWSFILES"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_AMRADIOFILES"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_SECRETDOCUMENTS"&& squad[sq]->loot[l]->get_itemtypename()!="LOOT_POLICERECORDS")continue; if(!havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())]) { loottypeindex.push_back(getloottype(squad[sq]->loot[l]->get_itemtypename())); havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())]=true; } } } if(loottypeindex.size()==0)return -1; clearformess=1; //PICK ONE do { erase(); set_color(COLOR_WHITE,COLOR_BLACK,0); move(0,0); addstr("Do you want to run a special edition?"); int x=1,y=10; char str[200],str2[200]; for(int l=page*18;l<loottypeindex.size()&&l<page*18+18;l++) { str[0]=l-page*18+'A'; str[1]='\x0'; strcat(str," - "); strcat(str,loottype[loottypeindex[l]]->get_name().c_str()); move(y,x); addstr(str); x+=26; if(x>53) { x=1; y++; } } //PAGE UP if(page>0) { move(17,1); addprevpagestr(); } //PAGE DOWN if((page+1)*18<loottype.size()) { move(17,53); addnextpagestr(); } move(24,1); addstr("X - Not in this month's Liberal Guardian"); refresh(); int c=getch(); translategetch(c); if(c>='a'&&c<='r') { int slot=c-'a'+page*18; if(slot>=0&&slot<loottypeindex.size()) { //DELETE THE ITEM for(int loc=0;loc<location.size();loc++) { if(location[loc]->renting==RENTING_NOCONTROL)continue; for(int l=0;l<location[loc]->loot.size();l++) { if(!location[loc]->loot[l]->is_loot())continue; if(getloottype(location[loc]->loot[l]->get_itemtypename())==loottypeindex[slot]) { location[loc]->loot[l]->decrease_number(1); if(location[loc]->loot[l]->get_number()==0) { delete location[loc]->loot[l]; location[loc]->loot.erase(location[loc]->loot.begin() + l); } return loottypeindex[slot]; } } } for(int sq=0;sq<squad.size();sq++) { for(int l=0;l<squad[sq]->loot.size();l++) { if(!squad[sq]->loot[l]->is_loot())continue; if(getloottype(squad[sq]->loot[l]->get_itemtypename())==loottypeindex[slot]) { squad[sq]->loot[l]->decrease_number(1); if(squad[sq]->loot[l]->get_number()==0) { delete squad[sq]->loot[l]; squad[sq]->loot.erase(squad[sq]->loot.begin() + l); } return loottypeindex[slot]; } } } //WHOOPS! return loottypeindex[slot]; } } if(c=='x') { return -1; } //PAGE UP if((c==interface_pgup||c==KEY_UP||c==KEY_LEFT)&&page>0)page--; //PAGE DOWN if((c==interface_pgdn||c==KEY_DOWN||c==KEY_RIGHT)&&(page+1)*18<loottype.size())page++; }while(1); return -1; }