--- deliantra/server/ext/nimbus.ext 2006/12/15 19:29:18 1.1 +++ deliantra/server/ext/nimbus.ext 2007/09/19 21:56:30 1.12 @@ -1,4 +1,4 @@ -#! perl +#! perl # mandatory # handle the nimbus map and other stuff @@ -53,7 +53,7 @@ # called when the player will likely die (modulo explore mode) # but before any stats/exp is changed -cf::attach_to_players +cf::player->attach ( on_death => sub { my ($pl) = @_; my $ob = $pl->ob; @@ -76,38 +76,11 @@ $ob->message ("\n"); } - my $path = sprintf "%s/%s/%s/%s", - cf::localdir, cf::playerdir, $ob->name, "nimbus"; - - if ($ob->map->path ne $path) { - my $nimbus = cf::map::find "/schmorp/nimbus"; - $nimbus->path ($path); - $nimbus->unique (1); - - $pl->savebed ($path, 24, 12); - } + $pl->savebed ("/nimbus", 24, 12); }, -; - -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->slaying ($map); - $portal->stats->hp ($x); - $portal->stats->sp ($y); - - $portal->apply ($pl->ob); - - $portal->destroy; -} +); -cf::register_attachment nimbus_exit => +cf::object::attachment nimbus_exit => on_trigger => sub { my ($self, $ob) = @_; @@ -131,23 +104,21 @@ @savebed = ("/scorn/taverns/inn", 10, 5); } - $pl->savebed (@savebed); - my $map = $ob->map; + $pl->savebed (@savebed); - teleport $pl, @savebed; - - # should make this a temporary map and let cf deal with it - unlink $map->path; - unlink $map->path . ".pst"; - - $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"); + cf::async { + $Coro::current->{desc} = "nimbus exit"; + $ob->goto (@savebed); + + $map->nuke; + + #$pl->play_sound (cf::sound::find "player_dies"); + + $ob->message ("You feel as if you woke up from a dream.\n" + . "You have a headache.\n" + . "Maybe you should have a drink.\n"); + }; cf::override; },