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.6 by root, Tue Mar 21 00:51:03 2006 UTC vs.
Revision 1.14 by root, Mon Aug 28 07:06:12 2006 UTC

53 } 53 }
54} 54}
55 55
56# called when the player will likely die (modulo explore mode) 56# called when the player will likely die (modulo explore mode)
57# but before any stats/exp is changed 57# but before any stats/exp is changed
58sub on_player_death { 58cf::attach_to_players
59 on_death => sub {
59 my ($event) = @_; 60 my ($pl) = @_;
61 my $ob = $pl->ob;
60 62
61 my $ob = $event->{who}; 63 # save player stats and experience to restore it later
62 my $pl = $ob->contr;
63 64
64 # save player stats and experience to restore it later 65 unless ($ob->{in_nimbus}) {
66 my $save = {
67 stats => stats_get $ob->stats,
68 orig_stats => stats_get $pl->orig_stats,
69 savebed => [$pl->get_savebed],
70 skill_exp => skills_get $ob,
71 };
65 72
66 my $save = { 73 $ob->{in_nimbus} = $save;
67 stats => stats_get $ob->stats,
68 orig_stats => stats_get $pl->orig_stats,
69 savebed => [$pl->get_savebed],
70 skill_exp => skills_get $ob,
71 };
72 74
73 $ob->{in_nimbus} ||= $save; 75 $ob->message ("\n");
76 $ob->message ("You start to feel dizzy.\n");
77 $ob->message ("The world around you blurs.\n");
78 $ob->message ("\n");
79 }
74 80
75 my $path = sprintf "%s/%s/%s/%s", 81 my $path = sprintf "%s/%s/%s/%s",
76 cf::localdir, cf::playerdir, $ob->name, "nimbus"; 82 cf::localdir, cf::playerdir, $ob->name, "nimbus";
77 83
84 if ($ob->map->path ne $path) {
78 my $nimbus = cf::map::get_map "/schmorp/nimbus"; 85 my $nimbus = cf::map::get_map "/schmorp/nimbus";
79 $nimbus->set_path ($path); 86 $nimbus->set_path ($path);
80 $nimbus->set_unique (1); 87 $nimbus->set_unique (1);
81 88
82 $pl->set_savebed ($path, 24, 12); 89 $pl->set_savebed ($path, 24, 12);
90 }
91 },
92;
83 93
84 $ob->message ("\n"); 94sub teleport {
85 $ob->message ("You start to feel dizzy.\n"); 95 my ($pl, $map, $x, $y) = @_;
86 $ob->message ("The world around you blurs.\n");
87 $ob->message ("\n");
88 96
89 0 97 return if $pl->ob->map->path eq $map
98 && abs ($pl->ob->x - $x) <= 1
99 && abs ($pl->ob->y - $y) <= 1;
100
101 my $portal = cf::object::new "exit";
102
103 $portal->set_slaying ($map);
104 $portal->set_hp ($x);
105 $portal->set_sp ($y);
106
107 $portal->apply ($pl->ob);
108
109 $portal->free;
90} 110}
91 111
92sub on_trigger { 112cf::register_attachment nimbus_exit =>
93 my ($event) = @_; 113 on_trigger => sub {
94 my $options = $event->{options}; 114 my ($self, $ob) = @_;
95 my $ob = $event->{activator};
96 my $pl = $ob->contr;
97 my @savebed;
98 115
99 warn "trigger $options $ob->{nimbus_save}\n";#d# 116 my $pl = $ob->contr;
100 warn $ob->name; 117 my @savebed;
101 118
102 if (my $save = delete $ob->{in_nimbus}) { 119 if (my $save = delete $ob->{in_nimbus}) {
103 @savebed = @{$save->{savebed}}; 120 @savebed = @{$save->{savebed}};
104 121
105 if ($options eq "restore" || 1) { 122 if ($self->{nimbus_exit}{restore}) {
106 $ob->message ("The gods acknowledge your success.\n"); 123 $ob->message ("The gods acknowledge your success.\n");
107 stats_set $ob->stats, $save->{stats}; 124 stats_set $ob->stats, $save->{stats};
108 stats_set $pl->orig_stats, $save->{orig_stats}; 125 stats_set $pl->orig_stats, $save->{orig_stats};
109 $ob->player_lvl_adj; # update overall level 126 $ob->player_lvl_adj; # update overall level
110 skills_set $ob, $save->{skill_exp}; 127 skills_set $ob, $save->{skill_exp};
128 } else {
129 $ob->message ("The gods are disappointed with you.\n");
130 }
131
111 } else { 132 } else {
112 $ob->message ("The gods are disappointed with you.\n"); 133 @savebed = ("/scorn/taverns/inn", 10, 5);
113 } 134 }
114 135
115 } else { 136 $pl->set_savebed (@savebed);
116 @savebed = ("/scorn/taverns/inn", 10, 5);
117 }
118 137
119 $pl->set_savebed (@savebed); 138 my $map = $ob->map;
120 139
121 my $map = $ob->map; 140 teleport $pl, @savebed;
122 141
123 $ob->teleport (cf::map::get_map $savebed[0], $savebed[1], $savebed[2]); 142 # should make this a temporary map and let cf deal with it
143 unlink $map->path;
144 unlink $map->path . ".pst";
145 unlink $map->path . ".cfperl";
124 146
125 $map->delete_map; 147 $map->delete_map;
126 148
127 $ob->message ("You feel as if you woke up from a dream.\n"); 149 $pl->play_sound_player_only (cf::SOUND_PLAYER_DIES);
128 $ob->message ("You have a headache.\n");
129 $ob->message ("Maybe you should have a drink.\n");
130 150
131 1 151 $ob->message ("You feel as if you woke up from a dream.\n");
132} 152 $ob->message ("You have a headache.\n");
153 $ob->message ("Maybe you should have a drink.\n");
133 154
155 cf::override;
156 },
157;
158
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