Skip to content

Commit

Permalink
Big update centered on mines.
Browse files Browse the repository at this point in the history
  • Loading branch information
Whales committed Oct 9, 2011
1 parent 6faf55e commit 7010072
Show file tree
Hide file tree
Showing 38 changed files with 1,671 additions and 102 deletions.
21 changes: 12 additions & 9 deletions calendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,15 @@ void calendar::standardize()

int calendar::minutes_past_midnight()
{
return minute + hour * 60;
//debugmsg("minute: %d hour: %d");
int ret = minute + hour * 60;
return ret;
}

moon_phase calendar::moon()
{
int phase = day / (DAYS_IN_SEASON / 4);
phase %= 4;
//phase %= 4; Redundant?
if (phase = 3)
return MOON_HALF;
else
Expand Down Expand Up @@ -290,24 +292,25 @@ bool calendar::is_night()
{
calendar sunrise_time = sunrise(), sunset_time = sunset();

int mins = minutes_past_midnight(),
int mins = minutes_past_midnight(),
sunrise_mins = sunrise_time.minutes_past_midnight(),
sunset_mins = sunset_time.minutes_past_midnight();

return (mins > sunset_mins + TWILIGHT_MINUTES && mins < sunrise_mins);
return (mins > sunset_mins + TWILIGHT_MINUTES || mins < sunrise_mins);
}

int calendar::sunlight()
{
calendar sunrise_time = sunrise(), sunset_time = sunset();

int mins = minutes_past_midnight(),
sunrise_mins = sunrise_time.minutes_past_midnight(),
sunset_mins = sunset_time.minutes_past_midnight();
int mins = 0, sunrise_mins = 0, sunset_mins = 0;
mins = minutes_past_midnight();
sunrise_mins = sunrise_time.minutes_past_midnight();
sunset_mins = sunset_time.minutes_past_midnight();

int moonlight = int(moon()) * MOONLIGHT_LEVEL;
int moonlight = 1 + int(moon()) * MOONLIGHT_LEVEL;

if (mins > sunset_mins + TWILIGHT_MINUTES && mins < sunrise_mins) // Night
if (mins > sunset_mins + TWILIGHT_MINUTES || mins < sunrise_mins) // Night
return moonlight;

else if (mins >= sunrise_mins && mins < sunrise_mins + TWILIGHT_MINUTES) {
Expand Down
6 changes: 3 additions & 3 deletions calendar.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#define SUNRISE_SOLSTICE 6
#define SUNRISE_SUMMER 5

#define SUNSET_WINTER 5
#define SUNSET_SOLSTICE 7
#define SUNSET_SUMMER 9
#define SUNSET_WINTER 17
#define SUNSET_SOLSTICE 19
#define SUNSET_SUMMER 21

// How long, in minutes, does sunrise/sunset last?
#define TWILIGHT_MINUTES 60
Expand Down
169 changes: 162 additions & 7 deletions computer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ void computer::use(game *g)

bool done = false; // Are we done using the computer?
do {
reset_terminal();
//reset_terminal();
print_line("");
print_line("%s - Root Menu", name.c_str());
for (int i = 0; i < options.size(); i++)
print_line("%d - %s", i + 1, options[i].name.c_str());
Expand Down Expand Up @@ -248,8 +249,8 @@ void computer::activate_function(game *g, computer_action action)
for (int x = 0; x < SEEX * 3; x++) {
for (int y = 0; y < SEEY * 3; y++) {
if (g->m.ter(x, y) == t_sewage_pump) {
for (int x1 = x - 1; x1 = x + 1; x1++) {
for (int y1 = y - 1; y1 = y + 1; y1++ ) {
for (int x1 = x - 1; x1 <= x + 1; x1++) {
for (int y1 = y - 1; y1 <= y + 1; y1++ ) {
if (g->m.ter(x1, y1) == t_counter) {
bool found_item = false;
for (int i = 0; i < g->m.i_at(x1, y1).size(); i++) {
Expand Down Expand Up @@ -367,7 +368,7 @@ void computer::activate_function(game *g, computer_action action)
}
} while(tmp.find_first_of('%') != 0 && getline(fin, tmp));
}
print_line(log.c_str());
print_line(" %s", log.c_str());
print_line("Press any key...");
getch();
} break;
Expand Down Expand Up @@ -430,6 +431,127 @@ void computer::activate_function(game *g, computer_action action)
case COMPACT_MISS_DISARM: // TODO: This!
break;

case COMPACT_LIST_BIONICS: {
std::vector<std::string> names;
int more = 0;
for (int x = 0; x < SEEX * 3; x++) {
for (int y = 0; y < SEEY * 3; y++) {
for (int i = 0; i < g->m.i_at(x, y).size(); i++) {
if (g->m.i_at(x, y)[i].is_bionic()) {
if (names.size() < 9)
names.push_back(g->m.i_at(x, y)[i].name);
else
more++;
}
}
}
}
for (int i = 0; i < names.size(); i++)
print_line(names[i].c_str());
if (more > 0)
print_line("%d OTHERS FOUND...");
} break;

case COMPACT_ELEVATOR_ON:
for (int x = 0; x < SEEX * 3; x++) {
for (int y = 0; y < SEEY * 3; y++) {
if (g->m.ter(x, y) == t_elevator_control_off)
g->m.ter(x, y) = t_elevator_control;
}
}
print_line("Elevator activated.");
break;

case COMPACT_AMIGARA_LOG: // TODO: This is static, move to data file?
print_line("NEPower Mine(%d:%d) Log", g->levx, g->levy);
print_line("\
ENTRY 47:\n\
Our normal mining routine has unearthed a hollow chamber. This would not be\n\
out of the ordinary, save for the odd, perfectly vertical faultline found.\n\
This faultline has several odd concavities in it which have the more\n\
superstitious crew members alarmed; they seem to be of human origin.\n\
\n\
ENTRY 48:\n\
The concavities are between 10 and 20 feet tall, and run the length of the\n\
faultline. Each one is vaguely human in shape, but with the proportions of\n\
the limbs, neck and head greatly distended, all twisted and curled in on\n\
themselves.\n");
if (!query_ynq("Continue reading?"))
return;
reset_terminal();
print_line("NEPower Mine(%d:%d) Log", g->levx, g->levy);
print_line("\
ENTRY 49:\n\
We've stopped mining operations in this area, obviously, until archaeologists\n\
have the chance to inspect the area. This is going to set our schedule back\n\
by at least a week. This stupid artifact-preservation law has been in place\n\
for 50 years, and hasn't even been up for termination despite the fact that\n\
these mining operations are the backbone of our economy.\n\
\n\
ENTRY 52:\n\
Still waiting on the archaeologists. We've done a little light insepction of\n\
the faultline; our sounding equipment is insufficient to measure the depth of\n\
the concavities. The equipment is rated at 15 miles depth, but it isn't made\n\
for such narrow tunnels, so it's hard to say exactly how far back they go.\n");
if (!query_ynq("Continue reading?"))
return;
reset_terminal();
print_line("NEPower Mine(%d:%d) Log", g->levx, g->levy);
print_line("\
ENTRY 54:\n\
I noticed a couple of the guys down in the chamber with a chisel, breaking\n\
off a piece of the sheer wall. I'm looking the other way. It's not like\n\
the eggheads are going to notice a little piece missing. Fuck em.\n\
\n\
ENTRY 55:\n\
Well, the archaeologists are down there now with a couple of the boys as\n\
guides. They're hardly Indiana Jones types; I doubt they been below 20\n\
feet. I hate taking guys off assignment just to babysit the scientists, but\n\
if they get hurt we'll be shut down for god knows how long.\n\
\n\
ENTRY 58:\n\
They're bringing in ANOTHER CREW? Christ, it's just some cave carvings! I\n\
know that's sort of a big deal, but come on, these guys can't handle it?\n");
if (!query_ynq("Continue reading?"))
return;
reset_terminal();
for (int i = 0; i < 10; i++)
print_gibberish_line();
print_line("");
print_line("");
print_line("");
print_line("AMIGARA PROJECT");
print_line("");
print_line("");
if (!query_ynq("Continue reading?"))
return;
reset_terminal();
print_line("\
SITE %d%d%d%d%d\n\
PERTINANT FOREMAN LOGS WILL BE PREPENDED TO NOTES",
g->cur_om.posx, g->cur_om.posy, g->levx, g->levy, abs(g->levz));
print_line("\n\
MINE OPERATIONS SUSPENDED; CONTROL TRANSFERRED TO AMIGARA PROJECT UNDER\n\
IMPERATIVE 2:07B\n\
FAULTLINE SOUNDING HAS PLACED DEPTH AT 30.09 KM\n\
DAMAGE TO FAULTLINE DISCOVERED; NEPOWER MINE CREW PLACED UNDER ARREST FOR\n\
VIOLATION OF REGULATION 87.08 AND TRANSFERRED TO LAB 89-C FOR USE AS\n\
SUBJECTS\n\
QUALITIY OF FAULTLINE NOT COMPROMISED\n\
INITIATING STANDARD TREMOR TEST...");
print_gibberish_line();
print_gibberish_line();
print_line("");
print_error("FILE CORRUPTED, PRESS ANY KEY...");
getch();
reset_terminal();
break;

case COMPACT_AMIGARA_START:
g->add_event(EVENT_AMIGARA, int(g->turn) + 10, 0, 0, 0);
g->u.add_disease(DI_AMIGARA, -1, g);
break;

} // switch (action)
}

Expand Down Expand Up @@ -459,7 +581,7 @@ void computer::activate_failure(game *g, computer_failure fail)
case COMPFAIL_ALARM:
g->sound(g->u.posx, g->u.posy, 60, "An alarm sounds!");
if (g->levz > 0 && !g->event_queued(EVENT_WANTED))
g->add_event(EVENT_WANTED, g->turn + 300, 0, g->levx, g->levy);
g->add_event(EVENT_WANTED, int(g->turn) + 300, 0, g->levx, g->levy);
break;

case COMPFAIL_MANHACKS: {
Expand All @@ -481,7 +603,7 @@ void computer::activate_failure(game *g, computer_failure fail)
} break;

case COMPFAIL_SECUBOTS: {
int num_robots = rng(4, 8);
int num_robots = rng(1, 3);
for (int i = 0; i < num_robots; i++) {
int mx, my, tries = 0;
do {
Expand Down Expand Up @@ -544,6 +666,13 @@ void computer::activate_failure(game *g, computer_failure fail)
}
}
break;

case COMPFAIL_AMIGARA:
g->add_event(EVENT_AMIGARA, int(g->turn) + 5, 0, 0, 0);
g->u.add_disease(DI_AMIGARA, -1, g);
g->explosion(rng(0, SEEX * 3), rng(0, SEEY * 3), 10, 10, false);
g->explosion(rng(0, SEEX * 3), rng(0, SEEY * 3), 10, 10, false);
break;
}// switch (fail)
}

Expand Down Expand Up @@ -576,8 +705,15 @@ void computer::print_line(const char *mes, ...)
char buff[6000];
vsprintf(buff, mes, ap);
va_end(ap);
// Replace any '\n' with "\n " to allow for the border
std::string message = buff;
size_t pos = 0;
while ((pos = message.find("\n", pos) != std::string::npos)) {
message.replace(pos, 1, "\n ");
pos += 2;
}
// Print the line.
wprintz(w_terminal, c_green, " %s%s", buff, "\n");
wprintz(w_terminal, c_green, "%s%s", message.c_str(), "\n");
// Reprint the border, in case we pushed a line over it
wborder(w_terminal, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
Expand All @@ -600,6 +736,25 @@ void computer::print_error(const char *mes, ...)
wrefresh(w_terminal);
}

void computer::print_gibberish_line()
{
std::string gibberish;
int length = rng(50, 70);
for (int i = 0; i < length; i++) {
switch (rng(0, 4)) {
case 0: gibberish += '0' + rng(0, 9); break;
case 1:
case 2: gibberish += 'a' + rng(0, 25); break;
case 3:
case 4: gibberish += 'A' + rng(0, 25); break;
}
}
wprintz(w_terminal, c_yellow, gibberish.c_str());
wborder(w_terminal, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
wrefresh(w_terminal);
}

void computer::reset_terminal()
{
werase(w_terminal);
Expand Down
7 changes: 7 additions & 0 deletions computer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ enum computer_action
COMPACT_MAPS,
COMPACT_MISS_LAUNCH,
COMPACT_MISS_DISARM,
COMPACT_LIST_BIONICS,
COMPACT_ELEVATOR_ON,
COMPACT_AMIGARA_LOG,
COMPACT_AMIGARA_START,
NUM_COMPUTER_ACTIONS
};

Expand All @@ -37,6 +41,7 @@ enum computer_failure
COMPFAIL_DAMAGE,
COMPFAIL_PUMP_EXPLODE,
COMPFAIL_PUMP_LEAK,
COMPFAIL_AMIGARA,
NUM_COMPUTER_FAILURES
};

Expand Down Expand Up @@ -93,6 +98,8 @@ class computer
void print_line(const char *text, ...);
// For now, the same as print_line but in red (TODO: change this?)
void print_error(const char *text, ...);
// Prints code-looking gibberish
void print_gibberish_line();
// Prints a line and waits for Y/N/Q
char query_ynq(const char *text, ...);
};
Expand Down
3 changes: 3 additions & 0 deletions disease.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ void dis_msg(game *g, dis_type type)
case DI_BLIND:
g->add_msg("You're blinded!");
break;
case DI_AMIGARA:
g->add_msg("You can't look away from the fautline...");
break;
}
}

Expand Down
Loading

0 comments on commit 7010072

Please sign in to comment.