pastebin - collaborative debugging tool
eathena.kpaste.net RSS

Difference between
modified post f57d by Anonymous on Mon 7th Feb 2011 23:27
original post 8dce7280f by Anonymous on Sun 6th Feb 2011 05:15
Download diff
Show old version | new version | both versions

    
11
Index: src/map/atcommand.c
22
===================================================================
3-
--- src/map/atcommand.c	(revision 14109)
3+
--- src/map/atcommand.c	(revision 14697)
44
+++ src/map/atcommand.c	(working copy)
5-
@@ -6074,35 +6074,84 @@
5+
@@ -6095,35 +6095,78 @@
66
 }
77
88
 /*==========================================
9-
- * @autolootitem
9+
- * @alootid
10-
+ * @autolootitem [modified version by Rad]
10+
+ * @alootid [modified version by Rad]
1111
+ * modified to enable players autoloot 5
1212
+ * different items. Uses array. Counter checks added :p
1413
  *------------------------------------------*/
15-
 int atcommand_autolootitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
14+
 ACMD_FUNC(autolootitem)
1615
 {
1716
 	struct item_data *item_data = NULL;
1817
+	int i, slot=0;
1918
+	char item_name[100];
2019
2120
-	if (!message || !*message) {
2221
-		if (sd->state.autolootid) {
2322
-			sd->state.autolootid = 0;
2423
+	memset(item_name, '\0', sizeof(item_name));
2524
+
2625
+	if (!message || !*message || (
27-
+		sscanf(message, "\"%99[^\"]\" %d", item_name, &slot) < 1 &&
26+
+	    sscanf(message, "\"%99[^\"]\" %d", item_name, &slot) < 1 &&
28-
+		sscanf(message, "%99s %d", item_name, &slot) < 1
27+
+	    sscanf(message, "%99s %d", item_name, &slot) < 1))
29-
+
28+
+	{
3229
+		if (sd->state.autolootactive) {
3330
+			sd->state.autolootactive = 0;
34-
 			clif_displaymessage(fd, "Autolootitem have been turned OFF.");
31+
 			clif_displaymessage(fd, "Autolootitem has been turned OFF.");
3532
-		} else
36-
-			clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @autolootitem <item_name_or_ID>).");
33+
-			clif_displaymessage(fd, "Please, enter item name or it's ID (usage: @alootid <item_name_or_ID>).");
34+
+		} else {
3737
+		}
4138
+		return -1;
4239
+	}
4340
44-
+	if(strcmp(item_name,"list")==0)
41+
+	if (strcmp(item_name,"list")==0) {
4642
+		clif_displaymessage(fd, "Autoloot items:");
47-
+		for(i=0; i < 5; i++){
43+
+		for (i=0; i < 5; i++) {
48-
+			if(sd->state.autolootid[i] <= 500)
44+
+			if (sd->state.autolootid[i] <= 500) {
49-
+			sprintf(atcmd_output, "Slot %d: %s",i+1,">>> Free autoloot slot <<<");
45+
+				sprintf(atcmd_output, "Slot %d: %s",i+1,">>> Free autoloot slot <<<");
50-
+			else{
46+
+			} else {
51-
+			item_data = itemdb_search(sd->state.autolootid[i]);
47+
+				item_data = itemdb_search(sd->state.autolootid[i]);
52-
+			sprintf(atcmd_output, "Slot %d: '%s'",i+1,item_data->name);
48+
+				sprintf(atcmd_output, "Slot %d: '%s'",i+1,item_data->name);
5349
+			}
5450
+			clif_displaymessage(fd, atcmd_output);
5551
+		}
5652
+		return 0;
57-
+		}
53+
+	} else if ((item_data = itemdb_searchname(item_name)) == NULL &&
54+
+	           (item_data = itemdb_exists(atoi(item_name))) == NULL)
6155
+	{
6256
+		clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
6357
 		return -1;
6458
 	}
6559
+
66-
+	if(slot<1 || slot>5) slot = 1; // check
60+
+	if (slot < 1 || slot > 5) slot = 1; // check
6761
+	slot = slot - 1;
6862
+
69-
+	if (slot < 0 || slot >4){ //counter check
63+
+	if (slot < 0 || slot > 4) { //counter check
70-
+	clif_displaymessage(fd, "Slot # can only be 1~5");
64+
+		clif_displaymessage(fd, "Slot # can only be 1~5");
71-
+	return -1;
65+
+		return -1;
7266
+	}
7367
7468
-	if ((item_data = itemdb_exists(atoi(message))) == NULL)
7569
-		item_data = itemdb_searchname(message);
7670
-
7771
 	if (!item_data) {
7872
 		// No items founds in the DB with Id or Name
7973
 		clif_displaymessage(fd, "Item not found.");
8074
 		return -1;
8175
 	}
8276
+
83-
+	for(i=0; i < 5; i++){ //to prevent duplicate entry
77+
+	for (i=0; i < 5; i++) { //to prevent duplicate entry
84-
+			if(item_data->nameid == sd->state.autolootid[i]){
78+
+		if (item_data->nameid == sd->state.autolootid[i]) {
8579
+			sprintf(atcmd_output, "'%s' is already auto-looted in Slot %d.",item_data->name, i+1);
8680
+			clif_displaymessage(fd, atcmd_output);
8781
+			return -1;
8982
+		}
83+
+	}
9084
9185
-	sd->state.autolootid = item_data->nameid; // Autoloot Activated
9286
+	sd->state.autolootid[slot] = item_data->nameid; // Autoloot Activated
9387
+	sd->state.autolootactive = 1;
9488
95-
-	sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
89+
-	sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d)",
9690
-		item_data->name, item_data->jname, item_data->nameid);
97-
+	sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d} , Stored in slot %d",
91+
+	sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d) , Stored in slot %d",
98-
+		item_data->name, item_data->jname, item_data->nameid,slot+1);
92+
+	    item_data->name, item_data->jname, item_data->nameid,slot+1);
9993
 	clif_displaymessage(fd, atcmd_output);
