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

Comparing cf.schmorp.de/maps/perl/nimbus.ext (file contents):
Revision 1.3 by root, Sat Mar 18 01:33:16 2006 UTC vs.
Revision 1.5 by root, Mon Mar 20 23:28:56 2006 UTC

3# handle the nimbus map and other stuff 3# handle the nimbus map and other stuff
4 4
5my @STATS = qw( 5my @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 exp food dam luck 8 food dam luck
9); 9);
10 10
11sub stats_get($) { 11sub stats_get($) {
12 my ($stats, $save) = @_; 12 my ($stats, $save) = @_;
13 13
32 32
33sub skills_get($) { 33sub skills_get($) {
34 my ($ob) = @_; 34 my ($ob) = @_;
35 35
36 +{ 36 +{
37 "" => $ob->stats->exp,
38
37 map +($_->skill => $_->stats->exp), 39 map +($_->skill => $_->stats->exp),
38 grep $_->type == cf::SKILL, 40 grep $_->type == cf::SKILL,
39 $ob->inv 41 $ob->inv
40 } 42 }
41} 43}
42 44
43sub skills_set($$) { 45sub skills_set($$) {
44 my ($ob, $skill) = @_; 46 my ($ob, $skill) = @_;
45 47
46 for (grep $_->type == cf::SKILL, $ob->inv) { 48 my $cur = skills_get $ob;
47 $_->set_exp ($skill->{$_->skill}) 49
48 if exists $skill->{$_->skill}; 50 while (my ($name, $exp) = each %$skill) {
51 if ($cur->{$name} < $exp) {
52 length $name
53 ? $ob->change_skill ($exp - $cur->{$name}, $name)
54 : $ob->change_skill ($exp - $cur->{$name});
55 }
49 } 56 }
50} 57}
51 58
52# called when the player will likely die (modulo explore mode) 59# called when the player will likely die (modulo explore mode)
53# but before any stats/exp is changed 60# but before any stats/exp is changed
64 orig_stats => stats_get $pl->orig_stats, 71 orig_stats => stats_get $pl->orig_stats,
65 savebed => [$pl->get_savebed], 72 savebed => [$pl->get_savebed],
66 skill_exp => skills_get $ob, 73 skill_exp => skills_get $ob,
67 }; 74 };
68 75
69 $ob->{nimbus_save} = $save; 76 $ob->{in_nimbus} ||= $save;
70 77
71 my $path = sprintf "%s/%s/%s/%s", 78 my $path = sprintf "%s/%s/%s/%s",
72 cf::localdir, cf::playerdir, $ob->name, "nimbus"; 79 cf::localdir, cf::playerdir, $ob->name, "nimbus";
73 80
74 my $nimbus = cf::map::get_map "/schmorp/nimbus"; 81 my $nimbus = cf::map::get_map "/schmorp/nimbus";
75 $nimbus->set_path ($path); 82 $nimbus->set_path ($path);
76 $nimbus->set_unique (1); 83 $nimbus->set_unique (1);
77 84
78 $pl->set_savebed ($path, 24, 12); 85 $pl->set_savebed ($path, 24, 12);
86
87 $pl->message ("\n");
88 $pl->message ("You start to feel dizzy.\n");
89 $pl->message ("The world around you blurs.\n");
90 $pl->message ("\n");
91
92 0
79} 93}
80 94
81sub on_trigger { 95sub on_trigger {
82 my ($event) = @_; 96 my ($event) = @_;
83 my $options = $event->{options}; 97 my $options = $event->{options};
86 my @savebed; 100 my @savebed;
87 101
88 warn "trigger $options $ob->{nimbus_save}\n";#d# 102 warn "trigger $options $ob->{nimbus_save}\n";#d#
89 warn $ob->name; 103 warn $ob->name;
90 104
91 if (my $save = delete $ob->{nimbus_save}) { 105 if (my $save = delete $ob->{in_nimbus}) {
92 @savebed = @{$save->{savebed}}; 106 @savebed = @{$save->{savebed}};
93 107
94 if ($options eq "restore" || 1) { 108 if ($options eq "restore" || 1) {
95 stats_set $ob->stats, $save->{stats}; 109 stats_set $ob->stats, $save->{stats};
96 stats_set $pl->orig_stats, $save->{orig_stats}; 110 stats_set $pl->orig_stats, $save->{orig_stats};
101 @savebed = ("/scorn/taverns/inn", 10, 5); 115 @savebed = ("/scorn/taverns/inn", 10, 5);
102 } 116 }
103 117
104 $pl->set_savebed (@savebed); 118 $pl->set_savebed (@savebed);
105 119
106 # TODO: you wake up... 120 my $map = $ob->map;
121
107 $ob->teleport (cf::map::get_map $savebed[0], $savebed[1], $savebed[2]); 122 $ob->teleport (cf::map::get_map $savebed[0], $savebed[1], $savebed[2]);
108 123
109 # TODO: invalidate map 124 $map->delete_map;
125
126 $pl->message ("You feel as if you woke up from a dream.\n");
127 $pl->message ("You have a headache.\n");
128 $pl->message ("Maybe you should have a drink.\n");
110 129
111 1 130 1
112} 131}
113 132

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines