summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2020-08-22 14:03:02 +0000
committergumi <git@gumi.ca>2020-08-22 14:03:02 +0000
commitf47ed38b0e286c059d7f4ca9a36676788a6177e9 (patch)
treef8d1004e1ed1a144ec4d51f5ec067ab85be291f6
parentb5cc367814b76f960f7366352a2a23d5cb1e7ab9 (diff)
parent6ecfee0a8a9a84ccb659bd41dfb9f108eeffb9e7 (diff)
downloadplugin-f47ed38b0e286c059d7f4ca9a36676788a6177e9.tar.gz
plugin-f47ed38b0e286c059d7f4ca9a36676788a6177e9.tar.bz2
plugin-f47ed38b0e286c059d7f4ca9a36676788a6177e9.tar.xz
plugin-f47ed38b0e286c059d7f4ca9a36676788a6177e9.zip
Merge branch 'card-group' into 'master'
Allow to use item groups in AllowCards See merge request evol/evol-hercules!27
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/pc.c55
-rw-r--r--src/emap/pc.h5
-rw-r--r--src/emap/script.c6
-rwxr-xr-xtools/vars.sh5
5 files changed, 68 insertions, 4 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index 19eaea5..a4902ba 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -270,6 +270,7 @@ HPExport void plugin_init (void)
addHookPre(battle, weapon_attack, ebattle_weapon_attack_pre);
addHookPre(bg, team_warp, ebg_team_warp_pre);
addHookPre(pc, can_Adopt, epc_can_Adopt_pre);
+ addHookPre(pc, additem, epc_additem_pre);
addHookPre(pc, adoption, epc_adoption_pre);
addHookPre(pc, readparam, epc_readparam_pre);
addHookPre(pc, setparam, epc_setparam_pre);
diff --git a/src/emap/pc.c b/src/emap/pc.c
index 21e59aa..68b892c 100644
--- a/src/emap/pc.c
+++ b/src/emap/pc.c
@@ -461,6 +461,29 @@ int epc_setnewpc_post(int retVal,
return retVal;
}
+int epc_additem_pre(struct map_session_data **sdPtr __attribute__ ((unused)),
+ const struct item **item_dataPtr,
+ int *amountPtr __attribute__ ((unused)),
+ e_log_pick_type *log_typePtr __attribute__ ((unused)))
+{
+#ifndef IT_VIRTUAL
+ return 0;
+#endif
+
+ const struct item *item_data = *item_dataPtr;
+
+ if (item_data != NULL) {
+ struct item_data *data = itemdb->search(item_data->nameid);
+
+ if (data != NULL && data->type == IT_VIRTUAL) {
+ hookStop();
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
int epc_additem_post(int retVal,
struct map_session_data *sd,
const struct item *item_data,
@@ -542,11 +565,28 @@ bool epc_can_insert_card_into_post(bool retVal,
const int newCardId = sd->status.inventory[idx_card].nameid;
int cardAmountLimit = 0;
+ struct item_group *card_group = NULL;
+
for (f = 0; f < sz; f ++)
{
struct ItemCardExt *const card = &VECTOR_INDEX(data->allowedCards, f);
- if (card->id == newCardId)
- {
+ struct item_data *card_itemdata = itemdb->search(card->id);
+
+ if (card_itemdata->group != NULL) {
+ card_group = card_itemdata->group;
+
+ for (int c = 0; c < card_group->qty; c++) {
+ if (card_group->nameid[c] == newCardId) {
+ cardAmountLimit = card->amount;
+ break;
+ }
+ }
+
+ if (cardAmountLimit) {
+ // we found it in a group, so break
+ break;
+ }
+ } else if (card->id == newCardId) {
cardAmountLimit = card->amount;
break;
}
@@ -559,8 +599,17 @@ bool epc_can_insert_card_into_post(bool retVal,
for (f = 0; f < slots; f ++)
{
const int cardId = sd->status.inventory[idx_equip].card[f];
- if (cardId == newCardId)
+ if (cardId == newCardId) {
cardsAmount ++;
+ } else if (card_group != NULL) {
+ // use the same counter for all cards that belong to the group
+ for (int c = 0; c < card_group->qty; c++) {
+ if (card_group->nameid[c] == cardId) {
+ cardsAmount++;
+ break;
+ }
+ }
+ }
}
return cardAmountLimit > cardsAmount;
}
diff --git a/src/emap/pc.h b/src/emap/pc.h
index db1a912..1cbd3c1 100644
--- a/src/emap/pc.h
+++ b/src/emap/pc.h
@@ -63,6 +63,11 @@ int epc_setnewpc_post(int retVal,
int sex,
int fd);
+int epc_additem_pre(struct map_session_data **sdPtr,
+ const struct item **item_dataPtr,
+ int *amountPtr,
+ e_log_pick_type *log_typePtr);
+
int epc_additem_post(int retVal,
struct map_session_data *sd,
const struct item *item_data,
diff --git a/src/emap/script.c b/src/emap/script.c
index d2a64e4..778ebe0 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -109,6 +109,12 @@ void escript_hardcoded_constants_pre(void)
script->set_constant("NPCSUBTYPE_SCRIPT", SCRIPT, false, false);
script->set_constant("NPCSUBTYPE_CASHSHOP", CASHSHOP, false, false);
script->set_constant("NPCSUBTYPE_TOMB", TOMB, false, false);
+
+ // new item types
+#ifdef IT_VIRTUAL
+ script->set_constant("IT_VIRTUAL", IT_VIRTUAL, false, false);
+#endif
+
script->constdb_comment(NULL);
eskill_addskill_conststants();
}
diff --git a/tools/vars.sh b/tools/vars.sh
index 3571999..1f5a596 100755
--- a/tools/vars.sh
+++ b/tools/vars.sh
@@ -13,6 +13,7 @@ OLD_SC_MAX=677 # in src/map/status.h
OLD_MAX_SKILL_ID=10015 # in src/common/mmo.h
OLD_MAX_SKILL_DB=1510 # in src/common/mmo.h
OLD_MAX_SKILL_TREE=86 # in src/common/mmo.h
+OLD_IT_MAX=19 # in src/common/mmo.h
# constants:
EVOL_FIRST_SKILL=20000 # skills have to be saved to SQL so they shouldn't change ID
@@ -24,8 +25,10 @@ SC_MAX=$(($OLD_SC_MAX + $MAX_EVOL_SC))
SI_MAX=$(($OLD_SI_MAX + $MAX_EVOL_SI))
CUSTOM_SKILL_RANGES="{${EVOL_FIRST_SKILL},${MAX_SKILL_ID}},"
MAX_SKILL_TREE=$(($OLD_MAX_SKILL_TREE + $MAX_EVOL_SKILLS))
+IT_VIRTUAL=$(($OLD_IT_MAX + 1))
+IT_MAX=$(($IT_VIRTUAL + 1))
# can be used for custom skill id: 10016 - 10036
-export VARS=" -DOLD_SI_MAX=${OLD_SI_MAX} -DOLD_SC_MAX=${OLD_SC_MAX} -DOLD_MAX_SKILL_DB=${OLD_MAX_SKILL_DB} -DMAX_SKILL_DB=${MAX_SKILL_DB} -DMAX_SKILL_ID=${MAX_SKILL_ID} -DMAX_EVOL_SKILLS=${MAX_EVOL_SKILLS} -DEVOL_FIRST_SKILL=${EVOL_FIRST_SKILL} -DCUSTOM_SKILL_RANGES=\"${CUSTOM_SKILL_RANGES}\" -DMAX_SKILL_TREE=${MAX_SKILL_TREE} -DSC_MAX=${SC_MAX} -DSI_MAX=${SI_MAX} -DBASE_GUILD_SIZE=100 -DMIN_PACKET_DB=0x63 -DMAX_PACKET_DB=0x7531"
+export VARS=" -DOLD_SI_MAX=${OLD_SI_MAX} -DOLD_SC_MAX=${OLD_SC_MAX} -DOLD_MAX_SKILL_DB=${OLD_MAX_SKILL_DB} -DMAX_SKILL_DB=${MAX_SKILL_DB} -DMAX_SKILL_ID=${MAX_SKILL_ID} -DMAX_EVOL_SKILLS=${MAX_EVOL_SKILLS} -DEVOL_FIRST_SKILL=${EVOL_FIRST_SKILL} -DCUSTOM_SKILL_RANGES=\"${CUSTOM_SKILL_RANGES}\" -DMAX_SKILL_TREE=${MAX_SKILL_TREE} -DSC_MAX=${SC_MAX} -DSI_MAX=${SI_MAX} -DBASE_GUILD_SIZE=100 -DMIN_PACKET_DB=0x63 -DMAX_PACKET_DB=0x7531 -DIT_VIRTUAL=${IT_VIRTUAL} -DIT_MAX=${IT_MAX}"
export CPPFLAGS="${VARS}"