Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (from_tags["area"] == "mansion_2"){
- //First room in the second half of the mansion.
- //Draw a line through the mansion layout from the last mansion_1 corridor room to
- //get the coordinates of the first mansion_2 corridor room.
- //todo: when we add the climb detour we'll have to change this
- class room_data last_corridor_room = DM->query_room_data(dun_id,
- features["grounds"]+features["ingress"]+features["mansion_1"] - 1);
- int *last_coords = last_corridor_room->tags["coords"];
- int *detour_coords;
- float *vector_1, *vector_2, mag_1, mag_2;
- int *sign;
- string dir_1, dir_2;
- from_coords = ({ features["mansion_length"] - last_coords[0] - 1,
- features["mansion_length"] - last_coords[1] - 1,
- last_coords[2] });
- from_tags["coords"] = from_coords;
- from_tags["room_type"] = "corridor";
- detour_coords = ({ features["mansion_length"] - (last_coords[0] * 2) - 1,
- features["mansion_length"] - (last_coords[1] * 2) - 1 });
- sign = ({
- detour_coords[0] ? detour_coords[0] / abs(detour_coords[0]) : 0,
- detour_coords[1] ? detour_coords[1] / abs(detour_coords[1]) : 0,
- });
- //Separate out the diagonal and cardinal components of the vector.
- //The diagonal component is in vector_1 and the cardinal component is in vector_2.
- if (abs(detour_coords[0]) >= abs(detour_coords[1])){
- vector_1 = ({ 0.0 + sign[0] * abs(detour_coords[1]), 0.0 + detour_coords[1] });
- vector_2 = ({ 0.0 + detour_coords[0] - vector_1[0], 0.0 });
- } else {
- vector_1 = ({ 0.0 + detour_coords[0], 0.0 + sign[1] * abs(detour_coords[0]) });
- vector_2 = ({ 0.0, 0.0 + detour_coords[1] - vector_1[1] });
- }
- //Then, find the direction of each component to determine which exit directions we're
- //using.
- dir_1 = "";
- if (vector_1[1] < 0)
- dir_1 += "north";
- else if (vector_1[1] > 0)
- dir_1 += "south";
- if (vector_1[0] < 0)
- dir_1 += "west";
- else if (vector_1[0] > 0)
- dir_1 += "east";
- dir_2 = "";
- if (vector_2[1] < 0)
- dir_2 += "north";
- else if (vector_2[1] > 0)
- dir_2 += "south";
- if (vector_2[0] < 0)
- dir_2 += "west";
- else if (vector_2[0] > 0)
- dir_2 += "east";
- //Finally, find the ratio between the magnitudes of each component to determine
- //how many of each exit we'll use.
- mag_1 = sqrt(pow(vector_1[0], 2) + pow(vector_1[1], 2));
- mag_2 = sqrt(pow(vector_2[0], 2) + pow(vector_2[1], 2));
- features["detour_directions"] = ({ });
- for (int i=1;i<4;i++){
- if ((mag_1+mag_2) * i/4 < mag_1)
- features["detour_directions"] += ({ dir_1 });
- else
- features["detour_directions"] += ({ dir_2 });
- }
- features["detour_directions"] = shuffle(features["detour_directions"]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement