⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atcommand.c

📁 传奇3源程序, 用vc开发的
💻 C
📖 第 1 页 / 共 4 页
字号:
	const char* command, const char* message)
{
	if (!map[sd->bl.m].flag.gvg) {
				map[sd->bl.m].flag.gvg = 1;
		clif_send0199(sd->bl.m, 3);
		clif_displaymessage(fd, msg_table[34]);
			}
	return 0;
}

int
atcommand_model(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int hair_style = 0, hair_color = 0, cloth_color = 0;
	if (!message || !*message)
		return -1;
	if (sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1)
		return -1;
	if (hair_style >= MIN_HAIR_STYLE && hair_style < MAX_HAIR_STYLE &&
		hair_color >= MIN_HAIR_COLOR && hair_color < MAX_HAIR_COLOR &&
		cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
				//暈偺怓曄峏
		if (cloth_color != 0 &&
			sd->status.sex == 1 &&
			(sd->status.class == 12 ||  sd->status.class == 17)) {
					//暈偺怓枹幚憰怑偺敾掕
					clif_displaymessage(fd,msg_table[35]);
				} else {
			pc_changelook(sd, LOOK_HAIR, hair_style);
			pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
			pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
			clif_displaymessage(fd, msg_table[36]);
				}
			} else {
		clif_displaymessage(fd, msg_table[37]);
		}

	return 0;
}

int
atcommand_go(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int town = 0;
			struct { char map[16]; int x,y; } data[] = {
				{	"prontera.gat",	156, 191	},	//	0=僾儘儞僥儔
				{	"morocc.gat",	156,  93	},	//	1=儌儘僋
				{	"geffen.gat",	119,  59	},	//	2=僎僼僃儞
				{	"payon.gat",	 89, 122	},	//	3=僼僃僀儓儞
				{	"alberta.gat",	192, 147	},	//	4=傾儖儀儖僞
				{	"izlude.gat",	128, 114	},	//	5=僀僘儖乕僪
				{	"aldebaran.gat",140, 131	},	//	6=傾儖僨僶儔儞
				{	"xmas.gat",		147, 134	},	//	7=儖僥傿僄
				{	"comodo.gat",	209, 143	},	//	8=僐儌僪
				{	"yuno.gat",		157,  51	},	//	9=僕儏僲乕
				{	"amatsu.gat",	198,  84	},	//	10=傾儅僣
				{	"gonryun.gat",	160, 120	},	//	11=僑儞儕儏儞
			};
	
	if (!message || !*message)
		return -1;
	
	town = atoi(message);
	if (town >= 0 && town < sizeof(data) / sizeof(data[0])) {
		pc_setpos((struct map_session_data*)sd,
			data[town].map, data[town].x, data[town].y, 3);
			} else {
		clif_displaymessage(fd, msg_table[38]);
		}
	return 0;
}

int
atcommand_monster(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	char name[100];
	char monster[100];
	int mob_id = 0;
	int number = 0;
	int x = 0;
	int y = 0;
	int count = 0;
	int i = 0;
	
	if (!message || !*message)
		return -1;
	if (sscanf(message, "%99s %99s %d %d %d", name, monster,
		&number, &x, &y) < 3)
		return -1;
	
	if ((mob_id = atoi(monster)) == 0)
		mob_id = mobdb_searchname(monster);
	if (number <= 0)
		number = 1;
	if (battle_config.etc_log)
		printf("%s monster=%s name=%s id=%d count=%d (%d,%d)\n",
			command, monster, name, mob_id, number, x, y);
	
	for (i = 0; i < number; i++) {
		int mx = 0, my = 0;
		if (x <= 0)
			mx = sd->bl.x + (rand() % 10 - 5);
		else
			mx = x;
		if (y <= 0)
			my = sd->bl.y + (rand() % 10 - 5);
		else
			my = y;
		count +=
			(mob_once_spawn((struct map_session_data*)sd,
				"this", mx, my, name, mob_id, 1, "") != 0) ?
			1 : 0;
				}
	if (count != 0) {
					clif_displaymessage(fd,msg_table[39]);
	} else {
					clif_displaymessage(fd,msg_table[40]);
				}
	
	return 0;
}

void
atcommand_killmonster_sub(
	const int fd, struct map_session_data* sd, const char* message,
	const int drop)
{
	int map_id = 0;
	
	if (!message || !*message) {
		map_id = sd->bl.m;
	} else {
		char map_name[100];
		sscanf(message, "%99s", map_name);
		if (strstr(map_name, ".gat") == NULL && strlen(map_name) < 16) {
			strcat(map_name, ".gat");
			}
		if ((map_id = map_mapname2mapid(map_name)) < 0)
			map_id = sd->bl.m;
						}
	map_foreachinarea(atkillmonster_sub, map_id, 0, 0,
		map[map_id].xs, map[map_id].ys, BL_MOB, drop);
}

int
atcommand_killmonster(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	atcommand_killmonster_sub(fd, sd, message, 1);
	
	return 0;
}

int
atcommand_killmonster2(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	atcommand_killmonster_sub(fd, sd, message, 0);
	
	return 0;
}

int
atcommand_refine(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int i = 0, position = 0, refine = 0, current_position = 0;
	struct map_session_data* p = (struct map_session_data*)sd;
	
	if (!message || !*message)
		return -1;
	
	if (sscanf(message, "%d %d", &position, &refine) >= 2) {
		for (i = 0; i < MAX_INVENTORY; i++) {
			if (sd->status.inventory[i].nameid &&	// 奩摉屄強偺憰旛傪惛楤偡傞
			    (sd->status.inventory[i].equip & position ||
				(sd->status.inventory[i].equip && !position))) {
				if (refine <= 0 || refine > 10)
					refine = 1;
				if (sd->status.inventory[i].refine < 10) {
					p->status.inventory[i].refine += refine;
					if (sd->status.inventory[i].refine > 10)
						p->status.inventory[i].refine = 10;
					current_position = sd->status.inventory[i].equip;
					pc_unequipitem((struct map_session_data*)sd, i, 0);
					clif_refine(fd, (struct map_session_data*)sd,
						0, i, sd->status.inventory[i].refine);
					clif_delitem((struct map_session_data*)sd, i, 1);
					clif_additem((struct map_session_data*)sd, i, 1, 0);
					pc_equipitem((struct map_session_data*)sd, i,
						current_position);
					clif_misceffect((struct block_list*)&sd->bl, 3);
					}
				}
			}
		}
	
	return 0;
}

int
atcommand_produce(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	char item_name[100];
	int item_id = 0, attribute = 0, star = 0;
	int flag = 0;
	if (!message || !*message)
		return -1;
	
	if (sscanf(message, "%99s %d %d", item_name, &attribute, &star) > 0) {
		if ((item_id = atoi(item_name)) == 0) {
			struct item_data *item_data = itemdb_searchname(item_name);
			if (item_data)
				item_id = item_data->nameid;
		}
		if (itemdb_exists(item_id) &&
			(item_id <= 500 || item_id > 1099) &&
			(item_id < 4001 || item_id > 4148) &&
			(item_id < 7001 || item_id > 10019) &&
			itemdb_isequip(item_id)) {
					struct item tmp_item;
			if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
				attribute = ATTRIBUTE_NORMAL;
			if (star < MIN_STAR || star > MAX_STAR)
				star = 0;
			memset(&tmp_item, 0, sizeof tmp_item);
			tmp_item.nameid = item_id;
			tmp_item.amount = 1;
			tmp_item.identify = 1;
			tmp_item.card[0] = 0x00ff;
			tmp_item.card[1] = ((star * 5) << 8) + attribute;
			*((unsigned long *)(&tmp_item.card[2])) = sd->char_id;
			clif_produceeffect(sd, 0, item_id); // 惢憿僄僼僃僋僩僷働僢僩
			clif_misceffect(&sd->bl, 3); // 懠恖偵傕惉岟傪捠抦
			if ((flag = pc_additem(sd, &tmp_item, 1)))
				clif_additem(sd, 0, 0, flag);
		} else {
			if (battle_config.error_log)
				printf("@produce NOT WEAPON [%d]\n", item_id);
		}
		}

	return 0;
}

int
atcommand_memo(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int position = 0;
	
	if (!message || !*message)
		return -1;
	
	position = atoi(message);
	if (position < MIN_PORTAL_MEMO || position > MAX_PORTAL_MEMO)
		position = MIN_PORTAL_MEMO;
	pc_memo(sd, position);
	return 0;
}

int
atcommand_gat(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	char output[BUFSIZ];
	int y = 0;
	for (y = 2; y >= -2; y--) {
		snprintf(output, sizeof output,
			"%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
			map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
			map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y),
			map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y),
			map_getcell(sd->bl.m, sd->bl.x,     sd->bl.y + y),
			map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y),
			map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y));
		clif_displaymessage(fd, output);
			}
	
	return 0;
}

int
atcommand_packet(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int x = 0, y = 0;
	
	if (!message || !*message)
		return -1;
	
	if (sscanf(message,"%d %d", &x, &y) < 2)
			return 1;
	clif_status_change(&sd->bl, x, y);
	return 0;
}

int
atcommand_statuspoint(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int point = 0;
	
	if (!message || !*message)
		return -1;
	point = atoi(message);
	if (point > 0 || sd->status.status_point + point >= 0) {
		sd->status.status_point += point;
		clif_updatestatus(sd, SP_STATUSPOINT);
	} else {
		clif_displaymessage(fd, msg_table[41]);
		}

	return 0;
}

int
atcommand_skillpoint(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int point = 0;
	if (!message || !*message)
		return -1;
	point = atoi(message);
	if (point > 0 || sd->status.skill_point + point >= 0) {
		sd->status.skill_point += point;
		clif_updatestatus(sd, SP_SKILLPOINT);
	} else {
		clif_displaymessage(fd, msg_table[41]);
		}

	return 0;
}

int
atcommand_zeny(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int zeny = 0;
	
	if (!message || !*message)
		return -1;
	zeny = atoi(message);
	if (zeny > 0 || sd->status.zeny + zeny >= 0) {
		if (sd->status.zeny + zeny > MAX_ZENY)
			zeny = MAX_ZENY - sd->status.zeny;
		sd->status.zeny += zeny;
		clif_updatestatus(sd, SP_ZENY);
	} else {
		clif_displaymessage(fd, msg_table[41]);
		}
	return 0;
}

int
atcommand_param(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int i = 0, value = 0, index = -1, new_value = 0;
	
	const char* param[] = {
		"@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL
	};
	short* status[] = {
		&sd->status.str,  &sd->status.agi, &sd->status.vit,
		&sd->status.int_, &sd->status.dex, &sd->status.luk
	};
	
	if (!message || !*message)
		return -1;
	value = atoi(message);
	
	for (i = 0; param[i] != NULL; i++) {
		if (strcmpi(command, param[i]) == 0) {
			index = i;
			break;
		}
	}
	if (index < 0 || index > MAX_STATUS_TYPE)
		return -1;
	
	new_value = (int)(*status[index]) + value;
	if (new_value < 1)
		value = 1 - *status[index];
	if (new_value > battle_config.max_parameter)
		value = battle_config.max_parameter - *status[index];
	*status[index] += value;
	
	clif_updatestatus(sd, SP_STR + index);
	clif_updatestatus(sd, SP_USTR + index);
	pc_calcstatus(sd, 0);
	clif_displaymessage(fd, msg_table[42]);
	
	return 0;
}

int
atcommand_guildlevelup(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int level = 0;
	struct guild *guild_info = NULL;
	
	if (!message || !*message)
		return -1;
	level = atoi(message);
	if (sd->status.guild_id <= 0 ||
		(guild_info = guild_search(sd->status.guild_id)) == NULL) {
		clif_displaymessage(fd, msg_table[43]);
		return 0;
	}
	if (strcmp(sd->status.name, guild_info->master) != 0) {
		clif_displaymessage(fd, msg_table[44]);
		return 0;
		}

	if (guild_info->guild_lv + level >= 1 &&
		guild_info->guild_lv + level <= MAX_GUILDLEVEL)
		intif_guild_change_basicinfo(guild_info->guild_id,
			GBI_GUILDLV, &level, 2);
	else
		clif_displaymessage(fd, msg_table[45]);
	
	return 0;
}

int
atcommand_makepet(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int id = 0, pet_id = 0;

	if (!message || !*message)
		return -1;
			
	id = atoi(message);
	pet_id = search_petDB_index(id, PET_CLASS);
	if (pet_id < 0)
		pet_id = search_petDB_index(id, PET_EGG);
	if (pet_id >= 0) {
		sd->catch_target_class = pet_db[pet_id].class;
		intif_create_pet(
			sd->status.account_id, sd->status.char_id,
			pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
			pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
			100, 0, 1, pet_db[pet_id].jname);
	} else {
		return -1;
		}

	return 0;
}
			
int
atcommand_petfriendly(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int friendly = 0;

	if (!message || !*message)
		return -1;

	friendly = atoi(message);
	if (sd->status.pet_id > 0 && sd->pd) {
		if (friendly >= 0 && friendly <= 1000) {
					int t = sd->pet.intimate;
			sd->pet.intimate = friendly;
					clif_send_petstatus(sd);
			if (battle_config.pet_status_support) {
				if ((sd->pet.intimate > 0 && t <= 0) ||
					(sd->pet.intimate <= 0 && t > 0)) {
					if (sd->bl.prev != NULL)
						pc_calcstatus(sd, 0);
							else
						pc_calcstatus(sd, 2);
					}
				}
		} else {
			return -1;
			}
		}

	return 0;
}

int
atcommand_pethungry(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	int hungry = 0;
	
	if (!message || !*message)
		return -1;
	
	hungry = atoi(message);
	if (sd->status.pet_id > 0 && sd->pd) {
		if (hungry >= 0 && hungry <= 100) {
			sd->pet.hungry = hungry;
					clif_send_petstatus(sd);
		} else {
			return -1;
				}
			}

	return 0;
}

int
atcommand_petrename(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	if (sd->status.pet_id > 0 && sd->pd) {
				sd->pet.rename_flag = 0;
		intif_save_petdata(sd->status.account_id, &sd->pet);
				clif_send_petstatus(sd);
			}

	return 0;
}

int
atcommand_recall(
	const int fd, struct map_session_data* sd,
	const char* command, const char* message)
{
	char character[100];
	struct map_session_data *pl_sd = NULL;
	
	if (!message || !*message)
		return -1;
	
	memset(character, '\0', sizeof character);
	memset(character, '\0', sizeof character);
	sscanf(message, "%99[^\n]", character);
	if ((pl_sd = map_nick2sd(character)) != NULL) {
		if (pc_isGM(sd) > pc_isGM(pl_sd)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -