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

Comparing deliantra/server/ext/schmorp-neko.ext (file contents):
Revision 1.1 by root, Fri Dec 15 19:29:18 2006 UTC vs.
Revision 1.10 by root, Mon Oct 1 01:43:39 2012 UTC

1#! perl 1#! perl # depends=irc
2 2
3# archetype nekosan 3# archetype nekosan
4
5sub teleport {
6 my ($pl, $map, $x, $y) = @_;
7
8 my $portal = cf::object::new "exit";
9
10 $portal->slaying ($map);
11 $portal->stats->hp ($x);
12 $portal->stats->sp ($y);
13
14 $portal->apply ($pl);
15
16 $portal->destroy;
17}
18 4
19sub find_target_player { 5sub find_target_player {
20 my ($obj) = @_; 6 my ($obj) = @_;
21 7
22 my ($time, $pl) = (time + 120, undef); 8 my ($time, $pl) = (AE::now + 120, undef);
23 9
24 for (map $_->ob, cf::player::list) { 10 for (map $_->ob, cf::player::list) {
25 next unless $obj->on_same_map_as ($_); 11 next unless $obj->on_same_map_as ($_);
26 12
27 my $ptime = List::Util::max $_->{neko_next_pester}, $_->{neko_next_cast}; 13 my $ptime = List::Util::max $_->{neko_next_pester}, $_->{neko_next_cast};
40 my ($d, undef, undef, $dir, undef) = $self->rangevector ($pl); 26 my ($d, undef, undef, $dir, undef) = $self->rangevector ($pl);
41 27
42 if ($d < 1.5) { 28 if ($d < 1.5) {
43 if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) { 29 if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) {
44 # she likes us! 30 # she likes us!
45 if ($pl->{neko_next_pester} < time) { 31 if ($pl->{neko_next_pester} < AE::now) {
46 $pl->{neko_next_pester} = time + 120 + rand 300; 32 $pl->{neko_next_pester} = AE::now + 120 + cf::rndm 300;
47 $pl->message ("Purr. (Purr)"); 33 $pl->message ("Purr. (Purr)");
48 } 34 }
49 35
50 if ($pl->{neko_next_cast} < time) { 36 if ($pl->{neko_next_cast} < AE::now) {
51 $pl->{neko_next_cast} = time + 40 + rand 60; 37 $pl->{neko_next_cast} = AE::now + 40 + cf::rndm 60;
52 38
53 # so heal her 39 # so heal her
54 my $spell = cf::object::new "spell_heal"; 40 my $spell = cf::object::new "spell_heal";
55 41
56 $spell->stats->sp (0); # makes casting work 42 $spell->stats->sp (0); # makes casting work
62 $spell->last_sp (100); # fill sp 48 $spell->last_sp (100); # fill sp
63 $spell->last_grace (100); # fill gr 49 $spell->last_grace (100); # fill gr
64 $spell->attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE); 50 $spell->attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE);
65 51
66 $pl->message ("(Neko-san makes strange noises)"); 52 $pl->message ("(Neko-san makes strange noises)");
67 $pl->cast_spell ($self, $dir, $spell); 53 $pl->cast_heal ($self, $spell, 0);
68 54
69 $spell->destroy; 55 $spell->destroy;
70 } 56 }
71 57
72 } else { 58 } else {
73 # check for fish in his inv and steal it 59 # check for fish in his inv and steal it
74 if (my $fish = (grep $_->arch->name eq "fishfood", $pl->inv)[0]) { 60 if (my $fish = (grep $_->arch->archname eq "fishfood", $pl->inv)[0]) {
75 # add force 61 # add force
76 my $gave_fish = cf::object::new "force"; 62 my $gave_fish = cf::object::new "force";
77 $gave_fish->slaying ("schmorp-neko-gave-fish"); 63 $gave_fish->slaying ("schmorp-neko-gave-fish");
78 $gave_fish->speed (0); 64 $gave_fish->speed (0);
79 $gave_fish->insert_ob_in_ob ($pl); 65 $pl->insert ($gave_fish);
80 66
81 # remove fish 67 # remove fish
82 $fish->destroy; 68 $fish->destroy;
83 69
84 # be nice 70 # be nice
85 $pl->message ("Meoww! (Thank you)"); 71 $pl->message ("Meoww! (Thank you)");
86 72
87 } else { 73 } else {
88 # pester user 74 # pester user
89 if ($pl->{neko_next_pester} < time) { 75 if ($pl->{neko_next_pester} < AE::now) {
90 $pl->{neko_next_pester} = time + 60 + rand 300; 76 $pl->{neko_next_pester} = AE::now + 60 + cf::rndm 300;
91 $pl->message ("Meow. (Please bring me fish)"); 77 $pl->message ("Meow. (Please bring me fish)");
92 } 78 }
93 } 79 }
94 } 80 }
95 81
105 91
106sub on_attack { 92sub on_attack {
107 my ($self, $hitter) = @_; 93 my ($self, $hitter) = @_;
108 94
109 if ($hitter->type == cf::PLAYER) { 95 if ($hitter->type == cf::PLAYER) {
110 if ($hitter->{neko_last_attack} < time - 300) { 96 if ($hitter->{neko_last_attack} < AE::now - 300) {
111 $hitter->{neko_attack} = 0; 97 $hitter->{neko_attack} = 0;
112 } 98 }
113 99
114 $hitter->{neko_last_attack} = time; 100 $hitter->{neko_last_attack} = AE::now;
115 $hitter->{neko_attack}++ 101 $hitter->{neko_attack}++
116 or ext::schmorp_irc::do_notice "Neko-san was attacked by ". $hitter->name . "!\n"; 102 or ext::irc::do_notice "Neko-san was attacked by " . $hitter->name . "!\n";
117 103
118 $hitter->message ("Meoow! (Please do not hurt me)") 104 $hitter->message ("Meoow! (Please do not hurt me)")
119 if !($hitter->{neko_attack} & 15); 105 if !($hitter->{neko_attack} & 15);
120 106
121 if ($hitter->{neko_attack} > 512) { 107 if ($hitter->{neko_attack} > 512) {
122 $hitter->{neko_attack} -= 128; 108 $hitter->{neko_attack} -= 128;
123 $hitter->message ("Neko-san is suddenly gone!"); 109 $hitter->message ("Neko-san is suddenly gone!");
124 teleport $hitter, "/scorn/misc/scorn_illusions", 15, 7; 110 $hitter->goto ("/scorn/misc/scorn_illusions", 15, 7);
125 $hitter->message ("You hear strange noises all around you..."); 111 $hitter->message ("You hear strange noises all around you...");
126 $hitter->message ("You feel dumb."); 112 $hitter->message ("You feel dumb.");
127 } 113 }
128 } else { 114 } else {
129# $hitter->stats->hp (-1); 115# $hitter->stats->hp (-1);
134} 120}
135 121
136sub on_say { 122sub on_say {
137 my ($self, $pl, $msg) = @_; 123 my ($self, $pl, $msg) = @_;
138 124
139 ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $pl->ob->name, $msg); 125 ext::irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $pl->ob->name, $msg);
140} 126}
141 127
142cf::register_attachment "Nekosan", package => __PACKAGE__; 128sub on_infect {
129 my ($self, $type, $disease) = @_;
143 130
131 my $owner = $disease->owner;
132
133 if ($owner && $owner->type == cf::PLAYER) {
134 ext::irc::do_notice "Neko-san was diseased by " . $owner->name . " with " . $type->name . "!\n";
135 warn "Neko-san was diseased by " . $owner->name . " with " . $type->name . "!\n";
136 $disease->remove;
137 $disease->level ($disease->level + 10);
138 $disease->magic (0);
139 $disease->stats->maxsp (1);
140 $disease->last_heal (1);
141 $disease->set_owner (undef);
142 $owner->insert ($disease);
143 $owner->message ("You have a funny feeling.");
144 } else {
145 $disease->destroy;
146 }
147
148 cf::override;
149}
150
151cf::object::attachment "Nekosan", package => __PACKAGE__;
152

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines