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