… | |
… | |
49 | |
49 | |
50 | =back |
50 | =back |
51 | |
51 | |
52 | =cut |
52 | =cut |
53 | |
53 | |
54 | cf::register_attachment check_inventory_on_apply => |
54 | cf::object::attachment check_inventory_on_apply => |
55 | on_apply => sub { |
55 | on_apply => sub { |
56 | my ($self, $pl) = @_; |
56 | my ($self, $pl) = @_; |
57 | my $cfg = $self->{check_inventory_on_apply}; |
57 | my $cfg = $self->{check_inventory_on_apply}; |
58 | my $match; |
58 | my $match; |
59 | rec_inv_by_slaying ($pl, $cfg->{key_string}, sub { |
59 | rec_inv_by_slaying ($pl, $cfg->{key_string}, sub { |
60 | my ($ob) = @_; |
60 | my ($ob) = @_; |
61 | $match = $ob; |
61 | $match = $ob; |
62 | }); |
62 | }); |
63 | if ($match) { |
63 | if ($match) { |
64 | $match->decrease_ob_nr ($cfg->{decrease_by_cnt}) if $cfg->{decrease_by_cnt}; |
64 | $match->decrease_ob_nr ($cfg->{decrease_by_cnt}) if $cfg->{decrease_by_cnt}; |
65 | $pl->message ($cfg->{message_on_match}) if defined $cfg->{message_on_match}; |
65 | $pl->message ($cfg->{message_on_match}, cf::NDI_UNIQUE) if defined $cfg->{message_on_match}; |
66 | } else { |
66 | } else { |
67 | $pl->message ($cfg->{message_on_nomatch}) if defined $cfg->{message_on_nomatch}; |
67 | $pl->message ($cfg->{message_on_nomatch}, cf::NDI_RED | cf::NDI_UNIQUE) if defined $cfg->{message_on_nomatch}; |
|
|
68 | cf::override; |
|
|
69 | } |
|
|
70 | }; |
|
|
71 | |
|
|
72 | |
|
|
73 | =item object attachment: 'trigger_on_dialog_flag' |
|
|
74 | |
|
|
75 | This attachment checks whether the player has a specific |
|
|
76 | dialog flag set (the ones you can set with @setflag, see also |
|
|
77 | L<NPC_Dialogue>, and triggers a connection depending on that. |
|
|
78 | |
|
|
79 | The attachment has following configuration: |
|
|
80 | |
|
|
81 | =over 4 |
|
|
82 | |
|
|
83 | =item flag |
|
|
84 | |
|
|
85 | This field should contain the name of the flag that you want to check |
|
|
86 | for. |
|
|
87 | |
|
|
88 | =item connection |
|
|
89 | |
|
|
90 | The connection ID of the connection you want to trigger. |
|
|
91 | |
|
|
92 | =item state |
|
|
93 | |
|
|
94 | The state of the connection: 0 for release, 1 for push. |
|
|
95 | |
|
|
96 | =back |
|
|
97 | |
|
|
98 | =cut |
|
|
99 | |
|
|
100 | cf::object::attachment trigger_on_dialog_flag => |
|
|
101 | on_move_trigger => sub { |
|
|
102 | my ($self, $who, $orig) = @_; |
|
|
103 | my $cfg = $self->{trigger_on_dialog_flag}; |
|
|
104 | if (exists $who->{ob}{dialog_flag}{$cfg->{flag}}) { |
|
|
105 | if ($who->{ob}{dialog_flag}{$cfg->{flag}}) { |
|
|
106 | $self->map->trigger ($cfg->{connection}, $cfg->{state}); |
|
|
107 | } |
68 | cf::override; |
108 | cf::override; |
69 | } |
109 | } |
70 | }; |
110 | }; |
71 | |
111 | |
72 | =back |
112 | =back |