Example #1
0
void builtin_jackknifed_semi(map& m, const std::string &terrainid)
{
    const VehicleLocation* loc = vplacement_id(terrainid+"_semi").obj().pick();
    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;
    }

    m.add_vehicle(vgroup_id("semi_truck"), semi_p, (facing + 135) % 360, -1, 1);
    m.add_vehicle(vgroup_id("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 = vplacement_id(replace != std::string::npos
                ? placement.substr(0,replace) + terrain_name + placement.substr(replace+2)
                : placement).obj().pick();

            if(! loc) {
                debugmsg("vehiclefunction_json: unable to get location to place vehicle.");
                return;
            }
            m.add_vehicle(vehicle, loc->pick_point(), loc->pick_facing(), fuel, status);
        }
        else {
            m.add_vehicle(vehicle, location->pick_point(), location->pick_facing(), fuel, status);
        }
    }
}
Example #3
0
void builtin_parkinglot(map& m, const std::string&)
{
    for(int v = 0; v < rng(1,4); v++) {
        point pos_p;
        pos_p.x = rng(0, 1) * 15 + rng(4,5);
        pos_p.y = rng(0, 4) * 4 + rng(2,4);

        if (!m.veh_at(pos_p.x,pos_p.y)) {
            m.add_vehicle(vgroup_id("parkinglot"), pos_p, (one_in(2)?0:180) + (one_in(10)*rng(0,179)), -1, -1);
        }
    }
}
Example #4
0
void 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 = vplacement_id("pileup").obj().pick();
        if(! loc) {
            debugmsg("builtin_policepileup unable to get location to place vehicle.");
            return;
        }

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

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