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.1 by root, Wed Feb 8 04:32:42 2006 UTC vs.
Revision 1.21 by root, Fri Aug 25 15:24:54 2006 UTC

1#! perl 1#! perl
2#CONVERSION: NONE
2 3
3# /var/crossfire/unique-items/world@world_105_115.v00 4# archetype nekosan
4
5# arch neko
6# face neko.115
7# friendly 1
8# unaggressive 1
9# level 200
10# hp 10000
11# exp 1
12# wc -120
13# ac -120
14# wis 100
15# str 100
16# dex 100
17# con 100
18# int 100
19# pow 100
20# cha 100
21# hitback 0
22# reflect_missile 1
23# reflect_spells 1
24# resist_death 100
25# resist_physical 100
26# resist_magic 100
27# resist_fire 100
28# resist_electricity 100
29# resist_cold 100
30# resist_confusion 100
31# resist_acid 100
32# resist_drain 100
33# resist_weaponmagic 100
34# resist_ghosthit 100
35# resist_poison 100
36# resist_slow 100
37# resist_paralyze 100
38# resist_fear 100
39# resist_deplete 100
40# resist_turn_undead 100
41# resist_death 100
42# resist_chaos 100
43# resist_blind 100
44# resist_holyword 100
45# resist_godpower 100
46# x 4
47# y 37
48# speed_left -0.699994
49# direction 5
50# unique 1
51# sleep 0
52# arch event_say
53# title perl
54# slaying schmorp-neko
55# end
56# arch event_attack
57# title perl
58# slaying schmorp-neko
59# end
60# arch event_move
61# title perl
62# slaying schmorp-neko
63# end
64# end
65 5
66use Data::Dumper; 6use Data::Dumper;
67 7
68sub teleport { 8sub teleport {
69 my ($pl, $map, $x, $y) = @_; 9 my ($pl, $map, $x, $y) = @_;
70 10
71 my $portal = cf::object::new ("exit"); 11 my $portal = cf::object::new "exit";
72 12
73 $portal->set_slaying ($map); 13 $portal->set_slaying ($map);
74 $portal->set_hp ($x); 14 $portal->set_hp ($x);
75 $portal->set_sp ($y); 15 $portal->set_sp ($y);
76 16
77 $portal->apply ($pl); 17 $portal->apply ($pl);
78 18
79 $portal->free; 19 $portal->free;
80} 20}
81 21
22sub find_target_player {
23 my ($obj) = @_;
24
25 my ($time, $pl) = (time + 120, undef);
26
27 for (map $_->ob, cf::player::list) {
28 next unless $obj->on_same_map_as ($_);
29
30 my $ptime = List::Util::max $_->{neko_next_pester}, $_->{neko_next_cast};
31
32 ($time, $pl) = ($ptime, $_)
33 if $time > $ptime;
34 }
35
36 $pl
37}
38
82sub on_move { 39sub on_move {
83 my ($data) = @_; 40 my ($event, $who) = @_;
84 41
85 if (my $pl = $data->{who}->nearest_player) { 42 if (my $pl = find_target_player $who) {
86 my (undef, undef, undef, $dir, undef) = $data->{who}->direction ($pl); 43 my ($d, undef, undef, $dir, undef) = $who->rangevector ($pl);
87 $data->{who}->move ($data->{who}, $dir); 44
45 if ($d < 1.5) {
46 if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) {
47 # she likes us!
48 if ($pl->{neko_next_pester} < time) {
49 $pl->{neko_next_pester} = time + 120 + rand 300;
50 $pl->message ("Purr. (Purr)");
51 }
52
53 if ($pl->{neko_next_cast} < time) {
54 $pl->{neko_next_cast} = time + 40 + rand 60;
55
56 # so heal her
57 my $spell = cf::object::new "spell_heal";
58
59 $spell->set_sp (0); # makes casting work
60 $spell->set_gp (0); # on unholy/nomagic ground
61
62 $spell->set_hp (0);
63 $spell->set_dam (($pl->maxhp - $pl->hp) * 0.5); # normal hp heal
64 $spell->set_food (50); # fill food
65 $spell->set_last_sp (100); # fill sp
66 $spell->set_last_grace (100); # fill gr
67 $spell->set_attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE);
68
69 $pl->message ("(Neko-san makes strange noises)");
70 $pl->cast_spell ($who, $dir, $spell);
71
72 $spell->free;
73 }
74
75 } else {
76 # check for fish in his inv and steal it
77 if (my $fish = (grep $_->archetype->name eq "fishfood", $pl->inv)[0]) {
78 # add force
79 my $gave_fish = cf::object::new "force";
80 $gave_fish->set_slaying ("schmorp-neko-gave-fish");
81 $gave_fish->set_speed (0);
82 $gave_fish->insert_ob_in_ob ($pl);
83
84 # remove fish
85 $fish->remove;
86 $fish->free;
87
88 # be nice
89 $pl->message ("Meoww! (Thank you)");
90
91 } else {
92 # pester user
93 if ($pl->{neko_next_pester} < time) {
94 $pl->{neko_next_pester} = time + 60 + rand 300;
95 $pl->message ("Meow. (Please bring me fish)");
96 }
97 }
98 }
99
100 # circular movement
101 $dir = $dir % 8 + 1 unless $d > 1.5;
102 }
103
104 $who->move ($dir);
88 } 105 }
89 106
90 1 107 1
91} 108}
92 109
93sub on_attack { 110sub on_attack {
94 my ($data) = @_; 111 my ($event, $ob, $who) = @_;
95 112
96 cf::LOG cf::llevDebug, sprintf "QBERT Neko-san was attacked by %s!", $data->{activator}->name; 113 if ($who->{neko_last_attack} < time - 300) {
114 $who->{neko_attack} = 0;
115 }
97 116
98 $data->{activator}->message ("Neko-san is suddenly gone!"); 117 $who->{neko_last_attack} = time;
99 teleport $data->{activator}, "/scorn/misc/scorn_illusions", 15, 7; 118 $who->{neko_attack}++
100 $data->{activator}->message ("You hear strange noises all around you..."); 119 or ext::schmorp_irc::do_notice "Neko-san was attacked by ". $who->name . "!\n";
101 $data->{activator}->message ("You feel dumb.");
102 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.");
103 0 130 }
131
132 1
104} 133}
105 134
106sub on_say { 135sub on_say {
107 my ($data) = @_; 136 my ($event, $ob, $who, $msg) = @_;
108 137
109 cf::LOG cf::llevDebug, "QBERT [Neko-fon] $data->{message}"; 138 cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $who->name, $msg;
110 139 ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $who->name, $msg);
111 0
112} 140}
113 141

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines