diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 9 | ||||
-rw-r--r-- | src/map/clif.c | 139 | ||||
-rw-r--r-- | src/map/clif.h | 5 | ||||
-rw-r--r-- | src/map/guild.c | 2 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/party.c | 2 | ||||
-rw-r--r-- | src/map/pc.c | 160 | ||||
-rw-r--r-- | src/map/pc.h | 5 | ||||
-rw-r--r-- | src/map/script.c | 27 | ||||
-rw-r--r-- | src/map/trade.c | 2 |
10 files changed, 207 insertions, 145 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 7a202d3fd..917d119bf 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -7536,9 +7536,7 @@ int atcommand_whereis(const int fd, struct map_session_data* sd, const char* com *------------------------------------------*/ int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message) { - struct map_session_data *pl_sd1 = NULL; - struct map_session_data *pl_sd2 = NULL; - struct map_session_data *pl_sd3 = NULL; + struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3; char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH]; char output[256]; @@ -7570,7 +7568,7 @@ int atcommand_adopt(const int fd, struct map_session_data* sd, const char* comma return -1; } - if( pc_adoption(pl_sd1, pl_sd2, pl_sd3) != 0 ) { + if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) { return -1; } @@ -8218,7 +8216,10 @@ int atcommand_auction(const int fd, struct map_session_data *sd, const char *com { nullpo_retr(0,sd); +#ifndef TXT_ONLY clif_Auction_openwindow(sd); +#endif + return 0; } diff --git a/src/map/clif.c b/src/map/clif.c index 3f6cf94f6..f910e5418 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5311,7 +5311,7 @@ int clif_party_member_info(struct party_data *p, struct map_session_data *sd) WBUFW(buf, 0) = 0x1e9; WBUFL(buf, 2) = sd->status.account_id; - WBUFL(buf, 6) = 0; //Apparently setting this to 1 makes you adoptable. + WBUFL(buf, 6) = 0; WBUFW(buf,10) = sd->bl.x; WBUFW(buf,12) = sd->bl.y; WBUFB(buf,14) = 0; //Unconfirmed byte, could be online/offline. @@ -6735,19 +6735,7 @@ void clif_callpartner(struct map_session_data *sd) return; } */ -/*========================================== - * Adopt baby [Celest] - *------------------------------------------*/ -void clif_adopt_process(struct map_session_data *sd) -{ - int fd; - nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x1f8)); - WFIFOW(fd,0)=0x1f8; - WFIFOSET(fd,packet_len(0x1f8)); -} /*========================================== * Marry [DracoRPG] *------------------------------------------*/ @@ -6781,18 +6769,6 @@ void clif_divorced(struct map_session_data* sd, const char* name) /*========================================== * *------------------------------------------*/ -void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) -{ - nullpo_retv(sd); - - WFIFOHEAD(fd,packet_len(0x1f6)); - WFIFOW(fd,0)=0x1f6; - WFIFOSET(fd, packet_len(0x1f6)); -} - -/*========================================== - * - *------------------------------------------*/ void clif_parse_ReqMarriage(int fd, struct map_session_data *sd) { nullpo_retv(sd); @@ -7959,7 +7935,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) //Login Event npc_script_event(sd, NPCE_LOGIN); mob_barricade_get(sd); - } else if( sd->state.changemap ) { + } else { //For some reason the client "loses" these on map-change. clif_updatestatus(sd,SP_STR); clif_updatestatus(sd,SP_AGI); @@ -7967,15 +7943,20 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) clif_updatestatus(sd,SP_INT); clif_updatestatus(sd,SP_DEX); clif_updatestatus(sd,SP_LUK); + } - //New 'night' effect by dynamix [Skotlex] + if( sd->state.changemap ) + { if (night_flag && map[sd->bl.m].flag.nightenabled) { //Display night. - if (!sd->state.night) { + if( !sd->state.night ) + { sd->state.night = 1; clif_status_load(&sd->bl, SI_NIGHT, 1); } - } else if (sd->state.night) { //Clear night display. + } + else if( sd->state.night ) + { //Clear night display. sd->state.night = 0; clif_status_load(&sd->bl, SI_NIGHT, 0); } @@ -11216,24 +11197,6 @@ void clif_parse_ReqFeel(int fd, struct map_session_data *sd, int skilllv) sd->menuskill_val = skilllv; } -void clif_parse_AdoptRequest(int fd,struct map_session_data *sd) -{ - //TODO: add somewhere the adopt code, checks for exploits, etc, etc. - //Missing packets are the client's reply packets to the adopt request one. - //[Skotlex] - int account_id; - struct map_session_data *sd2; - - account_id = RFIFOL(fd,2); - sd2 = map_id2sd(account_id); - if(sd2 && sd2->fd && sd2 != sd && sd2->status.party_id == sd->status.party_id) { //FIXME: No checks whatsoever are in place yet! - fd = sd2->fd; - WFIFOHEAD(fd,packet_len(0x1f9)); - WFIFOW(fd,0)=0x1f9; - WFIFOSET(fd, packet_len(0x1f9)); - } -} - /*========================================== * Homunculus packets *------------------------------------------*/ @@ -11725,6 +11688,24 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) * AUCTION SYSTEM * By Zephyrus *==========================================*/ +void clif_Auction_openwindow(struct map_session_data *sd) +{ + int fd = sd->fd; + + if( sd->state.storage_flag || sd->vender_id || sd->state.trading ) + return; + + WFIFOHEAD(fd,12); + WFIFOW(fd,0) = 0x25f; + WFIFOL(fd,2) = 0; + WFIFOB(fd,6) = 0xb6; + WFIFOB(fd,7) = 0x00; + WFIFOB(fd,8) = 0xa6; + WFIFOB(fd,9) = 0xde; + WFIFOW(fd,10) = 0; + WFIFOSET(fd,12); +} + void clif_Auction_results(struct map_session_data *sd, short count, short pages, unsigned char *buf) { int i, fd = sd->fd, len = sizeof(struct auction_data); @@ -12039,24 +12020,59 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) } /*========================================== - * AUCTIONS SYSTEM + * Adoption System *==========================================*/ -void clif_Auction_openwindow(struct map_session_data *sd) + +// 0 : You cannot adopt more that 1 son +// 1 : You should be at least lvl 70 to adopt +// 2 : You cannot adopt a married player +void clif_Adopt_reply(struct map_session_data *sd, int type) { int fd = sd->fd; - if( sd->state.storage_flag || sd->vender_id || sd->state.trading ) - return; + WFIFOHEAD(fd,6); + WFIFOW(fd,0) = 0x0216; + WFIFOL(fd,2) = type; + WFIFOSET(fd,6); +} - WFIFOHEAD(fd,12); - WFIFOW(fd,0) = 0x25f; - WFIFOL(fd,2) = 0; - WFIFOB(fd,6) = 0xb6; - WFIFOB(fd,7) = 0x00; - WFIFOB(fd,8) = 0xa6; - WFIFOB(fd,9) = 0xde; - WFIFOW(fd,10) = 0; - WFIFOSET(fd,12); +void clif_Adopt_request(struct map_session_data *sd, struct map_session_data *src, int p_id) +{ + int fd = sd->fd; + + WFIFOSET(fd,34); + WFIFOW(fd,0) = 0x01f6; + WFIFOL(fd,2) = src->status.account_id; + WFIFOL(fd,6) = p_id; + memcpy(WFIFOP(fd,10), src->status.name, NAME_LENGTH); + WFIFOSET(fd,34); +} + +void clif_parse_Adopt_request(int fd, struct map_session_data *sd) +{ + struct map_session_data *tsd = map_id2sd(RFIFOL(fd,2)), *p_sd = map_charid2sd(sd->status.partner_id); + + if( pc_can_Adopt(sd, tsd, p_sd) ) + { + tsd->adopt_invite = sd->status.account_id; + clif_Adopt_request(tsd, sd, p_sd->status.account_id); + } +} + +void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) +{ + struct map_session_data *p1_sd = map_id2sd(RFIFOL(fd,2)), *p2_sd = map_id2sd(RFIFOL(fd,6)); + int result = RFIFOL(fd,10), pid = sd->adopt_invite; + + sd->adopt_invite = 0; + + if( pid != p1_sd->status.account_id ) + return; // Not the same sender + + if( pc_can_Adopt(p1_sd, p2_sd, sd) ) + { + // Lets do the adoption!! + } } /*========================================== @@ -12497,7 +12513,6 @@ static int packetdb_readdb(void) {clif_parse_Taekwon,"taekwon"}, {clif_parse_RankingPk,"rankingpk"}, {clif_parse_FeelSaveOk,"feelsaveok"}, - {clif_parse_AdoptRequest,"adopt"}, {clif_parse_debug,"debug"}, {clif_parse_ChangeHomunculusName,"changehomunculusname"}, {clif_parse_HomMoveToMaster,"hommovetomaster"}, @@ -12508,6 +12523,8 @@ static int packetdb_readdb(void) {clif_parse_Hotkey,"hotkey"}, {clif_parse_AutoRevive,"autorevive"}, {clif_parse_Check,"check"}, + {clif_parse_Adopt_request,"adoptrequest"}, + {clif_parse_Adopt_reply,"adoptreply"}, #ifndef TXT_ONLY // MAIL SYSTEM {clif_parse_Mail_refreshinbox,"mailrefresh"}, diff --git a/src/map/clif.h b/src/map/clif.h index 286eaa6f1..8c48b7277 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -408,6 +408,7 @@ void clif_Mail_new(int fd, int mail_id, const char *sender, const char *title); void clif_Mail_refreshinbox(struct map_session_data *sd); void clif_Mail_getattachment(int fd, uint8 flag); // AUCTION SYSTEM +void clif_Auction_openwindow(struct map_session_data *sd); void clif_Auction_results(struct map_session_data *sd, short count, short pages, unsigned char *buf); void clif_Auction_message(int fd, unsigned char flag); void clif_Auction_close(int fd, unsigned char flag); @@ -416,7 +417,7 @@ void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd); void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd); -// AUCTION SYSTEM -void clif_Auction_openwindow(struct map_session_data *sd); +// ADOPTION +void clif_Adopt_reply(struct map_session_data *sd, int type); #endif /* _CLIF_H_ */ diff --git a/src/map/guild.c b/src/map/guild.c index 5644793b2..ed35aaccb 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -618,7 +618,7 @@ int guild_invite(struct map_session_data *sd,struct map_session_data *tsd) return 0; //Invite permission. if(!battle_config.invite_request_check) { - if (tsd->party_invite>0 || tsd->trade_partner) { // 相手が取引中かどうか + if (tsd->party_invite>0 || tsd->trade_partner || tsd->adopt_invite ) { // 相手が取引中かどうか clif_guild_inviteack(sd,0); return 0; } diff --git a/src/map/map.h b/src/map/map.h index c15af9b79..611e55d6e 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -746,6 +746,7 @@ struct map_session_data { } deal; int party_invite,party_invite_account; + int adopt_invite; // Adoption int guild_invite,guild_invite_account; int guild_emblem_id,guild_alliance,guild_alliance_account; diff --git a/src/map/party.c b/src/map/party.c index be89f6345..2e5370a80 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -288,7 +288,7 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd) } if(!battle_config.invite_request_check) { - if (tsd->guild_invite>0 || tsd->trade_partner) { + if (tsd->guild_invite>0 || tsd->trade_partner || tsd->adopt_invite) { clif_party_inviteack(sd,tsd->status.name,0); return 0; } diff --git a/src/map/pc.c b/src/map/pc.c index a06f1c474..9d8ef409b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -537,6 +537,119 @@ static int pc_isAllowedCardOn(struct map_session_data *sd,int s,int eqindex,int return 1; } +bool pc_isequipped(struct map_session_data *sd, int nameid) +{ + int i, j, index; + + for( i = 0; i < EQI_MAX; i++ ) + { + index = sd->equip_index[i]; + if( index < 0 ) continue; + + if( i == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index ) continue; + if( i == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index ) continue; + if( i == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index) ) continue; + + if( !sd->inventory_data[index] ) continue; + + if( sd->inventory_data[index]->nameid == nameid ) + return true; + + for( j = 0; j < sd->inventory_data[index]->slot; j++ ) + if( sd->status.inventory[index].card[j] == nameid ) + return true; + } + + return false; +} + +bool pc_can_Adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd ) +{ + if( !p1_sd || !p2_sd || !b_sd ) + return false; + + if( b_sd->status.father || b_sd->status.mother || b_sd->adopt_invite ) + return false; // allready adopted baby / in adopt request + + if( !p1_sd->status.partner_id || !p1_sd->status.party_id || p1_sd->status.party_id != b_sd->status.party_id ) + return false; // You need to be married and in party with baby to adopt + + if( p1_sd->status.partner_id != p2_sd->status.char_id || p2_sd->status.partner_id != p1_sd->status.char_id ) + return false; // Not married, wrong married + + if( p2_sd->status.party_id != p1_sd->status.party_id ) + return false; // Both parents need to be in the same party + + // Parents need to have their ring equipped + if( !pc_isequipped(p1_sd, WEDDING_RING_M) && !pc_isequipped(p1_sd, WEDDING_RING_F) ) + return false; + + if( !pc_isequipped(p2_sd, WEDDING_RING_M) && !pc_isequipped(p2_sd, WEDDING_RING_F) ) + return false; + + // Allready adopted a baby + if( p1_sd->status.child || p2_sd->status.child ) { + clif_Adopt_reply(p1_sd, 0); + return false; + } + + // Fathers need at least lvl 70 to adopt + if( p1_sd->status.base_level < 70 || p2_sd->status.base_level < 70 ) { + clif_Adopt_reply(p1_sd, 1); + return false; + } + + if( b_sd->status.partner_id ) { + clif_Adopt_reply(p1_sd, 2); + return false; + } + + return ( b_sd->status.class_ >= JOB_NOVICE && b_sd->status.class_ <= JOB_THIEF ); +} + +/*========================================== + * Adoption Process + *------------------------------------------*/ +bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd) +{ + int job, joblevel; + unsigned int jobexp; + + if( !pc_can_Adopt(p1_sd, p2_sd, b_sd) ) + return false; + + // Preserve current job levels and progress + joblevel = b_sd->status.job_level; + jobexp = b_sd->status.job_exp; + + job = pc_mapid2jobid(b_sd->class_|JOBL_BABY, b_sd->status.sex); + if( job != -1 && !pc_jobchange(b_sd, job, 0) ) + { // Success, proceed to configure parents and baby skills + p1_sd->status.child = b_sd->status.char_id; + p2_sd->status.child = b_sd->status.char_id; + b_sd->status.father = p1_sd->status.char_id; + b_sd->status.mother = p2_sd->status.char_id; + + // Restore progress + b_sd->status.job_level = joblevel; + clif_updatestatus(b_sd, SP_JOBLEVEL); + b_sd->status.job_exp = jobexp; + clif_updatestatus(b_sd, SP_JOBEXP); + + // Baby Skills + pc_skill(b_sd, WE_BABY, 1, 0); + pc_skill(b_sd, WE_CALLPARENT, 1, 0); + + // Parents Skills + pc_skill(p1_sd, WE_CALLBABY, 1, 0); + pc_skill(p1_sd, WE_CALLBABY, 1, 0); + + return true; + } + + return false; // Job Change Fail +} + int pc_isequip(struct map_session_data *sd,int n) { struct item_data *item; @@ -6712,53 +6825,6 @@ int pc_divorce(struct map_session_data *sd) } /*========================================== - * sd - father dstsd - mother jasd - child - *------------------------------------------*/ -int pc_adoption(struct map_session_data *sd,struct map_session_data *dstsd, struct map_session_data *jasd) -{ - int j,level, job; - unsigned int exp; - if (sd == NULL || dstsd == NULL || jasd == NULL || - sd->status.partner_id <= 0 || dstsd->status.partner_id <= 0 || - sd->status.partner_id != dstsd->status.char_id || dstsd->status.partner_id != sd->status.char_id || - sd->status.child > 0 || dstsd->status.child || jasd->status.father > 0 || jasd->status.mother > 0) - return -1; - jasd->status.father = sd->status.char_id; - jasd->status.mother = dstsd->status.char_id; - sd->status.child = jasd->status.char_id; - dstsd->status.child = jasd->status.char_id; - - for (j=0; j < MAX_INVENTORY; j++) { - if(jasd->status.inventory[j].nameid>0 && jasd->status.inventory[j].equip!=0) - pc_unequipitem(jasd, j, 3); - } - - //Preserve level and exp. - level = jasd->status.job_level; - exp = jasd->status.job_exp; - job = jasd->class_|JOBL_BABY; //Preserve current Job by babyfying it. [Skotlex] - job = pc_mapid2jobid(job, jasd->status.sex); - if (job != -1 && pc_jobchange(jasd, job, 0) == 0) - { //Success, and give Junior the Baby skills. [Skotlex] - //Restore job level and experience. - jasd->status.job_level = level; - jasd->status.job_exp = exp; - clif_updatestatus(jasd,SP_JOBLEVEL); - clif_updatestatus(jasd,SP_JOBEXP); - pc_skill(jasd,WE_BABY,1,0); - pc_skill(jasd,WE_CALLPARENT,1,0); - clif_displaymessage(jasd->fd, msg_txt(12)); // Your job has been changed. - //We should also grant the parent skills to the parents [Skotlex] - pc_skill(sd,WE_CALLBABY,1,0); - pc_skill(dstsd,WE_CALLBABY,1,0); - } else { - clif_displaymessage(jasd->fd, msg_txt(155)); // Impossible to change your job. - return -1; - } - return 0; -} - -/*========================================== * sdの相方のmap_session_dataを返す *------------------------------------------*/ struct map_session_data *pc_get_partner(struct map_session_data *sd) diff --git a/src/map/pc.h b/src/map/pc.h index da032deed..7942aab9d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -190,6 +190,10 @@ int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount); int pc_takeitem(struct map_session_data*,struct flooritem_data*); int pc_dropitem(struct map_session_data*,int,int); +bool pc_isequipped(struct map_session_data *sd, int nameid); +bool pc_can_Adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd ); +bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd); + int pc_updateweightstatus(struct map_session_data *sd); int pc_autoscript_add(struct s_autoscript *scripts, int max, short rate, short flag, struct script_code *script); @@ -289,7 +293,6 @@ int pc_calc_pvprank_timer(int tid,unsigned int tick,int id,int data); int pc_ismarried(struct map_session_data *sd); int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd); int pc_divorce(struct map_session_data *sd); -int pc_adoption(struct map_session_data *sd,struct map_session_data *dstsd,struct map_session_data *jasd); struct map_session_data *pc_get_partner(struct map_session_data *sd); struct map_session_data *pc_get_father(struct map_session_data *sd); struct map_session_data *pc_get_mother(struct map_session_data *sd); diff --git a/src/map/script.c b/src/map/script.c index 36c29e8d5..438fde722 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11424,32 +11424,6 @@ BUILDIN_FUNC(getrefine) } /*======================================================= - * Allows 2 Parents to adopt a character as a Baby - *-------------------------------------------------------*/ -BUILDIN_FUNC(adopt) -{ - int ret; - - const char *parent1 = script_getstr(st,2); - const char *parent2 = script_getstr(st,3); - const char *child = script_getstr(st,4); - - TBL_PC *p1_sd = map_nick2sd(parent1); - TBL_PC *p2_sd = map_nick2sd(parent2); - TBL_PC *c_sd = map_nick2sd(child); - - if (!p1_sd || !p2_sd || !c_sd || - p1_sd->status.base_level < 70 || - p2_sd->status.base_level < 70) - return 0; - - ret = pc_adoption(p1_sd, p2_sd, c_sd); - script_pushint(st,ret); - - return 0; -} - -/*======================================================= * Day/Night controls *-------------------------------------------------------*/ BUILDIN_FUNC(night) @@ -13310,7 +13284,6 @@ struct script_function buildin_func[] = { BUILDIN_DEF(isequippedcnt,"i*"), // check how many items/cards are being equipped [Celest] BUILDIN_DEF(cardscnt,"i*"), // check how many items/cards are being equipped in the same arm [Lupus] BUILDIN_DEF(getrefine,"*"), // returns the refined number of the current item, or an item with index specified [celest] - BUILDIN_DEF(adopt,"sss"), // allows 2 parents to adopt a child BUILDIN_DEF(night,""), // sets the server to night time BUILDIN_DEF(day,""), // sets the server to day time #ifdef PCRE_SUPPORT diff --git a/src/map/trade.c b/src/map/trade.c index a9f2a2fd5..4371bf6a8 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -49,7 +49,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta } if (!battle_config.invite_request_check) { - if (target_sd->guild_invite > 0 || target_sd->party_invite > 0) { + if (target_sd->guild_invite > 0 || target_sd->party_invite > 0 || target_sd->adopt_invite) { clif_tradestart(sd, 2); return; } |