--- cf.schmorp.de/maps/perl/nimbus.ext 2006/03/18 01:33:16 1.3 +++ cf.schmorp.de/maps/perl/nimbus.ext 2006/03/20 23:28:56 1.5 @@ -5,7 +5,7 @@ my @STATS = qw( Str Dex Con Wis Cha Int Pow wc ac hp maxhp sp maxsp grace maxgrace - exp food dam luck + food dam luck ); sub stats_get($) { @@ -34,6 +34,8 @@ my ($ob) = @_; +{ + "" => $ob->stats->exp, + map +($_->skill => $_->stats->exp), grep $_->type == cf::SKILL, $ob->inv @@ -43,9 +45,14 @@ sub skills_set($$) { my ($ob, $skill) = @_; - for (grep $_->type == cf::SKILL, $ob->inv) { - $_->set_exp ($skill->{$_->skill}) - if exists $skill->{$_->skill}; + my $cur = skills_get $ob; + + while (my ($name, $exp) = each %$skill) { + if ($cur->{$name} < $exp) { + length $name + ? $ob->change_skill ($exp - $cur->{$name}, $name) + : $ob->change_skill ($exp - $cur->{$name}); + } } } @@ -66,7 +73,7 @@ skill_exp => skills_get $ob, }; - $ob->{nimbus_save} = $save; + $ob->{in_nimbus} ||= $save; my $path = sprintf "%s/%s/%s/%s", cf::localdir, cf::playerdir, $ob->name, "nimbus"; @@ -76,6 +83,13 @@ $nimbus->set_unique (1); $pl->set_savebed ($path, 24, 12); + + $pl->message ("\n"); + $pl->message ("You start to feel dizzy.\n"); + $pl->message ("The world around you blurs.\n"); + $pl->message ("\n"); + + 0 } sub on_trigger { @@ -88,7 +102,7 @@ warn "trigger $options $ob->{nimbus_save}\n";#d# warn $ob->name; - if (my $save = delete $ob->{nimbus_save}) { + if (my $save = delete $ob->{in_nimbus}) { @savebed = @{$save->{savebed}}; if ($options eq "restore" || 1) { @@ -103,10 +117,15 @@ $pl->set_savebed (@savebed); - # TODO: you wake up... + my $map = $ob->map; + $ob->teleport (cf::map::get_map $savebed[0], $savebed[1], $savebed[2]); - # TODO: invalidate map + $map->delete_map; + + $pl->message ("You feel as if you woke up from a dream.\n"); + $pl->message ("You have a headache.\n"); + $pl->message ("Maybe you should have a drink.\n"); 1 }