… | |
… | |
3 | # handle the nimbus map and other stuff |
3 | # handle the nimbus map and other stuff |
4 | |
4 | |
5 | my @STATS = qw( |
5 | my @STATS = qw( |
6 | Str Dex Con Wis Cha Int Pow |
6 | Str Dex Con Wis Cha Int Pow |
7 | wc ac hp maxhp sp maxsp grace maxgrace |
7 | wc ac hp maxhp sp maxsp grace maxgrace |
8 | food dam luck |
8 | exp food dam luck |
9 | ); |
9 | ); |
10 | |
10 | |
11 | sub stats_get($) { |
11 | sub stats_get($) { |
12 | my ($stats, $save) = @_; |
12 | my ($stats, $save) = @_; |
13 | |
13 | |
… | |
… | |
32 | |
32 | |
33 | sub skills_get($) { |
33 | sub skills_get($) { |
34 | my ($ob) = @_; |
34 | my ($ob) = @_; |
35 | |
35 | |
36 | +{ |
36 | +{ |
37 | "" => $ob->stats->exp, |
|
|
38 | |
|
|
39 | map +($_->skill => $_->stats->exp), |
37 | map +($_->skill => $_->stats->exp), |
40 | grep $_->type == cf::SKILL, |
38 | grep $_->type == cf::SKILL, |
41 | $ob->inv |
39 | $ob->inv |
42 | } |
40 | } |
43 | } |
41 | } |
44 | |
42 | |
45 | sub skills_set($$) { |
43 | sub skills_set($$) { |
46 | my ($ob, $skill) = @_; |
44 | my ($ob, $skills) = @_; |
47 | |
45 | |
48 | my $cur = skills_get $ob; |
46 | for my $skill (grep $_->type == cf::SKILL, $ob->inv) { |
|
|
47 | my $name = $skill->skill; |
49 | |
48 | |
50 | while (my ($name, $exp) = each %$skill) { |
49 | if ($skill->stats->exp < $skills->{$name}) { |
51 | if ($cur->{$name} < $exp) { |
50 | $skill->stats->exp ($skills->{$name}); |
52 | length $name |
51 | $ob->player_lvl_adj ($skill); |
53 | ? $ob->change_skill ($exp - $cur->{$name}, $name) |
|
|
54 | : $ob->change_skill ($exp - $cur->{$name}); |
|
|
55 | } |
52 | } |
56 | } |
53 | } |
57 | } |
54 | } |
58 | |
55 | |
59 | # called when the player will likely die (modulo explore mode) |
56 | # called when the player will likely die (modulo explore mode) |
… | |
… | |
82 | $nimbus->set_path ($path); |
79 | $nimbus->set_path ($path); |
83 | $nimbus->set_unique (1); |
80 | $nimbus->set_unique (1); |
84 | |
81 | |
85 | $pl->set_savebed ($path, 24, 12); |
82 | $pl->set_savebed ($path, 24, 12); |
86 | |
83 | |
87 | $pl->message ("\n"); |
84 | $ob->message ("\n"); |
88 | $pl->message ("You start to feel dizzy.\n"); |
85 | $ob->message ("You start to feel dizzy.\n"); |
89 | $pl->message ("The world around you blurs.\n"); |
86 | $ob->message ("The world around you blurs.\n"); |
90 | $pl->message ("\n"); |
87 | $ob->message ("\n"); |
91 | |
88 | |
92 | 0 |
89 | 0 |
93 | } |
90 | } |
94 | |
91 | |
95 | sub on_trigger { |
92 | sub on_trigger { |
… | |
… | |
104 | |
101 | |
105 | if (my $save = delete $ob->{in_nimbus}) { |
102 | if (my $save = delete $ob->{in_nimbus}) { |
106 | @savebed = @{$save->{savebed}}; |
103 | @savebed = @{$save->{savebed}}; |
107 | |
104 | |
108 | if ($options eq "restore" || 1) { |
105 | if ($options eq "restore" || 1) { |
|
|
106 | $ob->message ("The gods acknowledge your success.\n"); |
109 | stats_set $ob->stats, $save->{stats}; |
107 | stats_set $ob->stats, $save->{stats}; |
110 | stats_set $pl->orig_stats, $save->{orig_stats}; |
108 | stats_set $pl->orig_stats, $save->{orig_stats}; |
|
|
109 | $ob->player_lvl_adj; # update overall level |
111 | skills_set $ob, $save->{skill_exp}; |
110 | skills_set $ob, $save->{skill_exp}; |
|
|
111 | } else { |
|
|
112 | $ob->message ("The gods are disappointed with you.\n"); |
112 | } |
113 | } |
113 | |
114 | |
114 | } else { |
115 | } else { |
115 | @savebed = ("/scorn/taverns/inn", 10, 5); |
116 | @savebed = ("/scorn/taverns/inn", 10, 5); |
116 | } |
117 | } |
… | |
… | |
121 | |
122 | |
122 | $ob->teleport (cf::map::get_map $savebed[0], $savebed[1], $savebed[2]); |
123 | $ob->teleport (cf::map::get_map $savebed[0], $savebed[1], $savebed[2]); |
123 | |
124 | |
124 | $map->delete_map; |
125 | $map->delete_map; |
125 | |
126 | |
126 | $pl->message ("You feel as if you woke up from a dream.\n"); |
127 | $ob->message ("You feel as if you woke up from a dream.\n"); |
127 | $pl->message ("You have a headache.\n"); |
128 | $ob->message ("You have a headache.\n"); |
128 | $pl->message ("Maybe you should have a drink.\n"); |
129 | $ob->message ("Maybe you should have a drink.\n"); |
129 | |
130 | |
130 | 1 |
131 | 1 |
131 | } |
132 | } |
132 | |
133 | |