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.14 by root, Mon Aug 28 07:06:12 2006 UTC vs.
Revision 1.19 by root, Tue Dec 12 16:59:34 2006 UTC

9); 9);
10 10
11sub stats_get($) { 11sub stats_get($) {
12 my ($stats, $save) = @_; 12 my ($stats, $save) = @_;
13 13
14 for my $stat (@STATS) {
15 $save->{$stat} = $stats->$stat; 14 $save->{$_} = $stats->$_
16 } 15 for @STATS;
17 16
18 $save 17 $save
19} 18}
20 19
21sub stats_set($$) { 20sub stats_set($$) {
22 my ($stats, $save) = @_; 21 my ($stats, $save) = @_;
23 22
24 for my $stat (@STATS) {
25 $stats->$stat ($save->{$stat}); 23 $stats->$_ ($save->{$_})
26 } 24 for @STATS;
27 25
28 $stats->hp ($stats->maxhp); 26 $stats->hp ($stats->maxhp);
29 $stats->grace ($stats->maxgrace); 27 $stats->grace ($stats->maxgrace);
30 $stats->food (999); 28 $stats->food (999);
31} 29}
64 62
65 unless ($ob->{in_nimbus}) { 63 unless ($ob->{in_nimbus}) {
66 my $save = { 64 my $save = {
67 stats => stats_get $ob->stats, 65 stats => stats_get $ob->stats,
68 orig_stats => stats_get $pl->orig_stats, 66 orig_stats => stats_get $pl->orig_stats,
69 savebed => [$pl->get_savebed], 67 savebed => [$pl->savebed],
70 skill_exp => skills_get $ob, 68 skill_exp => skills_get $ob,
71 }; 69 };
72 70
73 $ob->{in_nimbus} = $save; 71 $ob->{in_nimbus} = $save;
74 72
80 78
81 my $path = sprintf "%s/%s/%s/%s", 79 my $path = sprintf "%s/%s/%s/%s",
82 cf::localdir, cf::playerdir, $ob->name, "nimbus"; 80 cf::localdir, cf::playerdir, $ob->name, "nimbus";
83 81
84 if ($ob->map->path ne $path) { 82 if ($ob->map->path ne $path) {
85 my $nimbus = cf::map::get_map "/schmorp/nimbus"; 83 my $nimbus = cf::map::find "/schmorp/nimbus";
86 $nimbus->set_path ($path); 84 $nimbus->path ($path);
87 $nimbus->set_unique (1); 85 $nimbus->unique (1);
88 86
89 $pl->set_savebed ($path, 24, 12); 87 $pl->savebed ($path, 24, 12);
90 } 88 }
91 }, 89 },
92; 90;
93 91
94sub teleport { 92sub teleport {
98 && abs ($pl->ob->x - $x) <= 1 96 && abs ($pl->ob->x - $x) <= 1
99 && abs ($pl->ob->y - $y) <= 1; 97 && abs ($pl->ob->y - $y) <= 1;
100 98
101 my $portal = cf::object::new "exit"; 99 my $portal = cf::object::new "exit";
102 100
103 $portal->set_slaying ($map); 101 $portal->slaying ($map);
104 $portal->set_hp ($x); 102 $portal->stats->hp ($x);
105 $portal->set_sp ($y); 103 $portal->stats->sp ($y);
106 104
107 $portal->apply ($pl->ob); 105 $portal->apply ($pl->ob);
108 106
109 $portal->free; 107 $portal->destroy;
110} 108}
111 109
112cf::register_attachment nimbus_exit => 110cf::register_attachment nimbus_exit =>
113 on_trigger => sub { 111 on_trigger => sub {
114 my ($self, $ob) = @_; 112 my ($self, $ob) = @_;
131 129
132 } else { 130 } else {
133 @savebed = ("/scorn/taverns/inn", 10, 5); 131 @savebed = ("/scorn/taverns/inn", 10, 5);
134 } 132 }
135 133
136 $pl->set_savebed (@savebed); 134 $pl->savebed (@savebed);
137 135
138 my $map = $ob->map; 136 my $map = $ob->map;
139 137
140 teleport $pl, @savebed; 138 teleport $pl, @savebed;
141 139
142 # should make this a temporary map and let cf deal with it 140 # should make this a temporary map and let cf deal with it
143 unlink $map->path; 141 unlink $map->path;
144 unlink $map->path . ".pst"; 142 unlink $map->path . ".pst";
145 unlink $map->path . ".cfperl";
146 143
147 $map->delete_map; 144 $map->delete_map;
148 145
149 $pl->play_sound_player_only (cf::SOUND_PLAYER_DIES); 146 $pl->play_sound_player_only (cf::SOUND_PLAYER_DIES);
150 147
154 151
155 cf::override; 152 cf::override;
156 }, 153 },
157; 154;
158 155
159cf::attach_to_maps #TODO#d# remove, onyl for upgrading old to new nimbus
160 on_upgrade => sub {
161 my ($map) = @_;
162
163 if ($map->path =~ /\/nimbus$/) {
164 warn "NIMBUS UPGRADE ", $map->path, "\n";
165
166 (grep length $_->slaying, $map->at (11, 1))[0]->attach (nimbus_exit => restore => 1);
167
168 for my $x (37 .. 58) {
169 for my $y (32 .. 53) {
170 $_->remove for $map->at ($x, $y);
171
172 my $portal = cf::object::new "well";
173
174 $portal->set_name ("free ride, courtesy of your friendly upgrade script");
175 $portal->set_slaying ($map->path);
176 $portal->set_hp (1);
177 $portal->set_sp (1);
178
179 $portal->insert_ob_in_map_at ($map, undef, cf::INS_ABOVE_FLOOR_ONLY, $x, $y);
180 }
181 }
182 }
183 },
184;
185

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines