Repository navigation
Expand file tree
/
Copy pathcheckLooter.pl
More file actions
111 lines (101 loc) · 3.43 KB
/
Copy pathcheckLooter.pl
File metadata and controls
111 lines (101 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#
# checkLooter
# Author: Henrybk
#
# What this plugin does:
# This plugin extends the check_attackLooter hook and decides whether a monster
# should be considered a looter by reading its AI mode from monsters_table.txt.
# It is useful when attack logic or other automation wants to react differently
# to monsters that can pick up items.
#
# How it works:
# - When OpenKore runs the check_attackLooter hook, this plugin looks up the
# target monster through MonstersTable helper functions.
# - It reads the monster AI value from monsters_table.txt through
# monster_is_looter_by_ai.
# - It checks whether the looter flag is enabled for that AI mode.
# - If the monster is not a looter, the plugin sets $args->{return} = 1.
#
# How to configure it:
# This plugin does not require custom config.txt entries.
# Just enable the plugin and make sure your monsters_table.txt includes the Ai
# column generated by the converter.
#
# Examples:
# 1. Use this plugin together with attack systems that call check_attackLooter
# so non-looter monsters can be filtered out automatically.
#
# 2. Keep this plugin enabled while using eCast if you want the old split
# behavior where extended checks and looter checks are handled separately.
#
# Notes:
# - This plugin depends on monsters_table.txt having AI data for each monster.
# - If a monster is missing from MonstersTable, the plugin logs a warning and
# leaves the hook result unchanged.
#
package checkLooter;
use strict;
use Plugins;
use Globals;
use Log qw(debug warning);
use MonstersTable qw(monster_exists monster_is_looter_by_ai);
use constant {
PLUGIN_NAME => 'checkLooter',
};
Plugins::register(PLUGIN_NAME, 'Checks looter monsters using monsters_table.txt', \&onUnload);
my $hooks = Plugins::addHooks(
['check_attackLooter', \&oncheck_attackLooter, undef],
);
=pod
/// Monster mode definitions to clear up code reading. [Skotlex]
enum e_mode {
MD_NONE = 0x0000000,
MD_CANMOVE = 0x0000001,
MD_LOOTER = 0x0000002,
MD_AGGRESSIVE = 0x0000004,
MD_ASSIST = 0x0000008,
MD_CASTSENSORIDLE = 0x0000010,
MD_NORANDOMWALK = 0x0000020,
MD_NOCAST = 0x0000040,
MD_CANATTACK = 0x0000080,
//FREE = 0x0000100,
MD_CASTSENSORCHASE = 0x0000200,
MD_CHANGECHASE = 0x0000400,
MD_ANGRY = 0x0000800,
MD_CHANGETARGETMELEE = 0x0001000,
MD_CHANGETARGETCHASE = 0x0002000,
MD_TARGETWEAK = 0x0004000,
MD_RANDOMTARGET = 0x0008000,
MD_IGNOREMELEE = 0x0010000,
MD_IGNOREMAGIC = 0x0020000,
MD_IGNORERANGED = 0x0040000,
MD_MVP = 0x0080000,
MD_IGNOREMISC = 0x0100000,
MD_KNOCKBACKIMMUNE = 0x0200000,
MD_TELEPORTBLOCK = 0x0400000,
//FREE = 0x0800000,
MD_FIXEDITEMDROP = 0x1000000,
MD_DETECTOR = 0x2000000,
MD_STATUSIMMUNE = 0x4000000,
MD_SKILLIMMUNE = 0x8000000,
};
=cut
sub onUnload {
Plugins::delHooks($hooks);
}
sub oncheck_attackLooter {
my ($hook, $args) = @_;
return 0 if (!$args->{monster} || $args->{monster}->{nameID} eq '');
if (!monster_exists($args->{monster}->{nameID})) {
warning "[checkLooter] Monster {name '$args->{monster}->{name}'} {ID '$args->{monster}->{nameID}'} not found\n", 'checkLooter';
return;
}
my $is_looter = monster_is_looter_by_ai($args->{monster}->{nameID});
if (!$is_looter) {
debug "[checkLooter] [False] $args->{monster} ($args->{monster}->{nameID}) is not a Looter\n", 'checkLooter';
$args->{return} = 1;
} else {
debug "[checkLooter] [True] $args->{monster} ($args->{monster}->{nameID}) is a Looter\n", 'checkLooter';
}
}
1;