/// Invoked (from char-server) when a party member leaves the party. int party_member_leaved(int party_id, int account_id, int char_id) { struct map_session_data* sd = map_id2sd(account_id); struct party_data* p = party_search(party_id); int i; if( p ) { ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id ); if( i < MAX_PARTY ) { clif_party_leaved(p,sd,account_id,p->party.member[i].name,0x00); memset(&p->party.member[i], 0, sizeof(p->party.member[0])); memset(&p->data[i], 0, sizeof(p->data[0])); p->party.count--; party_check_state(p); } } if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id ) { sd->status.party_id = 0; clif_charnameupdate(sd); //Update name display [Skotlex] //TODO: hp bars should be cleared too } return 0; }
/// Invoked (from char-server) when a party member leaves the party. int party_member_withdraw(int party_id, int account_id, int char_id) { struct map_session_data* sd = map_id2sd(account_id); struct party_data* p = party_search(party_id); int i; if( p ) { ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id ); if( i < MAX_PARTY ) { clif_party_withdraw(p,sd,account_id,p->party.member[i].name,0x00); memset(&p->party.member[i], 0, sizeof(p->party.member[0])); memset(&p->data[i], 0, sizeof(p->data[0])); p->party.count--; party_check_state(p); clif_party_info(p, NULL); } } if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id ) { sd->status.party_id = 0; if( sd->state.spb ) { sd->state.spb = 0; clif_displaymessage(sd->fd, msg_txt(1451)); } clif_charnameupdate(sd); //Update name display [Skotlex] //TODO: hp bars should be cleared too if( p->instance_id ) instance_check_kick(sd); } return 0; }
int party_member_leaved(int party_id,int account_id,int char_id) { struct map_session_data *sd=map_id2sd(account_id); struct party_data *p=party_search(party_id); int i; if (sd && sd->status.char_id != char_id) //Wrong target sd = NULL; if(p!=NULL){ for(i=0;i<MAX_PARTY;i++) if(p->party.member[i].account_id==account_id && p->party.member[i].char_id==char_id){ clif_party_leaved(p,sd,account_id,p->party.member[i].name,0x00); memset(&p->party.member[i], 0, sizeof(p->party.member[0])); memset(&p->data[i], 0, sizeof(p->data[0])); p->party.count--; party_check_state(p); break; } } if(sd!=NULL && sd->status.party_id==party_id){ sd->status.party_id=0; sd->state.party_sent=0; clif_charnameupdate(sd); //Update name display [Skotlex] //TODO: hp bars should be cleared too } return 0; }
/// Invoked (from char-server) when a party member leaves the party. int party_member_withdraw(int party_id, int account_id, int char_id) { struct map_session_data* sd = map_id2sd(account_id); struct party_data* p = party_search(party_id); if( p ) { int i; ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id ); if( i < MAX_PARTY ) { clif_party_withdraw(p,sd,account_id,p->party.member[i].name,0x0); memset(&p->party.member[i], 0, sizeof(p->party.member[0])); memset(&p->data[i], 0, sizeof(p->data[0])); p->party.count--; party_check_state(p); } } if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id ) { int idxlist[MAX_INVENTORY]; //or malloc to reduce consumtion int j,i; j = pc_bound_chk(sd,3,idxlist); for(i=0;i<j;i++) pc_delitem(sd,idxlist[i],sd->status.inventory[idxlist[i]].amount,0,1,LOG_TYPE_OTHER); sd->status.party_id = 0; clif_charnameupdate(sd); //Update name display [Skotlex] //TODO: hp bars should be cleared too if( p->instance_id ) instance_check_kick(sd); } return 0; }
void party_send_movemap(struct map_session_data *sd) { struct party_data *p; if( sd->status.party_id == 0 ) return; intif_party_changemap(sd,1); p = party_search(sd->status.party_id); if( !p ) return; //Note that this works because this function is invoked before connect_new is cleared if( sd->state.connect_new ) { party_check_state(p); clif_party_option(p,sd,0x100); clif_party_info(p,sd); clif_party_member_info(p,sd); } if( sd->fd ) { //Synchronize minimap positions with the rest of the party int i; for( i = 0; i < MAX_PARTY; i++ ) { if( p->data[i].sd && p->data[i].sd != sd && p->data[i].sd->bl.m == sd->bl.m ) { clif_party_xy_single(sd->fd,p->data[i].sd); clif_party_xy_single(p->data[i].sd->fd,sd); } } } }
int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id, uint16 skill_lv) { struct party_data *p; struct map_session_data *p_sd; int i; if(!party_id || (p = party_search(party_id)) == NULL) return 0; party_check_state(p); switch(skill_id) { case TK_COUNTER: //Increase Triple Attack rate of Monks. if (!p->state.monk) return 0; break; case MO_COMBOFINISH: //Increase Counter rate of Star Gladiators if (!p->state.sg) return 0; break; case AM_TWILIGHT2: //Twilight Pharmacy, requires Super Novice return p->state.snovice; case AM_TWILIGHT3: //Twilight Pharmacy, Requires Taekwon return p->state.tk; default: return 0; //Unknown case? } for(i = 0; i < MAX_PARTY; i++) { if ((p_sd = p->data[i].sd) == NULL) continue; if (sd->bl.m != p_sd->bl.m) continue; switch(skill_id) { case TK_COUNTER: //Increase Triple Attack rate of Monks. if((p_sd->class_&MAPID_UPPERMASK) == MAPID_MONK && pc_checkskill(p_sd,MO_TRIPLEATTACK)) { sc_start4(&p_sd->bl,&p_sd->bl,SC_SKILLRATE_UP,100,MO_TRIPLEATTACK, 50+50*skill_lv, //+100/150/200% rate 0,0,skill_get_time(SG_FRIEND, 1)); } break; case MO_COMBOFINISH: //Increase Counter rate of Star Gladiators if((p_sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && sd->sc.data[SC_READYCOUNTER] && pc_checkskill(p_sd,SG_FRIEND)) { sc_start4(&p_sd->bl,&p_sd->bl,SC_SKILLRATE_UP,100,TK_COUNTER, 50+50*pc_checkskill(p_sd,SG_FRIEND), //+100/150/200% rate 0,0,skill_get_time(SG_FRIEND, 1)); } break; } } return 0; }
/// Invoked (from char-server) when a party member leaves the party. int party_member_withdraw(int party_id, uint32 account_id, uint32 char_id) { struct map_session_data* sd = map_id2sd(account_id); struct party_data* p = party_search(party_id); if( p ) { int i; ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id ); if( i < MAX_PARTY ) { clif_party_withdraw(p,sd,account_id,p->party.member[i].name,0x0); memset(&p->party.member[i], 0, sizeof(p->party.member[0])); memset(&p->data[i], 0, sizeof(p->data[0])); p->party.count--; party_check_state(p); } } if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id ) { #ifdef BOUND_ITEMS int idxlist[MAX_INVENTORY]; //or malloc to reduce consumtion int j,i; party_trade_bound_cancel(sd); j = pc_bound_chk(sd,BOUND_PARTY,idxlist); for(i = 0; i < j; i++) pc_delitem(sd,idxlist[i],sd->status.inventory[idxlist[i]].amount,0,1,LOG_TYPE_BOUND_REMOVAL); #endif sd->status.party_id = 0; clif_charnameupdate(sd); //Update name display [Skotlex] //TODO: hp bars should be cleared too if( p->instance_id ) { int16 m = sd->bl.m; if( map[m].instance_id ) { // User was on the instance map if( map[m].save.map ) pc_setpos(sd, map[m].save.map, map[m].save.x, map[m].save.y, CLR_TELEPORT); else pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT); } } } return 0; }
int party_recv_info(struct party *sp) { struct party_data *p; int i; bool party_new = false; nullpo_retr(0, sp); p = (struct party_data*)idb_ensure(party_db, sp->party_id, create_party); if (!p->party.party_id) //party just received. { party_new = true; party_check_member(sp); } memcpy(&p->party,sp,sizeof(struct party)); memset(&p->state, 0, sizeof(p->state)); memset(&p->data, 0, sizeof(p->data)); for(i=0;i<MAX_PARTY;i++){ if (!p->party.member[i].account_id) continue; p->data[i].sd = party_sd_check(p->party.party_id, p->party.member[i].account_id, p->party.member[i].char_id); } party_check_state(p); if (party_new) { //Send party data to all players. struct map_session_data *sd; for(i=0;i<MAX_PARTY;i++){ sd = p->data[i].sd; if(!sd) continue; clif_charnameupdate(sd); //Update other people's display. [Skotlex] clif_party_member_info(p,sd); clif_party_option(p,sd,0x100); clif_party_info(p,NULL); } } return 0; }
int party_recv_info(struct party *sp) { struct map_session_data *sd; struct party_data *p; int i; nullpo_retr(0, sp); p= idb_ensure(party_db, sp->party_id, create_party); if (!p->party.party_id) //party just received. party_check_member(sp); memcpy(&p->party,sp,sizeof(struct party)); memset(&p->state, 0, sizeof(p->state)); memset(&p->data, 0, sizeof(p->data)); for(i=0;i<MAX_PARTY;i++){ if (!p->party.member[i].account_id) continue; sd = map_id2sd(p->party.member[i].account_id); if (sd && sd->status.party_id==p->party.party_id && sd->status.char_id == p->party.member[i].char_id && !sd->state.waitingdisconnect) p->data[i].sd = sd; } party_check_state(p); for(i=0;i<MAX_PARTY;i++){ sd = p->data[i].sd; if(!sd || sd->state.party_sent) continue; clif_party_member_info(p,sd); clif_party_option(p,sd,0x100); clif_party_info(p,NULL); sd->state.party_sent=1; } return 0; }
int party_recv_info(struct party* sp, uint32 char_id) { struct party_data* p; struct party_member* member; struct map_session_data* sd; int removed[MAX_PARTY];// member_id in old data int removed_count = 0; int added[MAX_PARTY];// member_id in new data int added_count = 0; int member_id; nullpo_ret(sp); p = (struct party_data*)idb_get(party_db, sp->party_id); if( p != NULL ) { // diff members int i; for( member_id = 0; member_id < MAX_PARTY; ++member_id ) { member = &p->party.member[member_id]; if( member->char_id == 0 ) continue; // empty ARR_FIND(0, MAX_PARTY, i, sp->member[i].account_id == member->account_id && sp->member[i].char_id == member->char_id); if( i == MAX_PARTY ) removed[removed_count++] = member_id; } for( member_id = 0; member_id < MAX_PARTY; ++member_id ) { member = &sp->member[member_id]; if( member->char_id == 0 ) continue; // empty ARR_FIND(0, MAX_PARTY, i, p->party.member[i].account_id == member->account_id && p->party.member[i].char_id == member->char_id); if( i == MAX_PARTY ) added[added_count++] = member_id; } } else { for( member_id = 0; member_id < MAX_PARTY; ++member_id ) if( sp->member[member_id].char_id != 0 ) added[added_count++] = member_id; CREATE(p, struct party_data, 1); idb_put(party_db, sp->party_id, p); } while( removed_count > 0 ) { // no longer in party member_id = removed[--removed_count]; sd = p->data[member_id].sd; if( sd == NULL ) continue; // not online party_member_withdraw(sp->party_id, sd->status.account_id, sd->status.char_id); } memcpy(&p->party, sp, sizeof(struct party)); memset(&p->state, 0, sizeof(p->state)); memset(&p->data, 0, sizeof(p->data)); for( member_id = 0; member_id < MAX_PARTY; member_id++ ) { member = &p->party.member[member_id]; if ( member->char_id == 0 ) continue;// empty p->data[member_id].sd = party_sd_check(sp->party_id, member->account_id, member->char_id); } party_check_state(p); while( added_count > 0 ) { // new in party member_id = added[--added_count]; sd = p->data[member_id].sd; if( sd == NULL ) continue;// not online clif_charnameupdate(sd); //Update other people's display. [Skotlex] clif_party_member_info(p,sd); // Only send this on party creation, otherwise it will be sent by party_send_movemap [Lemongrass] if( sd->party_creating ){ clif_party_option(p,sd,0x100); } clif_party_info(p,NULL); if( p->instance_id != 0 ) instance_reqinfo(sd,p->instance_id); } if( char_id != 0 ) { // requester sd = map_charid2sd(char_id); if( sd && sd->status.party_id == sp->party_id && party_getmemberid(p,sd) == -1 ) sd->status.party_id = 0;// was not in the party } return 0; }