--- cf.schmorp.de/maps/perl/nimbus.ext 2006/03/21 00:51:03 1.6 +++ cf.schmorp.de/maps/perl/nimbus.ext 2006/03/28 16:08:19 1.8 @@ -56,9 +56,8 @@ # called when the player will likely die (modulo explore mode) # but before any stats/exp is changed sub on_player_death { - my ($event) = @_; + my ($ob) = @_; - my $ob = $event->{who}; my $pl = $ob->contr; # save player stats and experience to restore it later @@ -89,6 +88,24 @@ 0 } +sub teleport { + my ($pl, $map, $x, $y) = @_; + + return if $pl->ob->map->path eq $map + && abs ($pl->ob->x - $x) <= 1 + && abs ($pl->ob->y - $y) <= 1; + + my $portal = cf::object::new "exit"; + + $portal->set_slaying ($map); + $portal->set_hp ($x); + $portal->set_sp ($y); + + $portal->apply ($pl->ob); + + $portal->free; +} + sub on_trigger { my ($event) = @_; my $options = $event->{options}; @@ -96,13 +113,10 @@ my $pl = $ob->contr; my @savebed; - warn "trigger $options $ob->{nimbus_save}\n";#d# - warn $ob->name; - if (my $save = delete $ob->{in_nimbus}) { @savebed = @{$save->{savebed}}; - if ($options eq "restore" || 1) { + if ($options eq "restore") { $ob->message ("The gods acknowledge your success.\n"); stats_set $ob->stats, $save->{stats}; stats_set $pl->orig_stats, $save->{orig_stats}; @@ -120,10 +134,15 @@ my $map = $ob->map; - $ob->teleport (cf::map::get_map $savebed[0], $savebed[1], $savebed[2]); + teleport $pl, @savebed; + # should make this a temporary map and let cf deal with it + unlink $map->path; + unlink $map->path . ".cfperl"; $map->delete_map; + $pl->play_sound_player_only (cf::SOUND_PLAYER_DIES); + $ob->message ("You feel as if you woke up from a dream.\n"); $ob->message ("You have a headache.\n"); $ob->message ("Maybe you should have a drink.\n");