summaryrefslogtreecommitdiff
path: root/npc/sample/monster_controller.txt
blob: 4d368467cba66aa168314a6b4c3d2f7ce5f18ced (plain) (blame)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// Variables Logging:
// .mc_moblist[] - ID list of mobs
prontera,180,200,4	script	Monster Controller	123,{
	function display_info {
		getmobdata getarg(0), .@mob_data;
		set .@array_size, getarraysize(.@mob_data);
		for(set .@i, 0; .@i < .@array_size; set .@i, .@i + 1){
			mes .@i + " - " + .@mob_data[.@i];
		}
		return;
	}

	function remove_mob {
		removemob getarg(0);
		set .@mob_size, getarraysize(.mc_moblist);
		for(set .@i, 0; .@i < .@mob_size; set .@i, .@i + 1){
			if(.mc_moblist[.@i] == getarg(0))
				deletearray .mc_moblist[.@i], 1;
		}
	}

	function make_menu {
		set .@array_size, getarraysize(.mc_moblist);
		set .@tmp_str$, "";
		for(set .@i, 0; .@i < .@array_size; set .@i, .@i + 1){
			set .@tmp_str$, .@tmp_str$ + .mc_moblist[.@i] + ":";
		}
		select .@tmp_str$;
		return .mc_moblist[@menu-1];
	}

	function summon_mob {
		set .@mob_size, getarraysize(.mc_moblist);
		set .mc_moblist[.@mob_size], spawnmob("Slave - " + .@mob_size, getarg(0), "prontera", 180, 200);
		mobattach .mc_moblist[.@mob_size];
		setmobdata .mc_moblist[.@mob_size], 25, 
			AI_ACTION_TYPE_ATTACK|
			AI_ACTION_TYPE_DETECT|
            AI_ACTION_TYPE_DEAD|
			AI_ACTION_TYPE_ASSIST|
			AI_ACTION_TYPE_KILL|
            AI_ACTION_TYPE_UNLOCK|
            AI_ACTION_TYPE_WALKACK|
            AI_ACTION_TYPE_WARPACK;
		return;
	}

	function list_mobs {
		set .@mob_size, getarraysize(.mc_moblist);
		for(set .@i, 0; .@i < .@mob_size; set .@i, .@i + 1){
			mes "- " + .mc_moblist[.@i];
		}
		return;
	}

	if(getarraysize(.ai_action) == 4){
		mapannounce "prontera", "[Mob Control] AI Action Received from " + .ai_action[AI_ACTION_SRC] + "!",16;
		switch(.ai_action[AI_ACTION_TAR_TYPE]){
			case AI_ACTION_TAR_TYPE_PC:
				set .@action_from$, "Player";
				set .@action_name$, rid2name(.ai_action[AI_ACTION_TAR]);
				break;
			case AI_ACTION_TAR_TYPE_MOB:
				set .@action_from$, "Monster";
				set .@action_name$, rid2name(.ai_action[AI_ACTION_TAR]);
				break;
			case AI_ACTION_TAR_TYPE_PET:
				set .@action_from$, "Pet";
				set .@action_name$, rid2name(.ai_action[AI_ACTION_TAR]);
				break;
			case AI_ACTION_TAR_TYPE_HOMUN:
				set .@action_from$, "Homunculus";
				set .@action_name$, rid2name(.ai_action[AI_ACTION_TAR]);
				break;
			default:
				set .@action_from$, "Unknown";
				set .@action_name$, ""+.ai_action[AI_ACTION_TAR];
				break;
		}

		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";
				remove_mob .ai_action[AI_ACTION_SRC];
				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;
			case AI_ACTION_TYPE_WALKACK:
				set .@action_type$, "Completed Walking";
				break;
			case AI_ACTION_TYPE_WARPACK:
				set .@action_type$, "Warped";
				break;
		}

		mapannounce "prontera", "Details - " + .@action_type$ + " [" + .@action_from$ + "] " + .@action_name$ + "!", 16;
		deletearray .ai_action, 4;
		end;
	}

L_MainMenu:
	mes "[Monster Controller]";
	mes "Current active monsters:";
	list_mobs;
	switch(select("Summon","Remove","Information","Actions")){
		case 1: // Summon
			next;
			mes "[Monster Controller]";
			mes "Monster ID -";
			input @mob_id;
			next;
			summon_mob @mob_id;
			goto L_MainMenu;
			break;
		case 2: // Remove
			remove_mob make_menu();
			next;
			goto L_MainMenu;
			break;
		case 3: // Information
			set .@tmp, make_menu();
			next;
			mes "[Monster Info]";
			display_info .@tmp;
			next;
            goto L_MainMenu;
			break;
		case 4: // Actions
			goto L_AttackMenu;
			break;
	}

L_AttackMenu:
	switch(select("Walk","Follow","Attack","Stop","Defend","Talk","Emote","Random Walk","Callback","Back")){
		case 1: // Walk
			set .@src, make_menu();
			input .@x;
			input .@y;
			mobwalk .@src,.@x,.@y; // Mode 1: Walk to location.
			break;
		case 2: // Follow
			set .@src, make_menu();
			input .@tar;
			mobwalk .@src, .@tar; // Mode 2: Walk to target.
			break;
		case 3: // Attack
			set .@src, make_menu();
			input .@tar;
			mobattack .@src, .@tar;
			break;
		case 4: // Stop
			set .@src, make_menu();
			mobstop .@src;
			break;
		case 5: // Defend/Assist
			set .@src, make_menu();
			input .@tar;
			mobassist .@src, .@tar;
			break;
		case 6: // Talk
			set .@src, make_menu();
			input .@text$;
			mobtalk .@src, .@text$;
			break;
		case 7: // Emote
			set .@src, make_menu();
			input .@emote;
			mobemote .@src, .@emote;
			break;
		case 8:
			set .@src, make_menu();
			input .@flag;
			mobrandomwalk .@src, .@flag;
			break;
		case 9:
			set .@src, make_menu();
			input .@flag;
			setmobdata .@src, 25, .@flag;
			break;
		case 9:
			next;
			goto L_MainMenu;
	}
	goto L_AttackMenu;
}