1 | //(=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=) |
---|
2 | //( (c)2006 eAthena Development Team presents ) |
---|
3 | //( ______ __ __ ) |
---|
4 | //( /\ _ \/\ \__/\ \ v 1.00.00 ) |
---|
5 | //( __\ \ \_\ \ \ ,_\ \ \___ __ ___ __ ) |
---|
6 | //( /'__`\ \ __ \ \ \/\ \ _ `\ /'__`\/' _ `\ /'__`\ ) |
---|
7 | //( /\ __/\ \ \/\ \ \ \_\ \ \ \ \/\ __//\ \/\ \/\ \_\.\_ ) |
---|
8 | //( \ \____\\ \_\ \_\ \__\\ \_\ \_\ \____\ \_\ \_\ \__/.\_\ ) |
---|
9 | //( \/____/ \/_/\/_/\/__/ \/_/\/_/\/____/\/_/\/_/\/__/\/_/ ) |
---|
10 | //( _ _ _ _ _ _ _ _ _ _ _ _ _ ) |
---|
11 | //( / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ) |
---|
12 | //( ( e | A | t | h | e | n | a ) ( S | c | r | i | p | t ) ) |
---|
13 | //( \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ ) |
---|
14 | //( ) |
---|
15 | //(=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=) |
---|
16 | // Programmed by [Lance] ver. 1.1 |
---|
17 | // --------------------------------------------------------- |
---|
18 | // [ Sentry System ] |
---|
19 | // - Guards main towns against aggresive monsters and bad |
---|
20 | // players. |
---|
21 | // [ Customization ] |
---|
22 | // - See OnInit: |
---|
23 | // ========================================================= |
---|
24 | |
---|
25 | - script sentry_system -1,{ |
---|
26 | function spawn_guardian { |
---|
27 | set .mob_id[getarg(0)], mobspawn("Guardian Sentry",1904,.mob_map$[getarg(0)],.mob_x[getarg(0)],.mob_y[getarg(0)]); |
---|
28 | mobattach .mob_id[getarg(0)]; // Attach events to this script. |
---|
29 | setmobdata .mob_id[getarg(0)], 24, 1; // Enable killer mode. |
---|
30 | setmobdata .mob_id[getarg(0)], 25, |
---|
31 | AI_ACTION_TYPE_DETECT| |
---|
32 | AI_ACTION_TYPE_KILL| |
---|
33 | AI_ACTION_TYPE_UNLOCK| |
---|
34 | AI_ACTION_TYPE_DEAD| |
---|
35 | AI_ACTION_TYPE_ATTACK; // Define engine callback routines. |
---|
36 | setmobdata .mob_id[getarg(0)], 26, 1; // Prevents random walking. |
---|
37 | setmobdata .mob_id[getarg(0)], 10, 1; // Enable AI mode 1. |
---|
38 | getmobdata .mob_id[getarg(0)], .@temp; |
---|
39 | set .@temp[9], .@temp[9]^(0x400&.@temp[9]); // Check and remove MD_CHANGECHASE mode flag. |
---|
40 | setmobdata .mob_id[getarg(0)], 9, .@temp[9]; |
---|
41 | return; |
---|
42 | } |
---|
43 | |
---|
44 | function search_entry { |
---|
45 | set .@tmp, getarraysize(getarg(0)); |
---|
46 | for(set .@i, 0; .@i < .@tmp; set .@i, .@i + 1){ |
---|
47 | if(getelementofarray(getarg(0),.@i) == getarg(1)) |
---|
48 | break; |
---|
49 | } |
---|
50 | if(.@i == .@tmp) |
---|
51 | return -1; |
---|
52 | else |
---|
53 | return .@i; |
---|
54 | } |
---|
55 | |
---|
56 | // Script Entry Point - When an event from the script engine is received. |
---|
57 | if(getarraysize(.ai_action) == 4){ // Checks if the data is formatted correctly. |
---|
58 | set .@tmp, search_entry(.mob_id, .ai_action[AI_ACTION_SRC]); |
---|
59 | switch(.ai_action[AI_ACTION_TYPE]){ |
---|
60 | case AI_ACTION_TYPE_DETECT: // We see something... |
---|
61 | if(.ai_busy[.@tmp] == 0){ // Not busy |
---|
62 | switch(.ai_action[AI_ACTION_TAR_TYPE]){ // Check what have we here. |
---|
63 | case AI_ACTION_TAR_TYPE_PC: // It's a player |
---|
64 | if(Karma > .karma){ // pkarma is higher? |
---|
65 | unittalk .ai_action[AI_ACTION_SRC], "Who goes there!"; |
---|
66 | unitemote .ai_action[AI_ACTION_SRC], e_gasp; // ! |
---|
67 | unitattack .ai_action[AI_ACTION_SRC],.ai_action[AI_ACTION_TAR]; |
---|
68 | // We're currently busy. |
---|
69 | set .ai_busy[.@tmp], .ai_action[AI_ACTION_TAR]; |
---|
70 | } |
---|
71 | break; |
---|
72 | case AI_ACTION_TAR_TYPE_MOB: // It's a monster |
---|
73 | if(.ai_action[AI_ACTION_TAR] != .ai_action[AI_ACTION_SRC]){ |
---|
74 | getmobdata .ai_action[AI_ACTION_TAR], .@temp; |
---|
75 | if(.@temp[9]&0x804){ // In Aggressive mode? |
---|
76 | unittalk .ai_action[AI_ACTION_SRC], "Protect the villagers we must!"; |
---|
77 | unitemote .ai_action[AI_ACTION_SRC], e_gasp; // ! |
---|
78 | unitattack .ai_action[AI_ACTION_SRC],.ai_action[AI_ACTION_TAR]; |
---|
79 | // We're currently busy. |
---|
80 | set .ai_busy[.@tmp], .ai_action[AI_ACTION_TAR]; |
---|
81 | } |
---|
82 | } |
---|
83 | break; |
---|
84 | } |
---|
85 | } |
---|
86 | break; |
---|
87 | case AI_ACTION_TYPE_KILL: // We eliminated the criminal |
---|
88 | if(.ai_action[AI_ACTION_TAR_TYPE] == AI_ACTION_TAR_TYPE_PC) |
---|
89 | set Karma, 0; |
---|
90 | case AI_ACTION_TYPE_UNLOCK: // Target lost :( |
---|
91 | if(.@tmp != -1){ |
---|
92 | set .ai_busy[.@tmp], 0; // Remove him, we're free. |
---|
93 | } |
---|
94 | // Walk back to where we came from. |
---|
95 | unitwalk .ai_action[AI_ACTION_SRC],.mob_x[.@tmp],.mob_y[.@tmp]; |
---|
96 | break; |
---|
97 | case AI_ACTION_TYPE_DEAD: // We got killed :( |
---|
98 | if(.ai_action[AI_ACTION_TAR_TYPE] == AI_ACTION_TAR_TYPE_PC){ // Attacker is a player? |
---|
99 | if(Karma < 250) |
---|
100 | set Karma, Karma + 5; |
---|
101 | else |
---|
102 | set Karma, 255; |
---|
103 | } |
---|
104 | sleep 10000; // 10 seconds until reinforcements arrive |
---|
105 | spawn_guardian .@tmp; |
---|
106 | break; |
---|
107 | case AI_ACTION_TYPE_ATTACK: // Someone attacked us |
---|
108 | if(.ai_action[AI_ACTION_TAR_TYPE] == AI_ACTION_TAR_TYPE_PC){ // Attacker is a player? |
---|
109 | if(Karma < 250) |
---|
110 | set Karma, Karma + 1; |
---|
111 | else |
---|
112 | set Karma, 255; |
---|
113 | } |
---|
114 | // The system's AI will auto attack any attackers. So we leave it here. |
---|
115 | break; |
---|
116 | } |
---|
117 | } |
---|
118 | deletearray .ai_action, getarraysize(.ai_action); // Cleans up and frees up memory |
---|
119 | end; |
---|
120 | |
---|
121 | OnInit: |
---|
122 | // Customization --------------------------------------------------------------------- |
---|
123 | setarray .mob_map$, "prt_fild08", "prt_fild05", "prt_fild06", "prt_gld"; |
---|
124 | setarray .mob_x,176,369,29,165; |
---|
125 | setarray .mob_y,372,201,187,37; |
---|
126 | set .karma, 5; |
---|
127 | // ----------------------------------------------------------------------------------- |
---|
128 | set .@tmp, getarraysize(.mob_map$); |
---|
129 | for(set .@i, 0; .@i < .@tmp; set .@i, .@i + 1){ |
---|
130 | spawn_guardian .@i; |
---|
131 | } |
---|
132 | debugmes "[Sentry System] Spawned " + .@i + " guardians."; |
---|
133 | end; |
---|
134 | |
---|
135 | } |
---|