#include "version.h" #include #include "char.h" #include "object.h" #include "char_base.h" #include "npcutil.h" #include "npc_autopk.h" #include "lssproto_serv.h" #include "saacproto_cli.h" #include "readmap.h" #include "battle.h" #include "log.h" #include "enemy.h" #include "handletime.h" #include "npc_eventaction.h" #include "npc_healer.h" #include "configfile.h" #ifdef _GMRELOAD extern struct GMINFO gminfo[GMMAXNUM]; #endif #ifdef _JOB_AUTOPK extern int jobautopk; #endif #ifdef _AUTO_PK #define AWARDNO (1 << 0) #define AWARDPET (1 << 1) #define AWARDITEM (1 << 2) #define AWARDALL (AWARDPET|AWARDITEM) enum { WINDOW_START=1, WINDOW_SELECT, WINDOW_JOINPK, WINDOW_PKLIST, WINDOW_PKINFO, WINDOW_HISTORY, WINDOW_HISTORY_NEXT, WINDOW_HISTORY_PREV, WINDOW_END, }; typedef struct tagautopk { int winnum; char cdkey[CDKEYLEN]; char name[CHARNAMELEN]; }Autopk; typedef struct tagaward { int awardpetid; int awarditemid; char awardpet[32]; char awarditem[32]; int draw; }Award; static int baward = FALSE; Award award[5]; Autopk ship[5]; int autopklist; static int autopktime=-1; static int awardpetid=-1; static int awarditemid=-1; static char awardpet[32]; static char awarditem[32]; int autopkstart=0; int autopkcnt=0; int autopktype = 0; enum { NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, NPC_WORK_TIMEFLAG = CHAR_NPCWORKINT9, /* NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, NPC_WORK_MODE = CHAR_NPCWORKINT5, NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, NPC_WORK_SEFLG = CHAR_NPCWORKINT10, */ }; enum { NPC_AUTOPK_START, NPC_AUTOPK_SELECT, NPC_AUTOPK_JOINPK, NPC_AUTOPK_PKLIST, NPC_AUTOPK_PKAWARD, NPC_AUTOPK_HISTORY, NPC_AUTOPK_OK, NPC_AUTOPK_END, }; #define STANDBYTIME 50 static void NPC_AutoPk_selectWindow( int meindex, int toindex, int num,int select); BOOL AutoPk_GetHistoryStr( char *token, int page ); void AutoPk_PKNum( char *token ); BOOL AutoPk_AddItem( int charindex, int index ); BOOL AutoPk_AddPet( int charindex, int index ); BOOL NPC_AutoPkInit( int meindex ) { char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ print("TRANSER_MAN: GetArgStrErr!!"); return FALSE; } // CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); award[0].draw=0; award[1].draw=0; award[2].draw=0; award[3].draw=0; award[4].draw=0; return TRUE; } //CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); void NPC_AutoPkTalked( int meindex, int talkerindex, char *msg, int color ) { if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; } CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_START, 0); } void NPC_AutoPkWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) { char jiangbuf[256]; memset(jiangbuf, 0, sizeof(jiangbuf)); if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) return; switch( seqno) { case NPC_AUTOPK_START: break; case NPC_AUTOPK_SELECT: NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); break; case NPC_AUTOPK_JOINPK: if(autopktime>2 #ifdef _JOB_AUTOPK && CHAR_getInt( talkerindex, PROFESSION_CLASS ) == jobautopk #endif ){ char buf1[128]; char buf2[255]; int i; if(CHAR_getInt(talkerindex,CHAR_LV)0){ AutoPk_PKSystemTalk(jiangbuf,jiangbuf); } // if(!strcmp(ship[3].cdkey, CHAR_getChar( talkerindex, CHAR_CDKEY)) // && !strcmp(ship[3].name, CHAR_getChar( talkerindex, CHAR_NAME))){ // if((award[3].draw&AWARDPET)!=AWARDPET) // if(AutoPk_AddPet( talkerindex, 3 )) // award[3].draw=award[3].draw|AWARDPET; // if((award[3].draw&AWARDITEM)!=AWARDITEM) // if(AutoPk_AddItem( talkerindex, 3 )) // award[3].draw=award[3].draw|AWARDITEM; // }else if(!strcmp(ship[4].cdkey, CHAR_getChar( talkerindex, CHAR_CDKEY)) // && !strcmp(ship[4].name, CHAR_getChar( talkerindex, CHAR_NAME))){ // if((award[4].draw&AWARDPET)!=AWARDPET) // if(AutoPk_AddPet( talkerindex, 4 )) // award[4].draw=award[4].draw|AWARDPET; // if((award[4].draw&AWARDITEM)!=AWARDITEM) // if(AutoPk_AddItem( talkerindex, 4 )) // award[4].draw=award[4].draw|AWARDITEM; // } break; case NPC_AUTOPK_HISTORY: if( select == WINDOW_BUTTONTYPE_CANCEL ) return; if( select == WINDOW_BUTTONTYPE_NEXT ) { NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_HISTORY_NEXT, atoi( data)); return; } if( select == WINDOW_BUTTONTYPE_PREV ) { NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_HISTORY_PREV, atoi( data)); return; } break; case NPC_AUTOPK_OK: break; case NPC_AUTOPK_END: NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); break; } } static void NPC_AutoPk_selectWindow( int meindex, int toindex, int num,int select) { char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; char token[256]; int buttontype = 0, windowtype = 0, windowno = 0; int fd = getfdFromCharaIndex( toindex); if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) return; } memset( npcarg, 0, sizeof( npcarg)); if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ print("TRANSER_MAN: GetArgStrErr!!"); return; } memset( token, 0, sizeof( token)); switch( num) { case WINDOW_START: sprintf(token, "3\n      ★乱舞格斗PK赛管理员★\n\n" "     ∨有什么需要我为您服务的呢∨\n" "        《我要参加比赛》\n" "        《查看场内选手》\n" "        《领取比赛奖品》\n" "        《历史比赛记录》\n" "        《场外观看比赛》"); CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); windowtype = WINDOW_MESSAGETYPE_SELECT; buttontype = WINDOW_BUTTONTYPE_CANCEL; windowno = NPC_AUTOPK_SELECT; break; case WINDOW_SELECT: windowtype = WINDOW_MESSAGETYPE_MESSAGE; if(select==1){ if(autopktime>2){ sprintf(token, " ★乱舞格斗PK赛管理员★\n\n" "当前离比赛开始时间还剩%d分钟,请做好一切准备。",autopktime); buttontype = WINDOW_BUTTONTYPE_YESNO; windowno = NPC_AUTOPK_JOINPK; }else if(autopktime>0){ sprintf(token, "      ★乱舞格斗PK赛管理员★\n\n" "PK比赛将在%d分钟后开始!\n现在已无法进入比赛场地!\n\nPS:比赛最后两分钟无法进入场地,入场请提早。",autopktime); buttontype = WINDOW_BUTTONTYPE_CANCEL; }else{ sprintf(token, " ★乱舞格斗PK赛管理员★\n\n" "       目前还未举办PK比赛\n       请关注PK比赛最新消息\n       更多活动请关注官方论坛\n       ◆ www.waei.cc ◆\n\n       PS:最后两分钟无法入场"); buttontype = WINDOW_BUTTONTYPE_CANCEL; } }else if(select==2){ sprintf(token, "      ★乱舞格斗PK赛参赛名单★\n"); strcat(token, " 「转生」 「等级」  「玩家」\n"); AutoPk_PKNum(token); buttontype = WINDOW_BUTTONTYPE_CANCEL; windowno = NPC_AUTOPK_PKLIST; }else if(select==3){ AutoPk_GetAwardStr(); char buff[64]; sprintf(token, "      ★乱舞格斗PK赛奖品领取★\n      获胜者在比赛后立刻领取奖励\n\n");; // if(strlen(award[0].awardpet)>0) // sprintf(buff, " 冠军 宠物:%s\n", award[0].awardpet); // else // sprintf(buff, " 冠军 宠物:无\n"); // strcat(token, buff); if(strlen(award[0].awarditem)>0) sprintf(buff, "     「 冠 军 」 %s\n", award[0].awarditem); else sprintf(buff, "     「 冠 军 」 暂无\n"); strcat(token, buff); // if(strlen(award[1].awardpet)>0) // sprintf(buff, " 亚军 宠物:%s\n", award[1].awardpet); // else // sprintf(buff, " 亚军 宠物:无\n"); // strcat(token, buff); if(strlen(award[1].awarditem)>0) sprintf(buff, "     「 亚 军 」 %s\n", award[1].awarditem); else sprintf(buff, "     「 亚 军 」 暂无\n"); strcat(token, buff); // if(strlen(award[2].awardpet)>0) // sprintf(buff, " 季军 宠物:%s\n", award[2].awardpet); // else // sprintf(buff, " 季军 宠物:无\n"); // strcat(token, buff); if(strlen(award[2].awarditem)>0) sprintf(buff, "     「 季 军 」 %s\n", award[2].awarditem); else sprintf(buff, "     「 季 军 」 暂无\n"); strcat(token, buff); strcat(token,"\n 比赛名次按击杀点数计算,杀敌要迅速哦!"); // if(strlen(award[3].awardpet)>0) // sprintf(buff, " 优胜 宠物:%s\n", award[3].awardpet); // else // sprintf(buff, " 优胜 宠物:无\n"); // strcat(token, buff); // if(strlen(award[3].awarditem)>0) // sprintf(buff, " 优胜 物品:%s\n", award[3].awarditem); // else // sprintf(buff, " 优胜 物品:无\n"); // strcat(token, buff); // if(strlen(award[4].awardpet)>0) // sprintf(buff, " 优胜 宠物:%s\n", award[4].awardpet); // else // sprintf(buff, " 优胜 宠物:无\n"); // strcat(token, buff); // if(strlen(award[4].awarditem)>0) // sprintf(buff, " 优胜 物品:%s\n", award[4].awarditem); // else // sprintf(buff, " 优胜 物品:无\n"); // strcat(token, buff); if(baward && (!strcmp(ship[0].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) && !strcmp(ship[0].name, CHAR_getChar( toindex, CHAR_NAME)) && (award[0].draw&AWARDITEM)!=AWARDITEM) || (!strcmp(ship[1].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) && !strcmp(ship[1].name, CHAR_getChar( toindex, CHAR_NAME)) && (award[1].draw&AWARDITEM)!=AWARDITEM) || (!strcmp(ship[2].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) && !strcmp(ship[2].name, CHAR_getChar( toindex, CHAR_NAME)) && (award[2].draw&AWARDITEM)!=AWARDITEM) && autopktype == 0) buttontype = WINDOW_BUTTONTYPE_YESNO; else buttontype = WINDOW_BUTTONTYPE_CANCEL; windowno = NPC_AUTOPK_PKAWARD; }else if(select==4){ CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, 1); if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE))) buttontype = WINDOW_BUTTONTYPE_CANCEL; else buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; windowno = NPC_AUTOPK_HISTORY; }else if(select==5){ CHAR_talkToCli( toindex, -1, "[友情提示]:比赛开始后,请到渔村医院<远程观战员>处,查看比赛哦。", CHAR_COLORRED ); return; } break; case WINDOW_HISTORY_NEXT: windowtype = WINDOW_MESSAGETYPE_MESSAGE; CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1); if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE))) buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; else buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; windowno = NPC_AUTOPK_HISTORY; break; case WINDOW_HISTORY_PREV: windowtype = WINDOW_MESSAGETYPE_MESSAGE; CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)-1); if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)<1)CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,1); if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) || CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)==1) buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; else buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; windowno = NPC_AUTOPK_HISTORY; break; case WINDOW_END: return; break; } lssproto_WN_send( fd, windowtype, buttontype, windowno, CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); } void NPC_AutoPkLoop( void ) { } BOOL AutoPk_GetHistoryStr( char *token, int page ) { FILE* fp; fp = fopen("./data/autopk/autopkhistory.txt", "r"); if (fp == NULL) { print("查看比赛历史文件打开错误\n"); return FALSE; } typedef struct taghistory { char winnum[5]; char name[CHARNAMELEN]; }History; History history[5]; char hstime[5],line[255],buf[255]; int i; for(i=0;i0){ char buf1[64]; char buf2[128]; char qfgonggao[256]; #ifdef _YUANGUSA sprintf(qfgonggao,"[活动快讯]:乱舞格斗PK大赛将在[%d]分钟后进行,参加线路:%s",autopktime,getGameservername()); system_all_talk(qfgonggao); sprintf(buf1, "距离参加今日乱舞PK大赛时间还剩%d分钟,请大家提前入场!",autopktime); if(awardpetid!=-1 && awarditemid==-1) sprintf(buf2,"距离参加今日乱舞PK大赛时间还剩%d分钟,请大家提前入场,本次比赛奖品为:编号:%d,宠物:%s",autopktime-2,awardpetid,awardpet); else if(awardpetid==-1 && awarditemid!=-1) sprintf(buf2,"距离参加今日乱舞PK大赛时间还剩%d分钟,请大家提前入场,本次比赛奖品为:编号:%d,物品:%s",autopktime-2,awarditemid,awarditem); else if(awardpetid!=-1 && awarditemid!=-1) sprintf(buf2,"距离参加今日乱舞PK大赛时间还剩%d分钟,请大家提前入场,本次比赛奖品为:编号:%d,宠物:%s和编号:%d,物品:%s",autopktime-2,awardpetid,awardpet,awarditemid,awarditem); else sprintf(buf2, "距离今日乱舞PK大赛时间还剩%d分钟,请大家提前入场!",autopktime); #else sprintf(buf1, "距离截止参加PK比赛时间还剩%d分钟!",autopktime); if(awardpetid!=-1 && awarditemid==-1) sprintf(buf2,"距离截止参加PK比赛时间还剩%d分钟,本次比赛奖品为:编号:%d,宠物:%s",autopktime-2,awardpetid,awardpet); else if(awardpetid==-1 && awarditemid!=-1) sprintf(buf2,"距离截止参加PK比赛时间还剩%d分钟,本次比赛奖品为:编号:%d,物品:%s",autopktime-2,awarditemid,awarditem); else if(awardpetid!=-1 && awarditemid!=-1) sprintf(buf2,"距离截止参加PK比赛时间还剩%d分钟,本次比赛奖品为:编号:%d,宠物:%s和编号:%d,物品:%s",autopktime-2,awardpetid,awardpet,awarditemid,awarditem); else sprintf(buf2, "距离正式PK比赛时间还剩%d分钟!",autopktime); #endif AutoPk_PKSystemTalk(buf1, buf2); }else if(autopktime==0){ int i,charaindex,num=0; int playernum=CHAR_getPlayerMaxNum(); for(i=0;i=getAutoPkMinNum())break; } } if(num>=getAutoPkMinNum()){ AutoPk_PKSystemTalk("比赛正式开始咯!","比赛正式开始咯!"); AutoPk_PKSystemStart(); autopkstart=1; autopkcnt = 0; autopktime--; autopktype = 1; }else{ i = 0; for(i=0;i0){ awardpetid=petid; strcpy(awardpet,pet); }else{ awardpetid=-1; } if(itemid>0){ awarditemid=itemid; strcpy(awarditem,item); }else{ awarditemid=-1; } } #ifdef _NONUM_AUTOPK void AutoPk_ChampionShipSet( char *cdkey, char *name,int winnum, int win ) { strcpy(ship[win].cdkey, cdkey); strcpy(ship[win].name, name); ship[win].winnum=winnum; } #else void AutoPk_ChampionShipSet( char *cdkey, char *name, int winnum, int win ) { if(win==0){ char token[64]; if(winnum>ship[0].winnum){ sprintf( token, "[乱舞战报]:%s目前排名第一,击杀点数:%d", name, winnum); AutoPk_PKSystemTalk(token,token); if(strstr(ship[0].cdkey,cdkey) && strstr(ship[0].name,name)){ ship[0].winnum=winnum; }else if(strstr(ship[1].cdkey,cdkey) && strstr(ship[1].name,name)){ ship[1].winnum=ship[0].winnum; strcpy(ship[1].cdkey, ship[0].cdkey); strcpy(ship[1].name, ship[0].name); ship[0].winnum=winnum; strcpy(ship[0].cdkey, cdkey); strcpy(ship[0].name, name); }else{ ship[2].winnum=ship[1].winnum; strcpy(ship[2].cdkey, ship[1].cdkey); strcpy(ship[2].name, ship[1].name); ship[1].winnum=ship[0].winnum; strcpy(ship[1].cdkey, ship[0].cdkey); strcpy(ship[1].name, ship[0].name); ship[0].winnum=winnum; strcpy(ship[0].cdkey, cdkey); strcpy(ship[0].name, name); } }else if(winnum>ship[1].winnum){ sprintf( token, "[乱舞战报]:%s目前排名第二,击杀点数:%d", name, winnum); AutoPk_PKSystemTalk(token,token); if(strstr(ship[1].cdkey,cdkey) && strstr(ship[1].name,name)){ ship[1].winnum=winnum; }else{ ship[2].winnum=ship[1].winnum; strcpy(ship[2].cdkey, ship[1].cdkey); strcpy(ship[2].name, ship[1].name); ship[1].winnum=winnum; strcpy(ship[1].cdkey, cdkey); strcpy(ship[1].name, name); } }else if(winnum>ship[2].winnum){ sprintf( token, "[乱舞战报]:%s目前排名第三,击杀点数:%d", name, winnum); AutoPk_PKSystemTalk(token,token); ship[2].winnum=winnum; strcpy(ship[2].cdkey, cdkey); strcpy(ship[2].name, name); } }else if(win==1){ ship[3].winnum=winnum; strcpy(ship[3].cdkey, cdkey); strcpy(ship[3].name, name); }else if(win==2){ ship[4].winnum=winnum; strcpy(ship[4].cdkey, cdkey); strcpy(ship[4].name, name); } } #endif void AutoPk_GetChampionShip( void ) { char token[64]; if(strlen(ship[0].cdkey)>0){ sprintf( token, "[布告天下]:本届乱舞格斗大赛冠军获奖者「%s」", ship[0].name); AutoPk_PKSystemTalk(token,token); AutoPk_PKTimeSetOnly(-1); autopkstart=0; } if(strlen(ship[1].cdkey)>0){ sprintf( token, "[布告天下]:本届乱舞格斗大赛亚军获奖者「%s」", ship[1].name); AutoPk_PKSystemTalk(token,token); } if(strlen(ship[2].cdkey)>0){ sprintf( token, "[布告天下]:本届乱舞格斗大赛季军获奖者「%s」", ship[2].name); AutoPk_PKSystemTalk(token,token); } if(strlen(ship[3].cdkey)>0 && strlen(ship[4].cdkey)>0){ //sprintf( token, "恭喜%s和%s获得本次PK比赛第四和第五名!", ship[3].name,ship[4].name); //AutoPk_PKSystemTalk(token,token); } autopktype = 0; AutoPk_SetHistoryStr(); baward = TRUE; } BOOL AutoPk_AddItem( int charindex, int index ) { char msgbuf[64]; int ret; int spaceNum=5,i,itemindex=-1; itemindex = CHAR_findEmptyItemBox( charindex ); if( itemindex < 0 ) { CHAR_talkToCli( charindex, -1, "物品栏空间不足!!", CHAR_COLORYELLOW); return FALSE; } itemindex = ITEM_makeItemAndRegist( award[index].awarditemid ); if(itemindex == -1) return FALSE; ret = CHAR_addItemSpecificItemIndex( charindex, itemindex); if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { ITEM_endExistItemsOne( itemindex ); print ("\n ret error!!"); return FALSE; } sprintf( msgbuf,"拿到%s",ITEM_getChar( itemindex, ITEM_NAME)); CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW ); CHAR_sendItemDataOne( charindex, ret); return TRUE; } BOOL AutoPk_AddPet( int charindex, int index) { int ret; char msgbuf[64]; int enemynum; int i,j; int petindex, petindex2; for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { petindex = CHAR_getCharPet( charindex, i); if( petindex == -1 ) break; } if( i == CHAR_MAXPETHAVE ) { snprintf( msgbuf,sizeof( msgbuf), "宠物已满!!"); CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); return FALSE; } enemynum = ENEMY_getEnemyNum(); for( i = 0; i < enemynum; i ++ ) { if( ENEMY_getInt( i, ENEMY_ID) == award[index].awardpetid) { break; } } if( i == enemynum ) return FALSE; ret = ENEMY_createPetFromEnemyIndex( charindex, i); for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { if( CHAR_getCharPet( charindex, i ) == ret ) break; } petindex2 = CHAR_getCharPet(charindex, i); if( !CHAR_CHECKINDEX( petindex2) ) return FALSE; snprintf( msgbuf,sizeof( msgbuf), "拿到%s。", CHAR_getChar(petindex2,CHAR_NAME)); CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); CHAR_setInt(petindex2,CHAR_VARIABLEAI,10000); for(j = 0; j < CHAR_MAXPETHAVE; j++){ petindex = CHAR_getCharPet(charindex, j); if( !CHAR_CHECKINDEX( petindex) ) continue; CHAR_complianceParameter( petindex ); snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); CHAR_sendStatusString( charindex, msgbuf ); snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); CHAR_sendStatusString( charindex, msgbuf ); } return TRUE; } void NPC_AUTOPKHealerTalked( int meindex ) { if( CHAR_getInt( meindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; if( (CHAR_getWorkInt( meindex, CHAR_WORKPARTYMODE) == 0) || (CHAR_getWorkInt( meindex, CHAR_WORKPARTYMODE) == 2) ) { NPC_HealerAllHeal( meindex); CHAR_talkToCli( meindex, -1,"恭喜你获胜,请等待本轮比赛结束,体力已全部回复。",CHAR_COLORYELLOW); }else{ int i = 0; int otherindex; for( i=0 ; i < CHAR_PARTYMAX ; i++) { otherindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1 + i); if(otherindex != -1){ NPC_HealerAllHeal( otherindex); CHAR_talkToCli( otherindex, -1,"恭喜你获胜,体力已全部回复。",CHAR_COLORYELLOW); } } } } BOOL AutoPk_GetAwardStr( void ) { FILE* fp; int i=0; int j=0; int enemynum = ENEMY_getEnemyNum(); fp = fopen("./data/autopk/autopkaward.txt", "r"); if (fp == NULL) { print("查看比赛奖品文件打开错误\n"); return FALSE; } for(i=0;i<5;i++){ char line[64],buf[32]; if (fgets(line, sizeof(line), fp) == NULL)break; chop(line); getStringFromIndexWithDelim(line,"|", 1, buf, sizeof(buf)); award[i].awardpetid=atoi(buf); if(award[i].awardpetid!=-1){ for( j=0; j 0 && award[i].awarditemid <= getItemnum() ){ strcpy(award[i].awarditem,ITEM_getNameFromNumber(award[i].awarditemid)); } else{ strcpy(award[i].awarditem, "\0"); award[i].draw=AWARDNO; } } fclose(fp); return TRUE; } void AutoPk_SetAwardStr( char *token ) { FILE* fp; int i=0; fp = fopen("./data/autopk/autopkaward.txt", "w"); fwrite(token, strlen(token), 1, fp); fclose(fp); } void AutoPk_PKSystemStart( void ) { int i,charaindex,num=0; int pkindex[1000],pktype[1000]; int playernum=CHAR_getPlayerMaxNum(); for(i=0;i=2){ if(num%2==0){ int j = num-1; i=0; for(i=0;i