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

Comparing cf.schmorp.de/maps/perl/schmorp-neko.ext (file contents):
Revision 1.22 by root, Sun Aug 27 15:23:30 2006 UTC vs.
Revision 1.33 by root, Tue Dec 12 16:59:34 2006 UTC

5sub teleport { 5sub teleport {
6 my ($pl, $map, $x, $y) = @_; 6 my ($pl, $map, $x, $y) = @_;
7 7
8 my $portal = cf::object::new "exit"; 8 my $portal = cf::object::new "exit";
9 9
10 $portal->set_slaying ($map); 10 $portal->slaying ($map);
11 $portal->set_hp ($x); 11 $portal->stats->hp ($x);
12 $portal->set_sp ($y); 12 $portal->stats->sp ($y);
13 13
14 $portal->apply ($pl); 14 $portal->apply ($pl);
15 15
16 $portal->free; 16 $portal->destroy;
17} 17}
18 18
19sub find_target_player { 19sub find_target_player {
20 my ($obj) = @_; 20 my ($obj) = @_;
21 21
31 } 31 }
32 32
33 $pl 33 $pl
34} 34}
35 35
36sub on_move { 36sub on_monster_move {
37 my ($self, $enemy) = @_; 37 my ($self, $enemy) = @_;
38 #warn "move<@_>\n";#d#
39 38
40 if (my $pl = find_target_player $self) { 39 if (my $pl = find_target_player $self) {
41 my ($d, undef, undef, $dir, undef) = $self->rangevector ($pl); 40 my ($d, undef, undef, $dir, undef) = $self->rangevector ($pl);
42 41
43 if ($d < 1.5) { 42 if ($d < 1.5) {
52 $pl->{neko_next_cast} = time + 40 + rand 60; 51 $pl->{neko_next_cast} = time + 40 + rand 60;
53 52
54 # so heal her 53 # so heal her
55 my $spell = cf::object::new "spell_heal"; 54 my $spell = cf::object::new "spell_heal";
56 55
57 $spell->set_sp (0); # makes casting work 56 $spell->stats->sp (0); # makes casting work
58 $spell->set_gp (0); # on unholy/nomagic ground 57 $spell->stats->grace (0); # on unholy/nomagic ground
59 58
60 $spell->set_hp (0); 59 $spell->stats->hp (0);
61 $spell->set_dam (($pl->maxhp - $pl->hp) * 0.5); # normal hp heal 60 $spell->stats->dam (($pl->stats->maxhp - $pl->stats->hp) * 0.5); # normal hp heal
62 $spell->set_food (50); # fill food 61 $spell->stats->food (50); # fill food
63 $spell->set_last_sp (100); # fill sp 62 $spell->last_sp (100); # fill sp
64 $spell->set_last_grace (100); # fill gr 63 $spell->last_grace (100); # fill gr
65 $spell->set_attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE); 64 $spell->attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE);
66 65
67 $pl->message ("(Neko-san makes strange noises)"); 66 $pl->message ("(Neko-san makes strange noises)");
68 $pl->cast_spell ($self, $dir, $spell); 67 $pl->cast_spell ($self, $dir, $spell);
69 68
70 $spell->free; 69 $spell->destroy;
71 } 70 }
72 71
73 } else { 72 } else {
74 # check for fish in his inv and steal it 73 # check for fish in his inv and steal it
75 if (my $fish = (grep $_->archetype->name eq "fishfood", $pl->inv)[0]) { 74 if (my $fish = (grep $_->arch->name eq "fishfood", $pl->inv)[0]) {
76 # add force 75 # add force
77 my $gave_fish = cf::object::new "force"; 76 my $gave_fish = cf::object::new "force";
78 $gave_fish->set_slaying ("schmorp-neko-gave-fish"); 77 $gave_fish->slaying ("schmorp-neko-gave-fish");
79 $gave_fish->set_speed (0); 78 $gave_fish->speed (0);
80 $gave_fish->insert_ob_in_ob ($pl); 79 $gave_fish->insert_ob_in_ob ($pl);
81 80
82 # remove fish 81 # remove fish
83 $fish->remove; 82 $fish->destroy;
84 $fish->free;
85 83
86 # be nice 84 # be nice
87 $pl->message ("Meoww! (Thank you)"); 85 $pl->message ("Meoww! (Thank you)");
88 86
89 } else { 87 } else {
104 102
105 cf::override; 103 cf::override;
106} 104}
107 105
108sub on_attack { 106sub on_attack {
109 my ($self) = @_; 107 my ($self, $hitter) = @_;
110 #warn "attack<@_>\n";#d#
111 108
109 if ($hitter->type == cf::PLAYER) {
112 if ($self->{neko_last_attack} < time - 300) { 110 if ($hitter->{neko_last_attack} < time - 300) {
113 $self->{neko_attack} = 0; 111 $hitter->{neko_attack} = 0;
114 } 112 }
115 113
116 $self->{neko_last_attack} = time; 114 $hitter->{neko_last_attack} = time;
117 $self->{neko_attack}++ 115 $hitter->{neko_attack}++
118 or ext::schmorp_irc::do_notice "Neko-san was attacked by ". $self->name . "!\n"; 116 or ext::schmorp_irc::do_notice "Neko-san was attacked by ". $hitter->name . "!\n";
119 117
120 $self->message ("Meoow! (Please do not hurt me)") 118 $hitter->message ("Meoow! (Please do not hurt me)")
121 if !($self->{neko_attack} & 15); 119 if !($hitter->{neko_attack} & 15);
122 120
123 if ($self->{neko_attack} > 512) { 121 if ($hitter->{neko_attack} > 512) {
124 $self->{neko_attack} -= 128; 122 $hitter->{neko_attack} -= 128;
125 $self->message ("Neko-san is suddenly gone!"); 123 $hitter->message ("Neko-san is suddenly gone!");
126 teleport $self, "/scorn/misc/scorn_illusions", 15, 7; 124 teleport $hitter, "/scorn/misc/scorn_illusions", 15, 7;
127 $self->message ("You hear strange noises all around you..."); 125 $hitter->message ("You hear strange noises all around you...");
128 $self->message ("You feel dumb."); 126 $hitter->message ("You feel dumb.");
127 }
128 } else {
129# $hitter->stats->hp (-1);
130# $hitter->kill_object;
129 } 131 }
130 132
131 cf::override; 133 cf::override;
132} 134}
133 135
134sub on_listen { 136sub on_say {
135 my ($event, $ob, $who, $msg) = @_; 137 my ($self, $pl, $msg) = @_;
136 138
137 cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $who->name, $msg;
138 ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $who->name, $msg); 139 ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $pl->ob->name, $msg);
139} 140}
140 141
141cf::register_attachment "Nekosan", package => __PACKAGE__; 142cf::register_attachment "Nekosan", package => __PACKAGE__;
142 143

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines