summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorParadox924X <Paradox924X@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-10 18:57:14 +0000
committerParadox924X <Paradox924X@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-10 18:57:14 +0000
commitd95751dcd8b3e17f773117dac3897f0cf7cb90af (patch)
tree8fafe10caae1f6b5f9649006dda165d1d4b7e13d /src/map
parent84cdcd0f78c162511734466e1d1a37078ee1a786 (diff)
downloadhercules-d95751dcd8b3e17f773117dac3897f0cf7cb90af.tar.gz
hercules-d95751dcd8b3e17f773117dac3897f0cf7cb90af.tar.bz2
hercules-d95751dcd8b3e17f773117dac3897f0cf7cb90af.tar.xz
hercules-d95751dcd8b3e17f773117dac3897f0cf7cb90af.zip
Added an item_delay database usable for item-specific use delays.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14455 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-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
4 files changed, 76 insertions, 4 deletions
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)