/** * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point. */ void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn, const tripoint &location ) { const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 ); if ( startturn > endturn || !tr.is_funnel() ) { return; } it.bday = endturn; // bday == last fill check rainfall_data rainfall = get_rainfall( startturn, endturn, location ); // Technically 0.0 division is OK, but it will be cleaner without it if( rainfall.rain_amount > 0 ) { // This is kinda weird: we're dumping a "block" of water all at once // but the old formula ( rain_turns / turn_per_charge(total_amount) ) resulted in // water being produced at quadratic rate rather than linear with time const int rain = 1.0 / tr.funnel_turns_per_charge( rainfall.rain_amount ); it.add_rain_to_container( false, rain ); } if( rainfall.acid_amount > 0 ) { const int acid = 1.0 / tr.funnel_turns_per_charge( rainfall.acid_amount ); it.add_rain_to_container( true, acid ); } }
/** * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point. */ void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn, const tripoint &location ) { const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 ); if ( startturn > endturn || !tr.is_funnel() ) { return; } it.bday = endturn; // bday == last fill check int rain_amount = 0; int acid_amount = 0; int rain_turns = 0; int acid_turns = 0; for( calendar turn(startturn); turn < endturn; turn += 10) { // TODO: Z-level weather switch(g->weatherGen.get_weather_conditions(point(location.x, location.y), turn)) { case WEATHER_DRIZZLE: rain_amount += 4; rain_turns++; break; case WEATHER_RAINY: case WEATHER_THUNDER: case WEATHER_LIGHTNING: rain_amount += 8; rain_turns++; break; case WEATHER_ACID_DRIZZLE: acid_amount += 4; acid_turns++; break; case WEATHER_ACID_RAIN: acid_amount += 8; acid_turns++; break; default: break; } } // Technically 0.0 division is OK, but it will be cleaner without it if( rain_amount > 0 ) { int rain = rain_turns / tr.funnel_turns_per_charge( rain_amount ); it.add_rain_to_container( false, rain ); } if( acid_amount > 0 ) { int acid = acid_turns / tr.funnel_turns_per_charge( acid_amount ); it.add_rain_to_container( true, acid ); } }
/** * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point. */ void retroactively_fill_from_funnel( item &it, const trap &tr, int startturn, int endturn, const tripoint &location ) { if( startturn > endturn || !tr.is_funnel() ) { return; } it.bday = endturn; // bday == last fill check auto data = sum_conditions( startturn, endturn, location ); // Technically 0.0 division is OK, but it will be cleaner without it if( data.rain_amount > 0 ) { const int rain = divide_roll_remainder( 1.0 / tr.funnel_turns_per_charge( data.rain_amount ), 1.0f ); it.add_rain_to_container( false, rain ); // add_msg(m_debug, "Retroactively adding %d water from turn %d to %d", rain, startturn, endturn); } if( data.acid_amount > 0 ) { const int acid = divide_roll_remainder( 1.0 / tr.funnel_turns_per_charge( data.acid_amount ), 1.0f ); it.add_rain_to_container( true, acid ); } }
/** * Determine what a funnel has filled out of game, using funnelcontainer.bday as a starting point. */ void retroactively_fill_from_funnel( item &it, const trap &tr, const calendar &endturn, const tripoint &location ) { const calendar startturn = calendar( it.bday > 0 ? it.bday - 1 : 0 ); if ( startturn > endturn || !tr.is_funnel() ) { return; } it.bday = endturn; // bday == last fill check auto data = sum_conditions( startturn, endturn, location ); // Technically 0.0 division is OK, but it will be cleaner without it if( data.rain_amount > 0 ) { const int rain = 1.0 / tr.funnel_turns_per_charge( data.rain_amount ); it.add_rain_to_container( false, rain ); } if( data.acid_amount > 0 ) { const int acid = 1.0 / tr.funnel_turns_per_charge( data.acid_amount ); it.add_rain_to_container( true, acid ); } }