ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/schmorp-neko.ext
Revision: 1.8
Committed: Sun May 4 08:55:52 2008 UTC (16 years ago) by root
Branch: MAIN
CVS Tags: rel-2_82, rel-2_81, rel-2_80, rel-2_6, rel-2_7, rel-2_72, rel-2_73, rel-2_71, rel-2_76, rel-2_77, rel-2_74, rel-2_75, rel-2_54, rel-2_55, rel-2_56, rel-2_79, rel-2_53, rel-2_90, rel-2_92, rel-2_93, rel-2_78, rel-2_61
Changes since 1.7: +1 -15 lines
Log Message:
remove teleport hack and use goto

File Contents

# User Rev Content
1 root 1.5 #! perl # depends=irc
2 root 1.1
3     # archetype nekosan
4    
5     sub find_target_player {
6     my ($obj) = @_;
7    
8     my ($time, $pl) = (time + 120, undef);
9    
10     for (map $_->ob, cf::player::list) {
11     next unless $obj->on_same_map_as ($_);
12    
13     my $ptime = List::Util::max $_->{neko_next_pester}, $_->{neko_next_cast};
14    
15     ($time, $pl) = ($ptime, $_)
16     if $time > $ptime;
17     }
18    
19     $pl
20     }
21    
22     sub on_monster_move {
23     my ($self, $enemy) = @_;
24    
25     if (my $pl = find_target_player $self) {
26     my ($d, undef, undef, $dir, undef) = $self->rangevector ($pl);
27    
28     if ($d < 1.5) {
29     if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) {
30     # she likes us!
31     if ($pl->{neko_next_pester} < time) {
32     $pl->{neko_next_pester} = time + 120 + rand 300;
33     $pl->message ("Purr. (Purr)");
34     }
35    
36     if ($pl->{neko_next_cast} < time) {
37     $pl->{neko_next_cast} = time + 40 + rand 60;
38    
39     # so heal her
40     my $spell = cf::object::new "spell_heal";
41    
42     $spell->stats->sp (0); # makes casting work
43     $spell->stats->grace (0); # on unholy/nomagic ground
44    
45     $spell->stats->hp (0);
46     $spell->stats->dam (($pl->stats->maxhp - $pl->stats->hp) * 0.5); # normal hp heal
47     $spell->stats->food (50); # fill food
48     $spell->last_sp (100); # fill sp
49     $spell->last_grace (100); # fill gr
50     $spell->attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE);
51    
52     $pl->message ("(Neko-san makes strange noises)");
53 root 1.3 $pl->cast_heal ($self, $spell, 0);
54 root 1.1
55     $spell->destroy;
56     }
57    
58     } else {
59     # check for fish in his inv and steal it
60 root 1.6 if (my $fish = (grep $_->arch->archname eq "fishfood", $pl->inv)[0]) {
61 root 1.1 # add force
62     my $gave_fish = cf::object::new "force";
63     $gave_fish->slaying ("schmorp-neko-gave-fish");
64     $gave_fish->speed (0);
65 root 1.7 $pl->insert ($gave_fish);
66 root 1.1
67     # remove fish
68     $fish->destroy;
69    
70     # be nice
71     $pl->message ("Meoww! (Thank you)");
72    
73     } else {
74     # pester user
75     if ($pl->{neko_next_pester} < time) {
76     $pl->{neko_next_pester} = time + 60 + rand 300;
77     $pl->message ("Meow. (Please bring me fish)");
78     }
79     }
80     }
81    
82     # circular movement
83     $dir = $dir % 8 + 1 unless $d > 1.5;
84     }
85    
86     $self->move ($dir);
87     }
88    
89     cf::override;
90     }
91    
92     sub on_attack {
93     my ($self, $hitter) = @_;
94    
95     if ($hitter->type == cf::PLAYER) {
96     if ($hitter->{neko_last_attack} < time - 300) {
97     $hitter->{neko_attack} = 0;
98     }
99    
100     $hitter->{neko_last_attack} = time;
101     $hitter->{neko_attack}++
102 root 1.4 or ext::irc::do_notice "Neko-san was attacked by ". $hitter->name . "!\n";
103 root 1.1
104     $hitter->message ("Meoow! (Please do not hurt me)")
105     if !($hitter->{neko_attack} & 15);
106    
107     if ($hitter->{neko_attack} > 512) {
108     $hitter->{neko_attack} -= 128;
109     $hitter->message ("Neko-san is suddenly gone!");
110 root 1.8 $hitter->goto ("/scorn/misc/scorn_illusions", 15, 7);
111 root 1.1 $hitter->message ("You hear strange noises all around you...");
112     $hitter->message ("You feel dumb.");
113     }
114     } else {
115     # $hitter->stats->hp (-1);
116     # $hitter->kill_object;
117     }
118    
119     cf::override;
120     }
121    
122     sub on_say {
123     my ($self, $pl, $msg) = @_;
124    
125 root 1.4 ext::irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $pl->ob->name, $msg);
126 root 1.1 }
127    
128 root 1.2 cf::object::attachment "Nekosan", package => __PACKAGE__;
129 root 1.1