summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Renewal.txt2
-rw-r--r--db/item_delay.txt6
-rw-r--r--src/map/itemdb.c47
-rw-r--r--src/map/itemdb.h4
-rw-r--r--src/map/pc.c23
-rw-r--r--src/map/pc.h6
6 files changed, 84 insertions, 4 deletions
diff --git a/Changelog-Renewal.txt b/Changelog-Renewal.txt
index 116b45980..706ac02f2 100644
--- a/Changelog-Renewal.txt
+++ b/Changelog-Renewal.txt
@@ -1,5 +1,7 @@
Date Added
+2010/11/10
+ * Added an item_delay database usable for item-specific use delays. [Paradox924X]
2010/11/09
* Use packet 0xe7 instead of 0x1f5 within clif_tradestart() when there is no trade_partner (or an invalid one) specified even for PACKETVER >= 6. (bugreport:4544) [Paradox924X]
* Follow-up to r14368. Load last_map from SQL on char load so the information is available during char select for PACKETVER > 20100721. Patch based on Ai4rei's. (bugreport:4429) [Paradox924X]
diff --git a/db/item_delay.txt b/db/item_delay.txt
new file mode 100644
index 000000000..8faef0906
--- /dev/null
+++ b/db/item_delay.txt
@@ -0,0 +1,6 @@
+// Item Delay Database
+// Max number of entries is defined in itemdb.h as MAX_ITEMDELAYS
+// WARNING: Adding/removing/modifying entries here and then using @reloaditemdb will cause problems/inconsistencies!
+//
+// Structure:
+// Item ID,Delay in Milliseconds
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index fb7cbe86f..2096ddf9e 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -27,7 +27,7 @@ static struct item_group itemgroup_db[MAX_ITEMGROUP];
struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex]
-
+int item_delays = 0;
/*==========================================
* 名前で検索用
@@ -661,6 +661,50 @@ static int itemdb_read_itemtrade(void)
return 0;
}
+/*==========================================
+ * Reads item delay amounts [Paradox924X]
+ *------------------------------------------*/
+static int itemdb_read_itemdelay(void)
+{
+ FILE *fp;
+ int nameid, j;
+ char line[1024], *str[10], *p;
+ struct item_data *id;
+
+ sprintf(line, "%s/item_delay.txt", db_path);
+ if ((fp = fopen(line,"r")) == NULL) {
+ ShowError("can't read %s\n", line);
+ return -1;
+ }
+
+ while(fgets(line, sizeof(line), fp))
+ {
+ if (item_delays == MAX_ITEMDELAYS) {
+ ShowError("itemdb_read_itemdelay: Too many entries specified in %s/item_delay.txt!\n", db_path);
+ break;
+ }
+ if (line[0] == '/' && line[1] == '/')
+ continue;
+ memset(str, 0, sizeof(str));
+ for (j = 0, p = line; j < 2 && p; j++) {
+ str[j] = p;
+ p = strchr(p, ',');
+ if(p) *p++ = 0;
+ }
+
+ if (j < 2 || str[0] == NULL ||
+ (nameid = atoi(str[0])) < 0 || !(id = itemdb_exists(nameid)))
+ continue;
+
+ id->delay = atoi(str[1]);
+ item_delays++;
+ }
+ fclose(fp);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", item_delays, "item_delay.txt");
+
+ return 0;
+}
+
/*======================================
* Applies gender restrictions according to settings. [Skotlex]
*======================================*/
@@ -971,6 +1015,7 @@ static void itemdb_read(void)
itemdb_read_itemavail();
itemdb_read_noequip();
itemdb_read_itemtrade();
+ itemdb_read_itemdelay();
}
/*==========================================
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 62bbb2c5a..5b07b5c1b 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -8,6 +8,9 @@
#define MAX_RANDITEM 11000
+// The maximum number of item delays
+#define MAX_ITEMDELAYS 10
+
#define MAX_SEARCH 5 //Designed for search functions, species max number of matches to display.
#define ITEMID_YELLOW_GEMSTONE 715
@@ -54,6 +57,7 @@ struct item_data {
int elv;
int wlv;
int view_id;
+ int delay;
//Lupus: I rearranged order of these fields due to compatibility with ITEMINFO script command
// some script commands should be revised as well...
unsigned int class_base[3]; //Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2)
diff --git a/src/map/pc.c b/src/map/pc.c
index 834a7f871..433b67b46 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -67,6 +67,8 @@ char motd_text[MOTD_LINE_SIZE][256]; // Message of the day buffer [Valaris]
struct duel duel_list[MAX_DUEL];
int duel_count = 0;
+extern int item_delays; // [Paradox924X]
+
//Links related info to the sd->hate_mob[]/sd->feel_map[] entries
const struct sg_data sg_info[3] = {
{ SG_SUN_ANGER, SG_SUN_BLESS, SG_SUN_COMFORT, "PC_FEEL_SUN", "PC_HATE_MOB_SUN", is_day_of_sun },
@@ -531,6 +533,11 @@ int pc_setinventorydata(struct map_session_data *sd)
for(i=0;i<MAX_INVENTORY;i++) {
id = sd->status.inventory[i].nameid;
sd->inventory_data[i] = id?itemdb_search(id):NULL;
+ if(sd->inventory_data[i] && sd->inventory_data[i]->delay > 0) { // Load delays
+ sd->item_delay[item_delays].nameid = sd->inventory_data[i]->nameid;
+ sd->item_delay[item_delays].tick = 0;
+ ++item_delays;
+ }
}
return 0;
}
@@ -3654,8 +3661,8 @@ int pc_isUseitem(struct map_session_data *sd,int n)
*------------------------------------------*/
int pc_useitem(struct map_session_data *sd,int n)
{
- unsigned int tick = gettick();
- int amount;
+ unsigned int delay, tick = gettick();
+ int amount, i, nameid;
struct script_code *script;
nullpo_ret(sd);
@@ -3681,6 +3688,16 @@ int pc_useitem(struct map_session_data *sd,int n)
))
return 0;
+ // Store information for later use before it is lost (via pc_delitem) [Paradox924X]
+ nameid = sd->inventory_data[n]->nameid;
+ delay = sd->inventory_data[n]->delay;
+
+ if( sd->inventory_data[n]->delay > 0 ) { // Check if there is a delay on this item [Paradox924X]
+ ARR_FIND(0, item_delays, i, sd->item_delay[i].nameid == nameid);
+ if( i < item_delays && DIFF_TICK(sd->item_delay[i].tick, tick) > 0 )
+ return 0; // Delay has not expired yet
+ }
+
//Since most delay-consume items involve using a "skill-type" target cursor,
//perform a skill-use check before going through. [Skotlex]
//resurrection was picked as testing skill, as a non-offensive, generic skill, it will do.
@@ -3725,6 +3742,8 @@ int pc_useitem(struct map_session_data *sd,int n)
sd->canuseitem_tick = tick + battle_config.item_use_interval;
if( itemdb_iscashfood(sd->status.inventory[n].nameid) )
sd->canusecashfood_tick = tick + battle_config.cashfood_use_interval;
+ if( delay > 0 && i < item_delays )
+ sd->item_delay[i].tick = tick + delay;
run_script(script,0,sd->bl.id,fake_nd->bl.id);
potion_flag = 0;
diff --git a/src/map/pc.h b/src/map/pc.h
index da666f9a7..0c3cb89eb 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -204,6 +204,11 @@ struct map_session_data {
unsigned int cantalk_tick;
unsigned int cansendmail_tick; // [Mail System Flood Protection]
unsigned int ks_floodprotect_tick; // [Kill Steal Protection]
+
+ struct {
+ int nameid;
+ unsigned int tick;
+ } item_delay[MAX_ITEMDELAYS]; // [Paradox924X]
short weapontype1,weapontype2;
short disguise; // [Valaris]
@@ -404,7 +409,6 @@ struct map_session_data {
const char* debug_func;
};
-
//Update this max as necessary. 54 is the value needed for Super Baby currently
#define MAX_SKILL_TREE 54
//Total number of classes (for data storage)