#include #include #include #include #include #include #include #include #include #include #include #include #include #include "autil.h" #include "util.h" #include "net.h" #include "object.h" #include "char.h" #include "char_base.h" #include "log.h" #include "handletime.h" #include "npcserver.h" #include "lssproto_serv.h" #include "lssproto_util.h" #include "npcshandle.h" #include "npcutil.h" #include "npc_eventaction.h" #ifdef _NPCSERVER_NEW enum{ uEQUAL = 1, //等於 uBIGEQUALt, //大於等於 uSMALLEQUALt, //小於等於 uBIGTHAN = 5, //大於 uSMALLTHAN, //小於 uNEQUAL, //不等於 }; BOOL NPCS_HandleCheckFreeMess( int npcobjindex, int charaindex, int charobjindex, char *CheckfreeMess) { BOOL ReCall = FALSE; BOOL Enable = FALSE; char buf1[1024], buf2[256]; int i=1; //主条件判断 while( getStringFromIndexWithDelim( CheckfreeMess, "OVER", i, buf1, sizeof( buf1)) != FALSE ){ i++; if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2)) == NULL ) continue; if( NPCS_FreePassCheck( charaindex, buf2) == TRUE ){ if( NPC_Util_GetStrFromStrWithDelim( buf1, "FreeMess", buf2, sizeof( buf2)) == NULL ) continue; Enable = TRUE; if( NPCS_RunDoEventAction( charaindex, buf1) == FALSE ) return FALSE; //事件处理 NPCS_NpcstalkToCli( charaindex, npcobjindex, buf2, CHAR_COLORYELLOW); break; } } if( Enable == FALSE ){//所有条件不成立 NPCS_NpcstalkToCli( charaindex, npcobjindex, "条件不足!", CHAR_COLORYELLOW); return FALSE; } if( ReCall == TRUE ){ //判断是否recall } return TRUE; } BOOL NPCS_FreePassCheck( int charaindex, char *buf) { char buff2[256]; char buff3[128]; int i=1,j=1; int loop=0; while( getStringFromIndexWithDelim(buf,",",i,buff2,sizeof(buff2)) !=FALSE ) { i++; if(strstr(buff2,"&")!=NULL){ j=1; loop=0; while( getStringFromIndexWithDelim(buff2,"&",j,buff3,sizeof(buff3)) !=FALSE ) { j++; if(NPCS_FreeBigSmallCheck( charaindex, buff3)==FALSE) { loop=1; break; } } if(loop==0) return TRUE; }else{ if( NPCS_FreeBigSmallCheck( charaindex, buff2) == TRUE) return TRUE; } } CHAR_setWorkInt( charaindex, CHAR_WORKWARPCHECK, FALSE ); return FALSE; } BOOL NPCS_FreeBigSmallCheck( int charaindex,char* buf) { char buff1[128], buff2[128], Head[128]; int kosuu,temp=-1,flg=0; memset( Head, 0, sizeof( Head)); if( strstr( buf, "=" ) != NULL ){ strcpy( Head, "="); flg = uEQUAL; if( strstr( buf, ">") != NULL ){ strcat( Head, ">"); flg = uBIGEQUALt; }else if( strstr( buf, "<") != NULL ){ strcat( Head, "<"); flg = uSMALLEQUALt; }else if( strstr( buf, "!") != NULL ) { strcat( Head, "!"); flg = uNEQUAL; } }else if(strstr( buf, "<") != NULL){ strcpy( Head, "<"); flg = uSMALLTHAN; }else if(strstr( buf, ">") != NULL){ strcpy( Head, ">"); flg = uBIGTHAN; } Head[ strlen( Head)+1] = 0; getStringFromIndexWithDelim( buf, Head, 2, buff2, sizeof(buff2)); getStringFromIndexWithDelim( buf, Head, 1, buff1, sizeof(buff1)); if( strstr( buff2, "*") != NULL ){ char buff3[128]; getStringFromIndexWithDelim( buff2, "*", 1, buff3, sizeof(buff3)); temp = atoi( buff3); getStringFromIndexWithDelim( buff2, "*", 2, buff3, sizeof(buff3)); kosuu = atoi( buff3); }else { kosuu = atoi( buff2); temp = 1; } return NPCS_ArgumentFreeCheck( charaindex, buff1, kosuu, flg, temp); } BOOL NPCS_ArgumentFreeCheck( int charaindex, char* Argument, int amount, int temp, int probjID) {//amount 数量 Argument 参数 int MyPoint=0, reAmount; reAmount = 0; if( strcmp( Argument, "LV") == 0) {//等级 MyPoint = CHAR_getInt( charaindex, CHAR_LV); }else if( strcmp( Argument, "GOLD") == 0) {//石币 MyPoint = CHAR_getInt( charaindex, CHAR_GOLD); }else if( strcmp( Argument, "TRANS") == 0) {//转生次数 MyPoint = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); }else if( strcmp( Argument, "PET") == 0) {//宠物 ID 数量 MyPoint = NPCS_getUserPetAmount( charaindex, probjID, 1); }else if( strcmp( Argument, "ITEM") == 0) {//道具 ID 数量 MyPoint = NPCS_getUserItemAmount( charaindex, probjID, 1); }else if( strcmp( Argument, "ENDEV") == 0) {//结束旗标 return NPC_EventCheckFlg( charaindex, amount); }else if( strcmp( Argument, "NOWEV") == 0) {//开启旗标 return NPC_NowEventCheckFlg( charaindex, amount); }else if( strcmp( Argument, "PARTY") == 0) {//检查团队人数 MyPoint = NPCS_getUserPartyAmount( charaindex ); }else if( strcmp( Argument, "reITEM")== 0) {//剩馀道具栏位 NPCS_getUserItemAmount( charaindex, probjID, 0); MyPoint = reAmount; }else if( strcmp( Argument, "rePET") == 0) {//剩馀宠物栏位 NPCS_getUserPetAmount( charaindex, probjID, 0); MyPoint = reAmount; }else { } return NPCS_ArgumentBigSmallCheck( amount, MyPoint, temp); } BOOL NPCS_ArgumentBigSmallCheck( int point, int mypoint, int flg) { switch( flg){ case uEQUAL: //等於 if( mypoint == point ) return TRUE; break; case uBIGEQUALt: //大於等於 if( mypoint >= point ) return TRUE; break; case uSMALLEQUALt: //小於等於 if( mypoint <= point ) return TRUE; break; case uBIGTHAN: //大於 if( mypoint > point ) return TRUE; break; case uSMALLTHAN: //小於 if( mypoint < point ) return TRUE; break; case uNEQUAL: //不等於 if( mypoint != point ) return TRUE; break; } return FALSE; } int NPCS_getUserPetAmount( int charaindex, int objID, int flg) { int i, Amount=0, reAmount=0; for( i=0 ;i CHAR_COLORGREEN2 )return FALSE; #ifndef _CHANNEL_MODIFY snprintf( lastbuf, sizeof(lastbuf), "P|%s:%s", #else snprintf( lastbuf, sizeof(lastbuf), "P|P|%s:%s", #endif makeEscapeString( OBJECT_getName( npcobjindex), escapebuf, sizeof(escapebuf)), message); lssproto_TK_send( fd, npcobjindex, lastbuf, color); return TRUE; } #endif