10094
10195
 	return 0;
10296
Index: src/map/mob.c
10397
===================================================================
104-
--- src/map/mob.c	(revision 14109)
98+
--- src/map/mob.c	(revision 14697)
10599
+++ src/map/mob.c	(working copy)
106-
@@ -1719,7 +1719,7 @@
100+
@@ -1727,7 +1727,7 @@
107101
 	if( sd == NULL ) sd = map_charid2sd(dlist->third_charid);
108102
109103
 	if( sd
110104
-		&& (drop_rate <= sd->state.autoloot || ditem->item_data.nameid == sd->state.autolootid)
111105
+		&& (drop_rate <= sd->state.autoloot || mob_processdrop( sd, ditem->item_data.nameid ))
112106
 		&& (battle_config.idle_no_autoloot == 0 || DIFF_TICK(last_tick, sd->idletime) < battle_config.idle_no_autoloot)
113107
 		&& (battle_config.homunculus_autoloot?1:!flag)
114108
 #ifdef AUTOLOOT_DISTANCE
115-
@@ -1738,6 +1738,17 @@
109+
@@ -1746,6 +1746,17 @@
116110
 	dlist->item = ditem;
117111
 }
118112
119113
+int mob_processdrop(struct map_session_data * sd, int nameid)
120114
+{
121115
+	int i;
122-
+	for(i=0; i < 5; i++)
116+
+	for (i=0; i < 5; i++)
123117
+	{
124-
+	if(nameid == sd->state.autolootid[i])
118+
+	if (nameid == sd->state.autolootid[i])
125119
+		return 1;
126120
+	}
127121
+	return 0;
128122
+}
129123
+
130124
 int mob_timer_delete(int tid, unsigned int tick, int id, intptr data)
131125
 {
132126
 	struct block_list* bl = map_id2bl(id);
133127
Index: src/map/mob.h
134128
===================================================================
135-
--- src/map/mob.h	(revision 14109)
129+
--- src/map/mob.h	(revision 14697)
136130
+++ src/map/mob.h	(working copy)
137-
@@ -230,6 +230,7 @@
131+
@@ -247,6 +247,7 @@
138132
 int mob_dead(struct mob_data *md, struct block_list *src, int type);
139133
 void mob_revive(struct mob_data *md, unsigned int hp);
140134
 void mob_heal(struct mob_data *md,unsigned int heal);
141135
+int mob_processdrop(struct map_session_data * sd, int nameid);
142136
143137
 #define mob_stop_walking(md, type) unit_stop_walking(&(md)->bl, type)
144138
 #define mob_stop_attack(md) unit_stop_attack(&(md)->bl)
145139
Index: src/map/pc.h
146140
===================================================================
147-
--- src/map/pc.h	(revision 14109)
141+
--- src/map/pc.h	(revision 14697)
148142
+++ src/map/pc.h	(working copy)
149-
@@ -122,7 +122,8 @@
143+
@@ -129,7 +129,8 @@
150144
 		unsigned ignoreAll : 1;
151145
 		unsigned debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
152146
 		unsigned short autoloot;
153147
-		unsigned short autolootid; // [Zephyrus]
154-
+		unsigned short autolootid[5]; // [Zephyrus]
148+
+		unsigned short autolootid[5]; // [Zephyrus] [Rad]
155149
+		unsigned short autolootactive;
156150
 		unsigned noks : 3; // [Zeph Kill Steal Protection]
157151
 		bool changemap;
158152
 		short pmap; // Previous map on Map Change
159153

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at