Example #1
0
void VehicleFactory::builtin_jackknifed_semi(map& m, const std::string &terrainid)
{
    const VehicleLocation* loc = vehicle_controller->pick_location(terrainid+"_semi");
    if(! loc) {
        debugmsg("builtin_jackknifed_semi unable to get location to place vehicle. placement %s", (terrainid+"_semi").c_str());
        return;
    }

    int facing = loc->pick_facing();
    point semi_p = loc->pick_point();
    point trailer_p;

    if(facing == 0) {
        trailer_p.x = semi_p.x + 4;
        trailer_p.y = semi_p.y - 10;
    } else if(facing == 90) {
        trailer_p.x = semi_p.x + 12;
        trailer_p.y = semi_p.y + 1;
    } else if(facing == 180) {
        trailer_p.x = semi_p.x - 4;
        trailer_p.y = semi_p.y + 10;
    } else {
        trailer_p.x = semi_p.x - 12;
        trailer_p.y = semi_p.y - 1;
    }

    vehicle_controller->add_vehicle(m, "semi_truck", semi_p, (facing + 135) % 360, -1, 1);
    vehicle_controller->add_vehicle(m, "truck_trailer", trailer_p, (facing + 90) % 360, -1, 1);
}
Example #2
0
void VehicleFunction_json::apply(map& m, const std::string &terrain_name) const
{
    for(auto i = number.get(); i > 0; i--) {
        if(! location) {
            size_t replace = placement.find("%t");
            const VehicleLocation* loc = vehicle_controller->pick_location(
                replace != std::string::npos ? placement.substr(0,replace) + terrain_name + placement.substr(replace+2) : placement);

            if(! loc) {
                debugmsg("vehiclefunction_json: unable to get location to place vehicle.");
                return;
            }
            vehicle_controller->add_vehicle(m, vehicle, loc->pick_point(), loc->pick_facing(), fuel, status);
        }
        else {
            vehicle_controller->add_vehicle(m, vehicle, location->pick_point(), location->pick_facing(), fuel, status);
        }
    }
}
Example #3
0
void VehicleFactory::builtin_policepileup(map& m, const std::string&)
{
    vehicle *last_added_car = NULL;
    int num_cars = rng(18, 22);

    for(int i = 0; i < num_cars; i++) {
        const VehicleLocation* loc = vehicle_controller->pick_location("pileup");
        if(! loc) {
            debugmsg("builtin_policepileup unable to get location to place vehicle.");
            return;
        }

        last_added_car = vehicle_controller->add_vehicle(m, "policecar", loc->pick_point(),
            loc->pick_facing(), -1, 1);
    }

    if (last_added_car != NULL) {
        last_added_car->name = _("policecar pile-up");
    }
}