… | |
… | |
86 | cf::NDI_RED |
86 | cf::NDI_RED |
87 | ); |
87 | ); |
88 | # kill them. |
88 | # kill them. |
89 | # reminds me of the famous badness 10000 syndrome... |
89 | # reminds me of the famous badness 10000 syndrome... |
90 | $ob->stats->hp (-10000); #] if they survive this they deserved to live |
90 | $ob->stats->hp (-10000); #] if they survive this they deserved to live |
|
|
91 | $pl->killer ("a cave-in"); |
91 | } else { |
92 | } else { |
92 | $ob->message ( |
93 | $ob->message ( |
93 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
94 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
94 | . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " |
95 | . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " |
95 | . "Better use a savebed next time, much worse things could have happened... " |
96 | . "Better use a savebed next time, much worse things could have happened... " |
… | |
… | |
356 | |
357 | |
357 | $ob->set_animation (2); |
358 | $ob->set_animation (2); |
358 | $ob->add_statbonus; |
359 | $ob->add_statbonus; |
359 | |
360 | |
360 | while () { |
361 | while () { |
361 | $ns->send_msg (-1, "chargen-race-title", ucfirst $pl->title); |
362 | $ns->send_msg ("chargen-race-title", ucfirst $pl->title, -1); |
362 | my $msg = $ob->msg; |
363 | my $msg = $ob->msg; |
363 | $msg =~ s/(?<=\S)\n(?=\S)/ /g; |
364 | $msg =~ s/(?<=\S)\n(?=\S)/ /g; |
364 | $ns->send_msg (cf::NDI_BLUE, "chargen-race-description", $msg); |
365 | $ns->send_msg ("chargen-race-description", $msg, cf::NDI_BLUE); |
365 | |
366 | |
366 | my $res = query $ns, cf::CS_QUERY_SINGLECHAR, |
367 | my $res = query $ns, cf::CS_QUERY_SINGLECHAR, |
367 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"; |
368 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"; |
368 | |
369 | |
369 | last if $res =~ /[dD]/; |
370 | last if $res =~ /[dD]/; |
… | |
… | |
476 | }, |
477 | }, |
477 | ); |
478 | ); |
478 | |
479 | |
479 | ############################################################################# |
480 | ############################################################################# |
480 | |
481 | |
481 | our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs |
482 | our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs |
482 | our $SAVE_TIMEOUT = 20; # save players every n seconds |
483 | our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds |
483 | |
484 | |
484 | our $SCHEDULER = cf::async_ext { |
485 | our $SCHEDULER = cf::async_ext { |
485 | my $schedule_interval = Coro::Event->timer (after => 1, interval => $SCHEDULE_INTERVAL); |
486 | my $schedule_interval = Coro::Event->timer (after => 1); |
486 | while () { |
487 | while () { |
|
|
488 | $schedule_interval->interval ($SCHEDULE_INTERVAL); |
487 | $schedule_interval->next; |
489 | $schedule_interval->next; |
488 | |
490 | |
489 | # this weird form of iteration over values is used because |
491 | # this weird form of iteration over values is used because |
490 | # the hash changes underneath us frequently, and for |
492 | # the hash changes underneath us frequently, and for |
491 | # keeps a direct reference to the value without (in 5.8 perls) |
493 | # keeps a direct reference to the value without (in 5.8 perls) |
… | |
… | |
496 | or next; |
498 | or next; |
497 | $pl->valid or next; |
499 | $pl->valid or next; |
498 | |
500 | |
499 | eval { |
501 | eval { |
500 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
502 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
501 | cf::wait_for_tick_begin; |
|
|
502 | $pl->save; |
503 | $pl->save; |
503 | |
504 | |
504 | unless ($pl->active || $pl->ns) { |
505 | unless ($pl->active || $pl->ns) { |
505 | # check refcounts, this is tricky and needs to be adjusted to fit server internals |
506 | # check refcounts, this is tricky and needs to be adjusted to fit server internals |
506 | my $ob = $pl->ob; |
507 | my $ob = $pl->ob; |