void create() { generate_name(); set_weight(1); set("unit", "粒"); set("long", "一粒道家炼制的"+name()+"。\n"); set("value", 0); set("no_get", 1); set("no_give", 1); ::init_item(); }
void create() { generate_name(); set_weight(10); set("unit", "面"); set("long", "一面五色流苏绣花令旗(shootf)。\n"); set("value", 0); set("level", 100); set("no_drop", 1); set("no_burn",1); ::init_item(); }
void create() { generate_name(); set("race", "Ұ��"); set("age", 10 + random(20)); set("long", "һֻϡ��Źֵ����Σ�����������ʲô������\n"); set("max_kee", 800); set("max_qin", 800); set("max_sen", 200); set("str", 20 + random(40)); set("cor",50); set("limbs", ({ "ͷ��", "����", "β��","צ��" }) );
void initialize_contacts(ContactPtr *phead, ContactPtr *ptail) { *phead = (struct Contact *)malloc(sizeof(struct Contact)); Contact *temp = *phead; for(int i=0; i<CSIZE; i++) { generate_gender(temp); generate_name(temp); generate_phone(temp); temp->next = (struct Contact *)malloc(sizeof(struct Contact)); if(i != (CSIZE - 1)) temp = temp->next; } *ptail = temp; }
void create() { generate_name(); set_weight(1); set("unit", "丸"); set("long", "一丸微现宝光的仙丹,有急救延命的神效。\n"); set("value", 100000+ random(1000000)); set("no_get", 1); set("no_give", 1); set("no_drop", 1); set("no_sell", 1); set("no_burn", 1); set_temp("to_cure", "none"); set_temp("cure", 5); ::init_item(); }
void queue_test_capa(void) { odp_queue_capability_t capa; odp_queue_param_t qparams; char name[ODP_QUEUE_NAME_LEN]; odp_queue_t queue[MAX_QUEUES]; uint32_t num_queues, i; memset(&capa, 0, sizeof(odp_queue_capability_t)); CU_ASSERT(odp_queue_capability(&capa) == 0); CU_ASSERT(capa.max_queues != 0); CU_ASSERT(capa.max_ordered_locks != 0); CU_ASSERT(capa.max_sched_groups != 0); CU_ASSERT(capa.sched_prios != 0); for (i = 0; i < ODP_QUEUE_NAME_LEN; i++) name[i] = 'A' + (i % 26); name[ODP_QUEUE_NAME_LEN - 1] = 0; if (capa.max_queues > MAX_QUEUES) num_queues = MAX_QUEUES; else num_queues = capa.max_queues; odp_queue_param_init(&qparams); for (i = 0; i < num_queues; i++) { generate_name(name, i); queue[i] = odp_queue_create(name, &qparams); if (queue[i] == ODP_QUEUE_INVALID) { CU_FAIL("Queue create failed"); num_queues = i; break; } CU_ASSERT(odp_queue_lookup(name) != ODP_QUEUE_INVALID); } for (i = 0; i < num_queues; i++) CU_ASSERT(odp_queue_destroy(queue[i]) == 0); }
/*------------------------------------------------------------------------- * Function: generate_symbols * * Purpose: Initializes the global dataset infomration arrays. * * Parameters: N/A * * Return: Success: 0 * Failure: Can't fail * *------------------------------------------------------------------------- */ int generate_symbols(void) { unsigned u, v; /* Local index variables */ for(u = 0; u < NLEVELS; u++) { symbol_info[u] = (symbol_info_t *)malloc(symbol_count[u] * sizeof(symbol_info_t)); for(v = 0; v < symbol_count[u]; v++) { char name_buf[64]; generate_name(name_buf, u, v); symbol_info[u][v].name = (char *)malloc(strlen(name_buf) + 1); strcpy(symbol_info[u][v].name, name_buf); symbol_info[u][v].dsid = -1; symbol_info[u][v].nrecords = 0; } /* end for */ } /* end for */ return 0; } /* end generate_symbols() */
static void remider_add_pin(int iID, const RoadMapPosition *position){ RoadMapDynamicString dID = generate_id(iID); RoadMapDynamicString dName = generate_name(iID); RoadMapDynamicString dSprite= roadmap_string_new( "Reminder"); RoadMapDynamicString dGroup = roadmap_string_new( "Reminders"); RoadMapDynamicString dImage_Reminder = roadmap_string_new( "reminder_pin"); RoadMapGpsPosition Pos; Pos.longitude = position->longitude; Pos.latitude = position->latitude; Pos.altitude = 0; Pos.speed = 0; Pos.steering = 0; roadmap_object_add( dGroup, dID, dName, dSprite, dImage_Reminder, &Pos, NULL, 0, NULL); roadmap_object_set_action(dID, OnReminderShortClick); roadmap_string_release(dID); roadmap_string_release(dName); roadmap_string_release(dGroup); roadmap_string_release(dSprite); roadmap_string_release(dImage_Reminder); }
int main(int argc, char* argv[]) { init_console(); // do this FIRST //start curses initscr(); gamelog.initialize(GAMELOG_FILEPATH, OVERWRITE_GAMELOG, NEWLINEMODE_GAMELOG); //Initialize the gamelog (and also initialize artdir and homedir) time_t t = time(0); struct tm *now = localtime(&t); //Do not need to deallocate this. Statically allocated by system char datetime[41]; sprintf(datetime, "---------%i-%02i-%02i %02i:%02i:%02i---------\n\n\n", now->tm_year+1900, now->tm_mon+1, now->tm_mday, now->tm_hour, now->tm_min, now->tm_sec); //YYYY-MM-DD HH:MM:SS format gamelog.log(string("\n\n\n---------- PROGRAM STARTED ----------\n") + datetime); char file_name[13]; FILE *file; music.play(MUSIC_TITLEMODE); // initialize music and play title mode song (do this BEFORE displaying anything on the screen, but AFTER initializing artdir and homedir) // set window title char wtitle[50]; strcpy(wtitle,"Liberal Crime Squad "); strcat(wtitle,PACKAGE_VERSION); set_title(wtitle); noecho(); //initialize curses color start_color(); initMainRNG(); //initialize the array of color pairs for(int i=0;i<8;i++) for(int j=0;j<8;j++) { if(i==0&&j==0) { init_pair(7*8,0,0); continue; } if(i==7&&j==0) continue; init_pair(i*8+j,i,j); } //turns off cursor curs_set(0); //begin the game loop keypad(stdscr,TRUE); raw_output(TRUE); //addstr("Loading Graphics... "); //getkey(); loadgraphics(); //addstr("Loading Init File Options... "); //getkey(); loadinitfile(); //addstr("Loading sitemaps.txt... "); //getkey(); oldMapMode=!readConfigFile("sitemaps.txt"); // load site map data if(oldMapMode) { addstr("Failed to load sitemaps.txt! Reverting to old map mode.",gamelog); gamelog.nextMessage(); getkey(); } //move(1,0); //addstr("Setting initial game data... "); //getkey(); strcpy(slogan,"We need a slogan!"); if(!LCSrandom(20)) { switch(LCSrandom(7)) { case 0: strcpy(slogan,"To Rogues and Revolution!"); break; case 1: strcpy(slogan,"Hell yes, LCS!"); break; case 2: strcpy(slogan,"Striking high, standing tall!"); break; case 3: strcpy(slogan,"Revolution never comes with a warning!"); break; case 4: strcpy(slogan,"True Liberal Justice!"); break; case 5: strcpy(slogan,"Laissez ain't fair!"); break; case 6: strcpy(slogan,"This is a slogan!"); break; } } //Initialize sorting choices. for(int s=0;s<SORTINGCHOICENUM;s++) activesortingchoice[s]=SORTING_NONE; for(int v=0;v<VIEWNUM;v++) { attitude[v]=30+LCSrandom(25); public_interest[v]=0; background_liberal_influence[v]=0; } attitude[VIEW_LIBERALCRIMESQUAD]=0; attitude[VIEW_LIBERALCRIMESQUADPOS]=5; //attitude[VIEW_POLITICALVIOLENCE]=5; #ifdef REVOLUTIONNOW for(int v=0;v<VIEWNUM;v++) attitude[v]=100; #endif law[LAW_ABORTION]=1; law[LAW_ANIMALRESEARCH]=-1; law[LAW_POLICEBEHAVIOR]=-1; law[LAW_PRIVACY]=-1; law[LAW_DEATHPENALTY]=-1; law[LAW_NUCLEARPOWER]=-1; law[LAW_POLLUTION]=-1; law[LAW_LABOR]=0; law[LAW_GAY]=1; law[LAW_CORPORATE]=0; law[LAW_FREESPEECH]=0; law[LAW_FLAGBURNING]=1; law[LAW_GUNCONTROL]=-1; law[LAW_TAX]=0; law[LAW_WOMEN]=1; law[LAW_CIVILRIGHTS]=1; law[LAW_DRUGS]=-1; law[LAW_IMMIGRATION]=0; law[LAW_ELECTIONS]=0; law[LAW_MILITARY]=-1; law[LAW_PRISONS]=0; law[LAW_TORTURE]=-1; #ifdef SHITLAWS for(int l=0;l<LAWNUM;l++) law[l]=-2; #endif #ifdef PERFECTLAWS for(int l=0;l<LAWNUM;l++) law[l]=2; #endif for(int s=0;s<SENATENUM;s++) { if(s<25) senate[s]=-2; else if(s<60) senate[s]=-1; else if(s<80) senate[s]=0; else if(s<95) senate[s]=1; else senate[s]=2; } for(int h=0;h<HOUSENUM;h++) { if(h<50) house[h]=-2; else if(h<250) house[h]=-1; else if(h<350) house[h]=0; else if(h<400) house[h]=1; else house[h]=2; } for(int c=0;c<COURTNUM;c++) { if(c<3) court[c]=-2; else if(c<5) court[c]=-1; else if(c<5) court[c]=0; else if(c<8) court[c]=1; else court[c]=2; do { if(court[c]==-2) generate_name(courtname[c],GENDER_WHITEMALEPATRIARCH); else generate_name(courtname[c]); } while(len(courtname[c])>20); } for(int e=0;e<EXECNUM;e++) { exec[e]=-2; generate_name(execname[e],GENDER_WHITEMALEPATRIARCH); } initOtherRNG(attorneyseed); strcpy(lcityname,cityname()); xmllog.initialize("xmllog",true,1); bool xml_loaded_ok = true; xml_loaded_ok&=populate_from_xml(vehicletype,"vehicles.xml",xmllog); xml_loaded_ok&=populate_from_xml(cliptype,"clips.xml",xmllog); xml_loaded_ok&=populate_from_xml(weapontype,"weapons.xml",xmllog); xml_loaded_ok&=populate_from_xml(armortype,"armors.xml",xmllog); xml_loaded_ok&=populate_masks_from_xml(armortype,"masks.xml",xmllog); xml_loaded_ok&=populate_from_xml(loottype,"loot.xml",xmllog); xml_loaded_ok&=populate_from_xml(creaturetype,"creatures.xml",xmllog); xml_loaded_ok&=populate_from_xml(augmenttype,"augmentations.xml",xmllog); if(!xml_loaded_ok) end_game(EXIT_FAILURE); //addstr("Attempting to load saved game... "); //getkey(); //addstr("Setup complete!"); //getkey(); clear(); mode_title(); //deinitialize curses end_game(); return EXIT_SUCCESS; }
OOMember::OOMember(size_t s, size_t o, InsnSet e) : OOElement(s) { set_offset(o); add_evidence(e); generate_name(); assess_type_from_size(); }
/* endgame - attempts to pass a constitutional amendment to help win the game */ void tossjustices(char canseethings) { int j; if(canseethings) { music.play(MUSIC_ELECTIONS); erase(); set_color(COLOR_WHITE,COLOR_BLACK,1); move(12,6); addstr("The Elite Liberal Congress is proposing an ELITE LIBERAL AMENDMENT!"); getkey(); } //STATE THE AMENDMENT if(canseethings) { int tossnum=0; for(j=0;j<COURTNUM;j++) if(court[j]!=ALIGN_ELITELIBERAL) tossnum++; amendmentheading(); move(2,5); addstr("The following former citizen"); if(tossnum!=1)addstr("s are"); else addstr(" is"); addstr(" branded Arch-Conservative:"); int y=4; for(j=0;j<COURTNUM;j++) if(court[j]!=ALIGN_ELITELIBERAL) { move(y++,0); addstr(courtname[j]); } move(y+1,5); addstr("In particular, the aforementioned former citizen"); if(tossnum!=1)addstr("s"); addstr(" may"); move(y+2,0); addstr("not serve on the Supreme Court. Said former citizen"); if(tossnum!=1)addstr("s"); addstr(" will"); move(y+3,0); addstr("be deported to "); if(tossnum!=1)addstr("Conservative countries"); else addstr("a Conservative country"); addstr(" of the President's"); move(y+4,0); addstr("choosing to be replaced by "); if(tossnum!=1)addstr("Proper Justices"); else addstr("a Proper Justice"); addstr(", also of"); move(y+5,0); addstr("the President's choosing with the advice and consent of"); move(y+6,0); addstr("the Senate."); move(24,0); addstr("Press 'C' to watch the ratification process unfold."); while(getkey()!='c'); } if(ratify(2,-1,-1,1,canseethings)) { //BLAST JUSTICES for(int j=0;j<COURTNUM;j++) if(court[j]!=ALIGN_ELITELIBERAL) { do generate_name(courtname[j]); while(len(courtname[j])>20); court[j]=ALIGN_ELITELIBERAL; } amendnum++; } if(canseethings) { move(24,0); addstr("Press any key to reflect on what has happened."); getkey(); } }
std::string default_generate_map(size_t width, size_t height, size_t island_size, size_t island_off_center, size_t iterations, size_t hill_size, size_t max_lakes, size_t nvillages, size_t castle_size, size_t nplayers, bool roads_between_castles, std::map<map_location,std::string>* labels, const config& cfg) { log_scope("map generation"); // Odd widths are nasty VALIDATE(is_even(width), _("Random maps with an odd width aren't supported.")); int ticks = SDL_GetTicks(); // Find out what the 'flatland' on this map is, i.e. grassland. std::string flatland = cfg["default_flatland"]; if(flatland == "") { flatland = t_translation::write_terrain_code(t_translation::GRASS_LAND); } const t_translation::t_terrain grassland = t_translation::read_terrain_code(flatland); // We want to generate a map that is 9 times bigger // than the actual size desired. // Only the middle part of the map will be used, // but the rest is so that the map we end up using // can have a context (e.g. rivers flowing from // out of the map into the map, same for roads, etc.) width *= 3; height *= 3; LOG_NG << "generating height map...\n"; // Generate the height of everything. const height_map heights = generate_height_map(width,height,iterations,hill_size,island_size,island_off_center); LOG_NG << "done generating height map...\n"; LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks(); config naming = cfg.child_or_empty("naming"); // HACK: dummy names to satisfy unit_race requirements naming["id"] = "village_naming"; naming["plural_name"] = "villages"; // Make a dummy race for generating names const unit_race name_generator(naming); std::vector<terrain_height_mapper> height_conversion; BOOST_FOREACH(const config &h, cfg.child_range("height")) { height_conversion.push_back(terrain_height_mapper(h)); } terrain_map terrain(width, t_translation::t_list(height, grassland)); size_t x, y; for(x = 0; x != heights.size(); ++x) { for(y = 0; y != heights[x].size(); ++y) { for(std::vector<terrain_height_mapper>::const_iterator i = height_conversion.begin(); i != height_conversion.end(); ++i) { if(i->convert_terrain(heights[x][y])) { terrain[x][y] = i->convert_to(); break; } } } } std::map<int, t_translation::coordinate> starting_positions; LOG_NG << output_map(terrain, starting_positions); LOG_NG << "placed land forms\n"; LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks(); // Now that we have our basic set of flatland/hills/mountains/water, // we can place lakes and rivers on the map. // All rivers are sourced at a lake. // Lakes must be in high land - at least 'min_lake_height'. // (Note that terrain below a certain altitude may be made // into bodies of water in the code above - i.e. 'sea', // but these are not considered 'lakes', because // they are not sources of rivers). // // We attempt to place 'max_lakes' lakes. // Each lake will be placed at a random location, // if that random location meets the minimum terrain requirements for a lake. // We will also attempt to source a river from each lake. std::set<location> lake_locs; std::map<location, std::string> river_names, lake_names, road_names, bridge_names, mountain_names, forest_names, swamp_names; const size_t nlakes = max_lakes > 0 ? (rand()%max_lakes) : 0; for(size_t lake = 0; lake != nlakes; ++lake) { for(int tries = 0; tries != 100; ++tries) { const int x = rand()%width; const int y = rand()%height; if (heights[x][y] > cfg["min_lake_height"].to_int()) { std::vector<location> river = generate_river(heights, terrain, x, y, cfg["river_frequency"]); if(river.empty() == false && labels != NULL) { std::string base_name; LOG_NG << "generating name for river...\n"; const std::string& name = generate_name(name_generator,"river_name",&base_name); LOG_NG << "named river '" << name << "'\n"; size_t name_frequency = 20; for(std::vector<location>::const_iterator r = river.begin(); r != river.end(); ++r) { const map_location loc(r->x-width/3,r->y-height/3); if(((r - river.begin())%name_frequency) == name_frequency/2) { labels->insert(std::pair<map_location,std::string>(loc,name)); } river_names.insert(std::pair<location,std::string>(loc,base_name)); } LOG_NG << "put down river name...\n"; } LOG_NG << "generating lake...\n"; std::set<location> locs; bool res = generate_lake(terrain, x, y, cfg["lake_size"], locs); if(res && labels != NULL) { bool touches_other_lake = false; std::string base_name; const std::string& name = generate_name(name_generator,"lake_name",&base_name); std::set<location>::const_iterator i; // Only generate a name if the lake hasn't touched any other lakes, // so that we don't end up with one big lake with multiple names. for(i = locs.begin(); i != locs.end(); ++i) { if(lake_locs.count(*i) != 0) { touches_other_lake = true; // Reassign the name of this lake to be the same as the other lake const location loc(i->x-width/3,i->y-height/3); const std::map<location,std::string>::const_iterator other_name = lake_names.find(loc); if(other_name != lake_names.end()) { base_name = other_name->second; } } lake_locs.insert(*i); } if(!touches_other_lake) { const map_location loc(x-width/3,y-height/3); labels->erase(loc); labels->insert(std::pair<map_location,std::string>(loc,name)); } for(i = locs.begin(); i != locs.end(); ++i) { const location loc(i->x-width/3,i->y-height/3); lake_names.insert(std::pair<location, std::string>(loc, base_name)); } } break; } } } LOG_NG << "done generating rivers...\n"; LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks(); const size_t default_dimensions = 40*40*9; /* * Convert grassland terrain to other types of flat terrain. * * We generate a 'temperature map' which uses the height generation * algorithm to generate the temperature levels all over the map. Then we * can use a combination of height and terrain to divide terrain up into * more interesting types than the default. */ const height_map temperature_map = generate_height_map(width,height, cfg["temperature_iterations"].to_int() * width * height / default_dimensions, cfg["temperature_size"], 0, 0); LOG_NG << "generated temperature map...\n"; LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks(); std::vector<terrain_converter> converters; BOOST_FOREACH(const config &cv, cfg.child_range("convert")) { converters.push_back(terrain_converter(cv)); } LOG_NG << "created terrain converters\n"; LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks(); // Iterate over every flatland tile, and determine // what type of flatland it is, based on our [convert] tags. for(x = 0; x != width; ++x) { for(y = 0; y != height; ++y) { for(std::vector<terrain_converter>::const_iterator i = converters.begin(); i != converters.end(); ++i) { if(i->convert_terrain(terrain[x][y],heights[x][y],temperature_map[x][y])) { terrain[x][y] = i->convert_to(); break; } } } } LOG_NG << "placing villages...\n"; LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks(); /* * Place villages in a 'grid', to make placing fair, but with villages * displaced from their position according to terrain and randomness, to * add some variety. */ std::set<location> villages; LOG_NG << "placing castles...\n"; /** Try to find configuration for castles. */ const config &castle_config = cfg.child("castle"); if (!castle_config) { LOG_NG << "Could not find castle configuration\n"; return std::string(); } /* * Castle configuration tag contains a 'valid_terrain' attribute which is a * list of terrains that the castle may appear on. */ const t_translation::t_list list = t_translation::read_list(castle_config["valid_terrain"]); const is_valid_terrain terrain_tester(terrain, list); /* * Attempt to place castles at random. * * Once we have placed castles, we run a sanity check to make sure that the * castles are well-placed. If the castles are not well-placed, we try * again. Definition of 'well-placed' is if no two castles are closer than * 'min_distance' hexes from each other, and the castles appear on a * terrain listed in 'valid_terrain'. */ std::vector<location> castles; std::set<location> failed_locs; for(size_t player = 0; player != nplayers; ++player) { LOG_NG << "placing castle for " << player << "\n"; log_scope("placing castle"); const int min_x = width/3 + 3; const int min_y = height/3 + 3; const int max_x = (width/3)*2 - 4; const int max_y = (height/3)*2 - 4; int min_distance = castle_config["min_distance"]; location best_loc; int best_ranking = 0; for(int x = min_x; x != max_x; ++x) { for(int y = min_y; y != max_y; ++y) { const location loc(x,y); if(failed_locs.count(loc)) { continue; } const int ranking = rank_castle_location(x,y,terrain_tester,min_x,max_x,min_y,max_y,min_distance,castles,best_ranking); if(ranking <= 0) { failed_locs.insert(loc); } if(ranking > best_ranking) { best_ranking = ranking; best_loc = loc; } } } if(best_ranking == 0) { ERR_NG << "No castle location found, aborting.\n"; std::string error = _("No valid castle location found. Too many or too few mountain hexes? (please check the 'max hill size' parameter)"); throw mapgen_exception(error); } assert(std::find(castles.begin(), castles.end(), best_loc) == castles.end()); castles.push_back(best_loc); // Make sure the location can't get a second castle. failed_locs.insert(best_loc); } LOG_NG << "placing roads...\n"; LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks(); // Place roads. // We select two tiles at random locations on the borders // of the map, and try to build roads between them. int nroads = cfg["roads"]; if(roads_between_castles) { nroads += castles.size()*castles.size(); } std::set<location> bridges; road_path_calculator calc(terrain,cfg); for (int road = 0; road != nroads; ++road) { log_scope("creating road"); /* * We want the locations to be on the portion of the map we're actually * going to use, since roads on other parts of the map won't have any * influence, and doing it like this will be quicker. */ location src = random_point_at_side(width/3 + 2,height/3 + 2); location dst = random_point_at_side(width/3 + 2,height/3 + 2); src.x += width/3 - 1; src.y += height/3 - 1; dst.x += width/3 - 1; dst.y += height/3 - 1; if (roads_between_castles && road < int(castles.size() * castles.size())) { const size_t src_castle = road/castles.size(); const size_t dst_castle = road%castles.size(); if(src_castle >= dst_castle) { continue; } src = castles[src_castle]; dst = castles[dst_castle]; } // If the road isn't very interesting (on the same border), don't draw it. else if(src.x == dst.x || src.y == dst.y) { continue; } if (calc.cost(src, 0.0) >= 1000.0 || calc.cost(dst, 0.0) >= 1000.0) { continue; } // Search a path out for the road pathfind::plain_route rt = pathfind::a_star_search(src, dst, 10000.0, &calc, width, height); std::string road_base_name; const std::string& name = generate_name(name_generator, "road_name", &road_base_name); const int name_frequency = 20; int name_count = 0; bool on_bridge = false; // Draw the road. // If the search failed, rt.steps will simply be empty. for(std::vector<location>::const_iterator step = rt.steps.begin(); step != rt.steps.end(); ++step) { const int x = step->x; const int y = step->y; if(x < 0 || y < 0 || x >= static_cast<long>(width) || y >= static_cast<long>(height)) { continue; } // Find the configuration which tells us // what to convert this tile to, to make it into a road. if (const config &child = cfg.find_child("road_cost", "terrain", t_translation::write_terrain_code(terrain[x][y]))) { // Convert to bridge means that we want to convert // depending upon the direction the road is going. // Typically it will be in a format like, // convert_to_bridge=\,|,/ // '|' will be used if the road is going north-south // '/' will be used if the road is going south west-north east // '\' will be used if the road is going south east-north west // The terrain will be left unchanged otherwise // (if there is no clear direction). const std::string &convert_to_bridge = child["convert_to_bridge"]; if(convert_to_bridge.empty() == false) { if(step == rt.steps.begin() || step+1 == rt.steps.end()) continue; const location& last = *(step-1); const location& next = *(step+1); location adj[6]; get_adjacent_tiles(*step,adj); int direction = -1; // If we are going north-south if((last == adj[0] && next == adj[3]) || (last == adj[3] && next == adj[0])) { direction = 0; } // If we are going south west-north east else if((last == adj[1] && next == adj[4]) || (last == adj[4] && next == adj[1])) { direction = 1; } // If we are going south east-north west else if((last == adj[2] && next == adj[5]) || (last == adj[5] && next == adj[2])) { direction = 2; } if(labels != NULL && on_bridge == false) { on_bridge = true; std::string bridge_base_name; const std::string& name = generate_name(name_generator, "bridge_name", &bridge_base_name); const location loc(x - width / 3, y-height/3); labels->insert(std::pair<map_location,std::string>(loc,name)); bridge_names.insert(std::pair<location,std::string>(loc, bridge_base_name)); //add to use for village naming bridges.insert(loc); } if(direction != -1) { const std::vector<std::string> items = utils::split(convert_to_bridge); if(size_t(direction) < items.size() && items[direction].empty() == false) { terrain[x][y] = t_translation::read_terrain_code(items[direction]); } continue; } } else { on_bridge = false; } // Just a plain terrain substitution for a road const std::string &convert_to = child["convert_to"]; if(convert_to.empty() == false) { const t_translation::t_terrain letter = t_translation::read_terrain_code(convert_to); if(labels != NULL && terrain[x][y] != letter && name_count++ == name_frequency && on_bridge == false) { labels->insert(std::pair<map_location,std::string>(map_location(x-width/3,y-height/3),name)); name_count = 0; } terrain[x][y] = letter; const location loc(x - width / 3, y - height / 3); //add to use for village naming road_names.insert(std::pair<location,std::string>(loc, road_base_name)); } } } LOG_NG << "looked at " << calc.calls << " locations\n"; } // Now that road drawing is done, we can plonk down the castles. for(std::vector<location>::const_iterator c = castles.begin(); c != castles.end(); ++c) { if(c->valid() == false) { continue; } const int x = c->x; const int y = c->y; const int player = c - castles.begin() + 1; const struct t_translation::coordinate coord(x, y); starting_positions.insert(std::pair<int, t_translation::coordinate>(player, coord)); terrain[x][y] = t_translation::HUMAN_KEEP; const int castles[13][2] = { {-1, 0}, {-1, -1}, {0, -1}, {1, -1}, {1, 0}, {0, 1}, {-1, 1}, {-2, 1}, {-2, 0}, {-2, -1}, {-1, -2}, {0, -2}, {1, -2} }; for (size_t i = 0; i < castle_size - 1; i++) { terrain[x+castles[i][0]][y+castles[i][1]] = t_translation::HUMAN_CASTLE; } // Remove all labels under the castle tiles if(labels != NULL) { labels->erase(location(x-width/3,y-height/3)); for (size_t i = 0; i < castle_size - 1; i++) { labels->erase(location(x+castles[i][0]-width/3, y+castles[i][1]-height/3)); } } } LOG_NG << "placed castles\n"; LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks(); /*Random naming for landforms: mountains, forests, swamps, hills *we name these now that everything else is placed (as e.g., placing * roads could split a forest) */ for (x = width / 3; x < (width / 3)*2; x++) { for (y = height / 3; y < (height / 3) * 2;y++) { //check the terrain of the tile const location loc(x - width / 3, y - height / 3); const t_translation::t_terrain terr = terrain[x][y]; std::string name, base_name; std::set<std::string> used_names; if (t_translation::terrain_matches(terr, t_translation::ALL_MOUNTAINS)) { //name every 15th mountain if ((rand()%15) == 0) { for(size_t ntry = 0; ntry != 30 && (ntry == 0 || used_names.count(name) > 0); ++ntry) { name = generate_name(name_generator, "mountain_name", &base_name); } labels->insert(std::pair<map_location, std::string>(loc, name)); mountain_names.insert(std::pair<location, std::string>(loc, base_name)); } } else if (t_translation::terrain_matches(terr, t_translation::ALL_FORESTS)) { //if the forest tile is not named yet, name it const std::map<location, std::string>::const_iterator forest_name = forest_names.find(loc); if(forest_name == forest_names.end()) { for(size_t ntry = 0; ntry != 30 && (ntry == 0 || used_names.count(name) > 0); ++ntry) { name = generate_name(name_generator, "forest_name", &base_name); } forest_names.insert(std::pair<location, std::string>(loc, base_name)); // name all connected forest tiles accordingly flood_name(loc, base_name, forest_names, t_translation::ALL_FORESTS, terrain, width, height, 0, labels, name); } } else if (t_translation::terrain_matches(terr, t_translation::ALL_SWAMPS)) { //if the swamp tile is not named yet, name it const std::map<location, std::string>::const_iterator swamp_name = swamp_names.find(loc); if(swamp_name == swamp_names.end()) { for(size_t ntry = 0; ntry != 30 && (ntry == 0 || used_names.count(name) > 0); ++ntry) { name = generate_name(name_generator, "swamp_name", &base_name); } swamp_names.insert(std::pair<location, std::string>(loc, base_name)); // name all connected swamp tiles accordingly flood_name(loc, base_name, swamp_names, t_translation::ALL_SWAMPS, terrain, width, height, 0, labels, name); } } } } if (nvillages > 0) { config naming_cfg = cfg.child_or_empty("village_naming"); // HACK: dummy names to satisfy unit_race requirements naming_cfg["id"] = "village_naming"; naming_cfg["plural_name"] = "villages"; const unit_race village_names_generator(naming_cfg); // First we work out the size of the x and y distance between villages const size_t tiles_per_village = ((width*height)/9)/nvillages; size_t village_x = 1, village_y = 1; // Alternate between incrementing the x and y value. // When they are high enough to equal or exceed the tiles_per_village, // then we have them to the value we want them at. while(village_x*village_y < tiles_per_village) { if(village_x < village_y) { ++village_x; } else { ++village_y; } } std::set<std::string> used_names; tcode_list_cache adj_liked_cache; for(size_t vx = 0; vx < width; vx += village_x) { LOG_NG << "village at " << vx << "\n"; for(size_t vy = rand()%village_y; vy < height; vy += village_y) { const size_t add_x = rand()%3; const size_t add_y = rand()%3; const size_t x = (vx + add_x) - 1; const size_t y = (vy + add_y) - 1; const map_location res = place_village(terrain,x,y,2,cfg,adj_liked_cache); if(res.x >= static_cast<long>(width) / 3 && res.x < static_cast<long>(width * 2) / 3 && res.y >= static_cast<long>(height) / 3 && res.y < static_cast<long>(height * 2) / 3) { const std::string str = t_translation::write_terrain_code(terrain[res.x][res.y]); if (const config &child = cfg.find_child("village", "terrain", str)) { const std::string &convert_to = child["convert_to"]; if(convert_to != "") { terrain[res.x][res.y] = t_translation::read_terrain_code(convert_to); villages.insert(res); if(labels != NULL && naming_cfg.empty() == false) { const map_location loc(res.x-width/3,res.y-height/3); map_location adj[6]; get_adjacent_tiles(loc,adj); std::string name_type = "village_name"; const t_translation::t_list field = t_translation::t_list(1, t_translation::GRASS_LAND), forest = t_translation::t_list(1, t_translation::FOREST), mountain = t_translation::t_list(1, t_translation::MOUNTAIN), hill = t_translation::t_list(1, t_translation::HILL); size_t field_count = 0, forest_count = 0, mountain_count = 0, hill_count = 0; utils::string_map symbols; size_t n; for(n = 0; n != 6; ++n) { const std::map<location,std::string>::const_iterator road_name = road_names.find(adj[n]); if(road_name != road_names.end()) { symbols["road"] = road_name->second; name_type = "village_name_road"; break; } const std::map<location,std::string>::const_iterator river_name = river_names.find(adj[n]); if(river_name != river_names.end()) { symbols["river"] = river_name->second; name_type = "village_name_river"; const std::map<location,std::string>::const_iterator bridge_name = bridge_names.find(adj[n]); if(bridge_name != bridge_names.end()) { //we should always end up here, since if there is an adjacent bridge, there has to be an adjacent river too symbols["bridge"] = bridge_name->second; name_type = "village_name_river_bridge"; } break; } const std::map<location,std::string>::const_iterator forest_name = forest_names.find(adj[n]); if(forest_name != forest_names.end()) { symbols["forest"] = forest_name->second; name_type = "village_name_forest"; break; } const std::map<location,std::string>::const_iterator lake_name = lake_names.find(adj[n]); if(lake_name != lake_names.end()) { symbols["lake"] = lake_name->second; name_type = "village_name_lake"; break; } const std::map<location,std::string>::const_iterator mountain_name = mountain_names.find(adj[n]); if(mountain_name != mountain_names.end()) { symbols["mountain"] = mountain_name->second; name_type = "village_name_mountain"; break; } const std::map<location,std::string>::const_iterator swamp_name = swamp_names.find(adj[n]); if(swamp_name != swamp_names.end()) { symbols["swamp"] = swamp_name->second; name_type = "village_name_swamp"; break; } const t_translation::t_terrain terr = terrain[adj[n].x+width/3][adj[n].y+height/3]; if(std::count(field.begin(),field.end(),terr) > 0) { ++field_count; } else if(std::count(forest.begin(),forest.end(),terr) > 0) { ++forest_count; } else if(std::count(hill.begin(),hill.end(),terr) > 0) { ++hill_count; } else if(std::count(mountain.begin(),mountain.end(),terr) > 0) { ++mountain_count; } } if(n == 6) { if(field_count == 6) { name_type = "village_name_grassland"; } else if(forest_count >= 2) { name_type = "village_name_forest"; } else if(mountain_count >= 1) { name_type = "village_name_mountain_anonymous"; } else if(hill_count >= 2) { name_type = "village_name_hill"; } } std::string name; for(size_t ntry = 0; ntry != 30 && (ntry == 0 || used_names.count(name) > 0); ++ntry) { name = generate_name(village_names_generator,name_type,NULL,&symbols); } used_names.insert(name); labels->insert(std::pair<map_location,std::string>(loc,name)); } } } } } } } LOG_NG << "placed villages\n"; LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks(); return output_map(terrain, starting_positions); }
Configuration::Configuration(const std::string& directory, const std::string& filename) throw (ConfigurationException) { if (!filename.length()) { throw ConfigurationException("No valid configuration filename."); } std::string base_dir = get_home_directory(); create_directory(directory, base_dir); this->filename = base_dir + "/" + directory + "/" + filename; /* load file */ if (file_exists(this->filename)) { settings.read(this->filename); } /* load defaults */ cdef("player_name", generate_name()); cdef("show_player_name", "1"); cdef("player_skin", "goat"); cdef("fullscreen", "0"); cdef("show_scanlines", "1"); cdef("scanlines_intensity", "50"); cdef("music_volume", "128"); cdef("sfx_volume", "128"); cdef("master_server", "master.goatattack.net"); cdef("master_port", "25113"); cdef("server_name", "frederic's temple"); cdef("server_port", "25111"); cdef("game_mode", "0"); cdef("max_players", "12"); cdef("duration", "20"); cdef("warmup", "0"); cdef("bind_escape_device", "0"); cdef("bind_escape_param", "27"); cdef("bind_chat_device", "0"); cdef("bind_chat_param", "116"); cdef("bind_down_device", "0"); cdef("bind_down_param", "1073741905"); cdef("bind_drop1_device", "0"); cdef("bind_drop1_param", "115"); cdef("bind_drop2_device", "0"); cdef("bind_drop2_param", "100"); cdef("bind_drop3_device", "0"); cdef("bind_drop3_param", "102"); cdef("bind_fire_device", "0"); cdef("bind_fire_param", "97"); cdef("bind_jump_device", "0"); cdef("bind_jump_param", "32"); cdef("bind_left_device", "0"); cdef("bind_left_param", "1073741904"); cdef("bind_right_device", "0"); cdef("bind_right_param", "1073741903"); cdef("bind_stats_device", "0"); cdef("bind_stats_param", "9"); cdef("bind_up_device", "0"); cdef("bind_up_param", "1073741906"); cdef("deadzone_horizontal", "3200"); cdef("deadzone_vertical", "3200"); /* extract -> ready for quick access */ extract(); }
int rt_pipe_create(RT_PIPE *pipe, const char *name, int minor, size_t poolsize) #endif { struct rtipc_port_label plabel; struct sockaddr_ipc saddr; struct alchemy_pipe *pcb; struct service svc; size_t streambufsz; socklen_t addrlen; int ret, sock; if (threadobj_irq_p()) return -EPERM; CANCEL_DEFER(svc); pcb = xnmalloc(sizeof(*pcb)); if (pcb == NULL) { ret = -ENOMEM; goto out; } sock = __RT(socket(AF_RTIPC, SOCK_DGRAM, IPCPROTO_XDDP)); if (sock < 0) { warning("RTIPC/XDDP protocol not supported by kernel"); ret = -errno; xnfree(pcb); goto out; } if (name && *name) { namecpy(plabel.label, name); ret = __RT(setsockopt(sock, SOL_XDDP, XDDP_LABEL, &plabel, sizeof(plabel))); if (ret) goto fail_sockopt; } if (poolsize > 0) { ret = __RT(setsockopt(sock, SOL_XDDP, XDDP_POOLSZ, &poolsize, sizeof(poolsize))); if (ret) goto fail_sockopt; } streambufsz = ALCHEMY_PIPE_STREAMSZ; ret = __RT(setsockopt(sock, SOL_XDDP, XDDP_BUFSZ, &streambufsz, sizeof(streambufsz))); if (ret) goto fail_sockopt; memset(&saddr, 0, sizeof(saddr)); saddr.sipc_family = AF_RTIPC; saddr.sipc_port = minor; ret = __RT(bind(sock, (struct sockaddr *)&saddr, sizeof(saddr))); if (ret) goto fail_sockopt; if (minor == P_MINOR_AUTO) { /* Fetch the assigned minor device. */ addrlen = sizeof(saddr); ret = __RT(getsockname(sock, (struct sockaddr *)&saddr, &addrlen)); if (ret) goto fail_sockopt; if (addrlen != sizeof(saddr)) { ret = -EINVAL; goto fail_register; } minor = saddr.sipc_port; } generate_name(pcb->name, name, &pipe_namegen); pcb->sock = sock; pcb->minor = minor; pcb->magic = pipe_magic; if (syncluster_addobj(&alchemy_pipe_table, pcb->name, &pcb->cobj)) { ret = -EEXIST; goto fail_register; } pipe->handle = mainheap_ref(pcb, uintptr_t); CANCEL_RESTORE(svc); return minor; fail_sockopt: ret = -errno; if (ret == -EADDRINUSE) ret = -EBUSY; fail_register: __RT(close(sock)); xnfree(pcb); out: CANCEL_RESTORE(svc); return ret; }
OOMember::OOMember(size_t s, size_t o) : OOElement(s) { set_offset(o); generate_name(); assess_type_from_size(); }
/** * @fn int rt_buffer_create(RT_BUFFER *bf, const char *name, size_t bufsz, int mode) * @brief Create an IPC buffer. * * This routine creates an IPC object that allows tasks to send and * receive data asynchronously via a memory buffer. Data may be of an * arbitrary length, albeit this IPC is best suited for small to * medium-sized messages, since data always have to be copied to the * buffer during transit. Large messages may be more efficiently * handled by message queues (RT_QUEUE). * * @param bf The address of a buffer descriptor which can be later * used to identify uniquely the created object, upon success of this * call. * * @param name An ASCII string standing for the symbolic name of the * buffer. When non-NULL and non-empty, a copy of this string is used * for indexing the created buffer into the object registry. * * @param bufsz The size of the buffer space available to hold * data. The required memory is obtained from the main heap. * * @param mode The buffer creation mode. The following flags can be * OR'ed into this bitmask, each of them affecting the new buffer: * * - B_FIFO makes tasks pend in FIFO order for reading data from the * buffer. * * - B_PRIO makes tasks pend in priority order for reading data from * the buffer. * * This parameter also applies to tasks blocked on the buffer's write * side (see rt_buffer_write()). * * @return Zero is returned upon success. Otherwise: * * - -ENOMEM is returned if the system fails to get memory from the * main heap in order to create the buffer. * * - -EEXIST is returned if the @a name is conflicting with an already * registered buffer. * * - -EPERM is returned if this service was called from an * asynchronous context. * * Valid calling context: * * - Regular POSIX threads * - Xenomai threads * * @note Buffers can be shared by multiple processes which belong to * the same Xenomai session. */ int rt_buffer_create(RT_BUFFER *bf, const char *name, size_t bufsz, int mode) { struct alchemy_buffer *bcb; struct service svc; int sobj_flags = 0; int ret; if (threadobj_irq_p()) return -EPERM; if (bufsz == 0) return -EINVAL; CANCEL_DEFER(svc); bcb = xnmalloc(sizeof(*bcb)); if (bcb == NULL) { ret = __bt(-ENOMEM); goto fail; } bcb->buf = xnmalloc(bufsz); if (bcb == NULL) { ret = __bt(-ENOMEM); goto fail_bufalloc; } generate_name(bcb->name, name, &buffer_namegen); bcb->magic = buffer_magic; bcb->mode = mode; bcb->bufsz = bufsz; bcb->rdoff = 0; bcb->wroff = 0; bcb->fillsz = 0; if (mode & B_PRIO) sobj_flags = SYNCOBJ_PRIO; syncobj_init(&bcb->sobj, CLOCK_COPPERPLATE, sobj_flags, fnref_put(libalchemy, buffer_finalize)); if (syncluster_addobj(&alchemy_buffer_table, bcb->name, &bcb->cobj)) { ret = -EEXIST; goto fail_register; } bf->handle = mainheap_ref(bcb, uintptr_t); CANCEL_RESTORE(svc); return 0; fail_register: syncobj_uninit(&bcb->sobj); xnfree(bcb->buf); fail_bufalloc: xnfree(bcb); fail: CANCEL_RESTORE(svc); return ret; }
/* select new game options */ void setup_newgame() { music.play(MUSIC_NEWGAME); bool classicmode = false; bool strongccs = false; bool nightmarelaws = false; multipleCityMode = false; stalinmode = false; clear(); while(true) { set_color(COLOR_WHITE,COLOR_BLACK,1); move(4,6); addstr("New Game of Liberal Crime Squad: Advanced Gameplay Options"); move(7,0); set_color(COLOR_WHITE,COLOR_BLACK,0); if(classicmode) addstr("[X]"); else addstr("[ ]"); addstr(" A - Classic Mode: No Conservative Crime Squad."); move(9,0); if(!classicmode) set_color(COLOR_WHITE,COLOR_BLACK,0); else set_color(COLOR_BLACK,COLOR_BLACK,1); if(strongccs) addstr("[X]"); else addstr("[ ]"); addstr(" B - We Didn't Start The Fire: The CCS starts active and extremely strong."); move(11,0); set_color(COLOR_WHITE,COLOR_BLACK,0); if(nightmarelaws) addstr("[X]"); else addstr("[ ]"); addstr(" C - Nightmare Mode: Liberalism is forgotten. Is it too late to fight back?"); move(13,0); set_color(COLOR_WHITE,COLOR_BLACK,0); if(multipleCityMode) addstr("[X]"); else addstr("[ ]"); addstr(" D - National LCS: Advanced play across multiple cities."); move(15,0); if(nocourtpurge) addstr("[X]"); else addstr("[ ]"); addstr(" E - Marathon Mode: Prevent Liberals from amending the Constitution."); #ifdef ALLOWSTALIN move(17,0); if(stalinmode) addstr("[X]"); else addstr("[ ]"); addstr(" F - Stalinist Mode: Enable Stalinist Comrade Squad (not fully implemented)."); move(21,4); #else // ALLOWSTALIN move(19,4); #endif // ALLOWSTALIN addstr("Press any other key to continue..."); int c=getkey(); if(c=='a') { classicmode=!classicmode; continue; } if(c=='b') { strongccs=!strongccs; continue; } if(c=='c') { nightmarelaws=!nightmarelaws; continue; } if(c=='d') { multipleCityMode=!multipleCityMode; continue; } if(c=='e') { nocourtpurge=!nocourtpurge; notermlimit=!notermlimit; continue; } #ifdef ALLOWSTALIN if(c=='f') { stalinmode=!stalinmode; continue; } #endif break; } if(nightmarelaws) { for(int l=0;l<LAWNUM;l++) law[l]=ALIGN_ARCHCONSERVATIVE; for(int a=0;a<VIEWNUM-3;a++) attitude[a]=LCSrandom(20); for(int s=0;s<SENATENUM;s++) { if(s<55) senate[s]=ALIGN_ARCHCONSERVATIVE; else if(s<70) senate[s]=ALIGN_CONSERVATIVE; else if(s<80) senate[s]=ALIGN_MODERATE; else if(s<97) senate[s]=ALIGN_LIBERAL; else senate[s]=ALIGN_ELITELIBERAL; } for(int h=0;h<HOUSENUM;h++) { if(h<220) house[h]=ALIGN_ARCHCONSERVATIVE; else if(h<350) house[h]=ALIGN_CONSERVATIVE; else if(h<400) house[h]=ALIGN_MODERATE; else if(h<425) house[h]=ALIGN_LIBERAL; else house[h]=ALIGN_ELITELIBERAL; } for(int c=0;c<COURTNUM;c++) { if(c<5) court[c]=ALIGN_ARCHCONSERVATIVE; else if(c<7) court[c]=ALIGN_CONSERVATIVE; else if(c<8) court[c]=ALIGN_MODERATE; else if(c<8) court[c]=ALIGN_LIBERAL; else court[c]=ALIGN_ELITELIBERAL; do { if(court[c]==ALIGN_ARCHCONSERVATIVE) generate_name(courtname[c],GENDER_WHITEMALEPATRIARCH); else generate_name(courtname[c]); } while(len(courtname[c])>20); } } if(classicmode) endgamestate=ENDGAME_CCS_DEFEATED; else if(strongccs) { endgamestate=ENDGAME_CCS_ATTACKS; //attitude[VIEW_POLITICALVIOLENCE]=90; } clear(); while(true) { set_color(COLOR_WHITE,COLOR_BLACK,1); move(4,6); addstr("New Game of Liberal Crime Squad: Your Agenda"); move(7,0); set_color(COLOR_WHITE,COLOR_BLACK,0); if(wincondition==WINCONDITION_ELITE) addstr("[X]"); else addstr("[ ]"); addstr(" A - No Compromise Classic - I will make all our laws Elite Liberal!"); move(9,0); if(!classicmode) set_color(COLOR_WHITE,COLOR_BLACK,0); else set_color(COLOR_BLACK,COLOR_BLACK,1); if(wincondition==WINCONDITION_EASY) addstr("[X]"); else addstr("[ ]"); addstr(" B - Democrat Mode - Most laws must be Elite Liberal, some can be Liberal."); move(13,4); set_color(COLOR_WHITE,COLOR_BLACK,0); addstr("Press any other key to continue..."); int c=getkey(); if(c=='a') { wincondition=WINCONDITION_ELITE; continue; } if(c=='b') { wincondition=WINCONDITION_EASY; continue; } break; } clear(); while(true) { set_color(COLOR_WHITE,COLOR_BLACK,1); move(4,6); addstr("New Game of Liberal Crime Squad: Field Learning"); set_color(COLOR_WHITE,COLOR_BLACK,0); move(5,6); addstr("(affects Security, Stealth, Disguise, & Driving)"); move(8,0); if(fieldskillrate==FIELDSKILLRATE_FAST) addstr("[X]"); else addstr("[ ]"); addstr(" A - Fast skills - Grinding is Conservative!"); move(10,0); if(fieldskillrate==FIELDSKILLRATE_CLASSIC) addstr("[X]"); else addstr("[ ]"); addstr(" B - Classic - Excellence requires practice."); move(12,0); if(fieldskillrate==FIELDSKILLRATE_HARD) addstr("[X]"); else addstr("[ ]"); addstr(" C - Hard Mode - Learn from the best, or face arrest!"); move(16,4); set_color(COLOR_WHITE,COLOR_BLACK,0); addstr("Press any other key to continue..."); int c=getkey(); if(c=='a') { fieldskillrate=FIELDSKILLRATE_FAST; continue; } if(c=='b') { fieldskillrate=FIELDSKILLRATE_CLASSIC; continue; } if(c=='c') { fieldskillrate=FIELDSKILLRATE_HARD; continue; } break; } }
/* creates your founder */ void makecharacter() { Creature *newcr=new Creature; newcr->align=1; #ifdef BLIND newcr->special[SPECIALWOUND_RIGHTEYE]=1; newcr->special[SPECIALWOUND_LEFTEYE]=1; #endif #ifdef SPINE newcr->special[SPECIALWOUND_UPPERSPINE]=1; newcr->special[SPECIALWOUND_LOWERSPINE]=1; #endif #ifdef NOFACE newcr->special[SPECIALWOUND_TONGUE]=1; newcr->special[SPECIALWOUND_RIGHTEYE]=1; newcr->special[SPECIALWOUND_LEFTEYE]=1; newcr->special[SPECIALWOUND_NOSE]=1; #endif #ifdef NOWALK newcr->special[SPECIALWOUND_UPPERSPINE]=1; newcr->special[SPECIALWOUND_LOWERSPINE]=1; newcr->special[SPECIALWOUND_NECK]=1; newcr->wound[BODYPART_LEG_RIGHT]=1; newcr->wound[BODYPART_LEG_LEFT]=1; #endif #ifdef INTERNAL newcr->special[SPECIALWOUND_RIGHTLUNG]=1; newcr->special[SPECIALWOUND_LEFTLUNG]=1; newcr->special[SPECIALWOUND_HEART]=1; newcr->special[SPECIALWOUND_LIVER]=1; newcr->special[SPECIALWOUND_STOMACH]=1; newcr->special[SPECIALWOUND_LEFTKIDNEY]=1; newcr->special[SPECIALWOUND_RIGHTKIDNEY]=1; newcr->special[SPECIALWOUND_SPLEEN]=1; #endif newcr->set_attribute(ATTRIBUTE_HEART,8); newcr->set_attribute(ATTRIBUTE_WISDOM,1); newcr->set_attribute(ATTRIBUTE_INTELLIGENCE,3); newcr->set_attribute(ATTRIBUTE_AGILITY,5); newcr->set_attribute(ATTRIBUTE_STRENGTH,4); newcr->set_attribute(ATTRIBUTE_HEALTH,6); newcr->set_attribute(ATTRIBUTE_CHARISMA,4); for(int sk=0;sk<SKILLNUM;sk++)newcr->set_skill(sk,0); char first[3][80]; char last[80]; bool male = LCSrandom(2); // whether or not starting gender is male char gender = newcr->gender_liberal = newcr->gender_conservative = (male ? GENDER_MALE : GENDER_FEMALE); do { firstname(first[0], GENDER_NEUTRAL); firstname(first[1], GENDER_MALE); firstname(first[2], GENDER_FEMALE); lastname(last); } while(strcmp(first[0],last) == 0 && strcmp(first[1],last) == 0 && strcmp(first[2],last) == 0); { Armor a(*armortype[getarmortype("ARMOR_CLOTHES")]); newcr->give_armor(a,NULL); } bool choices=true; while(true) { erase(); set_color(COLOR_WHITE,COLOR_BLACK,1); move(4,6); addstr("The Founder of the Liberal Crime Squad"); move(7,2); addstr("FIRST NAME: "); addstr(first[(int)gender]); move(7,30); set_color(COLOR_BLACK,COLOR_BLACK,1); addstr(" (Press A to have your parents reconsider)"); move(9,2); set_color(COLOR_WHITE,COLOR_BLACK,1); addstr("LAST NAME: "); addstr(last); move(9,30); set_color(COLOR_BLACK,COLOR_BLACK,1); addstr(" (Press B to be born to a different family)"); move(11,2); set_color(COLOR_WHITE,COLOR_BLACK,1); addstr("SEX: "); if(newcr->gender_conservative == GENDER_MALE) { set_color(COLOR_CYAN,COLOR_BLACK,1); addstr("Male"); } else if(newcr->gender_conservative == GENDER_FEMALE) { set_color(COLOR_MAGENTA,COLOR_BLACK,1); addstr("Female"); } else { set_color(COLOR_YELLOW,COLOR_BLACK,1); addstr("It's Complicated"); } move(11,30); set_color(COLOR_BLACK,COLOR_BLACK,1); addstr(" (Press C to change your sex at birth)"); move(13,2); set_color(COLOR_WHITE,COLOR_BLACK,1); addstr("HISTORY: "); if(choices) { set_color(COLOR_GREEN,COLOR_BLACK,1); addstr("Let Me Choose"); } else { set_color(COLOR_RED,COLOR_BLACK,1); addstr("Let Fate Decide"); } move(13,30); set_color(COLOR_BLACK,COLOR_BLACK,1); addstr(" (Press D to toggle childhood)"); if(!multipleCityMode) { move(15,2); set_color(COLOR_WHITE,COLOR_BLACK,1); addstr("CITY: "); addstr(lcityname); move(15,30); set_color(COLOR_BLACK,COLOR_BLACK,1); addstr(" (Press E to relocate)"); } move(19-multipleCityMode*2,4); set_color(COLOR_WHITE,COLOR_BLACK,0); addstr("Press any other key when ready to begin..."); int c=getkey(); if(c=='a') { do { firstname(first[(int)gender],newcr->gender_conservative); } while(strcmp(first[(int)gender],last) == 0); continue; } if(c=='b') { do { lastname(last); } while(strcmp(first[0],last) == 0 && strcmp(first[1],last) == 0 && strcmp(first[2],last) == 0); continue; } if(c=='c') { if((newcr->gender_conservative == GENDER_FEMALE && !male) || (newcr->gender_conservative == GENDER_NEUTRAL && male)) newcr->gender_conservative = GENDER_MALE; else if((newcr->gender_conservative == GENDER_MALE && !male) || (newcr->gender_conservative == GENDER_FEMALE && male)) newcr->gender_conservative = GENDER_NEUTRAL; else newcr->gender_conservative = GENDER_FEMALE; gender = newcr->gender_liberal = newcr->gender_conservative; continue; } if(c=='d') { choices = !choices; continue; } if(c=='e' && !multipleCityMode) { strcpy(lcityname,cityname()); continue; } break; } strcpy(newcr->propername,first[(int)gender]); strcat(newcr->propername," "); strcat(newcr->propername,last); int c; bool hasmaps=false; bool makelawyer=false; bool gaylawyer=false; Vehicle * startcar = NULL; char recruits = RECRUITS_NONE; char base = SITE_RESIDENTIAL_SHELTER; for(int q=0;q<10;q++) { erase(); set_color(COLOR_WHITE,COLOR_BLACK,1); move(0,0); addstr("Insight into a Revolution: My Traumatic Childhood"); set_color(COLOR_WHITE,COLOR_BLACK,0); //A - Thief //B - Fighter //C - Student //D - Generalist/Sleepers //E - Recruiter char selection = LCSrandom(5); switch(q) { /* - The anniversary of Hitler's suicide. - SKILL_PISTOL 1 (lol) - Indira Gandhi Killed */ case 0: move(2,0);addstr("The day I was born in 1984..."); move(5,0); if(choices || selection == 0) addstr("A - the Polish priest Popieluszko was kidnapped by government agents."); //ATTRIBUTE_AGILITY 2 // Oct. 19, 1984 move(7,0); if(choices || selection == 1) addstr("B - was the 3rd anniversary of the assassination attempt on Ronald Reagan."); //ATTRIBUTE_STRENGTH 2 // Mar. 3, 1984 move(9,0); if(choices || selection == 2) addstr("C - the Macintosh was introduced."); //ATTRIBUTE_INTELLIGENCE 2 // Jan. 24, 1984 move(11,0); if(choices || selection == 3) addstr("D - the Nobel Peace Prize went to Desmond Tutu for opposition to apartheid."); //ATTRIBUTE_HEART 2 // Oct. 16, 1984 move(13,0); if(choices || selection == 4) addstr("E - the Sandanista Front won the elections in Nicaragua."); //ATTRIBUTE_CHARISMA 2 // Sept. 4, 1984 //move(14,0); //if(choices || selection == 5) //addstr("F - the United Nations condemned Iraq's use of chemical weapons."); //ATTRIBUTE_HEALTH 2 //March 30, 1984 move(17,0); addstr("The doctor said I was "); set_color(COLOR_WHITE,COLOR_BLACK,1); if(newcr->gender_conservative == GENDER_MALE) addstr("a boy"); else if(newcr->gender_conservative == GENDER_FEMALE) addstr("a girl"); else addstr("an intersex baby"); set_color(COLOR_WHITE,COLOR_BLACK,0); addstr("."); move(19,0); addstr("My parents "); if(newcr->gender_conservative == GENDER_NEUTRAL) { addstr("insisted otherwise."); move(20,0); addstr("They "); } addstr("named me "); set_color(COLOR_WHITE,COLOR_BLACK,1); addstr(newcr->propername); set_color(COLOR_WHITE,COLOR_BLACK,0); addstr("."); break; // My first memory was... // my father burning my back with a cigarette // When he was really into the sauce... // // XXX: Needs an option to have the founder have been in the Army -- LK // XXX: Something I forgot. case 1: move(2,0);addstr("When I was bad..."); move(5,0); if(choices || selection == 0) addstr("A - my parents grounded me and hid my toys, but I knew where they put them."); // Toy box //SKILL_SECURITY 1 //ATTRIBUTE_AGILITY 1 move(7,0); if(choices || selection == 1) addstr("B - my father beat me. I learned to take a punch earlier than most."); //SKILL_HANDTOHAND 1 //ATTRIBUTE_HEALTH 1 move(9,0); if(choices || selection == 2) addstr("C - I was sent to my room, where I studied quietly by myself, alone."); //SKILL_WRITING 1 //ATTRIBUTE_INTELLIGENCE 1 move(11,0); if(choices || selection == 3) addstr("D - my parents argued with each other about me, but I was never punished."); //SKILL_PERSUASION 1 //ATTRIBUTE_HEART 1 move(13,0); if(choices || selection == 4) addstr("E - my father lectured me endlessly, trying to make me think like him."); //SKILL_PSYCHOLOGY 1 //ATTRIBUTE_CHARISMA 1 /*switch(c) { case 'e': move(17,4); addstr("\"The worst has happened. Someone wanted to kill and killed"); move(18,4); addstr("not only the a man, not only a Pole, not only a priest."); move(19,4); addstr("Someone wanted to kill the hope that it is possible to avoid"); move(20,4); addstr("violence in Polish political life.\""); move(21,8); addstr("- Solidarity Leader Lech Walesa"); break; default: break; }*/ break; case 2: move(2,0);addstr("In elementary school..."); move(5,0); if(choices || selection == 0) addstr("A - I was mischievous, and always up to something."); //SKILL_DISGUISE 1 //ATTRIBUTE_AGILITY 1 move(7,0); if(choices || selection == 1) addstr("B - I had a lot of repressed anger. I hurt animals."); //SKILL_PSYCHOLOGY 1 //ATTRIBUTE_STRENGTH 1 //ATTRIBUTE_AGILITY 1 //ATTRIBUTE_HEART -1 <--- ! move(9,0); if(choices || selection == 2) addstr("C - I was at the head of the class, and I worked very hard."); //ATTRIBUTE_INTELLIGENCE 1 //SKILL_WRITING 1 move(11,0); if(choices || selection == 3) addstr("D - I was unruly and often fought with the other children."); //SKILL_HANDTOHAND 1 //ATTRIBUTE_STRENGTH 1 move(13,0); if(choices || selection == 4) addstr("E - I was the class clown. I even had some friends."); //SKILL_PERSUASION 1 //ATTRIBUTE_CHARISMA 1 break; case 3: move(2,0);addstr("When I turned 10..."); move(5,0); if(choices || selection == 0) addstr("A - my parents divorced. Whenever I talked, they argued, so I stayed quiet."); //SKILL_STEALTH 1 move(7,0); if(choices || selection == 1) addstr("B - my parents divorced. Violently."); //SKILL_HANDTOHAND 1 move(9,0); if(choices || selection == 2) addstr("C - my parents divorced. Acrimoniously. I once tripped over the paperwork!"); //SKILL_LAW 1 move(11,0); if(choices || selection == 3) addstr("D - my parents divorced. Mom slept with the divorce lawyer."); //SKILL_SEDUCTION 1 move(13,0); if(choices || selection == 4) addstr("E - my parents divorced. It still hurts to read my old diary."); //SKILL_WRITING 1 break; case 4: move(2,0);addstr("In junior high school..."); move(5,0); if(choices || selection == 0) addstr("A - I was into chemistry. I wanted to know what made the world tick."); //SKILL_SCIENCE 2 //ATTRIBUTE_INTELLIGENCE 2 move(7,0); if(choices || selection == 1) addstr("B - I played guitar in a grunge band. We sucked, but so did life."); //SKILL_MUSIC 2 //ATTRIBUTE_CHARISMA 2 move(9,0); if(choices || selection == 2) addstr("C - I drew things, a lot. I was drawing a world better than this."); //SKILL_ART 2 //ATTRIBUTE_HEART 2 move(11,0); if(choices || selection == 3) addstr("D - I played violent video games at home. I was a total outcast."); //SKILL_COMPUTERS 2 //ATTRIBUTE_AGILITY 2 move(13,0); if(choices || selection == 4) addstr("E - I was obsessed with swords, and started lifting weights."); //SKILL_SWORD 2 //ATTRIBUTE_STRENGTH 2 break; case 5: move(2,0);addstr("Things were getting really bad..."); move(5,0); if(choices || selection == 0) addstr("A - when I stole my first car. I got a few blocks before I totaled it."); //SKILL_DRIVING 1 //SKILL_SECURITY 1 move(7,0); if(choices || selection == 1) addstr("B - and I went to live with my dad. He had been in Nam and he still drank."); //SKILL_SHOTGUN 1 //SKILL_RIFLE 1 //SKILL_PSYCHOLOGY 1 move(9,0); if(choices || selection == 2) addstr("C - and I went completely goth. I had no friends and made costumes by myself."); //SKILL_TAILORING 2 move(11,0); if(choices || selection == 3) addstr("D - when I was sent to religious counseling, just stressing me out more."); //SKILL_RELIGION 1 //SKILL_PSYCHOLOGY 1 move(13,0); if(choices || selection == 4) addstr("E - and I tried being a teacher's assistant. It just made me a target."); //SKILL_TEACHING 2 break; case 6: move(2,0);addstr("Well, I knew it had reached a crescendo when..."); move(5,0); if(choices || selection == 0) addstr("A - I stole a cop car when I was only 14. I went to juvie for 6 months."); //SKILL_DRIVING 1 //SKILL_SECURITY 1 //ATTRIBUTE_INTELLIGENCE 1 move(7,0); if(choices || selection == 1) addstr("B - my step mom shot her ex-husband, my dad, with a shotgun. She got off.");//XXX: Sounds... Sexual... //SKILL_SHOTGUN 2 //ATTRIBUTE_AGILITY 1 move(9,0); if(choices || selection == 2) addstr("C - I tried wrestling for a quarter, desperate to fit in."); //ATTRIBUTE_STRENGTH 1 //SKILL_HANDTOHAND 2 move(11,0); if(choices || selection == 3) addstr("D - I got caught making out, and now I needed to be 'cured' of homosexuality."); //SKILL_SEDUCTION 1 //SKILL_RELIGION 1 //ATTRIBUTE_HEART 1 move(13,0); if(choices || selection == 4) addstr("E - I resorted to controlling people. Had my own clique of outcasts."); //SKILL_PERSUASION 2 //ATTRIBUTE_CHARISMA 1 break; case 7: move(2,0);addstr("I was only 15 when I ran away, and..."); move(5,0); if(choices || selection == 0) addstr("A - I started robbing houses: rich people only. I was fed up with their crap."); //SKILL_SECURITY 1 //SKILL_STEALTH 1 //ATTRIBUTE_AGILITY 1 move(7,0); if(choices || selection == 1) addstr("B - I hung out with thugs and beat the shit out of people."); //ATTRIBUTE_STRENGTH 1 //SKILL_HANDTOHAND 2 move(9,0); if(choices || selection == 2) addstr("C - I got a horrible job working fast food, smiling as people fed the man."); //ATTRIBUTE_CHARISMA 1 //SKILL_BUSINESS 2 move(11,0); if(choices || selection == 3) addstr("D - I let people pay me for sex. I needed the money to survive."); //ATTRIBUTE_HEART -1 //ATTRIBUTE_CHARISMA 2 //SKILL_SEDUCTION 2 move(13,0); if(choices || selection == 4) addstr("E - I volunteered for a left-wing candidate. It wasn't *real*, though, you know?"); //ATTRIBUTE_INTELLIGENCE 1 //SKILL_LAW 1 //SKILL_PERSUASION 1 break; case 8: move(2,0);addstr("Life went on. On my 18th birthday..."); move(5,0); if(choices || selection == 0) addstr("A - I got my hands on a sports car. The owner must have been pissed."); move(7,0); if(choices || selection == 1) addstr("B - I bought myself an assault rifle."); move(9,0); if(choices || selection == 2) addstr("C - I celebrated. I'd saved a thousand bucks!"); move(11,0); if(choices || selection == 3) addstr("D - I went to a party and met a cool law student. We've been dating since.");//XXX: No Seduction? move(13,0); if(choices || selection == 4) addstr("E - I managed to acquire secret maps of several major buildings downtown."); break; case 9: move(2,0);addstr("For the past few years, I've been..."); move(5,0); if(choices || selection == 0) addstr("A - stealing from Corporations. I know they're still keeping more secrets."); //ATTRIBUTE_INTELLIGENCE 2 //ATTRIBUTE_AGILITY 2 //SKILL_SECURITY 2 //SKILL_STEALTH 2 // +Downtown apartment // +$500 (one month rent) move(7,0); if(choices || selection == 1) addstr("B - a violent criminal. Nothing can change me, or stand in my way."); //SKILL_RIFLE 2 //SKILL_PISTOL 2 //SKILL_STREETSENSE 2 //ATTRIBUTE_AGILITY 2 //ATTRIBUTE_HEALTH 2 //ATTRIBUTE_STRENGTH 2 // +Crack house (with stockpiled rations) // +A crew (four gang members with knives and pistols) move(9,0); if(choices || selection == 2) addstr("C - taking college courses. I can see how much the country needs help."); //SKILL_SCIENCE 2 //SKILL_COMPUTERS 2 //SKILL_WRITING 2 //SKILL_TEACHING 2 //SKILL_BUSINESS 1 //SKILL_LAW 1 //ATTRIBUTE_INTELLIGENCE 4 // +University apartment // +$200 (one month rent) move(11,0); if(choices || selection == 3) addstr("D - surviving alone, just like anyone. But we can't go on like this."); //SKILL_FIRSTAID 2 //SKILL_STREETSENSE 2 //ATTRIBUTE_INTELLIGENCE 1 //ATTRIBUTE_AGILITY 1 //ATTRIBUTE_HEALTH 2 // +Homeless shelter // +1 all stats (except Wisdom) move(13,0); if(choices || selection == 4) addstr("E - writing my manifesto and refining my image. I'm ready to lead."); //ATTRIBUTE_CHARISMA 2 //ATTRIBUTE_INTELLIGENCE 2 //SKILL_LAW 1 //SKILL_PERSUASION 2 //SKILL_WRITING 1 // +Industrial apartment // +$100 (one month rent) // +50 juice move(17,0); addstr("I live in "); if(!multipleCityMode) addstr(lcityname); else addstr("Seattle, WA"); addstr(", and it's about to experience real change."); break; } do { c=getkey(); if(!choices) c='a'+selection; } while(c<'a'||c>'e'); switch(q) { case 0: // Oct. 19, 1984 if(c=='a') { newcr->adjust_attribute(ATTRIBUTE_AGILITY,+2); newcr->birthday_month = 10; newcr->birthday_day = 19; } // Mar. 3, 1984 if(c=='b') { newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+2); newcr->birthday_month = 3; newcr->birthday_day = 3; } // Jan. 24, 1984 if(c=='c') { newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+2); newcr->birthday_month = 1; newcr->birthday_day = 24; } // Oct. 16, 1984 if(c=='d') { newcr->adjust_attribute(ATTRIBUTE_HEART,+2); newcr->birthday_month = 10; newcr->birthday_day = 16; } // Sep. 4, 1984 if(c=='e') { newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+2); newcr->birthday_month = 9; newcr->birthday_day = 4; } newcr->age = year - 1984; // Don't count this year in founder's age if starting before birthday if(month < newcr->birthday_month || (month==newcr->birthday_month && day<newcr->birthday_day)) { newcr->age--; } break; case 1: if(c=='a') { newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(1)); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1); } if(c=='b') { newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(1)); newcr->adjust_attribute(ATTRIBUTE_HEALTH,+1); } if(c=='c') { newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1); newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+(1)); } if(c=='d') { newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(1)); newcr->adjust_attribute(ATTRIBUTE_HEART,+1); } if(c=='e') { newcr->set_skill(SKILL_PSYCHOLOGY,newcr->get_skill(SKILL_PSYCHOLOGY)+(1)); newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1); } break; case 2: if(c=='a') { newcr->set_skill(SKILL_DISGUISE,newcr->get_skill(SKILL_DISGUISE)+(1)); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1); } if(c=='b') { newcr->set_skill(SKILL_PSYCHOLOGY,newcr->get_skill(SKILL_PSYCHOLOGY)+(1)); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1); newcr->adjust_attribute(ATTRIBUTE_HEART,-1); newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1); } if(c=='c') { newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1); newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+(1)); } if(c=='d') { newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1); newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(1)); } if(c=='e') { newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(1)); newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1); } break; case 3: if(c=='a') { newcr->set_skill(SKILL_STEALTH,newcr->get_skill(SKILL_STEALTH)+(1)); } if(c=='b') { newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(1)); } if(c=='c') { newcr->set_skill(SKILL_LAW,newcr->get_skill(SKILL_LAW)+(1)); } if(c=='d') { newcr->set_skill(SKILL_SEDUCTION,newcr->get_skill(SKILL_SEDUCTION)+(1)); } if(c=='e') { newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+1); } break; case 4: if(c=='a') { newcr->set_skill(SKILL_SCIENCE,newcr->get_skill(SKILL_SCIENCE)+(2)); newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+2); } if(c=='b') { newcr->set_skill(SKILL_MUSIC,newcr->get_skill(SKILL_MUSIC)+(2)); newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+2); } if(c=='c') { newcr->set_skill(SKILL_ART,newcr->get_skill(SKILL_ART)+(2)); newcr->adjust_attribute(ATTRIBUTE_HEART,+2); } if(c=='d') { newcr->set_skill(SKILL_COMPUTERS,newcr->get_skill(SKILL_COMPUTERS)+(2)); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+2); } if(c=='e') { newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+2); newcr->set_skill(SKILL_SWORD,newcr->get_skill(SKILL_SWORD)+(2)); } break; case 5: if(c=='a') { newcr->set_skill(SKILL_DRIVING,newcr->get_skill(SKILL_DRIVING)+(1)); newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(1)); } if(c=='b') { newcr->set_skill(SKILL_SHOTGUN,newcr->get_skill(SKILL_SHOTGUN)+(1)); newcr->set_skill(SKILL_RIFLE,newcr->get_skill(SKILL_RIFLE)+(1)); newcr->set_skill(SKILL_PSYCHOLOGY,newcr->get_skill(SKILL_PSYCHOLOGY)+(1)); } if(c=='c') { newcr->set_skill(SKILL_TAILORING,newcr->get_skill(SKILL_TAILORING)+(2)); } if(c=='d') { newcr->set_skill(SKILL_RELIGION,newcr->get_skill(SKILL_RELIGION)+(1)); newcr->set_skill(SKILL_PSYCHOLOGY,newcr->get_skill(SKILL_PSYCHOLOGY)+(1)); } if(c=='e') { newcr->set_skill(SKILL_TEACHING,newcr->get_skill(SKILL_TEACHING)+(2)); } break; case 6: if(c=='a') { newcr->set_skill(SKILL_DRIVING,newcr->get_skill(SKILL_DRIVING)+(1)); newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(1)); newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1); } if(c=='b') { newcr->set_skill(SKILL_SHOTGUN,newcr->get_skill(SKILL_SHOTGUN)+(2)); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1); } if(c=='c') { newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1); newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(2)); } if(c=='d') { newcr->set_skill(SKILL_SEDUCTION,newcr->get_skill(SKILL_SEDUCTION)+(1)); newcr->set_skill(SKILL_RELIGION,newcr->get_skill(SKILL_RELIGION)+(1)); newcr->adjust_attribute(ATTRIBUTE_HEART,+1); gaylawyer=true; } if(c=='e') { newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(2)); newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1); } break; case 7: if(c=='a') { newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(1)); newcr->set_skill(SKILL_STEALTH,newcr->get_skill(SKILL_STEALTH)+(1)); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1); } if(c=='b') { newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1); newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(2)); } if(c=='c') { newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1); newcr->set_skill(SKILL_BUSINESS,newcr->get_skill(SKILL_BUSINESS)+(2)); } if(c=='d') { newcr->adjust_attribute(ATTRIBUTE_HEART,-1); newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+2); newcr->set_skill(SKILL_SEDUCTION,newcr->get_skill(SKILL_SEDUCTION)+(2)); } if(c=='e') { newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1); newcr->set_skill(SKILL_LAW,newcr->get_skill(SKILL_LAW)+(1)); newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(1)); } break; case 8: if(c=='a') { startcar = new Vehicle(*vehicletype[getvehicletype("SPORTSCAR")]); // Add heat to the starting vehicle because it is stolen. // This is so that you can't immediately sell it at full price. startcar->add_heat(10); vehicle.push_back(startcar); newcr->pref_carid = startcar->id(); } if(c=='b') { Weapon neww(*weapontype[getweapontype("WEAPON_AUTORIFLE_AK47")]); Clip newc(*cliptype[getcliptype("CLIP_ASSAULT")],9); newcr->give_weapon(neww,NULL); newcr->take_clips(newc,9); } if(c=='c') { ledger.force_funds(1000); } if(c=='d') { makelawyer=true; } if(c=='e') { hasmaps=true; } break; case 9: if(c=='a') { newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+2); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+2); newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(2)); newcr->set_skill(SKILL_STEALTH,newcr->get_skill(SKILL_STEALTH)+(2)); newcr->type = CREATURE_THIEF; newcr->type_idname = "CREATURE_THIEF"; base = SITE_RESIDENTIAL_APARTMENT_UPSCALE; ledger.force_funds(ledger.get_funds()+500); Armor newa(*armortype[getarmortype("ARMOR_BLACKCLOTHES")]); newcr->give_armor(newa,NULL); } if(c=='b') { newcr->set_skill(SKILL_RIFLE,newcr->get_skill(SKILL_RIFLE)+(2)); newcr->set_skill(SKILL_PISTOL,newcr->get_skill(SKILL_PISTOL)+(2)); newcr->set_skill(SKILL_STREETSENSE,newcr->get_skill(SKILL_STREETSENSE)+(2)); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+2); newcr->adjust_attribute(ATTRIBUTE_HEALTH,+2); newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+2); newcr->type = CREATURE_GANGMEMBER; newcr->type_idname = "CREATURE_GANGMEMBER"; base = SITE_BUSINESS_CRACKHOUSE; recruits = RECRUITS_GANG; } if(c=='c') { newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+4); newcr->set_skill(SKILL_SCIENCE,newcr->get_skill(SKILL_SCIENCE)+(2)); newcr->set_skill(SKILL_COMPUTERS,newcr->get_skill(SKILL_COMPUTERS)+(2)); newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+(2)); newcr->set_skill(SKILL_TEACHING,newcr->get_skill(SKILL_TEACHING)+(2)); newcr->set_skill(SKILL_BUSINESS,newcr->get_skill(SKILL_BUSINESS)+(1)); newcr->set_skill(SKILL_LAW,newcr->get_skill(SKILL_LAW)+(1)); newcr->type = CREATURE_COLLEGESTUDENT; newcr->type_idname = "CREATURE_COLLEGESTUDENT"; base = SITE_RESIDENTIAL_APARTMENT; ledger.force_funds(ledger.get_funds()+200); } if(c=='d') { newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1); newcr->adjust_attribute(ATTRIBUTE_HEALTH,+2); newcr->set_skill(SKILL_FIRSTAID,newcr->get_skill(SKILL_FIRSTAID)+(2)); newcr->set_skill(SKILL_STREETSENSE,newcr->get_skill(SKILL_STREETSENSE)+(2)); newcr->type = CREATURE_HSDROPOUT; newcr->type_idname = "CREATURE_HSDROPOUT"; base = SITE_RESIDENTIAL_SHELTER; newcr->adjust_attribute(ATTRIBUTE_HEART,+1); newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1); newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1); newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1); newcr->adjust_attribute(ATTRIBUTE_HEALTH,+1); newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1); } if(c=='e') { newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+2); newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+2); newcr->set_skill(SKILL_LAW,newcr->get_skill(SKILL_LAW)+(1)); newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+(1)); newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(2)); newcr->type = CREATURE_POLITICALACTIVIST; newcr->type_idname = "CREATURE_POLITICALACTIVIST"; base = SITE_RESIDENTIAL_TENEMENT; ledger.force_funds(ledger.get_funds()+50); newcr->juice+=50; } break; } } erase(); set_color(COLOR_WHITE,COLOR_BLACK,1); move(2,2); addstr("A NEW CONSERVATIVE ERA", gamelog); gamelog.newline(); set_color(COLOR_WHITE,COLOR_BLACK,0); move(4,2); addstr("The Year is ", gamelog); addstr(year, gamelog); addstr(".", gamelog); move(6,2); gamelog.newline(); addstr("Conservative President ", gamelog); char president[80]; generate_name(president,GENDER_WHITEMALEPATRIARCH); addstr(president, gamelog); addstr(" ends his second term with approval", gamelog); move(7,2); gamelog.newline(); addstr("ratings in the high 70s, and is succeeded by hardcore Arch-Conservative", gamelog); move(8,2); gamelog.newline(); addstr(execname[EXEC_PRESIDENT], gamelog); addstr(".", gamelog); gamelog.nextMessage(); move(10,2); addstr("With Conservatives sweeping into power in the House of Representatives", gamelog); move(11,2); gamelog.newline(); addstr("and Senate, and a Conservative majority in the Supreme Court of the", gamelog); move(12,2); gamelog.newline(); addstr("United States, commentators are hailing it as the beginning of a new", gamelog); move(13,2); gamelog.newline(); addstr("Conservative era.", gamelog); gamelog.nextMessage(); move(15,2); set_color(COLOR_RED,COLOR_BLACK,1); addstr("President ", gamelog); addstr(execname[EXEC_PRESIDENT], gamelog); addstr(" has asked the new Congress to move quickly", gamelog); move(16,2); gamelog.newline(); addstr("to rubber stamp his radical Arch-Conservative agenda. ", gamelog); set_color(COLOR_WHITE,COLOR_BLACK,0); addstr("The left seems", gamelog); gamelog.newline(); move(17,2); addstr("powerless to stop this imminent trampling of Liberal Sanity and Justice.", gamelog); gamelog.nextMessage(); move(19,2); addstr("In this dark time, the Liberal Crime Squad is born...", gamelog); gamelog.nextMessage(); getkey(); erase(); set_color(COLOR_WHITE,COLOR_BLACK,1); move(0,0); addstr("What is your name to the People?"); set_color(COLOR_WHITE,COLOR_BLACK,0); move(1,0); addstr("Press enter to be known by your real name instead."); enter_name(2,0,newcr->name,CREATURE_NAMELEN,newcr->propername); pool.push_back(newcr); make_world(hasmaps); squadst *newsq=new squadst; newsq->id=0;cursquadid++; newsq->squad[0]=newcr; newcr->squadid=0; strcpy(newsq->name,"The Liberal Crime Squad"); for(int l=0;l<len(location);l++) { if(location[l]->type==base) { newcr->base=l; newcr->location=l; if(startcar) startcar->set_location(l); switch(base) { case SITE_RESIDENTIAL_APARTMENT_UPSCALE:location[l]->renting=500;break; case SITE_RESIDENTIAL_APARTMENT:location[l]->renting=200;break; case SITE_RESIDENTIAL_TENEMENT:location[l]->renting=100;break; case SITE_BUSINESS_CRACKHOUSE: location[l]->renting=RENTING_PERMANENT; location[l]->compound_stores+=100; break; } location[l]->newrental=1; switch(recruits) { case RECRUITS_GANG: for(int i=0;i<4;i++) { Creature* recruit = new Creature; makecreature(*recruit,CREATURE_GANGMEMBER); if(recruit->get_weapon().get_itemtypename() == "WEAPON_AUTORIFLE_AK47" || recruit->get_weapon().get_itemtypename() == "WEAPON_SMG_MP5" || !recruit->is_armed()) { Weapon w(*weapontype[getweapontype("WEAPON_SEMIPISTOL_9MM")]); recruit->give_weapon(w,NULL); Clip c(*cliptype[getcliptype("CLIP_9")],4); recruit->take_clips(c,4); recruit->reload(false); } recruit->align=ALIGN_LIBERAL; recruit->set_attribute(ATTRIBUTE_HEART, recruit->get_attribute(ATTRIBUTE_HEART,false)+ recruit->get_attribute(ATTRIBUTE_WISDOM,false)/2); recruit->set_attribute(ATTRIBUTE_WISDOM, recruit->get_attribute(ATTRIBUTE_WISDOM,false)/2); recruit->namecreature(); strcpy(recruit->name,recruit->propername); recruit->location=l; recruit->base=l; recruit->hireid=newcr->id; newsq->squad[i+1]=recruit; recruit->squadid=newsq->id; pool.push_back(recruit); } break; } #ifdef GIVEBLOODYARMOR Armor *newa= new Armor(*armortype[getarmortype("ARMOR_CLOTHES")]); newa->set_bloody(true); location[l]->loot.push_back(newi); #endif #ifdef HIGHFUNDS ledger.force_funds(100000); #endif break; } } //newcr->juice=0; squad.push_back(newsq); activesquad=newsq; if(makelawyer) { Creature* lawyer=new Creature; makecreature(*lawyer,CREATURE_LAWYER); // Make sure lawyer is of the appropriate gender for dating the main character; // opposite sex by default, same sex if the option was chosen that mentions // homosexuality if(gaylawyer) { lawyer->gender_conservative=lawyer->gender_liberal=newcr->gender_conservative; // neutral founder gets neutral partner } else { if(newcr->gender_conservative==GENDER_MALE) lawyer->gender_liberal=lawyer->gender_conservative=GENDER_FEMALE; if(newcr->gender_conservative==GENDER_FEMALE) lawyer->gender_liberal=lawyer->gender_conservative=GENDER_MALE; // neutral founder gets random partner } // Ensure the lawyer has good heart/wisdom stats if(lawyer->get_attribute(ATTRIBUTE_HEART,false)<newcr->get_attribute(ATTRIBUTE_HEART,false)-2) lawyer->adjust_attribute(ATTRIBUTE_HEART,-2); lawyer->set_attribute(ATTRIBUTE_WISDOM,1); lawyer->namecreature(); lawyer->flag|=CREATUREFLAG_SLEEPER; lawyer->flag|=CREATUREFLAG_LOVESLAVE; lawyer->align=ALIGN_LIBERAL; lawyer->infiltration=0.3f; lawyer->age=28; location[lawyer->worklocation]->mapped=1; lawyer->hireid=newcr->id; pool.push_back(lawyer); lawyer->location=lawyer->base=lawyer->worklocation; } uniqueCreatures.initialize(); }
/* rolls up a creature's stats and equipment */ void makecreature(Creature &cr,short type) { cr.drop_weapons_and_clips(NULL); // Get rid of any old equipment from old encounters. cr.strip(NULL); // cr.creatureinit(); cr.exists=1; cr.squadid=-1; cr.type=type; cr.infiltration=0; cr.location=cursite; cr.worklocation=cursite; verifyworklocation(cr); const CreatureType* crtype=getcreaturetype(type); crtype->make_creature(cr); int attnum=crtype->attribute_points_.roll(); int attcap[ATTNUM]; for(int i=0;i<ATTNUM;i++) { cr.set_attribute(i,crtype->attributes_[i].min); attcap[i]=crtype->attributes_[i].max; } switch(type) { case CREATURE_BOUNCER: if(mode==GAMEMODE_SITE && location[cursite]->highsecurity) { strcpy(cr.name,"Enforcer"); cr.set_skill(SKILL_CLUB,LCSrandom(3)+3); } if(law[LAW_GUNCONTROL]==-2) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SMG_MP5")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_SMG")],4); } else if(law[LAW_GUNCONTROL]==-1) { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_44")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_44")],4); } else if(law[LAW_GUNCONTROL]==0) { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_38")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_38")],4); } else cr.give_weapon(*weapontype[getweapontype("WEAPON_NIGHTSTICK")],NULL); cr.reload(false); if(disguisesite(sitetype)) { cr.align=ALIGN_CONSERVATIVE; cr.infiltration=0.1f*LCSrandom(4); } else cr.align=ALIGN_MODERATE; break; case CREATURE_SECURITYGUARD: if(law[LAW_GUNCONTROL]==-2) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SMG_MP5")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_SMG")],4); } else if(law[LAW_GUNCONTROL]!=2) { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_38")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_38")],4); } else cr.give_weapon(*weapontype[getweapontype("WEAPON_NIGHTSTICK")],NULL); cr.reload(false); break; case CREATURE_SCIENTIST_LABTECH: crtype->give_weapon_civilian(cr); if(!cr.is_armed()&&!LCSrandom(2)) cr.give_weapon(*weapontype[getweapontype("WEAPON_SYRINGE")],NULL); break; case CREATURE_JUDGE_CONSERVATIVE: if(law[LAW_GUNCONTROL]==-2&&!LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_44")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_44")],4); } else if(!LCSrandom(2)) cr.give_weapon(*weapontype[getweapontype("WEAPON_GAVEL")],NULL); cr.reload(false); break; case CREATURE_SCIENTIST_EMINENT: crtype->give_weapon_civilian(cr); if(!cr.is_armed()&&!LCSrandom(2)) cr.give_weapon(*weapontype[getweapontype("WEAPON_SYRINGE")],NULL); break; case CREATURE_CORPORATE_CEO: generate_name(cr.propername,GENDER_WHITEMALEPATRIARCH); strcpy(cr.name,"CEO "); strcat(cr.name,cr.propername); cr.dontname=true; break; case CREATURE_WORKER_FACTORY_NONUNION: crtype->give_weapon_civilian(cr); if(!cr.is_armed()) cr.give_weapon(*weapontype[getweapontype("WEAPON_CHAIN")],NULL); if(cr.align==ALIGN_LIBERAL) cr.align=LCSrandom(2)-1; break; case CREATURE_WORKER_SWEATSHOP: cr.flag|=CREATUREFLAG_ILLEGALALIEN; break; case CREATURE_LAWYER: if(law[LAW_GUNCONTROL]==-2 && !LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_38")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_38")],1); cr.reload(false); } break; case CREATURE_DOCTOR: if(law[LAW_GUNCONTROL]==-2 && !LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_38")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_38")],1); cr.reload(false); } break; case CREATURE_PSYCHOLOGIST: if(law[LAW_GUNCONTROL]==-2 && !LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_38")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_38")],1); cr.reload(false); } if(cr.gender_liberal==GENDER_MALE||LCSrandom(2)) cr.give_armor(*armortype[getarmortype("ARMOR_CHEAPSUIT")],NULL); else cr.give_armor(*armortype[getarmortype("ARMOR_CHEAPDRESS")],NULL); break; case CREATURE_NURSE: if(law[LAW_GUNCONTROL]==-2 && !LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_38")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_38")],1); cr.reload(false); } break; case CREATURE_WORKER_FACTORY_UNION: crtype->give_weapon_civilian(cr); if(!cr.is_armed()) cr.give_weapon(*weapontype[getweapontype("WEAPON_CHAIN")],NULL); break; case CREATURE_TANK: cr.animalgloss=ANIMALGLOSS_TANK; cr.specialattack=ATTACK_CANNON; break; case CREATURE_MERC: cr.give_weapon(*weapontype[getweapontype(law[LAW_GUNCONTROL]<1?"WEAPON_AUTORIFLE_M16":"WEAPON_SEMIRIFLE_AR15")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_ASSAULT")],7); cr.reload(false); break; case CREATURE_HICK: switch(LCSrandom(7)) { case 0:strcpy(cr.name,"Country Boy");break; case 1:strcpy(cr.name,"Good ol' Boy");break; case 2:strcpy(cr.name,"Hick");break; case 3:strcpy(cr.name,"Hillbilly");break; case 4:strcpy(cr.name,"Redneck");break; case 5:strcpy(cr.name,"Rube");break; case 6:strcpy(cr.name,"Yokel");break; } if((law[LAW_GUNCONTROL]==-2&&!LCSrandom(2))||!LCSrandom(10)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SHOTGUN_PUMP")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_BUCKSHOT")],4); } else cr.give_weapon(*weapontype[getweapontype(LCSrandom(2)?"WEAPON_TORCH":"WEAPON_PITCHFORK")],NULL); cr.reload(false); break; case CREATURE_COP: if(law[LAW_POLICEBEHAVIOR]==2 && cr.align==ALIGN_LIBERAL && !LCSrandom(3)) // Peace Officer { cr.align=ALIGN_MODERATE; strcpy(cr.name,"Police Negotiator"); cr.set_skill(SKILL_PERSUASION,LCSrandom(4)+1); cr.set_skill(SKILL_PISTOL,LCSrandom(3)+1); cr.set_attribute(ATTRIBUTE_HEART,4); } else { if(law[LAW_GUNCONTROL]==-2 && !LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SMG_MP5")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_SMG")],4); } else if(!LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SEMIPISTOL_9MM")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_9")],4); } else if(!LCSrandom(2)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SHOTGUN_PUMP")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_BUCKSHOT")],4); } else cr.give_weapon(*weapontype[getweapontype("WEAPON_NIGHTSTICK")],NULL); cr.reload(false); cr.align=ALIGN_CONSERVATIVE; cr.set_skill(SKILL_PISTOL,LCSrandom(4)+1); cr.set_skill(SKILL_SHOTGUN,LCSrandom(3)+1); cr.set_skill(SKILL_CLUB,LCSrandom(2)+1); cr.set_skill(SKILL_HANDTOHAND,LCSrandom(2)+1); cr.set_attribute(ATTRIBUTE_WISDOM,4); } break; case CREATURE_FIREFIGHTER: if(law[LAW_FREESPEECH]==-2) { cr.give_weapon(*weapontype[getweapontype("WEAPON_FLAMETHROWER")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_GASOLINE")],4); cr.reload(false); cr.set_skill(SKILL_HEAVYWEAPONS,LCSrandom(3)+2); strcpy(cr.name,"Fireman"); cr.align=ALIGN_CONSERVATIVE; } else { cr.give_weapon(*weapontype[getweapontype("WEAPON_AXE")],NULL); cr.set_skill(SKILL_AXE,LCSrandom(3)+2); strcpy(cr.name,"Firefighter"); } if(sitealarm) // Respond to emergencies in bunker gear cr.give_armor(*armortype[getarmortype("ARMOR_BUNKERGEAR")],NULL); break; case CREATURE_CCS_MOLOTOV: if(mode==GAMEMODE_SITE/* && sitealarm>0*/) nameCCSMember(cr); break; case CREATURE_CCS_SNIPER: if(mode==GAMEMODE_SITE/* && sitealarm>0*/) nameCCSMember(cr); break; case CREATURE_CCS_VIGILANTE: cr.give_armor(*armortype[getarmortype("ARMOR_CLOTHES")],NULL); switch(LCSrandom(5)+endgamestate) { case 0: case 1: break; case 2: { cr.give_weapon(*weapontype[getweapontype("WEAPON_SEMIPISTOL_9MM")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_9")],7); break; } case 3: { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_44")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_44")],7); break; } case 4: { cr.give_weapon(*weapontype[getweapontype("WEAPON_SHOTGUN_PUMP")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_BUCKSHOT")],7); break; } case 5: { cr.give_weapon(*weapontype[getweapontype("WEAPON_SEMIRIFLE_AR15")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_ASSAULT")],7); cr.give_armor(*armortype[getarmortype("ARMOR_CIVILLIANARMOR")],NULL); break; } case 6: { cr.give_weapon(*weapontype[getweapontype("WEAPON_SEMIRIFLE_AR15")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_ASSAULT")],7); cr.give_armor(*armortype[getarmortype("ARMOR_ARMYARMOR")],NULL); break; } default: { cr.give_weapon(*weapontype[getweapontype("WEAPON_AUTORIFLE_M16")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_ASSAULT")],7); cr.give_armor(*armortype[getarmortype("ARMOR_ARMYARMOR")],NULL); break; } } cr.reload(false); if(mode==GAMEMODE_SITE/* && sitealarm>0*/) nameCCSMember(cr); break; case CREATURE_CCS_ARCHCONSERVATIVE: strcpy(cr.name,(location[cursite]->siege.siege?"CCS Team Leader":(ccs_kills<2?"CCS Lieutenant":"CCS Founder"))); break; case CREATURE_PRISONGUARD: if(law[LAW_GUNCONTROL]==-2&&!LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SMG_MP5")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_SMG")],4); } else if(!LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SHOTGUN_PUMP")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_BUCKSHOT")],4); } else cr.give_weapon(*weapontype[getweapontype("WEAPON_NIGHTSTICK")],NULL); cr.reload(false); break; case CREATURE_EDUCATOR: if(law[LAW_GUNCONTROL]==-2 && !LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SMG_MP5")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_SMG")],4); } else if(!LCSrandom(3)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SEMIPISTOL_9MM")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_9")],4); } else cr.give_weapon(*weapontype[getweapontype("WEAPON_SYRINGE")],NULL); cr.reload(false); break; case CREATURE_GENETIC: if(location[cursite]->type==SITE_CORPORATE_HOUSE) { strcpy(cr.name,"Pet "); attcap[ATTRIBUTE_CHARISMA]=10; } else strcpy(cr.name,""); switch(LCSrandom(11)) { case 0:strcat(cr.name,"Genetic Monster");break; case 1:strcat(cr.name,"Flaming Rabbit"); cr.specialattack=ATTACK_FLAME;break; case 2:strcat(cr.name,"Genetic Nightmare");break; case 3:strcat(cr.name,"Mad Cow");break; case 4:strcat(cr.name,"Giant Mosquito"); cr.specialattack=ATTACK_SUCK;break; case 5:strcat(cr.name,"Six-legged Pig");break; case 6:strcat(cr.name,"Purple Gorilla");break; case 7:strcat(cr.name,"Warped Bear");break; case 8:strcat(cr.name,"Writhing Mass");break; case 9:strcat(cr.name,"Something Bad");break; case 10:strcat(cr.name,"Pink Elephant");break; } cr.animalgloss=ANIMALGLOSS_ANIMAL; if(law[LAW_ANIMALRESEARCH]!=2)cr.money=0; break; case CREATURE_GUARDDOG: cr.animalgloss=ANIMALGLOSS_ANIMAL; if(law[LAW_ANIMALRESEARCH]!=2)cr.money=0; break; case CREATURE_PRISONER: // Prisoners should not be "prisoners" after recruiting them, // they should be some brand of criminal if(!LCSrandom(10)) { // Thief makecreature(cr,CREATURE_THIEF); } else switch(LCSrandom(5)) { case 0: // Gang member makecreature(cr,CREATURE_GANGMEMBER); break; case 1: // Prostitute makecreature(cr,CREATURE_PROSTITUTE); break; case 2: // Crack head makecreature(cr,CREATURE_CRACKHEAD); break; case 3: // Teenager makecreature(cr,CREATURE_TEENAGER); break; case 4: // HS Dropout makecreature(cr,CREATURE_HSDROPOUT); break; } cr.drop_weapons_and_clips(NULL); crtype->give_weapon(cr); cr.strip(NULL); crtype->give_armor(cr); cr.money=crtype->money_.roll(); cr.juice=crtype->juice_.roll(); cr.gender_liberal=cr.gender_conservative=crtype->roll_gender(); strcpy(cr.name,crtype->get_encounter_name()); if(cr.align==ALIGN_CONSERVATIVE) cr.align=LCSrandom(2); break; case CREATURE_BUM: crtype->give_weapon_civilian(cr); if(!cr.is_armed()&&!LCSrandom(5)) cr.give_weapon(*weapontype[getweapontype("WEAPON_SHANK")],NULL); if(cr.align==ALIGN_CONSERVATIVE)cr.align=LCSrandom(2); break; case CREATURE_MUTANT: crtype->give_weapon_civilian(cr); if(!cr.is_armed()&&!LCSrandom(5)) cr.give_weapon(*weapontype[getweapontype("WEAPON_SHANK")],NULL); break; case CREATURE_GANGMEMBER: if(!LCSrandom(20)||(law[LAW_GUNCONTROL]==-2&&!LCSrandom(5))) { cr.give_weapon(*weapontype[getweapontype("WEAPON_AUTORIFLE_AK47")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_ASSAULT")],3); } else if(!LCSrandom(16)||(law[LAW_GUNCONTROL]==-2&&!LCSrandom(5))) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SMG_MP5")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_SMG")],4); } else if(!LCSrandom(15)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SEMIPISTOL_45")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_45")],4); } else if(!LCSrandom(10)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SHOTGUN_PUMP")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_BUCKSHOT")],4); } else if(!LCSrandom(4)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SEMIPISTOL_9MM")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_9")],4); } else if(!LCSrandom(2)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_REVOLVER_38")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_38")],4); } else cr.give_weapon(*weapontype[getweapontype("WEAPON_COMBATKNIFE")],NULL); cr.reload(false); // We'll make the crack house a bit dicey if(location[cursite]->type==SITE_BUSINESS_CRACKHOUSE)cr.align=ALIGN_CONSERVATIVE; if(!LCSrandom(2))switch(LCSrandom(3)) { case 0://cr.crimes_committed[LAWFLAG_BROWNIES]++; cr.crimes_suspected[LAWFLAG_BROWNIES]++;break; case 1://cr.crimes_committed[LAWFLAG_ASSAULT]++; cr.crimes_suspected[LAWFLAG_ASSAULT]++;break; case 2://cr.crimes_committed[LAWFLAG_MURDER]++; cr.crimes_suspected[LAWFLAG_MURDER]++;break; } break; case CREATURE_CRACKHEAD: crtype->give_weapon_civilian(cr); if(!LCSrandom(5)) cr.give_weapon(*weapontype[getweapontype("WEAPON_SHANK")],NULL); if(cr.align==ALIGN_CONSERVATIVE)cr.align=LCSrandom(2); attcap[ATTRIBUTE_HEALTH]=1+LCSrandom(5); break; case CREATURE_FASTFOODWORKER: cr.age=(LCSrandom(2)?AGE_TEENAGER:AGE_YOUNGADULT); break; case CREATURE_FOOTBALLCOACH: if(LCSrandom(2)) { cr.set_attribute(ATTRIBUTE_HEALTH,5); cr.set_attribute(ATTRIBUTE_AGILITY,5); cr.set_attribute(ATTRIBUTE_STRENGTH,5); } break; case CREATURE_PROSTITUTE: if(LCSrandom(7))cr.gender_conservative=cr.gender_liberal=GENDER_FEMALE; else if(!LCSrandom(3))cr.gender_liberal=GENDER_FEMALE; if(cr.align==ALIGN_CONSERVATIVE)cr.align=LCSrandom(2); if(!LCSrandom(3))cr.crimes_suspected[LAWFLAG_PROSTITUTION]++; break; case CREATURE_HIPPIE: if(!LCSrandom(10)) cr.crimes_suspected[LAWFLAG_BROWNIES]++; break; case CREATURE_SOCIALITE: cr.give_armor(*armortype[getarmortype(cr.gender_liberal==GENDER_FEMALE?"ARMOR_EXPENSIVEDRESS":"ARMOR_EXPENSIVESUIT")],NULL); break; case CREATURE_THIEF: switch(LCSrandom(5)) { case 0:strcpy(cr.name,getcreaturetype(CREATURE_SOCIALITE)->get_encounter_name());break; case 1:strcpy(cr.name,getcreaturetype(CREATURE_CLERK)->get_encounter_name());break; case 2:strcpy(cr.name,getcreaturetype(CREATURE_OFFICEWORKER)->get_encounter_name());break; case 3:strcpy(cr.name,getcreaturetype(CREATURE_CRITIC_ART)->get_encounter_name());break; case 4:strcpy(cr.name,getcreaturetype(CREATURE_CRITIC_MUSIC)->get_encounter_name());break; } if(!LCSrandom(10))cr.crimes_suspected[(LCSrandom(2)?LAWFLAG_BREAKING:LAWFLAG_THEFT)]++; break; case CREATURE_MILITARYOFFICER: if(LCSrandom(4)) { cr.give_weapon(*weapontype[getweapontype("WEAPON_SEMIPISTOL_9MM")],NULL); cr.take_clips(*cliptype[getcliptype("CLIP_9")],4); cr.reload(false); } break; case CREATURE_JUDGE_LIBERAL: case CREATURE_POLITICIAN: case CREATURE_CORPORATE_MANAGER: case CREATURE_WORKER_SERVANT: case CREATURE_WORKER_JANITOR: case CREATURE_WORKER_SECRETARY: case CREATURE_LANDLORD: case CREATURE_BANK_TELLER: case CREATURE_BANK_MANAGER: case CREATURE_TEENAGER: case CREATURE_SOLDIER: case CREATURE_VETERAN: case CREATURE_HARDENED_VETERAN: case CREATURE_SWAT: case CREATURE_DEATHSQUAD: case CREATURE_GANGUNIT: case CREATURE_AGENT: case CREATURE_SECRET_SERVICE: case CREATURE_RADIOPERSONALITY: case CREATURE_NEWSANCHOR: case CREATURE_JUROR: case CREATURE_WORKER_FACTORY_CHILD: case CREATURE_SEWERWORKER: case CREATURE_COLLEGESTUDENT: case CREATURE_MUSICIAN: case CREATURE_MATHEMATICIAN: case CREATURE_TEACHER: case CREATURE_HSDROPOUT: case CREATURE_PRIEST: case CREATURE_ENGINEER: case CREATURE_TELEMARKETER: case CREATURE_CARSALESMAN: case CREATURE_OFFICEWORKER: case CREATURE_MAILMAN: case CREATURE_GARBAGEMAN: case CREATURE_PLUMBER: case CREATURE_CHEF: case CREATURE_CONSTRUCTIONWORKER: case CREATURE_AMATEURMAGICIAN: case CREATURE_AUTHOR: case CREATURE_JOURNALIST: case CREATURE_CRITIC_ART: case CREATURE_CRITIC_MUSIC: case CREATURE_BIKER: case CREATURE_TRUCKER: case CREATURE_TAXIDRIVER: case CREATURE_PROGRAMMER: case CREATURE_NUN: case CREATURE_RETIREE: case CREATURE_PAINTER: case CREATURE_SCULPTOR: case CREATURE_DANCER: case CREATURE_PHOTOGRAPHER: case CREATURE_CAMERAMAN: case CREATURE_HAIRSTYLIST: case CREATURE_FASHIONDESIGNER: case CREATURE_CLERK: case CREATURE_ACTOR: case CREATURE_YOGAINSTRUCTOR: case CREATURE_MARTIALARTIST: case CREATURE_ATHLETE: case CREATURE_LOCKSMITH: case CREATURE_MILITARYPOLICE: case CREATURE_SEAL: break; } vector<int> possible; for(int a=0;a<ATTNUM;a++) { attnum-=min(4,cr.get_attribute(a,false)); possible.push_back(a); } while(attnum>0&&len(possible)) { int i=LCSrandom(len(possible)); int a=possible[i]; if(a==ATTRIBUTE_WISDOM&&cr.align==ALIGN_LIBERAL&&LCSrandom(4)) a=ATTRIBUTE_HEART; if(a==ATTRIBUTE_HEART&&cr.align==ALIGN_CONSERVATIVE&&LCSrandom(4)) a=ATTRIBUTE_WISDOM; if(cr.get_attribute(a,false)<attcap[a]) { cr.adjust_attribute(a,+1); attnum--; } else possible.erase(possible.begin()+i); } if(cr.align==ALIGN_LIBERAL) cr.infiltration=0.15f+(LCSrandom(10)-5)*0.01f; else if(cr.align==ALIGN_MODERATE) cr.infiltration=0.25f+(LCSrandom(10)-5)*0.01f; else cr.infiltration+=0.35f*(1-cr.infiltration)+(LCSrandom(10)-5)*0.01f; if(cr.infiltration<0) cr.infiltration=0; if(cr.infiltration>1) cr.infiltration=1; int randomskills=LCSrandom(4)+4; if(cr.age>20) randomskills+=static_cast<int>(randomskills*((cr.age-20.0)/20.0)); else randomskills-=(20-cr.age)/2; possible.clear(); for(int s=0;s<SKILLNUM;s++)possible.push_back(s); //RANDOM STARTING SKILLS while(randomskills>0&&len(possible)) { int i=LCSrandom(len(possible)); int randomskill=possible[i]; // 95% chance of not allowing some skills for anybody... if(LCSrandom(20)) { if(randomskill==SKILL_HEAVYWEAPONS) continue; if(randomskill==SKILL_SMG) continue; if(randomskill==SKILL_SWORD) continue; if(randomskill==SKILL_RIFLE) continue; if(randomskill==SKILL_AXE) continue; if(randomskill==SKILL_CLUB) continue; if(randomskill==SKILL_PSYCHOLOGY) continue; } // 90% chance of not allowing some skills, other than // for conservatives if(LCSrandom(10)&&cr.align!=ALIGN_CONSERVATIVE) { if(randomskill==SKILL_SHOTGUN) continue; if(randomskill==SKILL_PISTOL) continue; } if(cr.skill_cap(randomskill,true)>cr.get_skill(randomskill)) { cr.set_skill(randomskill,cr.get_skill(randomskill)+1); randomskills--; while(randomskills&&LCSrandom(2)) { if(cr.skill_cap(randomskill,true)>cr.get_skill(randomskill) && cr.get_skill(randomskill) < 4) { cr.set_skill(randomskill,cr.get_skill(randomskill)+1); randomskills--; } else { possible.erase(possible.begin()+i); break; } } } else possible.erase(possible.begin()+i); } //ALIENATION if((sitealienate>=1&&cr.align==ALIGN_MODERATE)||(sitealienate==2&&cr.align==ALIGN_LIBERAL))conservatise(cr); }
void main (int argc, char *argv[]) { cout << "Squirrel 1.16/release, Adaptive answer Service for USR Voice modems" << endl; cout << "Copyright (c)2000 Eugeniy Gryaznov, Compiled on 02.05.00 at 21:09" << endl; if(argc<2) { cout << " Use <squirrel.exe> <action> [<action param>] [switches]" << endl; cout << " action: PLAY,REC,MAILER,MAIN" << endl; cout << " PLAY f.gsm Play file to speaker(modem)" << endl; cout << " REC f.gsm Record from microphone(modem) to file" << endl; cout << " MAILER Mailer compatible mode" << endl; cout << " MAIN Run in master mode" << endl; cout << " CONV f.gsm Convert GSM ->WAV" << endl; cout << " switches: [/L] [/D] [/P]" << endl; cout << " /L switch Playing/Recording device" << endl; cout << " /D switch Show debug info" << endl; cout << " /P switch close/real_close port" << endl; cout << " /B switch 8/16 bit wave output" << endl; cout << " Ex: squirrel play allo.gsm /L /D" << endl; cout << " squirrel main" << endl; ErrorExit(0,"Help screen"); } // Get default CTL name char ctl[128]; char *ext = "CTL"; strcpy(ctl,argv[0]); strcpy(ctl+strlen(ctl)-3,ext); SetDefault(); // Check ARGV int Task = 0, swch = 0; // 1 - PLAY, 2 - REC, 3 - MAILER, 4 - MAIN char TParam[128],fname[128],*outw; int postdo = 0; // Get task type if (strcmp(strupr(argv[1]),"PLAY")==0) { strcpy(TParam,argv[2]);Task=1; } else if (strcmp(strupr(argv[1]),"REC")==0) { strcpy(TParam,argv[2]);Task=2; } else if (strcmp(strupr(argv[1]),"MAILER")==0) { strcpy(TParam,argv[2]);Task=3; } else if (strcmp(strupr(argv[1]),"MAIN")==0) { strcpy(TParam,argv[2]);Task=4; } else if (strcmp(strupr(argv[1]),"CONV")==0) { strcpy(TParam,argv[2]);Task=5; } else ErrorExit(1,"Unknown action"); if ((Task==1||Task==2||Task==5)&&argc==2) ErrorExit(1,"not enough params"); // Process switches for (int argnum=2;argnum<argc;argnum++){ if ((Task!=1&&Task!=2&&Task!=5)||argnum!=2){ if (strcmp(strupr(argv[argnum]),"/D")==0) swch|=1; else if (strcmp(strupr(argv[argnum]),"/L")==0) swch|=2; else if (strcmp(strupr(argv[argnum]),"/P")==0) swch|=4; else if (strcmp(strupr(argv[argnum]),"/B")==0) swch|=8; else ErrorExit(1,"Unknown switch"); } } cout << "TASK: "; switch(Task){ case 1: cout << "playing file (device <- " << TParam << ")" << endl;break; case 2: cout << "recording file (device -> " << TParam << ")" << endl;break; case 3: cout << "mailer mode" << endl;break; case 4: cout << "master mode" << endl;break; } if (Task<5){ // Read config + FIX switches ReadConfig(ctl); if (swch&1) cfg.debuginfo=(cfg.debuginfo+1)%2; if (swch&2) cfg.pln=(cfg.pln+1)%2; if (swch&4) cfg.realcl=(cfg.realcl+1)%2; if (swch&8) cfg.wav8bit=(cfg.wav8bit+1)%2; // Open COMPort OpenComm(cfg.baud,cfg.ioport,cfg.irq); if(prtst!=-1) ErrorExit(3,"Communication port not found"); // Init screen StartupScr(); // Init modem SendModemStr(&cfg.init,"Initializing modem"); SendModemStr(&cfg.voice,"Voice mode"); } // Start Log if (Task==3||Task==4){ struct time _t; struct date _d; gettime(&_t);getdate(&_d); write_log("\n -- executed on "); write_log_num(_d.da_day);write_log("."); write_log_num(_d.da_mon);write_log("."); write_log_num(_d.da_year);write_log(" at "); write_log_num(_t.ti_hour);write_log(":"); write_log_num(_t.ti_min);write_log(" --\n"); } // Main work switch(Task){ case 1: PlayFile(TParam); break; case 2: cfg.wavout=0; RecFile(TParam,0); break; case 3: if (!cfg.gsmframe) ErrorExit(78,"mailer mode require USE_GSM=1"); cfg.up=0;cfg.pln=0; if (cfg.useaon&1){ AON(); } else { if (cfg.hook){ SendModemStr(&cfg.offhook,"Offhook"); delay(cfg.wallo); } } PlayFile(cfg.sallo); if (cfg.loglev&2) write_log("detecting\n"); switch (Detect()){ case 1: // Modem CreateFlag(cfg.ata); SendModemStr(&cfg.data,"Data mode"); SendModemStr(&cfg.mailinit,"Initializing modem to connect"); write_log("Detected: MODEM\n"); ErrorExit(0,"modem detected"); break; case 2: // Voice write_log("Detected: VOICE\n"); PlayFile(cfg.swait); for (int curring=0;curring<cfg.RTL;curring++){ if (!kbhit()){ if (strlen(cfg.soundfl)) CreateFlag(cfg.soundfl); else sound(cfg.khz); SendModemStr(&cfg.beep,"Beep"); nosound(); } if (kbhit()) break; if (curring+1!=cfg.RTL) delay(cfg.delayring); } ch=0;while (kbhit()) ch=getch(); if (cfg.auto_detect&&ch!=27&&ch!=32){ // check if voice present cout << " ! auto : speach in line" << endl;FixLine(); if (cfg.loglev&2) write_log("detecting\n"); ch=0;cfg.limit=cfg.auto_detect; if ((ch=Detect())==2) ch=32; if (ch==3||ch==4) break; } if (ch!=27) if (ch==32){ cout << " ! autoanswer skipped" << endl;FixLine(); write_log("autoanswer skipped\n"); postdo=1; } else { PlayFile(cfg.sauto); SendModemStr(&cfg.abeep,"aBeep"); generate_name(fname); write_log("Recording: ");write_log(fname);write_log("\n"); RecFile(fname,cfg.rec_time); } break; case 3: write_log("Detected: BUSY\n");break; case 4: write_log("Detected: DIAL TONE\n");break; } SendModemStr(&cfg.onhook,"Onhook"); break; case 4: int wring; char rng[100];cfg.up=0;cfg.pln=0; while(kbhit()) getch(); if (cfg.gsmframe==0&&cfg.useaon!=0) ErrorExit(73,"AON require USE_GSM=1"); while(!kbhit()){ cout << " Waiting for RING ...";rng[0]=0; while(!kbhit()&&strstr(rng,"RING")==NULL){ while(ReadComm(ch)){ rng[strlen(rng)+1]=0; rng[strlen(rng)]=ch; if (strlen(rng)==95) rng[0]=0; } } if (!kbhit()){ cout << endl;FixLine(); cout << " ! RING ."; for(wring=0;wring<(cfg.ring-1);wring++){ if (!WaitFor("RING",7,cfg.debuginfo)) { cout << " <no more rings>" << endl;FixLine();wring=0;break;} else cout << "."; } } if (!kbhit()&&wring){ // Wait cfg.ring cout << endl;FixLine(); if (cfg.useaon&2){ AON(); } else { SendModemStr(&cfg.offhook,"Offhook"); delay(cfg.wallo); } cfg.up=0; PlayFile(cfg.sauto); SendModemStr(&cfg.abeep,"aBeep"); generate_name(fname); RecFile(fname,cfg.rec_time); SendModemStr(&cfg.onhook,"Onhook"); SendModemStr(&cfg.init,"Initializing modem"); SendModemStr(&cfg.voice,"Voice mode"); while(kbhit()) getch(); } } cout << endl;FixLine(); while(kbhit()) getch(); break; case 5: // Open files if (swch&8) cfg.wav8bit=(cfg.wav8bit+1)%2; fp=fopen(TParam,"rb"); if (fp==NULL) ErrorExit(93,"error: .gsm input"); outw=TParam; cout << "GSM->WAV converting: " << TParam << " -> "; while (strchr(outw,'\\')!=NULL) outw=strchr(outw,'\\'); while (strchr(outw,'/')!=NULL) outw=strchr(outw,'/'); if (strlen(outw)==0) ErrorExit(153,"out name error"); if (strchr(outw,'.')!=NULL) *strchr(outw,'.')=0; strcat(strlwr(TParam),".wav"); cout << TParam;if(cfg.wav8bit) cout << " (8bit)";cout << endl; if (!Start_GSM_WAV(TParam,cfg.wav8bit)){ cout << "output file error";exit(1);} while (fread(gsmb,1,33,fp)==33){ decode_block(gsmb,cfg.wav8bit); } // close file fclose(fp); Close_GSM_WAV(); ErrorExit(0,"OK"); } // Deinit SendModemStr(&cfg.data,"Data mode"); SendModemStr(&cfg.deinit,"Deinitializing modem"); if (postdo&&cfg.postspace){ cout << " ! Press any key to return to Mailer"; getch();sound(440);delay(5);nosound(); cout << endl;FixLine(); } // Close COMPort & Exit ErrorExit(0,"All ok"); }
OOMember::OOMember(size_t s) : OOElement(s) { generate_name(); assess_type_from_size(); }