summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c136
1 files changed, 53 insertions, 83 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 24f71f47b..2cefa7674 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -565,72 +565,8 @@ static int pc_inventory_rental_clear(struct map_session_data *sd)
/* assumes i is valid (from default areas where it is called, it is) */
static void pc_rental_expire(struct map_session_data *sd, int i)
{
- int nameid;
-
nullpo_retv(sd);
Assert_retv(i >= 0 && i < sd->status.inventorySize);
- nameid = sd->status.inventory[i].nameid;
-
- /* Soon to be dropped, we got plans to integrate it with item db */
- switch( nameid ) {
- case ITEMID_BOARDING_HALTER:
- status_change_end(&sd->bl,SC_ALL_RIDING,INVALID_TIMER);
- break;
- case ITEMID_LOVE_ANGEL:
- if( sd->status.font == 1 ) {
- sd->status.font = 0;
- clif->font(sd);
- }
- break;
- case ITEMID_SQUIRREL:
- if( sd->status.font == 2 ) {
- sd->status.font = 0;
- clif->font(sd);
- }
- break;
- case ITEMID_GOGO:
- if( sd->status.font == 3 ) {
- sd->status.font = 0;
- clif->font(sd);
- }
- break;
- case ITEMID_PICTURE_DIARY:
- if( sd->status.font == 4 ) {
- sd->status.font = 0;
- clif->font(sd);
- }
- break;
- case ITEMID_MINI_HEART:
- if( sd->status.font == 5 ) {
- sd->status.font = 0;
- clif->font(sd);
- }
- break;
- case ITEMID_NEWCOMER:
- if( sd->status.font == 6 ) {
- sd->status.font = 0;
- clif->font(sd);
- }
- break;
- case ITEMID_KID:
- if( sd->status.font == 7 ) {
- sd->status.font = 0;
- clif->font(sd);
- }
- break;
- case ITEMID_MAGIC_CASTLE:
- if( sd->status.font == 8 ) {
- sd->status.font = 0;
- clif->font(sd);
- }
- break;
- case ITEMID_BULGING_HEAD:
- if( sd->status.font == 9 ) {
- sd->status.font = 0;
- clif->font(sd);
- }
- break;
- }
clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_RENTAL);
@@ -1536,17 +1472,16 @@ static int pc_reg_received(struct map_session_data *sd)
if (sd->status.guild_id)
guild->member_joined(sd);
- // pet
- if (sd->status.pet_id > 0)
- intif->request_petdata(sd->status.account_id, sd->status.char_id, sd->status.pet_id);
-
- // Homunculus [albator]
- if( sd->status.hom_id > 0 )
- intif->homunculus_requestload(sd->status.account_id, sd->status.hom_id);
- if( sd->status.mer_id > 0 )
- intif->mercenary_request(sd->status.mer_id, sd->status.char_id);
- if( sd->status.ele_id > 0 )
- intif->elemental_request(sd->status.ele_id, sd->status.char_id);
+ if (sd->state.standalone == 0 && sd->state.autotrade == 0) { // prevents loading pets, homunculi, mercenaries or elementals if the character doesn't have a client attached
+ if (sd->status.pet_id != 0)
+ intif->request_petdata(sd->status.account_id, sd->status.char_id, sd->status.pet_id);
+ if (sd->status.hom_id != 0)
+ intif->homunculus_requestload(sd->status.account_id, sd->status.hom_id);
+ if (sd->status.mer_id != 0)
+ intif->mercenary_request(sd->status.mer_id, sd->status.char_id);
+ if (sd->status.ele_id != 0)
+ intif->elemental_request(sd->status.ele_id, sd->status.char_id);
+ }
map->addiddb(&sd->bl);
map->delnickdb(sd->status.char_id, sd->status.name);
@@ -4790,13 +4725,15 @@ static int pc_additem(struct map_session_data *sd, const struct item *item_data,
pc->equipitem(sd, i, data->equip);
/* rental item check */
- if( item_data->expire_time ) {
- if( time(NULL) > item_data->expire_time ) {
- pc->rental_expire(sd,i);
+ if (item_data->expire_time > 0) {
+ if (time(NULL) > item_data->expire_time) {
+ pc->rental_expire(sd, i);
} else {
- int seconds = (int)( item_data->expire_time - time(NULL) );
+ int seconds = (int)(item_data->expire_time - time(NULL));
clif->rental_time(sd->fd, sd->status.inventory[i].nameid, seconds);
pc->inventory_rental_add(sd, seconds);
+ if (data->rental_start_script != NULL)
+ script->run_item_rental_start_script(sd, data, 0);
}
}
quest->questinfo_refresh(sd);
@@ -4827,12 +4764,21 @@ static int pc_delitem(struct map_session_data *sd, int n, int amount, int type,
sd->status.inventory[n].amount -= amount;
sd->weight -= sd->inventory_data[n]->weight*amount ;
+
+ // It's here because the data would most likely get zeroed in following if [Hemagx]
+ struct item_data *itd = sd->inventory_data[n];
+ bool is_rental = (sd->status.inventory[n].expire_time > 0) ? true : false;
+
if( sd->status.inventory[n].amount <= 0 ){
if(sd->status.inventory[n].equip)
pc->unequipitem(sd, n, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0]));
sd->inventory_data[n] = NULL;
}
+
+ if (is_rental && itd->rental_end_script != NULL)
+ script->run_item_rental_end_script(sd, itd, 0);
+
if(!(type&1))
clif->delitem(sd,n,amount,reason);
if(!(type&2))
@@ -7765,7 +7711,7 @@ static int pc_resetskill(struct map_session_data *sd, int flag)
pc->setoption(sd, i);
if( homun_alive(sd->hd) && pc->checkskill(sd, AM_CALLHOMUN) )
- homun->vaporize(sd, HOM_ST_REST);
+ homun->vaporize(sd, HOM_ST_REST, true);
if ((sd->sc.data[SC_SPRITEMABLE] && pc->checkskill(sd, SU_SPRITEMABLE)))
status_change_end(&sd->bl, SC_SPRITEMABLE, INVALID_TIMER);
@@ -8006,7 +7952,7 @@ static void pc_damage(struct map_session_data *sd, struct block_list *src, unsig
if( sd->status.pet_id > 0 && sd->pd && battle_config.pet_damage_support )
pet->target_check(sd,src,1);
- if( sd->status.ele_id > 0 )
+ if (sd->status.ele_id != 0 && sd->ed != NULL)
elemental->set_target(sd,src);
if (battle_config.prevent_logout_trigger & PLT_DAMAGE)
@@ -8054,7 +8000,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src)
if (sd->status.hom_id > 0){
if(battle_config.homunculus_auto_vapor && sd->hd)
- homun->vaporize(sd, HOM_ST_REST);
+ homun->vaporize(sd, HOM_ST_REST, true);
}
if( sd->md )
@@ -9069,7 +9015,7 @@ static int pc_jobchange(struct map_session_data *sd, int class, int upper)
pc->setoption(sd, i);
if(homun_alive(sd->hd) && !pc->checkskill(sd, AM_CALLHOMUN))
- homun->vaporize(sd, HOM_ST_REST);
+ homun->vaporize(sd, HOM_ST_REST, true);
if ((sd->sc.data[SC_SPRITEMABLE] && pc->checkskill(sd, SU_SPRITEMABLE)))
status_change_end(&sd->bl, SC_SPRITEMABLE, INVALID_TIMER);
@@ -12215,6 +12161,29 @@ 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
+ * @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)
+{
+ if (chain_id >= itemdb->chain_count) {
+ ShowError("itemdb_chain_item: unknown chain id %d\n", chain_id);
+ return INDEX_NOT_FOUND;
+ }
+
+ for (int n = 0; n < itemdb->chains[chain_id].qty; n++) {
+ struct item_chain_entry *entry = &itemdb->chains[chain_id].items[n];
+ int index = pc->search_inventory(sd, entry->id);
+ if (index != INDEX_NOT_FOUND)
+ return index;
+ }
+
+ return INDEX_NOT_FOUND;
+}
+
+/**
* Checks if player have basic skills learned.
* @param sd Player Data
* @param level Required Level of Novice Skill
@@ -12823,6 +12792,7 @@ void pc_defaults(void)
pc->update_idle_time = pc_update_idle_time;
pc->have_magnifier = pc_have_magnifier;
+ pc->have_item_chain = pc_have_item_chain;
pc->check_basicskill = pc_check_basicskill;