--- cf.schmorp.de/maps/perl/nimbus.ext 2006/03/31 22:47:20 1.10 +++ cf.schmorp.de/maps/perl/nimbus.ext 2006/08/25 15:07:43 1.12 @@ -1,4 +1,5 @@ #! perl +#CONVERSION: PARTIAL # handle the nimbus map and other stuff @@ -55,40 +56,41 @@ # called when the player will likely die (modulo explore mode) # but before any stats/exp is changed -sub on_player_death { - my ($ob) = @_; - - my $pl = $ob->contr; - - # save player stats and experience to restore it later - - my $save = { - stats => stats_get $ob->stats, - orig_stats => stats_get $pl->orig_stats, - savebed => [$pl->get_savebed], - skill_exp => skills_get $ob, - }; - - unless ($ob->{in_nimbus}) { - $ob->{in_nimbus} = $save; +cf::attach_to_players + on_death => sub { + my ($pl) = @_; + my $ob = $pl->ob; + + # save player stats and experience to restore it later + + unless ($ob->{in_nimbus}) { + my $save = { + stats => stats_get $ob->stats, + orig_stats => stats_get $pl->orig_stats, + savebed => [$pl->get_savebed], + skill_exp => skills_get $ob, + }; + + $ob->{in_nimbus} = $save; + + $ob->message ("\n"); + $ob->message ("You start to feel dizzy.\n"); + $ob->message ("The world around you blurs.\n"); + $ob->message ("\n"); + } my $path = sprintf "%s/%s/%s/%s", cf::localdir, cf::playerdir, $ob->name, "nimbus"; - my $nimbus = cf::map::get_map "/schmorp/nimbus"; - $nimbus->set_path ($path); - $nimbus->set_unique (1); - - $pl->set_savebed ($path, 24, 12); - - $ob->message ("\n"); - $ob->message ("You start to feel dizzy.\n"); - $ob->message ("The world around you blurs.\n"); - $ob->message ("\n"); - } - - 0 -} + if ($ob->map->path ne $path) { + my $nimbus = cf::map::get_map "/schmorp/nimbus"; + $nimbus->set_path ($path); + $nimbus->set_unique (1); + + $pl->set_savebed ($path, 24, 12); + } + }, +; sub teleport { my ($pl, $map, $x, $y) = @_;