-
Notifications
You must be signed in to change notification settings - Fork 26
/
@monster_nodropexp.c
152 lines (129 loc) · 4.15 KB
/
@monster_nodropexp.c
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
#include "common/hercules.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "common/HPMi.h"
#include "common/nullpo.h"
#include "common/memmgr.h"
#include "common/mmo.h"
#include "map/atcommand.h"
#include "map/battle.h"
#include "map/clif.h"
#include "map/map.h"
#include "map/mob.h"
#include "map/pc.h"
#include "plugins/HPMHooking.h"
#include "common/HPMDataCheck.h"
HPExport struct hplugin_info pinfo = {
"monster_nodropexp", // Plugin name
SERVER_TYPE_MAP,// Which server types this plugin works with?
"1.0", // Plugin version
HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
};
struct tmp_data {
bool no_drop_exp;
};
ACMD(monster_nde)
{
char name[NAME_LENGTH];
char monster[NAME_LENGTH];
char eventname[EVENT_NAME_LENGTH] = "";
char atcmd_output[256];
int mob_id;
int number = 0;
int count;
int i, range;
short mx, my;
unsigned int size;
memset(name, '\0', sizeof(name));
memset(monster, '\0', sizeof(monster));
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!*message) {
clif->message(fd, msg_fd(fd,80)); // Please specify a display name or monster name/id.
return false;
}
if (sscanf(message, "\"#[^\"]\" #s %d", name, monster, &number) > 1 ||
sscanf(message, "#s \"#[^\"]\" %d", monster, name, &number) > 1) {
//All data can be left as it is.
} else if ((count=sscanf(message, "#s %d #s", monster, &number, name)) > 1) {
//Here, it is possible name was not given and we are using monster for it.
if (count < 3) //Blank mob's name.
name[0] = '\0';
} else if (sscanf(message, "#s #s %d", name, monster, &number) > 1) {
//All data can be left as it is.
} else if (sscanf(message, "#s", monster) > 0) {
//As before, name may be already filled.
name[0] = '\0';
} else {
clif->message(fd, msg_fd(fd,80)); // Give a display name and monster name/id please.
return false;
}
if ((mob_id = mob->db_searchname(monster)) == 0) // check name first (to avoid possible name beginning by a number)
mob_id = mob->db_checkid(atoi(monster));
if (mob_id == 0) {
clif->message(fd, msg_fd(fd,40)); // Invalid monster ID or name.
return false;
}
if (number <= 0)
number = 1;
if( !name[0] )
strcpy(name, "--ja--");
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
if (battle->bc->atc_spawn_quantity_limit && number > battle->bc->atc_spawn_quantity_limit)
number = battle->bc->atc_spawn_quantity_limit;
if (strcmpi(command, "monstersmall") == 0)
size = SZ_MEDIUM;
else if (strcmpi(command, "monsterbig") == 0)
size = SZ_BIG;
else
size = SZ_SMALL;
if (battle->bc->etc_log)
ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
count = 0;
range = (int)sqrt((float)number) 2; // calculation of an odd number ( 4 area around)
for (i = 0; i < number; i ) {
int k;
struct mob_data *md;
map->search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
k = mob->once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE|(mob_id == MOBID_EMPELIUM?0x200:0x0));
if (k) {
struct tmp_data *tmpd;
md = (TBL_MOB*)map->id2bl(k);
CREATE(tmpd,struct tmp_data,1);
tmpd->no_drop_exp = true;
addToMOBDATA(md,tmpd,0,true);
}
count = (k != 0) ? 1 : 0;
}
if (count != 0)
if (number == count)
clif->message(fd, msg_fd(fd,39)); // All monster summoned!
else {
sprintf(atcmd_output, msg_fd(fd,240), count); // %d monster(s) summoned!
clif->message(fd, atcmd_output);
}
else {
clif->message(fd, msg_fd(fd,40)); // Invalid monster ID or name.
return false;
}
return true;
}
int mob_dead_nde(struct mob_data **md, struct block_list **src, int *type) {
struct tmp_data *tmpd;
tmpd = getFromMOBDATA(*md, 0);
if (tmpd != NULL)
if (tmpd->no_drop_exp)
*type = 3;
return 3;
}
/* Server Startup */
HPExport void plugin_init(void)
{
addAtcommand("monster_nde", monster_nde);
addHookPre(mob, dead, mob_dead_nde);
}
HPExport void server_online(void)
{
ShowInfo("'%s' Plugin by Dastgir/Hercules. Version '%s'\n", pinfo.name, pinfo.version);
}