ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/nimbus.ext
(Generate patch)

Comparing deliantra/maps/perl/nimbus.ext (file contents):
Revision 1.1 by root, Fri Mar 17 02:40:09 2006 UTC vs.
Revision 1.2 by root, Fri Mar 17 03:13:49 2006 UTC

16 } 16 }
17 17
18 $save 18 $save
19} 19}
20 20
21sub stats_fix($) {
22 my ($stats) = @_;
23
24 $stats->hp = $stats->maxhp;
25 $stats->grace = $stats->maxgrace;
26 $stats->food = 999;
27}
28
29sub stats_set($$) { 21sub stats_set($$) {
30 my ($stats, $save) = @_; 22 my ($stats, $save) = @_;
31 23
32 for my $stat (@STATS) { 24 for my $stat (@STATS) {
33 $stats->$stat ($save->{$stat}); 25 $stats->$stat ($save->{$stat});
34 } 26 }
27
28 $stats->hp ($stats->maxhp);
29 $stats->grace ($stats->maxgrace);
30 $stats->food (999);
35} 31}
36 32
37sub skills_get($) { 33sub skills_get($) {
38 my ($ob) = @_; 34 my ($ob) = @_;
39 35
36 +{
40 [map [$_->skill, $_->exp], 37 map +($_->skill => $_->exp),
41 grep $_->type == cf::SKILL, 38 grep $_->type == cf::SKILL,
42 $ob->inv] 39 $ob->inv
40 }
43} 41}
44 42
45sub skills_set($) { 43sub skills_set($$) {
46 die; 44 my ($ob, $skill) = @_;
45
46 for (grep $_->type == cf::SKILL, $ob->inv) {
47 $_->set_exp ($skill->{$_->skill})
48 if exists $skill->{$_->skill};
49 }
47} 50}
48 51
49# called when the player will likely die (modulo explore mode) 52# called when the player will likely die (modulo explore mode)
50# but before any stats/exp is changed 53# but before any stats/exp is changed
51sub on_player_death { 54sub on_player_death {
86 warn $ob->name; 89 warn $ob->name;
87 90
88 if (my $save = delete $ob->{nimbus_save}) { 91 if (my $save = delete $ob->{nimbus_save}) {
89 @savebed = @{$save->{savebed}}; 92 @savebed = @{$save->{savebed}};
90 93
91 use Data::Dumper; 94 if ($options eq "restore" || 1) {
92 print STDERR Dumper $save; 95 stats_set $ob->stats, $save->{stats};
96 stats_set $pl->orig_stats, $save->{orig_stats};
97 skills_set $ob, $save->{skill_exp};
98 }
99
93 } else { 100 } else {
94 @savebed = ("/scorn/taverns/inn", 10, 5); 101 @savebed = ("/scorn/taverns/inn", 10, 5);
95 } 102 }
96 103
97 $pl->set_savebed (@savebed); 104 $pl->set_savebed (@savebed);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines