diff options
author | Haru <haru@dotalux.com> | 2020-01-12 18:05:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-12 18:05:50 +0100 |
commit | 45b8982191160dc5f5ffc28e0eb8b28c6b8a138b (patch) | |
tree | e478723e7253df646d0c2c051b4a7dfb39e0e201 | |
parent | fae84f28068f5c1893f90bc63eb2ef83351feb21 (diff) | |
parent | f8d457ea0e6b0d97785eb75b1dc6e00387dc94e5 (diff) | |
download | hercules-45b8982191160dc5f5ffc28e0eb8b28c6b8a138b.tar.gz hercules-45b8982191160dc5f5ffc28e0eb8b28c6b8a138b.tar.bz2 hercules-45b8982191160dc5f5ffc28e0eb8b28c6b8a138b.tar.xz hercules-45b8982191160dc5f5ffc28e0eb8b28c6b8a138b.zip |
Merge pull request #2603 from Asheraf/neoinsurance
Add support for auto exp insurance items
-rw-r--r-- | db/pre-re/item_chain.conf | 4 | ||||
-rw-r--r-- | db/pre-re/item_db.conf | 7 | ||||
-rw-r--r-- | db/re/item_chain.conf | 4 | ||||
-rw-r--r-- | src/map/itemdb.c | 5 | ||||
-rw-r--r-- | src/map/itemdb.h | 1 | ||||
-rw-r--r-- | src/map/pc.c | 29 | ||||
-rw-r--r-- | src/map/pc.h | 3 |
7 files changed, 46 insertions, 7 deletions
diff --git a/db/pre-re/item_chain.conf b/db/pre-re/item_chain.conf index cdc92d92c..b00447bb2 100644 --- a/db/pre-re/item_chain.conf +++ b/db/pre-re/item_chain.conf @@ -125,3 +125,7 @@ ITMCHAIN_FOOD: { Banana: 100 Apple: 600 } + +ITMCHAIN_NEO_INSURANCE: { + New_Insurance: 1 +} diff --git a/db/pre-re/item_db.conf b/db/pre-re/item_db.conf index 199416825..8be95353c 100644 --- a/db/pre-re/item_db.conf +++ b/db/pre-re/item_db.conf @@ -55846,6 +55846,13 @@ item_db: ( Weight: 10 }, { + Id: 6413 + AegisName: "New_Insurance" + Name: "New Insurance" + Buy: 2 + Weight: 10 +}, +{ Id: 6415 AegisName: "Strange_Embryo" Name: "Strange Embryo" diff --git a/db/re/item_chain.conf b/db/re/item_chain.conf index cdc92d92c..b00447bb2 100644 --- a/db/re/item_chain.conf +++ b/db/re/item_chain.conf @@ -125,3 +125,7 @@ ITMCHAIN_FOOD: { Banana: 100 Apple: 600 } + +ITMCHAIN_NEO_INSURANCE: { + New_Insurance: 1 +} diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 5dc3d9317..b016af1c9 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1552,6 +1552,11 @@ static void itemdb_read_chains(void) else itemdb->chain_cache[ECC_SIEGFRIED] = i; + if (!script->get_constant("ITMCHAIN_NEO_INSURANCE", &i)) + ShowWarning("itemdb_read_chains: failed to find 'ITMCHAIN_NEO_INSURANCE' chain to link to cache!\n"); + else + itemdb->chain_cache[ECC_NEO_INSURANCE] = i; + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename); } diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 14ead7707..ecdcbcafc 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -359,6 +359,7 @@ enum geneticist_item_list { enum e_chain_cache { ECC_ORE, ECC_SIEGFRIED, + ECC_NEO_INSURANCE, /* */ ECC_MAX, }; diff --git a/src/map/pc.c b/src/map/pc.c index 179a4b78a..6ea3b3393 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8189,6 +8189,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) && pc->isDeathPenaltyJob(sd->job) && !map->list[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m) && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY] + && !pc->auto_exp_insurance(sd) ) { if (battle_config.death_penalty_base > 0) { unsigned int base_penalty = 0; @@ -12162,15 +12163,15 @@ static int pc_have_magnifier(struct map_session_data *sd) /** * checks if player have any item that listed in item chain * @param sd map_session_data of Player - * @param chain_id unsigned short of item chain id + * @param chain_cache_id cache id of item chain * @return index of inventory, INDEX_NOT_FOUND if it is not found */ -static int pc_have_item_chain(struct map_session_data *sd, unsigned short chain_id) +static int pc_have_item_chain(struct map_session_data *sd, enum e_chain_cache chain_cache_id) { - if (chain_id >= itemdb->chain_count) { - ShowError("itemdb_chain_item: unknown chain id %d\n", chain_id); - return INDEX_NOT_FOUND; - } + nullpo_retr(INDEX_NOT_FOUND, sd); + Assert_retr(INDEX_NOT_FOUND, chain_cache_id >= ECC_ORE && chain_cache_id < ECC_MAX); + + int chain_id = itemdb->chain_cache[chain_cache_id]; for (int n = 0; n < itemdb->chains[chain_id].qty; n++) { struct item_chain_entry *entry = &itemdb->chains[chain_id].items[n]; @@ -12392,6 +12393,21 @@ static bool pc_expandInventory(struct map_session_data *sd, int adjustSize) return true; } +static bool pc_auto_exp_insurance(struct map_session_data *sd) +{ + nullpo_retr(false, sd); + + int item_position = pc->have_item_chain(sd, ECC_NEO_INSURANCE); + if (item_position == INDEX_NOT_FOUND) + return false; + + pc->delitem(sd, item_position, 1, 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME); +#if PACKETVER >= 20100914 + clif->msgtable(sd, MSG_NOTIFY_NEO_INSURANCE_ITEM_USE); +#endif + return true; +} + static void do_final_pc(void) { @@ -12798,4 +12814,5 @@ void pc_defaults(void) pc->isDeathPenaltyJob = pc_isDeathPenaltyJob; pc->has_second_costume = pc_has_second_costume; pc->expandInventory = pc_expandInventory; + pc->auto_exp_insurance = pc_auto_exp_insurance; } diff --git a/src/map/pc.h b/src/map/pc.h index 7a42be5be..5957a3319 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1186,7 +1186,7 @@ END_ZEROED_BLOCK; /* End */ void (*update_idle_time) (struct map_session_data* sd, enum e_battle_config_idletime type); int (*have_magnifier) (struct map_session_data *sd); - int (*have_item_chain) (struct map_session_data *sd, unsigned short chain_id); + int (*have_item_chain) (struct map_session_data *sd, enum e_chain_cache chain_cache_id); bool (*process_chat_message) (struct map_session_data *sd, const char *message); int (*wis_message_to_gm) (const char *sender_name, int permission, const char *message); @@ -1196,6 +1196,7 @@ END_ZEROED_BLOCK; /* End */ bool (*isDeathPenaltyJob) (uint16 job); bool (*has_second_costume) (struct map_session_data *sd); bool (*expandInventory) (struct map_session_data *sd, int adjustSize); + bool (*auto_exp_insurance) (struct map_session_data *sd); }; #ifdef HERCULES_CORE |