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