1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | # archetype nekosan |
3 | # archetype nekosan |
4 | |
|
|
5 | use Data::Dumper; |
|
|
6 | |
4 | |
7 | sub teleport { |
5 | sub teleport { |
8 | my ($pl, $map, $x, $y) = @_; |
6 | my ($pl, $map, $x, $y) = @_; |
9 | |
7 | |
10 | my $portal = cf::object::new "exit"; |
8 | my $portal = cf::object::new "exit"; |
… | |
… | |
33 | } |
31 | } |
34 | |
32 | |
35 | $pl |
33 | $pl |
36 | } |
34 | } |
37 | |
35 | |
38 | sub on_move { |
36 | sub on_monster_move { |
39 | my ($event, $who) = @_; |
37 | my ($self, $enemy) = @_; |
40 | |
38 | |
41 | if (my $pl = find_target_player $who) { |
39 | if (my $pl = find_target_player $self) { |
42 | my ($d, undef, undef, $dir, undef) = $who->rangevector ($pl); |
40 | my ($d, undef, undef, $dir, undef) = $self->rangevector ($pl); |
43 | |
41 | |
44 | if ($d < 1.5) { |
42 | if ($d < 1.5) { |
45 | if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) { |
43 | if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) { |
46 | # she likes us! |
44 | # she likes us! |
47 | if ($pl->{neko_next_pester} < time) { |
45 | if ($pl->{neko_next_pester} < time) { |
… | |
… | |
64 | $spell->set_last_sp (100); # fill sp |
62 | $spell->set_last_sp (100); # fill sp |
65 | $spell->set_last_grace (100); # fill gr |
63 | $spell->set_last_grace (100); # fill gr |
66 | $spell->set_attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE); |
64 | $spell->set_attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE); |
67 | |
65 | |
68 | $pl->message ("(Neko-san makes strange noises)"); |
66 | $pl->message ("(Neko-san makes strange noises)"); |
69 | $pl->cast_spell ($who, $dir, $spell); |
67 | $pl->cast_spell ($self, $dir, $spell); |
70 | |
68 | |
71 | $spell->free; |
69 | $spell->free; |
72 | } |
70 | } |
73 | |
71 | |
74 | } else { |
72 | } else { |
… | |
… | |
98 | |
96 | |
99 | # circular movement |
97 | # circular movement |
100 | $dir = $dir % 8 + 1 unless $d > 1.5; |
98 | $dir = $dir % 8 + 1 unless $d > 1.5; |
101 | } |
99 | } |
102 | |
100 | |
103 | $who->move ($dir); |
101 | $self->move ($dir); |
104 | } |
102 | } |
105 | |
103 | |
106 | 1 |
104 | cf::override; |
107 | } |
105 | } |
108 | |
106 | |
109 | sub on_attack { |
107 | sub on_attack { |
110 | my ($event, $ob, $who) = @_; |
108 | my ($self, $hitter) = @_; |
111 | |
109 | |
112 | $who->{neko_attack}++ |
110 | if ($hitter->{neko_last_attack} < time - 300) { |
113 | or cf::LOG cf::llevDebug, sprintf "QBERT Neko-san was attacked by %s!\n", $who->name; |
|
|
114 | |
|
|
115 | $who->message ("Meoow! (Please do not hurt me)") |
|
|
116 | if !($who->{neko_attack} & 15); |
|
|
117 | |
|
|
118 | if ($who->{neko_attack} > 512) { |
|
|
119 | $who->{neko_attack} -= 128; |
111 | $hitter->{neko_attack} = 0; |
120 | $who->message ("Neko-san is suddenly gone!"); |
|
|
121 | teleport $who, "/scorn/misc/scorn_illusions", 15, 7; |
|
|
122 | $who->message ("You hear strange noises all around you..."); |
|
|
123 | $who->message ("You feel dumb."); |
|
|
124 | } |
112 | } |
125 | |
113 | |
|
|
114 | $hitter->{neko_last_attack} = time; |
|
|
115 | $hitter->{neko_attack}++ |
|
|
116 | or ext::schmorp_irc::do_notice "Neko-san was attacked by ". $hitter->name . "!\n"; |
|
|
117 | |
|
|
118 | $hitter->message ("Meoow! (Please do not hurt me)") |
|
|
119 | if !($hitter->{neko_attack} & 15); |
|
|
120 | |
|
|
121 | if ($hitter->{neko_attack} > 512) { |
|
|
122 | $hitter->{neko_attack} -= 128; |
|
|
123 | $hitter->message ("Neko-san is suddenly gone!"); |
|
|
124 | teleport $hitter, "/scorn/misc/scorn_illusions", 15, 7; |
|
|
125 | $hitter->message ("You hear strange noises all around you..."); |
|
|
126 | $hitter->message ("You feel dumb."); |
126 | 1 |
127 | } |
|
|
128 | |
|
|
129 | cf::override; |
127 | } |
130 | } |
128 | |
131 | |
129 | sub on_say { |
132 | sub on_listen { |
130 | my ($event, $ob, $who, $msg) = @_; |
133 | my ($event, $ob, $who, $msg) = @_; |
131 | |
134 | |
132 | cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $who->name, $msg; |
135 | cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $who->name, $msg; |
|
|
136 | ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $who->name, $msg); |
133 | } |
137 | } |
134 | |
138 | |
|
|
139 | cf::register_attachment "Nekosan", package => __PACKAGE__; |
|
|
140 | |