Ejemplo n.º 1
0
// Returns true if the room is too dark to see, false if the room has enough
// light to see
bool
room_is_dark(struct room_data * room)
{
    if (!room) {
        errlog("room_is_dark() called with NULL room");
        return false;
    }

    if (!room->zone) {
        errlog("room_is_dark() called with NULL room->zone [%d]",
            room->number);
        return false;
    }

    if (!room->zone->weather) {
        errlog("room_is_dark() called with NULL room->zone->weather [%d]",
            room->number);
        return false;
    }

    if (room->light)
        return false;
    if (SECT(room) == SECT_ELEMENTAL_OOZE)
        return true;
    if (ROOM_FLAGGED(room, ROOM_DARK))
        return true;
    if (!PRIME_MATERIAL_ROOM(room))
        return false;
    if (ROOM_FLAGGED(room, ROOM_INDOORS))
        return false;
    if (SECT(room) == SECT_INSIDE)
        return false;
    if (SECT(room) == SECT_VEHICLE)
        return false;
    if (SECT(room) == SECT_CITY)
        return false;

    return !room_is_sunny(room);
}
Ejemplo n.º 2
0
// Returns true if the room is outside and sunny, otherwise returns false
bool
room_is_sunny(struct room_data *room)
{
    int sunlight;

    // Explicitly dark
    if (ROOM_FLAGGED(room, ROOM_DARK))
        return false;
    // Only the prime material plane has a sun
    if (!PRIME_MATERIAL_ROOM(room))
        return false;
    // Sun doesn't reach indoors
    if (ROOM_FLAGGED(room, ROOM_INDOORS))
        return false;
    // Or rooms that are inside
    if (SECT(room) == SECT_INSIDE)
        return false;

    // Actual sunlight check
    sunlight = room->zone->weather->sunlight;
    return (sunlight == SUN_RISE || sunlight == SUN_LIGHT);
}
Ejemplo n.º 3
0
void
another_hour(void)
{
    struct zone_data *zone = NULL;
    struct time_info_data local_time;
    int LUNAR_RISE_TIME;
    int lunar_phase;

    time_info.hours++;

    lunar_phase = get_lunar_phase(lunar_day);

    while (time_info.hours > 23) {
        time_info.hours -= 24;
        time_info.day++;
        lunar_day++;
        if (lunar_day > 23)
            lunar_day = 0;

        if (lunar_phase != get_lunar_phase(lunar_day)) {
            lunar_phase = get_lunar_phase(lunar_day);
            switch (lunar_phase) {
            case MOON_FULL:
                send_to_clerics(EVIL,
                    "The vile light of the full moon dampens your magic power.\r\n");
                send_to_clerics(GOOD,
                    "The blessed light of the full moon fills you with strength.\r\n");
                break;
            case MOON_WANE_GIBBOUS:
                send_to_clerics(EVIL,
                    "Your magic strengthens as the blasphemous light of the full moon passes.\r\n");
                send_to_clerics(GOOD,
                    "The blessing of the full moon leaves you as the moon wanes.\r\n");
                break;
            case MOON_NEW:
                send_to_clerics(EVIL,
                    "The unholy strength of the new moon fills you.\r\n");
                send_to_clerics(GOOD,
                    "The cold darkness of the new moon drains your strength.\r\n");
                break;
            case MOON_WAX_CRESCENT:
                send_to_clerics(EVIL,
                    "Your unholy strength wanes with the passing of the new moon.\r\n");
                send_to_clerics(GOOD,
                    "You feel your strength return as the new moon passes.\r\n");
                break;
            }
        }
    }

    while (time_info.day > 34) {
        time_info.day -= 35;
        time_info.month++;
    }
    while (time_info.month > 15) {
        time_info.month -= 16;
        time_info.year++;
    }

    for (zone = zone_table; zone; zone = zone->next) {
        if (!zone->world)
            continue;

        if (!PRIME_MATERIAL_ROOM(zone->world) ||
            zone->time_frame == TIME_TIMELESS ||
            GET_PLANE(zone->world) == PLANE_UNDERDARK)
            continue;

        set_local_time(zone, &local_time);

        if (local_time.hours == (4 - daylight_mod[(int)local_time.month])) {
            if (!number(0, 2))
                send_to_zone("A small blue sun rises in the east.\r\n", zone,
                    1);
            else if (zone->weather->sky == SKY_CLOUDLESS)
                send_to_zone
                    ("The blue sun rises in the cloudless skies of the east.\r\n",
                    zone, 1);
            else if (zone->weather->sky == SKY_CLOUDY)
                send_to_zone
                    ("Through the veil of clouds, you see a glimmer of blue to the east.\r\n",
                    zone, 1);
            else if (zone->weather->sky == SKY_RAINING)
                send_to_zone
                    ("The faint light of the blue sun appears through the rain to the east.\r\n",
                    zone, 1);
            else
                send_to_zone("A small blue sun rises in the east.\r\n", zone,
                    1);

            /* SUN_RISE */
        } else if (local_time.hours ==
            (5 - daylight_mod[(int)local_time.month])) {
            zone->weather->sunlight = SUN_RISE;
            if (!number(0, 2))
                send_to_zone
                    ("The huge red sun rises over the eastern horizon.\r\n",
                    zone, 1);
            else if (zone->weather->sky == SKY_CLOUDLESS)
                send_to_zone
                    ("The blazing red giant rises into the clear sky.\r\n",
                    zone, 1);
            else if (zone->weather->sky == SKY_CLOUDY)
                send_to_zone
                    ("The red light of the sun appears in the cloudy sky.\r\n",
                    zone, 1);
            else
                send_to_zone
                    ("The huge red sun rises over the eastern horizon.\r\n",
                    zone, 1);

        } else if (local_time.hours ==
            (6 - daylight_mod[(int)local_time.month])) {
            zone->weather->sunlight = SUN_LIGHT;
            if (!number(0, 2))
                send_to_zone
                    ("The day has begun, both suns above the horizon.\r\n",
                    zone, 1);
            else if (zone->weather->sky == SKY_CLOUDLESS)
                send_to_zone("The day begins under a cloudless sky.\r\n", zone,
                    1);
            else if (zone->weather->sky == SKY_CLOUDY)
                send_to_zone("The cloudy day has begun.\r\n", zone, 1);
            else if (zone->weather->sky == SKY_RAINING)
                send_to_zone("The rainy day has begun.\r\n", zone, 1);
            else if (zone->weather->sky == SKY_LIGHTNING)
                send_to_zone("The day begins, immersed in a thunderstorm.\r\n",
                    zone, 1);
            else
                send_to_zone
                    ("The day has begun, both suns above the horizon.\r\n",
                    zone, 1);

            if (local_time.day == 0) {
                switch (local_time.month) {
                case 2:
                    send_to_zone("It is the first day of spring.\r\n", zone,
                        1);
                    break;
                case 6:
                    send_to_zone("It is the first day of summer.\r\n", zone,
                        1);
                    break;
                case 10:
                    send_to_zone("It is the first day of autumn.\r\n", zone,
                        1);
                    break;
                case 14:
                    send_to_zone("It is the first day of winter.\r\n", zone,
                        1);
                    break;
                }
            }
            break;

        } else if (local_time.hours == 12) {
            send_to_zone("The red giant is high overhead now, at noon.\r\n",
                zone, 1);

        } else if (local_time.hours ==
            (20 + daylight_mod[(int)local_time.month])) {
            zone->weather->sunlight = SUN_SET;
            send_to_zone("The red giant sun slowly sets in the west.\r\n",
                zone, 1);

        } else if (local_time.hours ==
            (21 + daylight_mod[(int)local_time.month])) {
            zone->weather->sunlight = SUN_SET;
            send_to_zone("The red giant sun slowly sets in the west.\r\n",
                zone, 1);

        } else if (local_time.hours ==
            (22 + daylight_mod[(int)local_time.month])) {
            zone->weather->sunlight = SUN_DARK;
            send_to_zone("The night has begun.\r\n", zone, 1);
        }

        /* lunar stuff here */

        if (lunar_phase == MOON_NEW)
            return;

        LUNAR_RISE_TIME = lunar_day + 5;
        if (LUNAR_RISE_TIME > 23)
            LUNAR_RISE_TIME -= 24;

        if (local_time.hours == LUNAR_RISE_TIME) {
            zone->weather->moonlight = MOON_SKY_RISE;
            if (zone->weather->sky || !lunar_day)
                return;
            snprintf(buf, sizeof(buf), "The %s moon rises in the east.\r\n",
                lunar_phases[lunar_phase]);
            send_to_zone(buf, zone, 1);
        }
        if (local_time.hours == LUNAR_RISE_TIME + 1 ||
            local_time.hours == LUNAR_RISE_TIME - 23) {
            zone->weather->moonlight = MOON_SKY_EAST;
        }
        if (local_time.hours == LUNAR_RISE_TIME + 7 ||
            local_time.hours == LUNAR_RISE_TIME - 17) {
            zone->weather->moonlight = MOON_SKY_HIGH;

            if (zone->weather->sky || !lunar_day)
                return;
            snprintf(buf, sizeof(buf), "The %s moon is directly overhead.\r\n",
                lunar_phases[lunar_phase]);
            send_to_zone(buf, zone, 1);

        }
        if (local_time.hours == LUNAR_RISE_TIME + 8 ||
            local_time.hours == LUNAR_RISE_TIME - 16) {
            zone->weather->moonlight = MOON_SKY_WEST;
        }
        if (local_time.hours == LUNAR_RISE_TIME + 13 ||
            local_time.hours == LUNAR_RISE_TIME - 11) {
            zone->weather->moonlight = MOON_SKY_SET;
            snprintf(buf, sizeof(buf), "The %s moon begins to sink low in the west.\r\n",
                lunar_phases[lunar_phase]);
            send_to_zone(buf, zone, 1);

        }
        if (local_time.hours == LUNAR_RISE_TIME + 14 ||
            local_time.hours == LUNAR_RISE_TIME - 10) {
            zone->weather->moonlight = MOON_SKY_NONE;
            if (zone->weather->sky || !lunar_day)
                return;
            snprintf(buf, sizeof(buf), "The %s moon sets in the west.\r\n",
                lunar_phases[lunar_phase]);
            send_to_zone(buf, zone, 1);
        }
    }
}