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

Comparing deliantra/maps/perl/schmorp-neko.ext (file contents):
Revision 1.14 by root, Fri Feb 17 23:01:40 2006 UTC vs.
Revision 1.31 by root, Wed Sep 13 00:29:46 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines