void man(int hcx, int hcy) { glColor3f(0, 0, 0); circle(15, hcx, hcy); glLineWidth(1.5); glBegin(GL_LINES);//torso glVertex2f(hcx, hcy); glVertex2f(hcx, hcy - 46.87); glEnd(); glBegin(GL_LINES);//right leg(far) glVertex2f(hcx, hcy - 46.87); glVertex2f(hcx - 15, hcy - 82.015); //glVertex2f(60,30); glEnd(); glBegin(GL_LINES);//left leg(near) glVertex2f(hcx, hcy - 46.87); //glvertex2f(20,10); glVertex2f(hcx + 15, hcy - 82.015); glEnd(); glBegin(GL_LINES);//right arm(far) glVertex2f(hcx, hcy - 18.75); glVertex2f(hcx - 15, hcy - 46.87); glEnd(); gun(hcx - 18.75, hcy - 46.87); glBegin(GL_LINES);//left arm(near) glVertex2f(hcx, hcy - 18.75); glVertex2f(hcx + 15, hcy - 46.87); glEnd(); glColor3f(1, 1, 1); }
void CGunTurret::DrawDebug() { IPersistantDebug *pDebug = gEnv->pGame->GetIGameFramework()->GetIPersistantDebug(); pDebug->Begin("CGunTurret::DrawDebug", true); Vec3 gun(ZERO),rocket(ZERO),radar(ZERO),barrel(ZERO); gun = GetSlotHelperPos(eIGS_ThirdPerson,m_fireHelper,true); rocket = GetSlotHelperPos(eIGS_ThirdPerson,m_rocketHelper,true); barrel = GetSlotHelperPos(eIGS_ThirdPerson,m_barrelHelper,true); radar = GetSlotHelperPos(eIGS_Aux0,m_radarHelper,true); pDebug->AddSphere(gun, 0.2f, ColorF(1,0,0,1), 1.f); pDebug->AddSphere(rocket, 0.2f, ColorF(0,1,0,1), 1.f); pDebug->AddSphere(radar, 0.2f, ColorF(0,0,1,1), 1.f); pDebug->AddSphere(barrel, 0.2f, ColorF(1,0,1,1), 1.f); }
void point(int x,int y) { int i; cleardevice(); setcolor(1); gun(x,y); //setfillstyle(i, getmaxcolor()); //bar3d(300,500,x,y,5, 3); line(x-15,y,x-5,y); line(x+5,y,x+15,y); line(x,y-15,x,y-5); line(x,y+5,x,y+15); setcolor(2); line(x-18,y-18,x-18,y+18); line(x+18,y-18,x+18,y+18); for(i=1;i<=10;i++) { putpixel(x-18+i,y-18,5); putpixel(x-18+i,y+18,5); putpixel(x+18-i,y-18,5); putpixel(x+18-i,y+18,5); delay(3); } }
void setup() { /* glider(0,0); glider(10,0); glider(0,10); glider(10,10); */ gun(); eater(55,41); /*int i,j; for (i=0;i<16;i++) for (j=0;j<16;j++) write(i,j,1); */ }
void gameScreen::keyPressed(int key){ if(key==OF_KEY_UP||key==OF_KEY_DOWN||key==OF_KEY_RIGHT||key==OF_KEY_LEFT){ if(player.isCollided(furniture)==0){ player.move(key); } else{ player.alternateMove(key); } } else if(key==' '){ gun g = gun(); guns.push_back(g); ofVec2f a = ofVec2f(); //shoot from the center of the player a.x = player.location.x+player.b.width/2; a.y = player.location.y+player.b.height/2; //shoot the latest bullet guns[guns.size()-1].shoot(a,player.currentDirection); } }
void fun(T... val) { auto init={gun(val)...}; (void)init; //silence "unused variable" warning ;-) }
bool game::dump_stats( const std::string &what, dump_mode mode, const std::vector<std::string> &opts ) { try { loading_ui ui( false ); load_core_data( ui ); load_packs( _( "Loading content packs" ), { mod_id( "dda" ) }, ui ); DynamicDataLoader::get_instance().finalize_loaded_data( ui ); } catch( const std::exception &err ) { std::cerr << "Error loading data from json: " << err.what() << std::endl; return false; } std::vector<std::string> header; std::vector<std::vector<std::string>> rows; int scol = 0; // sorting column std::map<std::string, standard_npc> test_npcs; test_npcs[ "S1" ] = standard_npc( "S1", { "gloves_survivor", "mask_lsurvivor" }, 4, 8, 10, 8, 10 /* DEX 10, PER 10 */ ); test_npcs[ "S2" ] = standard_npc( "S2", { "gloves_fingerless", "sunglasses" }, 4, 8, 8, 8, 10 /* PER 10 */ ); test_npcs[ "S3" ] = standard_npc( "S3", { "gloves_plate", "helmet_plate" }, 4, 10, 8, 8, 8 /* STAT 10 */ ); test_npcs[ "S4" ] = standard_npc( "S4", {}, 0, 8, 10, 8, 10 /* DEX 10, PER 10 */ ); test_npcs[ "S5" ] = standard_npc( "S5", {}, 4, 8, 10, 8, 10 /* DEX 10, PER 10 */ ); test_npcs[ "S6" ] = standard_npc( "S6", { "gloves_hsurvivor", "mask_hsurvivor" }, 4, 8, 10, 8, 10 /* DEX 10, PER 10 */ ); std::map<std::string, item> test_items; test_items[ "G1" ] = item( "glock_19" ).ammo_set( "9mm" ); test_items[ "G2" ] = item( "hk_mp5" ).ammo_set( "9mm" ); test_items[ "G3" ] = item( "ar15" ).ammo_set( "223" ); test_items[ "G4" ] = item( "remington_700" ).ammo_set( "270" ); test_items[ "G4" ].emplace_back( "rifle_scope" ); if( what == "AMMO" ) { header = { "Name", "Ammo", "Volume", "Weight", "Stack", "Range", "Dispersion", "Recoil", "Damage", "Pierce" }; auto dump = [&rows]( const item & obj ) { // a common task is comparing ammo by type so ammo has multiple repeat the entry for( const auto &e : obj.type->ammo->type ) { std::vector<std::string> r; r.push_back( obj.tname( 1, false ) ); r.push_back( e.str() ); r.push_back( to_string( obj.volume() / units::legacy_volume_factor ) ); r.push_back( to_string( to_gram( obj.weight() ) ) ); r.push_back( to_string( obj.type->stack_size ) ); r.push_back( to_string( obj.type->ammo->range ) ); r.push_back( to_string( obj.type->ammo->dispersion ) ); r.push_back( to_string( obj.type->ammo->recoil ) ); damage_instance damage = obj.type->ammo->damage; r.push_back( to_string( damage.total_damage() ) ); r.push_back( to_string( damage.empty() ? 0 : ( *damage.begin() ).res_pen ) ); rows.push_back( r ); } }; for( const itype *e : item_controller->all() ) { if( e->ammo ) { dump( item( e, calendar::turn, item::solitary_tag {} ) ); } } } else if( what == "ARMOR" ) { header = { "Name", "Encumber (fit)", "Warmth", "Weight", "Storage", "Coverage", "Bash", "Cut", "Acid", "Fire" }; auto dump = [&rows]( const item & obj ) { std::vector<std::string> r; r.push_back( obj.tname( 1, false ) ); r.push_back( to_string( obj.get_encumber() ) ); r.push_back( to_string( obj.get_warmth() ) ); r.push_back( to_string( to_gram( obj.weight() ) ) ); r.push_back( to_string( obj.get_storage() / units::legacy_volume_factor ) ); r.push_back( to_string( obj.get_coverage() ) ); r.push_back( to_string( obj.bash_resist() ) ); r.push_back( to_string( obj.cut_resist() ) ); r.push_back( to_string( obj.acid_resist() ) ); r.push_back( to_string( obj.fire_resist() ) ); rows.push_back( r ); }; body_part bp = opts.empty() ? num_bp : get_body_part_token( opts.front() ); for( const itype *e : item_controller->all() ) { if( e->armor ) { item obj( e ); if( bp == num_bp || obj.covers( bp ) ) { if( obj.has_flag( "VARSIZE" ) ) { obj.item_tags.insert( "FIT" ); } dump( obj ); } } } } else if( what == "EDIBLE" ) { header = { "Name", "Volume", "Weight", "Stack", "Calories", "Quench", "Healthy" }; for( const auto &v : vitamin::all() ) { header.push_back( v.second.name() ); } auto dump = [&rows]( const item & obj ) { std::vector<std::string> r; r.push_back( obj.tname( false ) ); r.push_back( to_string( obj.volume() / units::legacy_volume_factor ) ); r.push_back( to_string( to_gram( obj.weight() ) ) ); r.push_back( to_string( obj.type->stack_size ) ); r.push_back( to_string( obj.type->comestible->get_calories() ) ); r.push_back( to_string( obj.type->comestible->quench ) ); r.push_back( to_string( obj.type->comestible->healthy ) ); auto vits = g->u.vitamins_from( obj ); for( const auto &v : vitamin::all() ) { r.push_back( to_string( vits[ v.first ] ) ); } rows.push_back( r ); }; for( const itype *e : item_controller->all() ) { item food( e, calendar::turn, item::solitary_tag {} ); if( food.is_food() && g->u.can_eat( food ).success() ) { dump( food ); } } } else if( what == "GUN" ) { header = { "Name", "Ammo", "Volume", "Weight", "Capacity", "Range", "Dispersion", "Effective recoil", "Damage", "Pierce", "Aim time", "Effective range", "Snapshot range", "Max range" }; std::set<std::string> locations; for( const itype *e : item_controller->all() ) { if( e->gun ) { std::transform( e->gun->valid_mod_locations.begin(), e->gun->valid_mod_locations.end(), std::inserter( locations, locations.begin() ), []( const std::pair<gunmod_location, int> &q ) { return q.first.name(); } ); } } for( const auto &e : locations ) { header.push_back( e ); } auto dump = [&rows, &locations]( const standard_npc & who, const item & obj ) { std::vector<std::string> r; r.push_back( obj.tname( 1, false ) ); r.push_back( obj.ammo_type() ? obj.ammo_type().str() : "" ); r.push_back( to_string( obj.volume() / units::legacy_volume_factor ) ); r.push_back( to_string( to_gram( obj.weight() ) ) ); r.push_back( to_string( obj.ammo_capacity() ) ); r.push_back( to_string( obj.gun_range() ) ); r.push_back( to_string( obj.gun_dispersion() ) ); r.push_back( to_string( obj.gun_recoil( who ) ) ); damage_instance damage = obj.gun_damage(); r.push_back( to_string( damage.total_damage() ) ); r.push_back( to_string( damage.empty() ? 0 : ( *damage.begin() ).res_pen ) ); r.push_back( to_string( who.gun_engagement_moves( obj ) ) ); for( const auto &e : locations ) { const auto &vml = obj.type->gun->valid_mod_locations; const auto iter = vml.find( e ); r.push_back( to_string( iter != vml.end() ? iter->second : 0 ) ); } rows.push_back( r ); }; for( const itype *e : item_controller->all() ) { if( e->gun ) { item gun( e ); if( !gun.magazine_integral() ) { gun.emplace_back( gun.magazine_default() ); } gun.ammo_set( gun.ammo_type()->default_ammotype(), gun.ammo_capacity() ); dump( test_npcs[ "S1" ], gun ); if( gun.type->gun->barrel_length > 0 ) { gun.emplace_back( "barrel_small" ); dump( test_npcs[ "S1" ], gun ); } } } } else if( what == "RECIPE" ) { // optionally filter recipes to include only those using specified skills recipe_subset dict; for( const auto &r : recipe_dict ) { if( opts.empty() || std::any_of( opts.begin(), opts.end(), [&r]( const std::string & s ) { if( r.second.skill_used == skill_id( s ) && r.second.difficulty > 0 ) { return true; } auto iter = r.second.required_skills.find( skill_id( s ) ); return iter != r.second.required_skills.end() && iter->second > 0; } ) ) { dict.include( &r.second ); } } // only consider skills that are required by at least one recipe std::vector<Skill> sk; std::copy_if( Skill::skills.begin(), Skill::skills.end(), std::back_inserter( sk ), [&dict]( const Skill & s ) { return std::any_of( dict.begin(), dict.end(), [&s]( const recipe * r ) { return r->skill_used == s.ident() || r->required_skills.find( s.ident() ) != r->required_skills.end(); } ); } ); header = { "Result" }; for( const auto &e : sk ) { header.push_back( e.ident().str() ); } for( const recipe *e : dict ) { std::vector<std::string> r; r.push_back( e->result_name() ); for( const auto &s : sk ) { if( e->skill_used == s.ident() ) { r.push_back( to_string( e->difficulty ) ); } else { auto iter = e->required_skills.find( s.ident() ); r.push_back( to_string( iter != e->required_skills.end() ? iter->second : 0 ) ); } } rows.push_back( r ); } } else if( what == "VEHICLE" ) { header = { "Name", "Weight (empty)", "Weight (fueled)", "Max velocity (mph)", "Safe velocity (mph)", "Acceleration (mph/turn)", "Mass coeff %", "Aerodynamics coeff %", "Friction coeff %", "Traction coeff % (grass)" }; auto dump = [&rows]( const vproto_id & obj ) { auto veh_empty = vehicle( obj, 0, 0 ); auto veh_fueled = vehicle( obj, 100, 0 ); std::vector<std::string> r; r.push_back( veh_empty.name ); r.push_back( to_string( to_kilogram( veh_empty.total_mass() ) ) ); r.push_back( to_string( to_kilogram( veh_fueled.total_mass() ) ) ); r.push_back( to_string( veh_fueled.max_velocity() / 100 ) ); r.push_back( to_string( veh_fueled.safe_velocity() / 100 ) ); r.push_back( to_string( veh_fueled.acceleration() / 100 ) ); r.push_back( to_string( ( int )( 100 * veh_fueled.k_mass() ) ) ); r.push_back( to_string( ( int )( 100 * veh_fueled.k_aerodynamics() ) ) ); r.push_back( to_string( ( int )( 100 * veh_fueled.k_friction() ) ) ); r.push_back( to_string( ( int )( 100 * veh_fueled.k_traction( veh_fueled.wheel_area( false ) / 2.0f ) ) ) ); rows.push_back( r ); }; for( auto &e : vehicle_prototype::get_all() ) { dump( e ); } } else if( what == "VPART" ) { header = { "Name", "Location", "Weight", "Size" }; auto dump = [&rows]( const vpart_info & obj ) { std::vector<std::string> r; r.push_back( obj.name() ); r.push_back( obj.location ); r.push_back( to_string( int( ceil( to_gram( item( obj.item ).weight() ) / 1000.0 ) ) ) ); r.push_back( to_string( obj.size / units::legacy_volume_factor ) ); rows.push_back( r ); }; for( const auto &e : vpart_info::all() ) { dump( e.second ); } } else { std::cerr << "unknown argument: " << what << std::endl; return false; } rows.erase( std::remove_if( rows.begin(), rows.end(), []( const std::vector<std::string> &e ) { return e.empty(); } ), rows.end() ); if( scol >= 0 ) { std::sort( rows.begin(), rows.end(), [&scol]( const std::vector<std::string> &lhs, const std::vector<std::string> &rhs ) { return lhs[ scol ] < rhs[ scol ]; } ); } rows.erase( std::unique( rows.begin(), rows.end() ), rows.end() ); switch( mode ) { case dump_mode::TSV: rows.insert( rows.begin(), header ); for( const auto &r : rows ) { std::copy( r.begin(), r.end() - 1, std::ostream_iterator<std::string>( std::cout, "\t" ) ); std::cout << r.back() << "\n"; } break; case dump_mode::HTML: std::cout << "<table>"; std::cout << "<thead>"; std::cout << "<tr>"; for( const auto &col : header ) { std::cout << "<th>" << col << "</th>"; } std::cout << "</tr>"; std::cout << "</thead>"; std::cout << "<tdata>"; for( const auto &r : rows ) { std::cout << "<tr>"; for( const auto &col : r ) { std::cout << "<td>" << col << "</td>"; } std::cout << "</tr>"; } std::cout << "</tdata>"; std::cout << "</table>"; break; } return true; }
bool game::dump_stats( const std::string& what, dump_mode mode, const std::vector<std::string> &opts ) { try { load_core_data(); } catch( const std::exception &err ) { std::cerr << "Error loading data from json: " << err.what() << std::endl; return false; } DynamicDataLoader::get_instance().finalize_loaded_data(); std::vector<std::string> header; std::vector<std::vector<std::string>> rows; int scol = 0; // sorting column std::map<std::string, standard_npc> test_npcs; test_npcs[ "S1" ] = standard_npc( "S1", { "gloves_survivor", "mask_lsurvivor" }, 4, 8, 10, 8, 10 /* DEX 10, PER 10 */ ); test_npcs[ "S2" ] = standard_npc( "S2", { "gloves_fingerless", "sunglasses" }, 4, 8, 8, 8, 10 /* PER 10 */ ); test_npcs[ "S3" ] = standard_npc( "S3", { "gloves_plate", "helmet_plate" }, 4, 10, 8, 8, 8 /* STAT 10 */ ); test_npcs[ "S4" ] = standard_npc( "S4", {}, 0, 8, 10, 8, 10 /* DEX 10, PER 10 */ ); test_npcs[ "S5" ] = standard_npc( "S5", {}, 4, 8, 10, 8, 10 /* DEX 10, PER 10 */ ); test_npcs[ "S6" ] = standard_npc( "S6", { "gloves_hsurvivor", "mask_hsurvivor" }, 4, 8, 10, 8, 10 /* DEX 10, PER 10 */ ); std::map<std::string, item> test_items; test_items[ "G1" ] = item( "glock_19" ).ammo_set( "9mm" ); test_items[ "G2" ] = item( "hk_mp5" ).ammo_set( "9mm" ); test_items[ "G3" ] = item( "ar15" ).ammo_set( "223" ); test_items[ "G4" ] = item( "remington_700" ).ammo_set( "270" ); test_items[ "G4" ].emplace_back( "rifle_scope" ); if( what == "AMMO" ) { header = { "Name", "Ammo", "Volume", "Weight", "Stack", "Range", "Dispersion", "Recoil", "Damage", "Pierce" }; auto dump = [&rows]( const item& obj ) { // a common task is comparing ammo by type so ammo has multiple repeat the entry for( const auto &e : obj.type->ammo->type ) { std::vector<std::string> r; r.push_back( obj.tname( 1, false ) ); r.push_back( e.str() ); r.push_back( to_string( obj.volume() / units::legacy_volume_factor ) ); r.push_back( to_string( obj.weight() ) ); r.push_back( to_string( obj.type->stack_size ) ); r.push_back( to_string( obj.type->ammo->range ) ); r.push_back( to_string( obj.type->ammo->dispersion ) ); r.push_back( to_string( obj.type->ammo->recoil ) ); r.push_back( to_string( obj.type->ammo->damage ) ); r.push_back( to_string( obj.type->ammo->pierce ) ); rows.push_back( r ); } }; for( auto& e : item_controller->get_all_itypes() ) { if( e.second.ammo ) { dump( item( e.first, calendar::turn, item::solitary_tag {} ) ); } } } else if( what == "ARMOR" ) { header = { "Name", "Encumber (fit)", "Warmth", "Weight", "Storage", "Coverage", "Bash", "Cut", "Acid", "Fire" }; auto dump = [&rows]( const item& obj ) { std::vector<std::string> r; r.push_back( obj.tname( 1, false ) ); r.push_back( to_string( obj.get_encumber() ) ); r.push_back( to_string( obj.get_warmth() ) ); r.push_back( to_string( obj.weight() ) ); r.push_back( to_string( obj.get_storage() / units::legacy_volume_factor ) ); r.push_back( to_string( obj.get_coverage() ) ); r.push_back( to_string( obj.bash_resist() ) ); r.push_back( to_string( obj.cut_resist() ) ); r.push_back( to_string( obj.acid_resist() ) ); r.push_back( to_string( obj.fire_resist() ) ); rows.push_back( r ); }; body_part bp = opts.empty() ? num_bp : get_body_part_token( opts.front() ); for( auto& e : item_controller->get_all_itypes() ) { if( e.second.armor ) { item obj( e.first ); if( bp == num_bp || obj.covers( bp ) ) { if( obj.has_flag( "VARSIZE" ) ) { obj.item_tags.insert( "FIT" ); } dump( obj ); } } } } else if( what == "EDIBLE" ) { header = { "Name", "Volume", "Weight", "Stack", "Calories", "Quench", "Healthy" }; for( const auto& v : vitamin::all() ) { header.push_back( v.second.name() ); } auto dump = [&rows,&test_npcs]( const item& obj ) { std::vector<std::string> r; r.push_back( obj.tname( false ) ); r.push_back( to_string( obj.volume() / units::legacy_volume_factor ) ); r.push_back( to_string( obj.weight() ) ); r.push_back( to_string( obj.type->stack_size ) ); r.push_back( to_string( obj.type->comestible->get_calories() ) ); r.push_back( to_string( obj.type->comestible->quench ) ); r.push_back( to_string( obj.type->comestible->healthy ) ); auto vits = g->u.vitamins_from( obj ); for( const auto& v : vitamin::all() ) { r.push_back( to_string( vits[ v.first ] ) ); } rows.push_back( r ); }; for( auto& e : item_controller->get_all_itypes() ) { if( e.second.comestible && ( e.second.comestible->comesttype == "FOOD" || e.second.comestible->comesttype == "DRINK" ) ) { item food( e.first, calendar::turn, item::solitary_tag {} ); if( g->u.can_eat( food, false, true ) == EDIBLE ) { dump( food ); } } } } else if( what == "GUN" ) { header = { "Name", "Ammo", "Volume", "Weight", "Capacity", "Range", "Dispersion", "Effective recoil", "Damage", "Pierce", "Aim time", "Effective range", "Snapshot range", "Max range" }; std::set<std::string> locations; for( const auto& e : item_controller->get_all_itypes() ) { if( e.second.gun ) { std::transform( e.second.gun->valid_mod_locations.begin(), e.second.gun->valid_mod_locations.end(), std::inserter( locations, locations.begin() ), []( const std::pair<std::string, int>& e ) { return e.first; } ); } } for( const auto &e : locations ) { header.push_back( e ); } auto dump = [&rows,&locations]( const standard_npc &who, const item& obj ) { std::vector<std::string> r; r.push_back( obj.tname( 1, false ) ); r.push_back( obj.ammo_type() ? obj.ammo_type().str() : "" ); r.push_back( to_string( obj.volume() / units::legacy_volume_factor ) ); r.push_back( to_string( obj.weight() ) ); r.push_back( to_string( obj.ammo_capacity() ) ); r.push_back( to_string( obj.gun_range() ) ); r.push_back( to_string( obj.gun_dispersion() ) ); r.push_back( to_string( obj.gun_recoil( who ) ) ); r.push_back( to_string( obj.gun_damage() ) ); r.push_back( to_string( obj.gun_pierce() ) ); r.push_back( to_string( who.gun_engagement_moves( obj ) ) ); r.push_back( string_format( "%.1f", who.gun_engagement_range( obj, player::engagement::effective ) ) ); r.push_back( string_format( "%.1f", who.gun_engagement_range( obj, player::engagement::snapshot ) ) ); r.push_back( string_format( "%.1f", who.gun_engagement_range( obj, player::engagement::maximum ) ) ); for( const auto &e : locations ) { r.push_back( to_string( obj.type->gun->valid_mod_locations[ e ] ) ); } rows.push_back( r ); }; for( const auto& e : item_controller->get_all_itypes() ) { if( e.second.gun ) { item gun( e.first ); if( !gun.magazine_integral() ) { gun.emplace_back( gun.magazine_default() ); } gun.ammo_set( default_ammo( gun.ammo_type() ), gun.ammo_capacity() ); dump( test_npcs[ "S1" ], gun ); if( gun.type->gun->barrel_length > 0 ) { gun.emplace_back( "barrel_small" ); dump( test_npcs[ "S1" ], gun ); } } } } else if( what == "VEHICLE" ) { header = { "Name", "Weight (empty)", "Weight (fueled)", "Max velocity (mph)", "Safe velocity (mph)", "Acceleration (mph/turn)", "Mass coeff %", "Aerodynamics coeff %", "Friction coeff %", "Traction coeff % (grass)" }; auto dump = [&rows]( const vproto_id& obj ) { auto veh_empty = vehicle( obj, 0, 0 ); auto veh_fueled = vehicle( obj, 100, 0 ); std::vector<std::string> r; r.push_back( veh_empty.name ); r.push_back( to_string( veh_empty.total_mass() ) ); r.push_back( to_string( veh_fueled.total_mass() ) ); r.push_back( to_string( veh_fueled.max_velocity() / 100 ) ); r.push_back( to_string( veh_fueled.safe_velocity() / 100 ) ); r.push_back( to_string( veh_fueled.acceleration() / 100 ) ); r.push_back( to_string( (int)( 100 * veh_fueled.k_mass() ) ) ); r.push_back( to_string( (int)( 100 * veh_fueled.k_aerodynamics() ) ) ); r.push_back( to_string( (int)( 100 * veh_fueled.k_friction() ) ) ); r.push_back( to_string( (int)( 100 * veh_fueled.k_traction( veh_fueled.wheel_area( false ) / 2.0f ) ) ) ); rows.push_back( r ); }; for( auto& e : vehicle_prototype::get_all() ) { dump( e ); } } else if( what == "VPART" ) { header = { "Name", "Location", "Weight", "Size" }; auto dump = [&rows]( const vpart_info &obj ) { std::vector<std::string> r; r.push_back( obj.name() ); r.push_back( obj.location ); r.push_back( to_string( int( ceil( item( obj.item ).weight() / 1000.0 ) ) ) ); r.push_back( to_string( obj.size / units::legacy_volume_factor ) ); rows.push_back( r ); }; for( const auto &e : vpart_info::all() ) { dump( e.second ); } } else if( what == "AIMING" ) { scol = -1; // unsorted output so graph columns have predictable ordering const int cycles = 1400; header = { "Name" }; for( int i = 0; i <= cycles; ++i ) { header.push_back( to_string( i ) ); } auto dump = [&rows]( const standard_npc &who, const item &gun) { std::vector<std::string> r( 1, string_format( "%s %s", who.get_name().c_str(), gun.tname().c_str() ) ); double penalty = MIN_RECOIL; for( int i = 0; i <= cycles; ++i ) { penalty -= who.aim_per_move( gun, penalty ); r.push_back( string_format( "%.2f", who.gun_current_range( gun, penalty ) ) ); } rows.push_back( r ); }; if( opts.empty() ) { dump( test_npcs[ "S1" ], test_items[ "G1" ] ); dump( test_npcs[ "S1" ], test_items[ "G2" ] ); dump( test_npcs[ "S1" ], test_items[ "G3" ] ); dump( test_npcs[ "S1" ], test_items[ "G4" ] ); } else { for( const auto &str : opts ) { auto idx = str.find( ':' ); if( idx == std::string::npos ) { std::cerr << "cannot parse test case: " << str << std::endl; return false; } auto test = std::make_pair( test_npcs.find( str.substr( 0, idx ) ), test_items.find( str.substr( idx + 1 ) ) ); if( test.first == test_npcs.end() || test.second == test_items.end() ) { std::cerr << "invalid test case: " << str << std::endl; return false; } dump( test.first->second, test.second->second ); } } } else if( what == "EXPLOSIVE" ) { header = { // @todo Should display more useful data: shrapnel damage, safe range "Name", "Power", "Power at 5 tiles", "Power halves at", "Shrapnel count", "Shrapnel mass" }; auto dump = [&rows]( const std::string &name, const explosion_data &ex ) { std::vector<std::string> r; r.push_back( name ); r.push_back( to_string( ex.power ) ); r.push_back( string_format( "%.1f", ex.power_at_range( 5.0f ) ) ); r.push_back( string_format( "%.1f", ex.expected_range( 0.5f ) ) ); r.push_back( to_string( ex.shrapnel.count ) ); r.push_back( to_string( ex.shrapnel.mass ) ); rows.push_back( r ); }; for( const auto& e : item_controller->get_all_itypes() ) { const auto &itt = e.second; const auto use = itt.get_use( "explosion" ); if( use != nullptr && use->get_actor_ptr() != nullptr ) { const auto actor = dynamic_cast<const explosion_iuse *>( use->get_actor_ptr() ); if( actor != nullptr ) { dump( itt.nname( 1 ), actor->explosion ); } } auto c_ex = dynamic_cast<const explosion_iuse *>( itt.countdown_action.get_actor_ptr() ); if( c_ex != nullptr ) { dump( itt.nname( 1 ), c_ex->explosion ); } } } else { std::cerr << "unknown argument: " << what << std::endl; return false; } rows.erase( std::remove_if( rows.begin(), rows.end(), []( const std::vector<std::string>& e ) { return e.empty(); } ), rows.end() ); if( scol >= 0 ) { std::sort( rows.begin(), rows.end(), [&scol]( const std::vector<std::string>& lhs, const std::vector<std::string>& rhs ) { return lhs[ scol ] < rhs[ scol ]; } ); } rows.erase( std::unique( rows.begin(), rows.end() ), rows.end() ); switch( mode ) { case dump_mode::TSV: rows.insert( rows.begin(), header ); for( const auto& r : rows ) { std::copy( r.begin(), r.end() - 1, std::ostream_iterator<std::string>( std::cout, "\t" ) ); std::cout << r.back() << "\n"; } break; case dump_mode::HTML: std::cout << "<table>"; std::cout << "<thead>"; std::cout << "<tr>"; for( const auto& col : header ) { std::cout << "<th>" << col << "</th>"; } std::cout << "</tr>"; std::cout << "</thead>"; std::cout << "<tdata>"; for( const auto& r : rows ) { std::cout << "<tr>"; for( const auto& col : r ) { std::cout << "<td>" << col << "</td>"; } std::cout << "</tr>"; } std::cout << "</tdata>"; std::cout << "</table>"; break; } return true; }
UINT MainLoop(WindowManager *winmgr) { //window setting Window window; winmgr->RegisterWindow(&window); ARSG g(window.hWnd, WINDOW_WIDTH, WINDOW_HEIGHT, true); ARSI *keyIn = window.GetInputHandler(); ARSS s; Sound bgm, badend, atk; s.CreateSoundBuffer(&atk, L"../sound/atk.wav"); s.CreateSoundBuffer(&bgm, L"../sound/bgm.wav"); s.CreateSoundBuffer(&badend, L"../sound/fadein.wav"); //Texture Texture board; Texture bg; Texture mask; Texture gameover; Texture clear; //BitPlane BitPlane source; BitPlane stored; BitPlane hitArea; BitPlane bitmask; //Light Light light; g.CreateLight(&light); light.SetLightIntensity(10); //Camera ARSD d; d.Init(); d.AttachCam(0); d.BindBitPlane(&source); d.StartGraph(); while (!source.GetPointer()); source.GetSize(&sizex, &sizey, &depth); source.CopyTo(&stored); //background g.CreateTexture(&bg, L"../img/bgbg.jpg"); bg.SetDrawMode(true); g.CreateTexture(&mask, L"../img/mask.jpg"); mask.SetDrawMode(true); mask.GetBitData(&bitmask); g.CreateTexture(&board, sizex, sizey); board.SetDrawMode(true); Mesh f; g.CreateMesh(&f, L"../model/f4.x"); float scale=25.0f; f.SetScale(scale, scale, scale, GL_ABSOLUTE); f.SetPosition(45.0f, -4.0f, 65.0f, GL_ABSOLUTE); f.SetRotationY(1.57f); g.CreateTexture(&gameover, L"../img/gameover.jpg"); gameover.SetDrawMode(true); g.CreateTexture(&clear, L"../img/clear.PNG"); gameover.SetDrawMode(true); //gun Gun gun(&g, &s, L"gun2.x", L"../sound/gun2.wav"); gun.DefaultPosition(0.0f, -1.2f, -17.0f); gun.SetRotation(-0.1f, 3.14f, 0.0f, GL_ROTXYZ, GL_ABSOLUTE); //enemy int i, j; Batman bats[BAT]; for(i=0,j=-1; i<BAT; ++i,j*=-1){ new(bats+i)Batman(j*3.0f, 5.0f, 25.0f, j*-1*0.02f, -0.03f, -0.25f, j*-1*0.04f); bats[i].setting(&g, L"../model/bat.x"); } Bone bons[BONE]; for(i=0; i<BONE; ++i){ new(bons+i)Bone(i*2, -4.8f, 20.0f, 0.0f, 0.01f, -0.25f); bons[i].setting(&g, L"../model/bone.x"); } Boss boss(0.0f, -8.0f, 5.0f); boss.setSize(3.0f); boss.setting(&g, L"../model/teki.x"); //add g.RegisterLight(&light); g.RegisterShape(&bg); g.RegisterShape(&f); for(i=0; i<BAT; ++i) g.RegisterShape(&bats[i]); g.RegisterShape(&board); g.RegisterShape(&gun); Effect e(&g); Player p(&g); enum {START, BAD, SCARLE, ARMER, BOSS, GAMEOVER, END}; int state = START; unsigned int cnt=0; j=0; bgm.Play(true); while (!winmgr->WaitingForTermination()){ if (keyIn->GetKeyTrig('A')) source.CopyTo(&stored); if (keyIn->GetKeyTrig('Q')) break; subtract_maskf(&bitmask, &hitArea,&stored,&source,0x50505050); gun.move(&hitArea); switch(state){ case START: if(cnt==20){ cnt=0; state=BAD; } break; case BAD: if(cnt<400) f.SetPosition(-0.004f, 0.0f, -0.05f, GL_RELATIVE); else if(cnt<410) f.SetPosition(-0.01f, 0.0f, -0.15f, GL_RELATIVE); else if(cnt<420){ f.SetRotationY(-0.157f); f.SetPosition(-9.0f, 0.0f, -1.7f, GL_RELATIVE); }else if(cnt<565){ f.SetRotationY(-0.001f); f.SetPosition(-0.04f, 0.0f, -0.14f, GL_RELATIVE); }else if(cnt<745){ f.SetRotationY(0.001f); f.SetPosition(0.0f, 0.0f, -0.15f, GL_RELATIVE); }else if(cnt<770){ f.SetRotationY(0.052f); f.SetPosition(1.5f, 0.0f, 0.72f, GL_RELATIVE); }else if(cnt==771){ cnt=0; j=0; state=SCARLE; for(i=0; i<BONE; ++i) g.RegisterShape(&bons[i]); e.reSet(); } break; case SCARLE: if(cnt<45){ f.SetPosition(0.0f, 0.0f, 0.31f, GL_RELATIVE); }else if(cnt == 201){ cnt=0; j=0; state=ARMER; for(i=0; i<BONE; ++i) g.UnregisterShape(&bons[i]); } break; case ARMER: if(cnt<20){ f.SetRotationY(0.055f); f.SetPosition(1.5f, 0.0f, 0.72f, GL_RELATIVE); }else if(cnt<100){ f.SetRotationY(0.005f); f.SetPosition(0.12f, 0.0f, -0.16f, GL_RELATIVE); }else if(cnt<210){ f.SetPosition(0.0f, 0.0f, -0.175f, GL_RELATIVE); }else if(cnt<220){ f.SetRotationY(-0.055f); f.SetPosition(-0.1f, 0.0f, -0.2f, GL_RELATIVE); }else if(cnt<370){ f.SetRotationY(0.003f); f.SetPosition(0.0f, 0.0f, -0.12f, GL_RELATIVE); } if(p.getWin()){ state=BOSS; } if(cnt==360){ g.RegisterShape(&boss); e.reSet(); } if(cnt>370){ boss.move(&p, &e, &atk); boss.hitCheck(&gun, &e, &p); } break; case BOSS: bgm.Stop(); g.RegisterShape(&clear); state=END; break; case GAMEOVER: bgm.Stop(); badend.Play(); g.RegisterShape(&gameover); state=END; break; default: break; } if(state==START || state==BAD){ if(j<BAT && cnt%61==0) ++j; for(i=0; i<j; ++i){ bats[i].move(&p, &e, &atk); bats[i].hitCheck(&gun, &e); } } if(state==SCARLE){ if(j<BONE && cnt%61==0) ++j; for(i=0; i<j; ++i){ bons[i].move(&p, &e, &atk); bons[i].hitCheck(&gun, &e); } } e.addEffect(); if(p.checkHP()) state=GAMEOVER; board.SetBitData(&hitArea); g.Draw(); ++cnt; } d.StopGraph(); return 0; }
void gun_actor::shoot( monster &z, Creature &target, const gun_mode_id &mode ) const { if( require_sunlight && !g->is_in_sunlight( z.pos() ) ) { if( one_in( 3 ) && g->u.sees( z ) ) { add_msg( _( failure_msg ), z.name() ); } return; } const bool require_targeting = ( require_targeting_player && target.is_player() ) || ( require_targeting_npc && target.is_npc() ) || ( require_targeting_monster && target.is_monster() ); const bool not_targeted = require_targeting && !z.has_effect( effect_targeted ); const bool not_laser_locked = require_targeting && laser_lock && !target.has_effect( effect_was_laserlocked ); if( not_targeted || not_laser_locked ) { if( targeting_volume > 0 && !targeting_sound.empty() ) { sounds::sound( z.pos(), targeting_volume, sounds::sound_t::alarm, _( targeting_sound ) ); } if( not_targeted ) { z.add_effect( effect_targeted, time_duration::from_turns( targeting_timeout ) ); } if( not_laser_locked ) { target.add_effect( effect_laserlocked, 5_turns ); target.add_effect( effect_was_laserlocked, 5_turns ); target.add_msg_if_player( m_warning, _( "You're not sure why you've got a laser dot on you..." ) ); } z.moves -= targeting_cost; return; } z.moves -= move_cost; item gun( gun_type ); gun.gun_set_mode( mode ); itype_id ammo = ( ammo_type != "null" ) ? ammo_type : gun.ammo_default(); if( ammo != "null" ) { gun.ammo_set( ammo, z.ammo[ ammo ] ); } if( !gun.ammo_sufficient() ) { if( !no_ammo_sound.empty() ) { sounds::sound( z.pos(), 10, sounds::sound_t::combat, _( no_ammo_sound ) ); } return; } standard_npc tmp( _( "The " ) + z.name(), {}, 8, fake_str, fake_dex, fake_int, fake_per ); tmp.set_fake( true ); tmp.setpos( z.pos() ); tmp.set_attitude( z.friendly ? NPCATT_FOLLOW : NPCATT_KILL ); tmp.recoil = 0; // no need to aim for( const auto &pr : fake_skills ) { tmp.set_skill_level( pr.first, pr.second ); } tmp.weapon = gun; tmp.i_add( item( "UPS_off", calendar::turn, 1000 ) ); if( g->u.sees( z ) ) { add_msg( m_warning, _( description ), z.name(), tmp.weapon.tname() ); } z.ammo[ammo] -= tmp.fire_gun( target.pos(), gun.gun_current_mode().qty ); if( require_targeting ) { z.add_effect( effect_targeted, time_duration::from_turns( targeting_timeout_extend ) ); } if( laser_lock ) { // To prevent spamming laser locks when the player can tank that stuff somehow target.add_effect( effect_was_laserlocked, 5_turns ); } }
void game::dump_stats( const std::string& what, dump_mode mode ) { load_core_data(); DynamicDataLoader::get_instance().finalize_loaded_data(); std::vector<std::string> header; std::vector<std::vector<std::string>> rows; if( what == "AMMO" ) { header = { "Name", "Ammo", "Volume", "Weight", "Stack", "Range", "Dispersion", "Recoil", "Damage", "Pierce" }; auto dump = [&rows]( const item& obj ) { std::vector<std::string> r; r.push_back( obj.tname( false ) ); r.push_back( obj.type->ammo->type ); r.push_back( std::to_string( obj.volume() ) ); r.push_back( std::to_string( obj.weight() ) ); r.push_back( std::to_string( obj.type->stack_size ) ); r.push_back( std::to_string( obj.type->ammo->range ) ); r.push_back( std::to_string( obj.type->ammo->dispersion ) ); r.push_back( std::to_string( obj.type->ammo->recoil ) ); r.push_back( std::to_string( obj.type->ammo->damage ) ); r.push_back( std::to_string( obj.type->ammo->pierce ) ); rows.push_back( r ); }; for( auto& e : item_controller->get_all_itypes() ) { if( e.second->ammo ) { dump( item( e.first, calendar::turn, item::solitary_tag {} ) ); } } } else if( what == "EDIBLE" ) { header = { "Name", "Volume", "Weight", "Stack", "Calories", "Quench", "Healthy" }; for( const auto& v : vitamin::all() ) { header.push_back( v.second.name() ); } auto dump = [&rows]( const item& obj ) { std::vector<std::string> r; r.push_back( obj.tname( false ) ); r.push_back( std::to_string( obj.volume() ) ); r.push_back( std::to_string( obj.weight() ) ); r.push_back( std::to_string( obj.type->stack_size ) ); r.push_back( std::to_string( obj.type->comestible->get_calories() ) ); r.push_back( std::to_string( obj.type->comestible->quench ) ); r.push_back( std::to_string( obj.type->comestible->healthy ) ); auto vits = g->u.vitamins_from( obj ); for( const auto& v : vitamin::all() ) { r.push_back( std::to_string( vits[ v.first ] ) ); } rows.push_back( r ); }; for( auto& e : item_controller->get_all_itypes() ) { if( e.second->comestible && ( e.second->comestible->comesttype == "FOOD" || e.second->comestible->comesttype == "DRINK" ) ) { item food( e.first, calendar::turn, item::solitary_tag {} ); if( g->u.can_eat( food, false, true ) == EDIBLE ) { dump( food ); } } } } else if( what == "GUN" ) { header = { "Name", "Ammo", "Volume", "Weight", "Capacity", "Range", "Dispersion", "Recoil", "Damage", "Pierce" }; std::set<std::string> locations; for( const auto& e : item_controller->get_all_itypes() ) { if( e.second->gun ) { std::transform( e.second->gun->valid_mod_locations.begin(), e.second->gun->valid_mod_locations.end(), std::inserter( locations, locations.begin() ), []( const std::pair<std::string, int>& e ) { return e.first; } ); } } for( const auto &e : locations ) { header.push_back( e ); } auto dump = [&rows,&locations]( const item& obj ) { std::vector<std::string> r; r.push_back( obj.tname( false ) ); r.push_back( obj.ammo_type() != "NULL" ? obj.ammo_type() : "" ); r.push_back( std::to_string( obj.volume() ) ); r.push_back( std::to_string( obj.weight() ) ); r.push_back( std::to_string( obj.ammo_capacity() ) ); r.push_back( std::to_string( obj.gun_range() ) ); r.push_back( std::to_string( obj.gun_dispersion() ) ); r.push_back( std::to_string( obj.gun_recoil() ) ); r.push_back( std::to_string( obj.gun_damage() ) ); r.push_back( std::to_string( obj.gun_pierce() ) ); for( const auto &e : locations ) { r.push_back( std::to_string( obj.type->gun->valid_mod_locations[ e ] ) ); } rows.push_back( r ); }; for( const auto& e : item_controller->get_all_itypes() ) { if( e.second->gun ) { item gun( e.first ); if( gun.is_reloadable() ) { gun.ammo_set( default_ammo( gun.ammo_type() ), gun.ammo_capacity() ); } dump( gun ); if( gun.type->gun->barrel_length > 0 ) { gun.emplace_back( "barrel_small" ); dump( gun ); } } } } else if( what == "VEHICLE" ) { header = { "Name", "Weight (empty)", "Weight (fueled)" }; auto dump = [&rows]( const vproto_id& obj ) { auto veh_empty = vehicle( obj, 0, 0 ); auto veh_fueled = vehicle( obj, 100, 0 ); std::vector<std::string> r; r.push_back( veh_empty.name ); r.push_back( std::to_string( veh_empty.total_mass() ) ); r.push_back( std::to_string( veh_fueled.total_mass() ) ); rows.push_back( r ); }; for( auto& e : vehicle_prototype::get_all() ) { dump( e ); } } else if( what == "VPART" ) { header = { "Name", "Location", "Weight", "Size" }; auto dump = [&rows]( const vpart_info *obj ) { std::vector<std::string> r; r.push_back( obj->name() ); r.push_back( obj->location ); r.push_back( std::to_string( int( ceil( item( obj->item ).weight() / 1000.0 ) ) ) ); r.push_back( std::to_string( obj->size ) ); rows.push_back( r ); }; for( const auto e : vpart_info::get_all() ) { dump( e ); } } rows.erase( std::remove_if( rows.begin(), rows.end(), []( const std::vector<std::string>& e ) { return e.empty(); } ), rows.end() ); std::sort( rows.begin(), rows.end(), []( const std::vector<std::string>& lhs, const std::vector<std::string>& rhs ) { return lhs[ 0 ] < rhs[ 0 ]; } ); rows.erase( std::unique( rows.begin(), rows.end() ), rows.end() ); switch( mode ) { case dump_mode::TSV: rows.insert( rows.begin(), header ); for( const auto& r : rows ) { std::copy( r.begin(), r.end() - 1, std::ostream_iterator<std::string>( std::cout, "\t" ) ); std::cout << r.back() << "\n"; } break; case dump_mode::HTML: std::cout << "<table>"; std::cout << "<thead>"; std::cout << "<tr>"; for( const auto& col : header ) { std::cout << "<th>" << col << "</th>"; } std::cout << "</tr>"; std::cout << "</thead>"; std::cout << "<tdata>"; for( const auto& r : rows ) { std::cout << "<tr>"; for( const auto& col : r ) { std::cout << "<td>" << col << "</td>"; } std::cout << "</tr>"; } std::cout << "</tdata>"; std::cout << "</table>"; break; } }