Added an item group for Token of Siegfried (#4047)

* Fixes #4041.
* Created an item group used to remove hard coding of Token of Siegfried.
* Added the other Token of Siegfried's to work with this feature.
Thanks to @daisyanne1380!
This commit is contained in:
Aleos 2019-04-19 10:33:35 -04:00 committed by GitHub
parent 21a5854c16
commit 53f5013149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 8 deletions

View File

@ -644,3 +644,7 @@ IG_Mercenary,12179,1 // SpearMercenary_Scroll7
IG_Mercenary,12180,1 // SpearMercenary_Scroll8
IG_Mercenary,12181,1 // SpearMercenary_Scroll9
IG_Mercenary,12182,1 // SpearMercenary_Scroll10
// Token of Siegfried
IG_Token_Of_Siegfried,6293,1 // F_Token_Of_Siegfried
IG_Token_Of_Siegfried,6316,1 // E_Token_Of_Siegfried
IG_Token_Of_Siegfried,7621,1 // Token_Of_Siegfried

View File

@ -1403,3 +1403,7 @@ IG_PrizeOfHero,22037,2 // Vet_Ungo_Boots
// Private Airship items
IG_PRIVATE_AIRSHIP,6909,1 // Actinidia_Cat_Fruit
IG_PRIVATE_AIRSHIP,25464,1 // World_Moving_Rights
// Token of Siegfried
IG_Token_Of_Siegfried,6293,1 // F_Token_Of_Siegfried
IG_Token_Of_Siegfried,6316,1 // E_Token_Of_Siegfried
IG_Token_Of_Siegfried,7621,1 // Token_Of_Siegfried

View File

@ -14935,22 +14935,20 @@ void clif_parse_HomMenu(int fd, struct map_session_data *sd)
/// 0292
void clif_parse_AutoRevive(int fd, struct map_session_data *sd)
{
short item_position = pc_search_inventory(sd, ITEMID_TOKEN_OF_SIEGFRIED);
if (sd->sc.data[SC_HELLPOWER]) // Cannot resurrect while under the effect of SC_HELLPOWER.
return;
int16 item_position = itemdb_group_item_exists_pc(sd, IG_TOKEN_OF_SIEGFRIED);
uint8 hp = 100, sp = 100;
if (item_position < 0) {
if (sd->sc.data[SC_LIGHT_OF_REGENE]) {
// HP restored
hp = sd->sc.data[SC_LIGHT_OF_REGENE]->val2;
sp = 0;
}
else
} else
return;
}
if (sd->sc.data[SC_HELLPOWER]) //Cannot res while under the effect of SC_HELLPOWER.
return;
if (!status_revive(&sd->bl, hp, sp))
return;

View File

@ -51,6 +51,7 @@ struct s_item_group_db *itemdb_group_exists(unsigned short group_id) {
/**
* Check if an item exists in a group
* @param group_id: Item Group ID
* @param nameid: Item to check for in group
* @return True if item is in group, else false
*/
@ -70,6 +71,30 @@ bool itemdb_group_item_exists(unsigned short group_id, unsigned short nameid)
return false;
}
/**
* Check if an item exists from a group in a player's inventory
* @param group_id: Item Group ID
* @return Item's index if found or -1 otherwise
*/
int16 itemdb_group_item_exists_pc(struct map_session_data *sd, unsigned short group_id)
{
struct s_item_group_db *group = (struct s_item_group_db *)uidb_get(itemdb_group, group_id);
if (!group)
return -1;
for (int i = 0; i < MAX_ITEMGROUP_RANDGROUP; i++) {
for (int j = 0; j < group->random[i].data_qty; j++) {
int16 item_position = pc_search_inventory(sd, group->random[i].data[j].nameid);
if (item_position != -1)
return item_position;
}
}
return -1;
}
/**
* Search for item name
* name = item alias, so we should find items aliases first. if not found then look for "jname" (full name)

View File

@ -87,7 +87,6 @@ enum item_itemid
ITEMID_COATING_BOTTLE = 7139,
ITEMID_FRAGMENT_OF_CRYSTAL = 7321,
ITEMID_SKULL_ = 7420,
ITEMID_TOKEN_OF_SIEGFRIED = 7621,
ITEMID_TRAP_ALLOY = 7940,
ITEMID_MERCENARY_RED_POTION = 12184,
ITEMID_MERCENARY_BLUE_POTION = 12185,
@ -732,6 +731,7 @@ enum e_random_item_group {
IG_SANTA_GIFT,
IG_PRIZEOFHERO,
IG_PRIVATE_AIRSHIP,
IG_TOKEN_OF_SIEGFRIED,
};
/// Enum for bound/sell restricted selling
@ -953,6 +953,7 @@ struct item_combo *itemdb_combo_exists(unsigned short combo_id);
struct s_item_group_db *itemdb_group_exists(unsigned short group_id);
bool itemdb_group_item_exists(unsigned short group_id, unsigned short nameid);
int16 itemdb_group_item_exists_pc(struct map_session_data *sd, unsigned short group_id);
char itemdb_pc_get_itemgroup(uint16 group_id, bool identify, struct map_session_data *sd);
bool itemdb_parse_roulette_db(void);

View File

@ -4823,6 +4823,7 @@
export_constant(IG_SANTA_GIFT);
export_constant(IG_PRIZEOFHERO);
export_constant(IG_PRIVATE_AIRSHIP);
export_constant(IG_TOKEN_OF_SIEGFRIED);
/* unit stop walking */
export_constant(USW_NONE);