summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
Diffstat (limited to 'npc')
-rw-r--r--npc/custom/Lance/Sentry.cpp119
-rw-r--r--npc/sample/monster_controller.cpp28
-rw-r--r--npc/scripts_custom.conf3
3 files changed, 141 insertions, 9 deletions
diff --git a/npc/custom/Lance/Sentry.cpp b/npc/custom/Lance/Sentry.cpp
new file mode 100644
index 000000000..e76ff18f2
--- /dev/null
+++ b/npc/custom/Lance/Sentry.cpp
@@ -0,0 +1,119 @@
+//(=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)
+//( (c)2006 eAthena Development Team presents )
+//( ______ __ __ )
+//( /\ _ \/\ \__/\ \ v 1.00.00 )
+//( __\ \ \_\ \ \ ,_\ \ \___ __ ___ __ )
+//( /'__`\ \ __ \ \ \/\ \ _ `\ /'__`\/' _ `\ /'__`\ )
+//( /\ __/\ \ \/\ \ \ \_\ \ \ \ \/\ __//\ \/\ \/\ \_\.\_ )
+//( \ \____\\ \_\ \_\ \__\\ \_\ \_\ \____\ \_\ \_\ \__/.\_\ )
+//( \/____/ \/_/\/_/\/__/ \/_/\/_/\/____/\/_/\/_/\/__/\/_/ )
+//( _ _ _ _ _ _ _ _ _ _ _ _ _ )
+//( / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ )
+//( ( e | A | t | h | e | n | a ) ( S | c | r | i | p | t ) )
+//( \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ )
+//( )
+//(=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)
+// Programmed by [Lance] ver. 1.0
+// ---------------------------------------------------------
+// [ Sentry System ]
+// - Guards main towns against aggresive monsters and bad
+// players.
+// [ Customization ]
+// - See OnInit:
+// =========================================================
+
+- script sentry_system -1,{
+ function spawn_guardian {
+ set .mob_id[getarg(0)], spawnmob("Guardian Sentry",1904,.mob_map$[getarg(0)],.mob_x[getarg(0)],.mob_y[getarg(0)]);
+ mobattach .mob_id[getarg(0)]; // Attach events to this script.
+ mobrandomwalk .mob_id[getarg(0)], 0; // Prevents random walking.
+ mobattack .mob_id[getarg(0)]; // Enable all viewing.
+ return;
+ }
+
+ function search_entry {
+ set .@tmp, getarraysize(getarg(0));
+ for(set .@i, 0; .@i < .@tmp; set .@i, .@i + 1){
+ if(getelementofarray(getarg(0),.@i) == getarg(1))
+ break;
+ }
+ if(.@i == .@tmp)
+ return -1;
+ else
+ return .@i;
+ }
+
+ // Script Entry Point - When an event from the script engine is received.
+ if(getarraysize(.ai_action) == 4){ // Checks if the data is formatted correctly.
+ set .@tmp, search_entry(.mob_id, .ai_action[AI_ACTION_SRC]);
+ switch(.ai_action[AI_ACTION_TYPE]){
+ case AI_ACTION_TYPE_DETECT: // We see something...
+ if(.ai_busy[.@tmp] == 0){ // Not busy
+ switch(.ai_action[AI_ACTION_TAR_TYPE]){ // Check what have we here.
+ case AI_ACTION_TAR_TYPE_PC: // It's a player
+ if(getd("$pkarma_"+.ai_action[AI_ACTION_TAR]) > .karma){ // pkarma is higher?
+ mobtalk .ai_action[AI_ACTION_SRC], "Who goes there!";
+ mobemote .ai_action[AI_ACTION_SRC], e_gasp; // !
+ mobattack .ai_action[AI_ACTION_SRC],.ai_action[AI_ACTION_TAR];
+ // We're currently busy.
+ set .ai_busy[.@tmp], .ai_action[AI_ACTION_TAR];
+ }
+ break;
+ case AI_ACTION_TAR_TYPE_MOB: // It's a monster
+ if(.ai_action[AI_ACTION_TAR] != .ai_action[AI_ACTION_SRC]){
+ getmobdata .ai_action[AI_ACTION_TAR], .@temp;
+ if(.@temp[9]&0x804){ // In Aggressive mode?
+ mobtalk .ai_action[AI_ACTION_SRC], "Protect the villagers we must!";
+ mobemote .ai_action[AI_ACTION_SRC], e_gasp; // !
+ mobattack .ai_action[AI_ACTION_SRC],.ai_action[AI_ACTION_TAR];
+ // We're currently busy.
+ set .ai_busy[.@tmp], .ai_action[AI_ACTION_TAR];
+ }
+ }
+ break;
+ }
+ }
+ break;
+ case AI_ACTION_TYPE_KILL: // We eliminated the criminal
+ if(.ai_action[AI_ACTION_TAR_TYPE] == AI_ACTION_TAR_TYPE_PC)
+ setd "$pkarma_"+.ai_action[AI_ACTION_TAR], 0;
+ case AI_ACTION_TYPE_UNLOCK: // Target lost :(
+ if(.@tmp != -1){
+ set .ai_busy[.@tmp], 0; // Remove him, we're free.
+ }
+ // Walk back to where we came from.
+ mobwalk .ai_action[AI_ACTION_SRC],.mob_x[.@tmp],.mob_y[.@tmp];
+ break;
+ case AI_ACTION_TYPE_DEAD: // We got killed :(
+ if(.ai_action[AI_ACTION_TAR_TYPE] == AI_ACTION_TAR_TYPE_PC){ // Attacker is a player?
+ setd "$pkarma_"+.ai_action[AI_ACTION_TAR], getd("$pkarma_"+.ai_action[AI_ACTION_TAR]) + 5;
+ }
+ sleep 10000; // 10 seconds until reinforcements arrive
+ spawn_guardian .@tmp;
+ break;
+ case AI_ACTION_TYPE_ATTACK: // Someone attacked us
+ if(.ai_action[AI_ACTION_TAR_TYPE] == AI_ACTION_TAR_TYPE_PC){ // Attacker is a player?
+ setd "$pkarma_"+.ai_action[AI_ACTION_TAR], getd("$pkarma_"+.ai_action[AI_ACTION_TAR]) + 1;
+ }
+ // The system's AI will auto attack any attackers. So we leave it here.
+ break;
+ }
+ }
+ deletearray .ai_action, getarraysize(.ai_action); // Cleans up and frees up memory
+ end;
+
+OnInit:
+ // Customization ---------------------------------------------------------------------
+ setarray .mob_map$, "prt_fild08.gat", "prt_fild05.gat", "prt_fild06.gat", "prt_gld.gat";
+ setarray .mob_x,176,369,29,165;
+ setarray .mob_y,372,201,187,37;
+ set .karma, 5;
+ // -----------------------------------------------------------------------------------
+ set .@tmp, getarraysize(.mob_map$);
+ for(set .@i, 0; .@i < .@tmp; set .@i, .@i + 1){
+ spawn_guardian .@i;
+ }
+ debugmes "[Sentry System] Spawned " + .@i + " guardians.";
+ end;
+
+} \ No newline at end of file
diff --git a/npc/sample/monster_controller.cpp b/npc/sample/monster_controller.cpp
index 035215300..385059d31 100644
--- a/npc/sample/monster_controller.cpp
+++ b/npc/sample/monster_controller.cpp
@@ -69,14 +69,26 @@ prontera.gat,180,200,4 script Monster Controller 123,{
break;
}
- if(.ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_ATTACK)
- set .@action_type$, "Attacked by";
- else if(.ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_DETECT)
- set .@action_type$, "Detected";
- else if (.ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_ASSIST)
- set .@action_type$, "Killed by";
- else
- set .@action_type$, "Assisting";
+ switch(.ai_action[AI_ACTION_TYPE]){
+ case AI_ACTION_TYPE_ATTACK:
+ set .@action_type$, "Attacked by";
+ break;
+ case AI_ACTION_TYPE_DETECT:
+ set .@action_type$, "Detected";
+ break;
+ case AI_ACTION_TYPE_DEAD:
+ set .@action_type$, "Killed by";
+ break;
+ case AI_ACTION_TYPE_ASSIST:
+ set .@action_type$, "Assisting";
+ break;
+ case AI_ACTION_TYPE_UNLOCK:
+ set .@action_type$, "Unlocked target";
+ break;
+ case AI_ACTION_TYPE_KILL:
+ set .@action_type$, "Killed";
+ break;
+ }
announce "Details - " + .@action_type$ + " [" + .@action_from$ + "] " + .@action_name$ + "!", bc_all;
deletearray .ai_action, 4;
diff --git a/npc/scripts_custom.conf b/npc/scripts_custom.conf
index 88002b121..8207d8b1a 100644
--- a/npc/scripts_custom.conf
+++ b/npc/scripts_custom.conf
@@ -20,7 +20,6 @@
//npc: npc/location/to/script.txt
// Your scripts go here!!
// --------------------------------------------------------------
-//npc: npc/sample/monster_controller.cpp
// ----------------------- Basic Scripts -----------------------
// -- Adoption NPC [Fredzilla]
npc: npc/custom/adoption.txt
@@ -91,6 +90,8 @@ npc: npc/custom/adoption.txt
//npc: npc/custom/Lance/FR_WeatherController.c
//npc: npc/custom/Lance/FR_MailSystem.c
//npc: npc/sample/npc_dynamic_shop.txt
+//npc: npc/sample/monster_controller.cpp
+//npc: npc/custom/Lance/Sentry.cpp
// --------------------------------------------------------------
// --------------------------------------------------------------