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.12 by root, Fri Aug 25 15:07:43 2006 UTC vs.
Revision 1.18 by root, Fri Sep 8 17:33:55 2006 UTC

1#! perl 1#! perl
2#CONVERSION: PARTIAL
3 2
4# handle the nimbus map and other stuff 3# handle the nimbus map and other stuff
5 4
6my @STATS = qw( 5my @STATS = qw(
7 Str Dex Con Wis Cha Int Pow 6 Str Dex Con Wis Cha Int Pow
10); 9);
11 10
12sub stats_get($) { 11sub stats_get($) {
13 my ($stats, $save) = @_; 12 my ($stats, $save) = @_;
14 13
15 for my $stat (@STATS) {
16 $save->{$stat} = $stats->$stat; 14 $save->{$_} = $stats->$_
17 } 15 for @STATS;
18 16
19 $save 17 $save
20} 18}
21 19
22sub stats_set($$) { 20sub stats_set($$) {
23 my ($stats, $save) = @_; 21 my ($stats, $save) = @_;
24 22
25 for my $stat (@STATS) {
26 $stats->$stat ($save->{$stat}); 23 $stats->$_ ($save->{$_})
27 } 24 for @STATS;
28 25
29 $stats->hp ($stats->maxhp); 26 $stats->hp ($stats->maxhp);
30 $stats->grace ($stats->maxgrace); 27 $stats->grace ($stats->maxgrace);
31 $stats->food (999); 28 $stats->food (999);
32} 29}
65 62
66 unless ($ob->{in_nimbus}) { 63 unless ($ob->{in_nimbus}) {
67 my $save = { 64 my $save = {
68 stats => stats_get $ob->stats, 65 stats => stats_get $ob->stats,
69 orig_stats => stats_get $pl->orig_stats, 66 orig_stats => stats_get $pl->orig_stats,
70 savebed => [$pl->get_savebed], 67 savebed => [$pl->savebed],
71 skill_exp => skills_get $ob, 68 skill_exp => skills_get $ob,
72 }; 69 };
73 70
74 $ob->{in_nimbus} = $save; 71 $ob->{in_nimbus} = $save;
75 72
81 78
82 my $path = sprintf "%s/%s/%s/%s", 79 my $path = sprintf "%s/%s/%s/%s",
83 cf::localdir, cf::playerdir, $ob->name, "nimbus"; 80 cf::localdir, cf::playerdir, $ob->name, "nimbus";
84 81
85 if ($ob->map->path ne $path) { 82 if ($ob->map->path ne $path) {
86 my $nimbus = cf::map::get_map "/schmorp/nimbus"; 83 my $nimbus = cf::map::find "/schmorp/nimbus";
87 $nimbus->set_path ($path); 84 $nimbus->path ($path);
88 $nimbus->set_unique (1); 85 $nimbus->unique (1);
89 86
90 $pl->set_savebed ($path, 24, 12); 87 $pl->savebed ($path, 24, 12);
91 } 88 }
92 }, 89 },
93; 90;
94 91
95sub teleport { 92sub teleport {
99 && abs ($pl->ob->x - $x) <= 1 96 && abs ($pl->ob->x - $x) <= 1
100 && abs ($pl->ob->y - $y) <= 1; 97 && abs ($pl->ob->y - $y) <= 1;
101 98
102 my $portal = cf::object::new "exit"; 99 my $portal = cf::object::new "exit";
103 100
104 $portal->set_slaying ($map); 101 $portal->slaying ($map);
105 $portal->set_hp ($x); 102 $portal->stats->hp ($x);
106 $portal->set_sp ($y); 103 $portal->stats->sp ($y);
107 104
108 $portal->apply ($pl->ob); 105 $portal->apply ($pl->ob);
109 106
110 $portal->free; 107 $portal->free;
111} 108}
112 109
113sub on_trigger { 110cf::register_attachment nimbus_exit =>
114 my ($event, $porter, $ob) = @_; 111 on_trigger => sub {
112 my ($self, $ob) = @_;
115 113
116 my $options = $event->options;
117 my $pl = $ob->contr; 114 my $pl = $ob->contr;
118 my @savebed; 115 my @savebed;
119 116
120 if (my $save = delete $ob->{in_nimbus}) { 117 if (my $save = delete $ob->{in_nimbus}) {
121 @savebed = @{$save->{savebed}}; 118 @savebed = @{$save->{savebed}};
122 119
123 if ($options eq "restore") { 120 if ($self->{nimbus_exit}{restore}) {
124 $ob->message ("The gods acknowledge your success.\n"); 121 $ob->message ("The gods acknowledge your success.\n");
125 stats_set $ob->stats, $save->{stats}; 122 stats_set $ob->stats, $save->{stats};
126 stats_set $pl->orig_stats, $save->{orig_stats}; 123 stats_set $pl->orig_stats, $save->{orig_stats};
127 $ob->player_lvl_adj; # update overall level 124 $ob->player_lvl_adj; # update overall level
128 skills_set $ob, $save->{skill_exp}; 125 skills_set $ob, $save->{skill_exp};
126 } else {
127 $ob->message ("The gods are disappointed with you.\n");
128 }
129
129 } else { 130 } else {
130 $ob->message ("The gods are disappointed with you.\n"); 131 @savebed = ("/scorn/taverns/inn", 10, 5);
131 } 132 }
132 133
133 } else { 134 $pl->savebed (@savebed);
134 @savebed = ("/scorn/taverns/inn", 10, 5);
135 }
136 135
137 $pl->set_savebed (@savebed); 136 my $map = $ob->map;
138 137
139 my $map = $ob->map; 138 teleport $pl, @savebed;
140 139
141 teleport $pl, @savebed; 140 # should make this a temporary map and let cf deal with it
141 unlink $map->path;
142 unlink $map->path . ".pst";
142 143
143 # should make this a temporary map and let cf deal with it
144 unlink $map->path;
145 unlink $map->path . ".cfperl";
146 $map->delete_map; 144 $map->delete_map;
147 145
148 $pl->play_sound_player_only (cf::SOUND_PLAYER_DIES); 146 $pl->play_sound_player_only (cf::SOUND_PLAYER_DIES);
149 147
150 $ob->message ("You feel as if you woke up from a dream.\n"); 148 $ob->message ("You feel as if you woke up from a dream.\n");
151 $ob->message ("You have a headache.\n"); 149 $ob->message ("You have a headache.\n");
152 $ob->message ("Maybe you should have a drink.\n"); 150 $ob->message ("Maybe you should have a drink.\n");
153 151
154 1 152 cf::override;
155} 153 },
154;
156 155

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines