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.11 by root, Sat Apr 8 14:53:12 2006 UTC

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 { 58sub on_player_death {
59 my ($event) = @_; 59 my ($ob) = @_;
60 60
61 my $ob = $event->{who};
62 my $pl = $ob->contr; 61 my $pl = $ob->contr;
63 62
64 # save player stats and experience to restore it later 63 # save player stats and experience to restore it later
65 64
65 unless ($ob->{in_nimbus}) {
66 my $save = { 66 my $save = {
67 stats => stats_get $ob->stats, 67 stats => stats_get $ob->stats,
68 orig_stats => stats_get $pl->orig_stats, 68 orig_stats => stats_get $pl->orig_stats,
69 savebed => [$pl->get_savebed], 69 savebed => [$pl->get_savebed],
70 skill_exp => skills_get $ob, 70 skill_exp => skills_get $ob,
71 }; 71 };
72 72
73 $ob->{in_nimbus} ||= $save; 73 $ob->{in_nimbus} = $save;
74
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);
83 90 }
84 $ob->message ("\n");
85 $ob->message ("You start to feel dizzy.\n");
86 $ob->message ("The world around you blurs.\n");
87 $ob->message ("\n");
88 91
89 0 92 0
90} 93}
91 94
95sub teleport {
96 my ($pl, $map, $x, $y) = @_;
97
98 return if $pl->ob->map->path eq $map
99 && abs ($pl->ob->x - $x) <= 1
100 && abs ($pl->ob->y - $y) <= 1;
101
102 my $portal = cf::object::new "exit";
103
104 $portal->set_slaying ($map);
105 $portal->set_hp ($x);
106 $portal->set_sp ($y);
107
108 $portal->apply ($pl->ob);
109
110 $portal->free;
111}
112
92sub on_trigger { 113sub on_trigger {
93 my ($event) = @_; 114 my ($event, $porter, $ob) = @_;
115
94 my $options = $event->{options}; 116 my $options = $event->options;
95 my $ob = $event->{activator};
96 my $pl = $ob->contr; 117 my $pl = $ob->contr;
97 my @savebed; 118 my @savebed;
98
99 warn "trigger $options $ob->{nimbus_save}\n";#d#
100 warn $ob->name;
101 119
102 if (my $save = delete $ob->{in_nimbus}) { 120 if (my $save = delete $ob->{in_nimbus}) {
103 @savebed = @{$save->{savebed}}; 121 @savebed = @{$save->{savebed}};
104 122
105 if ($options eq "restore" || 1) { 123 if ($options eq "restore") {
106 $ob->message ("The gods acknowledge your success.\n"); 124 $ob->message ("The gods acknowledge your success.\n");
107 stats_set $ob->stats, $save->{stats}; 125 stats_set $ob->stats, $save->{stats};
108 stats_set $pl->orig_stats, $save->{orig_stats}; 126 stats_set $pl->orig_stats, $save->{orig_stats};
109 $ob->player_lvl_adj; # update overall level 127 $ob->player_lvl_adj; # update overall level
110 skills_set $ob, $save->{skill_exp}; 128 skills_set $ob, $save->{skill_exp};
118 136
119 $pl->set_savebed (@savebed); 137 $pl->set_savebed (@savebed);
120 138
121 my $map = $ob->map; 139 my $map = $ob->map;
122 140
123 $ob->teleport (cf::map::get_map $savebed[0], $savebed[1], $savebed[2]); 141 teleport $pl, @savebed;
124 142
143 # should make this a temporary map and let cf deal with it
144 unlink $map->path;
145 unlink $map->path . ".cfperl";
125 $map->delete_map; 146 $map->delete_map;
147
148 $pl->play_sound_player_only (cf::SOUND_PLAYER_DIES);
126 149
127 $ob->message ("You feel as if you woke up from a dream.\n"); 150 $ob->message ("You feel as if you woke up from a dream.\n");
128 $ob->message ("You have a headache.\n"); 151 $ob->message ("You have a headache.\n");
129 $ob->message ("Maybe you should have a drink.\n"); 152 $ob->message ("Maybe you should have a drink.\n");
130 153

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines